How do I push an object to a mouse specified location, and can i specify the speed it travels?

I have a first person camera on a plane with a static sphere. I am looking to be able to ‘push’ the sphere along the plane to where the mouse is pointing.
I would like this to happen only when the fpc is standing next to the sphere - like the player is guiding the sphere to a specific location.

Is there a known way to code ‘pushing’ like this?
I am new to this, but I want to learn!

Thanks for reading and for any help you can offer.

2 Answers

2

You could add a rigidbody to your player object and set the rigidbody to iskinematic.

Then give the ball a rigidbody as well. Assuming both have colliders, then you can use player.Translate(player.forward * Time.deltaTime) and the two physics objects should ‘push’ against each other.

Advanced: If you don’t want the ball to roll away, you can change the sphere’s rigid object to either have a much larger mass (harder to push) or or higher angularDrag (stops rolling more quickly).

Nice one, thanks!

I’ll get experimenting now, thanks again.

No problem. If you like my answer would you mind selecting it as the correct one?