Braqoon Posted March 1, 2016 Share Posted March 1, 2016 Hi, So on collision if object we are colliding with has a script attached to it it will be an entity with eg. name function Script:Collision(entity, position, normal, speed) if(entity:GetKeyValue("name") == "wall") then --Do Something end end Now I guess that in order to code specifically certain behaviours based on what object I'm colliding with, that object should be an entity which equals to have a script attached to it, right ? regardless is that a primitive or a prefab model. Even if that object is doing nothing apart from being just an obstacle. Is that correct ? Is that approach is one that everybody is using or should be used or is there another, simple, go to method of finding about an object player have just collided with ? Quote Link to comment Share on other sites More sharing options...
Brutile Posted March 1, 2016 Share Posted March 1, 2016 If its just an obstacle, it doesn't need a script. You make the collision function in the player for example, and when the player collides with something the Collision function will be called, which passes the entity that you collided with so you can do something with it. Quote Link to comment Share on other sites More sharing options...
Braqoon Posted March 1, 2016 Author Share Posted March 1, 2016 Yes, I understand that, basics are simple. I'm wandering how should I approach where collision is a trigger to do other things. Take for example a shooter game (which I got it working), so if ship collides with something that it's not an entity I have no way of telling what it was, and I have to apply one rule for all on such collision. That makes me think that if I want this ship of mine to eg. bounce of the side walls, those walls needs at least a name that collision function of my ship can detect. Otherwise any wall will just trigger collision in the same way and here I might don't want that. Quote Link to comment Share on other sites More sharing options...
Brutile Posted March 1, 2016 Share Posted March 1, 2016 In that example, I would personally create a script just for the walls that apply a force to any object that touches it. That way it stays consistent, but that might not be what you want, so I guess its up to you how to go about it. You could either do the collision on the player and check for a name, or a have a script for the walls that checks for the player (or maybe all objects). If your walls don't specifically have a collision shape, then I would write a script for the wall to create a collision shape. Quote Link to comment Share on other sites More sharing options...
Josh Posted March 1, 2016 Share Posted March 1, 2016 Why would you need a script to make your ship bounce off of walls? Won't it just do that automatically? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Brutile Posted March 1, 2016 Share Posted March 1, 2016 Why would you need a script to make your ship bounce off of walls? Won't it just do that automatically? I'm pretty sure he means to literally bounce off the walls. i.e. adding force velocity, rather than just colliding. 1 Quote Link to comment Share on other sites More sharing options...
Braqoon Posted March 1, 2016 Author Share Posted March 1, 2016 Yes Brutile. This is just an example. So overall you need to have a script attached to an object if you want more than physical collision with that object, even if this is just to get the name of the object. 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.
Note: Your post will require moderator approval before it will be visible.