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

Tank head rotate angle ?

Question

Hi guys 

 

I have issue that bring me a headache ~X(.

the head of this tank rotate to aim at the target but it get out from the body of the tank !!

I locked the X & Z angles but it doesn't work correctly ! This always happen when moving the tank up or down.

image.png

 

It should be like this

010.png

 

here is my script:

Please login or register to see this code.

file link

Please login or register to see this link.

 

I really need to solve this problem. HELP ME GUYS :(

Share this post


Link to post
Share on other sites

5 answers to this question

  • 0
Please login or register to see this quote.

I did what you said. But the head rotate to opposite side !

Please login or register to see this code.

image.png

 

Share this post


Link to post
Share on other sites
  • 0

Try changing 

Please login or register to see this code.

to 

Please login or register to see this code.

or

Please login or register to see this code.

Both ways should result in same behaviour

Share this post


Link to post
Share on other sites
  • 0

It's because your rotating the localrotation to the world rotation. You have to convert world rotation to local, then zero out x and z. For instance: rotation = worldLookRotation; localRotation.xz = 0;

Share this post


Link to post
Share on other sites
  • 0

Thank you guys for your help. I really appreciate it.
Now, I or We solved the rotation problem of the tank head. and script works fine. But new issue show-up. I added new script to moving tank by arrows. I found the head not aiming the target when turn tank around !! 

image.png


010.png

 

 This new script i added on "prototype_Tank" object.

Please login or register to see this code.

Game Link

Please login or register to see this link.

 

How to solve this issue ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this