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 Nzingha · Aug 29, 2014 at 11:36 PM · rotationjavascriptquaternioncarmaze

Rotation along the x-axis to that player can turn around?

Ok I am working on a 3D project where my player piece is navigating through a maze. I can't make it rotate on the X axis. It can move left and right but it does not turn. So the view is only straight forward. My Code is below. You can see in my comments i am trying everything. Please Help!

 #pragma strict
 
 var speed : float = 2;
 var distToGround: float;
 var centerOfMass : Transform;
 var cam : Transform;
 
 
 function Start()
 {
   // get the distance to ground
   distToGround = collider.bounds.extents.y;
 }
  
  
  
 function IsGrounded(): boolean 
 {
   return Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1);
 }
 
 
 
 function FixedUpdate () 
 
 {
 //THe directions the player peice will go based the keyboard arrows
     var moveHorizontal : float=  Input.GetAxis ("Horizontal");
     var moveVertical : float= Input.GetAxis ("Vertical");
     
     var movement : Vector3 = new Vector3 (moveHorizontal,0.0f,moveVertical); 
 
 
 // When the player peice turns left or right, it tilts slightly
     rigidbody.rotation = Quaternion.Euler (0.0f, rigidbody.velocity.x, 0.0f);
    
    
 // The acceleration for the player peice 
     var XYVelocity = rigidbody.velocity;
     rigidbody.velocity = movement * speed;
 
 
 // The Camera is following the player peice
     rigidbody.AddForce (transform.rotation * cam.transform.forward * moveVertical);
     rigidbody.AddForce (transform.rotation * cam.transform.right * moveHorizontal);
 }
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

Answer by Commander5518 · Aug 30, 2014 at 05:55 AM

Import your Standard Assests. Use the 3rd person controller. Switch out the construction worker for your sphere. It has a mouse control script with it. Your script is not very well organized so it is kind of difficult to tell what you are trying to move with. Sorry if I' way off

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 Nzingha · Aug 30, 2014 at 12:17 PM 0
Share

No need for apologies. Im new to coding so I need the criticism. I changed my coding. I hope its more understandable. Reading your comments are you saying that I need to import my components again? Is your advice based you not understanding my coding? I want the players to use the $$anonymous$$eyboard and not the mouse to control the main piece.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Determining Look Rotation As > A Number? 1 Answer

Rotate object following mouse movement. Object jumps/ flips 1 Answer

Child Obj Ignoring Parents Rotation! Help 1 Answer

Rotation using Quaternion.Lerp 1 Answer

Gradual Rotation of Character from 2 Axis Input Sources 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