- Home /
Rigidbody Moving around a tower
Hi guys, I'm trying to move a rigidbody object around a tower by applying a force. I need to be able to uses forces to move it, so I can't set it's x and z positions using a cos/sin functions as you'd normally do to achieve this.
Currently, I'm apply a forward force using AddRelativeForce (green line on picture) and rotating the object based on it's position around the tower - so the object is pushed forward, I turn it, it's pushed forward again etc
This kind of gets the result I'm after but as you'd imagine, the object moves further away from the tower over time. I'm wondering if there'd be a better way to approach this? Effectively I need the objects to be driven by physics but the object needs to rotate around the tower.
Thanks in advance!

How about using a clamp? Calculate the desired distance between your object and tower's center and make sure that the distance never exceeds?
Since its moving on XZ plane, would sth like this work?
transform.position.x = $$anonymous$$athf.Clamp(transform.position.x, tower.position.x - distance, tower.position.x + distance); transform.position.z = $$anonymous$$athf.Clamp(transform.position.z, tower.position.z - distance, tower.position.z + distance);
Your answer
Follow this Question
Related Questions
Preventing a grenade from colliding with its thrower 2 Answers
Configure configurableJoint to act as the disctontinued driveJoint 0 Answers
Problem with Colliders 1 Answer
Drag & Drop GameObject with MovePosition shoots other Gameobject away in case of them colliding 1 Answer
Enemy can't trigger a hit when the player doesn't move 0 Answers