How to ensure that two different sized objects move forward at same speed

Hi all,

I am new at unity and just stumbled over this issue. In my game the player is being chased by a chaser object. The player is a sphere at the moment and the chaser object is a cube. Both should move forward at a delta time * 3f rate. However it seem like the cube is moving forward at a slower pace even though both use the same value within the Translate method. How can I ensure that different objects and different sizes objects move forward at the same speed?

thank you so much for your help

Size of object shouldn’t affect it. Sounds like one of the speeds isn’t what you think it is. Or perhaps something else is slowing the other object down, such as friction if it is a Rigidbody object.

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run?
  • what are the values of the variables involved? Are they initialized?

Knowing this information will help you reason about the behavior you are seeing.

I believe the default Transform.Translate method uses the object’s local coordinate system. If your objects do not have uniform scaling, that could cause the translation to be scaled as well.

Solution: use the relativeTo: Space.World option for Translate, or set the world position directly, or adjust your object hierarchy such that your movement script is on a uniformly scaled object.

Thank you guys for such a quick response. I am using a Rigidbody for both objects, so there might be something slowing the chasing object down. Both objects are a sphere so you would think they would move at the same speed. I will need to dig deeper to figure out what is going on.

Check for frictions, generally located on PhysicMaterials.