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 ForrestS · Oct 07, 2013 at 09:50 PM · rotationcollidertransformquaternion

Transform/Quaternion affecting collider?

I have a script that rotates the player in the direction he is firing; it's a top-down sort of game, and the player just faces whichever way he or she is firing. I have another script that deals with controls, and also gives the player a brief invulnerability period on a new life. The way this invulnerability period works is is simply deactivating the collider on the object until the period is over. For some reason, when I'm firing during the invulnerability period, the collider turns back on. Only when a fire button is pressed - when I stop, the collider turns back off. I've deduced it's something to do with rotate script, as when I deactivate the script, the problem is fixed. I just can't figure out what it is in the rotate script that's causing it, or whether it's interfering with another script. Here is the rotate script:

 using UnityEngine;
 using System.Collections;
 
 public class RotatePlayer : MonoBehaviour {
 
     public float rotateSpeed = 3.0f;
     
     void Start () {
         //rotation = Quaternion.LookRotation ( lookRotation );
     }
     
     // Update is called once per frame
     void Update () {
         Vector3 fireDirection =  new Vector3 ( Input.GetAxis ( "FireHorizontal" ), Input.GetAxis ( "FireVertical" ), 0 );
         if ( Input.GetKey ( KeyCode.UpArrow ) || Input.GetKey (KeyCode.DownArrow) || Input.GetKey (KeyCode.LeftArrow) || Input.GetKey (KeyCode.RightArrow)) {
             transform.rotation = Quaternion.RotateTowards ( Quaternion.LookRotation ( transform.forward, transform.up ), Quaternion.LookRotation ( fireDirection, transform.up ), Mathf.Rad2Deg * rotateSpeed * Time.deltaTime );
         }
     }
 }

I can comment out the transform.rotation line and the collider stays off. I'm wondering if I'm messing with the collider somehow in that line?

Thanks!

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
0
Best Answer

Answer by ForrestS · Oct 08, 2013 at 06:23 PM

I fixed my problem. I needed to use rigidbody.rotation instead of transform.rotation since all of my movement is being done via the rigidbody. The transform.rotation line was turning the collider back on because transform is linked to the collider, right?

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

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

15 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

Related Questions

Why is this rotation acting odd? 0 Answers

Efficiency of transform.forward, up, and right 2 Answers

Connecting transform with Vector3 4 Answers

Quaternions acting up 1 Answer

Make object lay flat on a sphere + look up? 0 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