|
Post by Red Moon Entertainment on Sept 10, 2017 10:53:51 GMT
I wanted to ask something about scripting.
Is it possible to make an object move towards another object and then, when it reaches a certain distance an animation is played by the object moving which is moving towards the other.
Thx.
PS: Does C sharp has something like EventOnContact?
|
|
|
Post by GH Games on Sept 10, 2017 11:44:53 GMT
1. Yes that's possible, I'm not sure how as I'm not too experienced with Unity yet, all I have done is made a custom FPS Camera with jump, run etc
2. C# is the MASTER! In Unity I think the EventOnContact equivalent is a RayCast... not 100% sure but it would make sense
|
|
|
Post by Power Supersport on Sept 10, 2017 12:26:46 GMT
Unity has callback methods dedicated to collision detection, some of them being OnCollisionEnter, OnCollisionStay and OnCollisionExit. To detect collision with another object, you'd have a similar scenario: void OnCollisionEnter (Collision other) { // Your stuff } The "other" variable is an object with information about the collision. I'd better redirect you straight to the documentation for more info on this callback docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html
|
|
|
Post by Red Moon Entertainment on Sept 11, 2017 14:34:13 GMT
1. Yes that's possible, I'm not sure how as I'm not too experienced with Unity yet, all I have done is made a custom FPS Camera with jump, run etc 2. C# is the MASTER! In Unity I think the EventOnContact equivalent is a RayCast... not 100% sure but it would make sense Unity has callback methods dedicated to collision detection, some of them being OnCollisionEnter, OnCollisionStay and OnCollisionExit. To detect collision with another object, you'd have a similar scenario: void OnCollisionEnter (Collision other) { // Your stuff } The "other" variable is an object with information about the collision. I'd better redirect you straight to the documentation for more info on this callback docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.htmlThx for every suggestion! I'll check documentation to try to learn sth, even C sharp seem quite difficult ... However, I have to try! I need scripting in my current project ... Can't avoid it
|
|