| Home Page | Recent Changes | Preferences

VitalOverdose/Speed Trap

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'. This then gets passed to the function Test_Speed for processing. and the touch function can go back to checking if something else is toucing us.

The test_speed function converts the valid vehicles velocity into a more managable number through using Vsize?. A typical test for a vehicle stopping within the collisiion hash of the Speed_Trap would be lower than 400.

function test_speed(vehicle thvec)
{
 if (((bLessThan) && (thvec).VSize(velocity)<TestSpeed) || 
    ((!bLessThan) && (thvec).VSize(velocity)>TestSpeed))
    triggerevent(event,self,instigator);
}

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

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