Transform.position in 2d game or better way to move player working with colliders.
I am a rookie and trying to make my first game using Unity3D. And i have a problem I don't understand what better way to move green object in my field and when it goes in collision of another green object it will stuck or push it on one "step" in the direct u move. So i make that my green object(Player) are moving accros this square field and because i am using Transfrom.position x or y it step like a teleport and ignore other colliders. Can u help me with this question. Pls tell me what is better to use. Always check for colliders or use AddForce with rigidbody. Pls give me an example of code.
Answer by hexagonius · Jan 31, 2017 at 09:52 PM
use either AddForce or change velocity of the rigidbody in FixedUpdate.
since you're using a grid, with a little math you don't even need collision. if you have a 5*5 array with two gameobjects in it which you can map to world coordinates, you always know if you try to move into an empty or filled cell.
thanks for the answer, but how can i map it to world coorditantes its new for me. Still don't understand how it works.
I tryied transfrom.Translate(Vector3.left(right etc...)) and it works the only thing that i want make positioning of my gameobject using steps, Transform.translate gives me very smoothly movement.
Your answer
Follow this Question
Related Questions
No overload for method. (Question) 0 Answers
Object reference not set to an instance of an object 0 Answers
Detecting missing collision in 2D platformer to change direction for enemy - without Raycast 1 Answer
Player passenger moving when being pushed by two platforms 0 Answers
Cannot get my double jump to work (2D) , 0 Answers