Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
Aeleas

Problem with the angles of robot ?

Question

My problem is that when I post this script to my robot, I found that when he moves on a hill or anything above ground, he can't rotate his angle to moves with the ground under him. that's because the "ManFace" object rotate only right and left.

00000.png

 

Please login or register to see this code.

What i need is to let the "Manface" effect on right and left sides of robot only, other angles are free.

000.png

 

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 1

Ah gotcha. Forgot you can't do that in c#, only js. You have to do this:

 

transform.eulerAngles = new Vector3(transform.eulerAngles.x, ManFace.eulerAngles.y, transform.eulerAngles.z);

  • Like 1

Share this post


Link to post
Share on other sites

  • 0

You only need the y rotation of the manface transform, not the entire vector

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

I tried all these and no one works.

Please login or register to see this code.

 

Share this post


Link to post
Share on other sites
  • 0

And if you have a rigidbody attached to it, make sure the x rotation is not locked and also use a physics method like AddForce and AddTorque instead of manipulating the transform component directly. If you have a character controller component attached, x and z rotations are auto locked which means they cannot be rotated

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

It should work but it doesn't. it gives me this error // Cannot modify the return value of 'UnityEngine.Transform.rotation' because it is not a variable. //

 

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

Yes. this is good. but new thing come u. Now when this robot comes down from the hill he keeps looking down and walking like that. what I have to do to let him look straight ?

Share this post


Link to post
Share on other sites
  • 0

You have no logic for x rotation implemented so there should never be rotation on that axis. Are you use a rigidbody? If so,just lock the x rotation in the inspector

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...