HELP: What did I collide with?

There are no stupid questions, just stupid answers.
3 posts Page 1 of 1
tientien123
Posts: 1
Joined: Wed Apr 18, 2018 10:47 am
  by tientien123 » Thu Apr 19, 2018 11:21 am
When driving a vehicle if I crash into a rock or tree I would like to know what I collided with. It would also be good if I could affect the object I hit. Trees and rocks are TSStatic.
In vehicle.cs I used onCollision and onImpact, in these functions have tried using %col.getClassName(), %col.getType(), %col.GetName(), %col.GetTargetName(0), %col.GetInternalName() etc. but nothing works.
The script document indicates that most of these should be valid for a TSStatic but some of them give an error when calling them.
So how do I get this information?
Jason Campbell
Posts: 258
Joined: Fri Feb 13, 2015 2:51 am
 
by Jason Campbell » Sat Apr 21, 2018 12:48 am
Perhaps you could use a Raycast with TypeMasks? This link covers a fake melee attack but perhaps the basic idea could be applied, without the weapon of course.
https://www.garagegames.com/community/blogs/view/20273
LukasPJ
Site Admin
Posts: 380
Joined: Tue Feb 03, 2015 7:25 pm
 
by LukasPJ » Sat Apr 21, 2018 7:08 am
The information should be available.
Around the bottom of this wiki tutorial, you can find an example of a onCollision function :
http://wiki.torque3d.org/coincollection:introduction

Make sure you are using it correctly. That said, can you share the error message, console.log and /or the script that is failing?
3 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest