Jump to content

ItemData collision


Hodo33

Recommended Posts

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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/resources/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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...