Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 gadoy- · Mar 25, 2020 at 11:13 PM · rotationrotaterotatingrotate rotation

Rotate turret faster if hull is rotating the same way

Hello, What i want is pretty easy, I have a tank, so a turret and a hull. Both rotate perfectly fine. But the turret's rotation speed is not calculated depending on the hull's rotation speed. Another way of saying it is : both hull and turret rotates at 25 degres/sec no matter what happens. I'd like to make it so when the hull is rotating left and the turret right, the turret stays still (the hull's rotation cancels out the turret's rotation since it's rotating the opposite way). And if the turret is rotating left and the same for the hull, then the turret goes twice faster (hull rotation speed + turret rotation speed)

Here is the code I have at the moment :

alt text

The 18 th line is to make the turret rotates where the mouse is pointing with a continuous speed

alt text

And here's the code to make the whole tank rotates Note that the Camera is a child of the hull. Turret and Hull are both direct Children of the tank gameobject.

Thanks for any help [2]: /storage/temp/155069-2.jpg

2.jpg (43.0 kB)
capture.jpg (24.3 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by gadoy- · Apr 06, 2020 at 10:07 PM

bump up, anybody?

Comment
Add comment · 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
0

Answer by JxWolfe · Apr 06, 2020 at 11:58 PM

Ok, I've built many a tank game, and from what you said about the tank it works like this:


Tank Gameobejct (empty) has tank script (rotates)

  • Hull Gameobject (model) doesn't have any scripting (maybe shaders, do they count?)

  • Turret Gameobject (model)

  • Camera


This if this is how the tank is laid out, then the script on the tank parent should just need a reference to the turret model and rotate that. If the tank parent is rotating, then the children would rotate as well, meaning that no additional calculations are required.


However, if for some reason you don't want to have your tank laid out that way, or cannot for some reason when you rotate the hull of the tank you could also get a reference to the turret and rotate it as well. (In addition to moving the turret on the controller) This way, if you are moving both tank and turret it would move approperetly. (spelling. and this would act the same as putting the tank in the layout I suggested.


IF you want the tank to keep aiming at the same place, and use the tank turret control only to move the turret, then you could set it up so when you move the tank hull, check if the control to move the turret is active, and if it is, then move it along with the hull. (In addition to moving the turret on the controller) Otherwise, it will keep aiming at the same location.


I hope that helps!

Comment
Add comment · Show 1 · 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 JxWolfe · Apr 07, 2020 at 12:00 AM 0
Share

don't know why enter lines didn't show up. they used to.

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

164 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 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 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 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 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 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 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 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 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

How can i follow an object by 1-axis-rotation? 0 Answers

Rotation for 180 degrees of character 1 Answer

How do I call a function containing a while loop, inside the update function? 2 Answers

How can i rotate the aircraft elevator around the yellow axis up and down ?? as shown in the pic 0 Answers

Is 360° the same as 0°? 2 Answers


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