| Home Page | Recent Changes | Preferences

Speed Trap

Delete Me - Duplicated. VitalOverdose/Speed Trap is more upto date

UT2004 :: Actor >> Trigger >> Speed_Trap (Package: custom) -tested : Works online.

by VitalOverdose

Part of Vital'sPMT

This custom class is a trigger that tests the speed of the vehicle against a value set in unrealed by the mapper.

The test against the value set can be greater than or lesser than. Its a boolean variable (true/false) and is set to greater than as a default and can set by the mapper in unrealed.

Once the condition has been me the speedtrap will call whatever is in its event property.

  • Can Test For > or < lower than stateted speed set by the mapper.
  • Triggers self when condition is met.

Whatever touched us gets validated in the touch function, if we get touched by a vehicle or one of its children the result is a valid ref to a vehicle stored in local variable 'vec'.

At the movent the speed of the vehicle is measured by velocity but can be converted to a more managable number through using Vsize?. A typical value for testing fast or slow is about 350.

    if ((bLessThan) && (VSize(vec.velocity)<TestSpeed))  
       Triggerevent(event,self,instigator);             // TRIGGER SELF

    if ( (!bLessThan) && (VSize(vec.velocity)>TestSpeed) )
        Triggerevent(event,self,instigator);           // TRIGGER SELF 

So quite simply when a vehicle traving the right speed to meet the condition set by the mapper touches the speed_trap it calls whatever is store in the event property just like a normal tigger.

Completed Script

The completed script looks like this;-

//-----------------------------------------------------------
//
//-----------------------------------------------------------
class Speed_Trap extends Trigger;

var () float                                    TestSpeed;
var () bool                                     bLessThan;

function Touch(actor other)
{
 local Vehicle vec;
 vec=Vehicle(other);

 if ( vec != none )                                     // IF TOUCHED BY A VEHICLE
    {
    if ((bLessThan) && (VSize(vec.velocity)<TestSpeed))  
       Triggerevent(event,self,instigator);             // TRIGGER SELF

    if ( (!bLessThan) && (VSize(vec.velocity)>TestSpeed) )
        Triggerevent(event,self,instigator);           // TRIGGER SELF 
    }
 }

Download

Here is a link to the .UC for this script;-[Download .U file]

Related

VitalOverdose/VecTagger

VitalOverdose/VecBooster

VitalOverdose/QuickVecSpawner

VitalOverdose/BoostingVehicleFactory

Discussion

Tarquin: please use standard formatting, Vital. Also, no other class names use underscores, so I would suggest you call this SpeedTrap.

Tarquin: There's also VitalOverdose/Speed Trap. Please delete one.

Category Custom Class

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In