Move Rigidbody from point to point

Hello everyone! :smile:
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

here:

rigidbody.AddForce(speedTime.deltaTime(positions[i+direction] - transform.position).normalized);
if(transform.position==positions[i+1]) i++;

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… :slight_smile:
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.

its very important man… :stuck_out_tongue:
so thanks but your solution isn’t good for me :smile:

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.

Very important like needs to be spot on, or important like could just be 0.5 units (change the 10)

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. :rage:

1226782--51248--$move.png

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 :wink:
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);

Thank’s for the help man! :slight_smile:

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.

Here is my prbolem:
1226782--51248--$move.png

Sorry if my English isn’t the best in the world. :stuck_out_tongue:

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.

:wink:

So, if the platform and player, come into contact, the platform is dominent, and the player, is slave to the platforms momentum?

If so, here is my solution.

If you are controlling the player via CharacterController Move(), I would…

  1. make the platform a trigger. Since both the player and platform are moving, add a rigidbody to either.
  2. onTriggerEnter, of platform, tell the charcaterController Move() to Move(0); stopping its momentum.
  3. I would then parent the player to the platform. Thus insuring it travels with the platform.

I don’t know man… if I will parent the player to the platform, than the player will stuck on the platform :neutral:

Nothing is permanent. Hit jump, for instance, and you release him. I am just giving you ideas. Do what is best for you.