Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Emilyanis · Dec 08, 2013 at 09:48 AM · camera rotaterotate objectgun scripttanks

Tank stabilization

Hi! I using standart mouselook script for my tank turret and gun and its works fine, but now I need vertical and horizontal stabilization. This means that the turret should not repeat the tank Y axis rotation, and rotate that axis only by mouselook script. Gun also should not repeat the rotation of the tank, but only on the X axis and also rotate that axis by mouselook script, plus the have a limit of rotation, taking into account the the tank rotation. Is that possible?

Here some pictures of tank stabilization

alt text

alt text

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by haim96 · Dec 08, 2013 at 11:57 AM

assuming that you need to stabilize the gun on target. you could set point in space by mouse and make the gun lookat that point. you can also check the rotation and limit it if it too high. i hope it's help somehow.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Emilyanis · Dec 08, 2013 at 01:12 PM 0
Share

Yeah I think about it and maybe this is best solution. Now I need to understand how is should work.

avatar image haim96 · Dec 08, 2013 at 01:45 PM 0
Share

search google for "unity lookat one axis" you may find several script examples for this. now make the turret rotate in one axis (left or right) and the barrel in the other axis (up or down).

avatar image Emilyanis · Dec 11, 2013 at 01:47 PM 0
Share

Okey now I have vertical stabilization script without lookat, just with free mouse look, but I have problem. #pragma strict

 var tank : Transform;
 var $$anonymous$$Angle : float;
 var maxAngle : float;
 
 private var rotX : float = 0;
 private var angle :float = 0;
 
 function Update () {
     var tankX = tank.transform.eulerAngles.x;
     
     angle -= Input.GetAxis("$$anonymous$$ouse Y") * 0.5;
     angle = $$anonymous$$athf.Clamp(angle,$$anonymous$$Angle,maxAngle);
     
     rotX = angle-tankX;//20*$$anonymous$$athf.Sin(Time.time);
     rotX = $$anonymous$$athf.Clamp(rotX,$$anonymous$$Angle,maxAngle);
     
     transform.localEulerAngles = Vector3(rotX,0,0);
     
     print(tankX);
     
 }

tank.transform.eulerAngles.x gives me strange angle. I tried $$anonymous$$athf.Rad2Deg(tank.transform.rotation.x)*2 also not works fine. How to get normal tank X axis angle?

avatar image Emilyanis · Dec 11, 2013 at 06:22 PM 0
Share

anyone?...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rotation around Z axis wont lock correctly (2D) 1 Answer

Rotation too complicated 3 Answers

How to make the camera to focus on a player 1 Answer

how can a camera zoom into a game object? 3 Answers

Lerp Rotation broken 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges