i'm not completely familiar with torquescript so a lot of my jabs at it are lucky guesses when using other script references.
the basic idea is i'm trying to make an event that toggles a vehicle like the gravity jeep to connect to walls and stuff or not. i modified some speedkarts to add this same gravity effect. is the event not correctly targeting the vehicle because it's regarding an obj? is vehicle.obj a thing?
the solution is probably painfully obvious and i'm just not understanding it because i'm dumb. thanks in advance
edit: also another thing i was wondering: the bool stuff for the event i found had the outcomes as true or false. does it matter if i use %obj.isshiftinggravity=1; over %obj.isshiftinggravity=true; ? i'd imagine it wouldn't but just making sure
registerOutputEvent("Vehicle", "ToggleGravity", "bool",1);
function ToggleGravity(%obj, %bool)
{
if(%bool==true)
%obj.isshiftinggravity=1;
else
if(%bool==false)
%obj.isshiftinggravity=0;
}
the script from the gravity jeep:
$GravityJeepTypemasks=$typemasks::fxbrickobjecttype | $typemasks::interiorobjecttype | $typemasks::terrainobjecttype | $typemasks::StaticObjectType;
datablock wheeledvehicledata(GravityJeepVehicle : JeepVehicle){
cameraRoll=true;
cameramaxdist=8;
cameraoffset=0;
uiname="Gravity Jeep";
};
function GravityJeepVehicle::onadd(%this,%obj){
%obj.isshiftinggravity=1;
%obj.grav="0 0 -0.5";
shiftgravitycheck(%obj);
parent::onadd(%this,%obj);
}
function shiftgravitycheck(%obj){
if(!%obj.isshiftinggravity)
return;
%pos=%obj.getposition();
%ray=containerraycast(%pos,vectoradd(%pos,vectorscale(%obj.getupvector(),"-4 -4 -4")),$GravityJeepTypemasks,%obj);
%normal=getwords(%ray,4,6);
if(%normal!$="")
%obj.grav=vectorscale(%normal,"-0.5 -0.5 -0.5");
%obj.setvelocity(vectoradd(%obj.getvelocity(),vectoradd("0 0 0.5",%obj.grav)));
schedule(25,0,shiftgravitycheck,%obj);
}