Hodo33 Posted May 20, 2018 Share Posted May 20, 2018 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... Quote Link to comment Share on other sites More sharing options...
Duion Posted May 20, 2018 Share Posted May 20, 2018 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. Quote Link to comment Share on other sites More sharing options...
Hodo33 Posted May 21, 2018 Author Share Posted May 21, 2018 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 Quote Link to comment Share on other sites More sharing options...
Duion Posted May 21, 2018 Share Posted May 21, 2018 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/18147But 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.