I was following every step to make my character rotate but keep failing. can somebody help me solve this?
Hi Zikri,
In Unity, game objects do not do anything by default. Each behaviour needs a component. Is the PlayerController component attached to the Inspector of the Player game object?
If it is attached, copy and paste one of the AddTorque lines outside the if-/else-if-statements in Update(). Then click the “Play” button to see if the player rotates. If he doesn’t, check the value of “Torque Amount” in your component in the Inspector. It must not be 0.
See also:
- Forum User Guides : How to apply code formatting within your post
- Forum User Guides : How to mark a topic as solved
it rotate the player game object when I put AddTorque lines outside the if-/else-if-statement in Update().
I now I don’t understand why the value of Torque Amount doesn’t change when I press Right or Left button
Alright. It rotate when I put value of float TorqueAmount 50f.
thank you so much for respond
I’m glad you found a suitable value.
Compared to other people’s value, it’s a bit high. I’m wondering if that’s because of the Scale value in the Player’s Transform. Usually, it is not advisable to scale game objects with a Rigidbody2D and/or Collider2D attached because that sometimes results in odd behaviours within the physics simulation. Since a common torque value in this game is about 5, and since your scale is 10, and your value 50, and 50/10 = 5, it might be that the scale is indeed causing the problem.
Is there any specific reason why you scaled the root game object instead of, for example, the children who have only the MeshRenderer attached?
If you used a different sprite than Rick, and if that sprite is too small in your scene, I would suggest to select the sprite file in the Assets folder. Then decrease the Pixel Per Unit value. Half the current value means twice the current size in the Scene.
I hope this helped.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.