Why don't we use just transform.Translate?

Hey everybody, thanks for the course
Please, tell me, why can’t we use transform.translate? How does this method (through offsets) helps us understand the thing better?

Hi,

Welcome to our community! :slight_smile:

Who said that we could not use transform.translate? Did you test it? In many cases, there are multiple ways to solve problems in Unity. Rick cannot show every single one. Also, since this is a course, Rick and Gary try to teach a variety of techniques, not just one.

1 Like

Didn’t mean it to be any offensive, sorry, if it sounded like that, Nina
I meant, what exactly does THIS method Rick shows is better for us? I saw it being used for camerawork (before I was introduced to Cinemachine) but as for controllable objects it looks bulkier.
Maybe, due to my lack of expertise, I should use the method provided in the course as it will help me understand a much harder (complex) structure?

No worries. You did not sound offensive at all. It was a good question but, of course, I cannot know if you heard/read somewhere that, for example, technique A was better than B. Without any further information, there is no way to tell whether something is better than something else. I don’t know everything, so it might have been that you had a good argument for transform.Translate. :slight_smile:

My personal opinion regarding the Transform is this: If we use any of the Transform properties or methods, we ignore the physics simulation. Maybe you experienced issues with a fast player in the Obstacle Course game. Depending on the speed, the player was able to move through walls and obstacles.

That’s because we overrode the transform.position directly. Actually, we should have used a Rigidbody method such as AddRelativeForce. However, Rick figured that it makes more sense to teach about the Transform object first before overwhelming students with both the Transform object and the physics simulation.

In the Project Boost section, he teaches about the physics simulation. To be able to move our player with the physics simulation, we use the AddRelativeForce method instead of overriding the player’s position values directly.

With this information in mind, think about the problem(s) we want to solve in the Project Boost game. Does our game rely on physically correct collisions? If so, we want to use the Rigidbody. If not, we could either use the Transform or the Rigidbody.

If our game object is supposed to simply move from A to B without any collisions or physics involved, a more performant solution is to manipulate the position directly with the Transform.

Is this what you wanted to know?

As a side note, please bear in mind that this is a course for beginners. Rick and Gary do not focus on performance optimisation. For this reason, not every single solution in their project is “the best”. They tried to find a good balance between performance and simplicity.


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms