Jump Pad

Scripts and code that enhance the gameplay functionality of the engine.
3 posts Page 1 of 1
Posts: 8
Joined: Sat Aug 19, 2017 12:55 am
by Mack » Thu Jun 20, 2019 9:42 am
Trigger based Jump Pad (like Quake 3)
This Trigger will launch the AI or Player wherever the Trigger is "facing".
This assumes you are familiar with creating and using Triggers within Torque.

UPDATE: The force that the Jump Pad pushes the AI or Player can now be set as a Dynamic Value within the Trigger itself. This will allow you to have multiple Jump Pads with various amounts of force within your mission.

datablock TriggerData(JumpPadTrigger)
   tickPeriodMS = 1000;

function JumpPadTrigger::onEnterTrigger(%this, %trigger, %obj)
   //set the force the Jump Pad pushes the player at as a Dynamic Value
   %jumppadforce = %trigger.getFieldValue(JumpPadForceRef);

   //get the direction the trigger is "facing" (theta)
   %aim = %trigger.getForwardVector();
   //take the getForwardVector and add some force
   %impulseVec = vectorScale(%aim, %jumppadforce);
   //take the above mix and add some additional direction if needed
   %impulseVec = vectorAdd(%impulseVec, "0 0 0");
   //apply this to any AI/Player that enters the trigger
   %obj.applyImpulse("0 0 0", %impulseVec);

   //TODO: add your audio here

function JumpPadTrigger::onLeaveTrigger(%this, %trigger, %obj)
After creating your JumpPadTrigger within the editor create a Dynamic Field called JumpPadForceRef and set its value to the amount of force you want to push the AI or Player at.
Last edited by Mack on Fri Jun 21, 2019 1:47 am, edited 1 time in total.
Posts: 1646
Joined: Sun Feb 08, 2015 1:51 am
by Duion » Thu Jun 20, 2019 9:47 am
I had this idea before, but then I realized, I had no idea how to teach the AI to use those jump pads.
Posts: 63
Joined: Sat Mar 07, 2015 3:13 pm
by XIXWYRMEXIX » Thu Jun 20, 2019 1:35 pm
Cool resource Mack! I will throw it into my test world and see how it does.
3 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests