ItemData collision

Scripting questions, discussions, etc
4 posts Page 1 of 1
Hodo33
Posts: 22
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Sun May 20, 2018 9:46 pm
I have a grenade I can toss into a room. Created as ItemData. Can someone tell me where the collision against a wall or floor or vehicle takes place? I can't find a Grenade::onCollision() function in script.
The reason I ask is I want it to explode if it hits a certain type of object like a door or vehicle instead of exploding on timeout. I need for it to bounce off a wall, hit a vehicle then explode...
Thanks...
Duion
Posts: 1006
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Sun May 20, 2018 10:39 pm
Can't you just create the onCollision function? If it does not exist, just make the grenade as something that does have that function already, so you do not have to add it yourself.

For example make it as projectile, I think ItemData is just the thing you pick up.
Hodo33
Posts: 22
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Mon May 21, 2018 4:34 am
Thanks for the reply, yes I have a grenade::onCollision that will detect hitting a door but typedef for building, floor, wall still eludes me
Duion
Posts: 1006
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Mon May 21, 2018 9:18 am
I don't think the engine can distinguish between floor or walls, how is that supposed to work? The engine can distinguish between the different classes of objects liks TSStatics, ItemData, Terrain, Player etc and do something different on collision then. Buildings, walls, floors, ceilings etc in most cases will be TSStatics.

So you have to add code yourself that can distinguish between those objects.

There is a resource that implements different behavior of bullets when hitting different materials, if that is enough for you, you can implement that resource: http://www.garagegames.com/community/re ... view/18147

But maybe you are thinking too complicated, since in reality no grenade exists that can detect what it hits, so maybe think of something other as a solution. I think you can already distinguish in the engine between static shapes and players or vehicles, so it should work that you can make it only explode when it hits a target like a player or vehicle.

The current grenade from the grenade launcher in Torque3D has an arming delay so everything it hits under that delay it will bounce off, after that explode, I think it should be good enough for your case if you adjust it well, it will then not explode on timeout, but when it hits something and is armed.
4 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests