Hello everyone!
I want to move my rigidbody object from one point to another.
I mean, something like this:
1)Move object from p1 to p2.
2)If(position == p2) → move to p3
but the problem is that the position is not exactly p2 so its dont move to point 3.
So I need something that will do this: transform.position = Vector2.MoveTowards(transform.position,positions[i+1],speed*Time.deltaTime);
but with rigidbody instead…
So can I solve this problem? :neutral:
how important is accuracy?
if((transform.position - positions[i+i]).magnitude < 10) i++
changes destination if it gest within 10 units of the position.
Why do you need to reference the rigidbody if accuracy is extremely important? Why not transform.MoveTo() or transform.Translate(). Each can still have a rigidbody.
Doesn’t working - The object doesn’t move in the direction I want. :neutral:
1)I didn’t found any function of transform that called “MoveTo”.
2)With translate its doesn’t working.
I don’t want to use transform because when I’m using transofrm than my player (Character Controller) will just
going through the object, and I want the rigidbody to still move in it’s direction and that
the rigidbody will push the player with him.
*I tried now to use rigidobdy.velocity = … and its working…but I still have the problem with the player
going through the rigidbody.
Does your player have a collider? Is it a trigger? Does the box have a collider? Is it a trigger? If it has no collider, either one, no collision. If either are a trigger, no collision.
You said velocity, there is no collision, so the issue is your colliders, not what method you use to move them. And yes, sorry, MoveTo() is iTween.
You are right that the issue is my coliiders, so I deleted the rigidbody component from the object
and I will try whatever you will tell me to do
Now what I have is:
1)Player - Cube mesh for the shape of the player (But no box collider) and character controller.
The player moves using controller.Move(Vector3 Direction).
2)Moving Object - Now it’s just box collider because I deleted the rigidbody.
The object moves using transform.position = Vector2.MoveTowards(transform.position,positions[i+1],speed*Time.deltaTime);
I am really not sure what to tell you. What is your issue? Moving a body to a specific point or colliders, not detecting one another? Sorry, slightly confused.
As you can see, the problem is that when the moving platform move left (just for the example)
and my player move right then my player will continue to move right , and what I want is that the player will
be pushed by the moving platform to the right side instead of going through the moving platform.
And of course I want the moving platform to still move to his destination.