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 uberokeer · Mar 21, 2013 at 01:52 AM · rotationcharacteraxis

Character rotation on foot?

Hello, I have a problem. When rotating my character he rotates on one foot. I want the rotation to be directly in the middle of him, My entire code is here:

 #pragma strict
 
 public var Dest : boolean = false;
 
 var speed : float;
 var rotateSpeed : float = 3.0;
 var MisslePREF : Transform;
 var jumpSpeed : float = 3.0;
 var Health : int = 100;
 var Mainplayer : Transform;
 var CSpawn : Transform;
 var DPlayer : Transform;
 var isGrounded : boolean;
 function Start () {
 Screen.lockCursor = false;
 Health = 100;
 Physics.gravity = Vector3(0, -115.0, 0);
 }
 
 function Update (){
 
 
 Screen.lockCursor = true;
 
 if(Health <= 0){
 Respawn();
 }
 
 Screen.lockCursor = true;
 if(!animation.isPlaying){
 animation.CrossFade ("fps_idle");
 animation["fps_idle"].speed = 0.5;
 }
     if(Input.GetButton("forward")){
     transform.position += transform.right;
     animation["fps_run"].speed = 1;
     animation.CrossFade("fps_run");
     }
         if(Input.GetButton("backward")){
     transform.position -= transform.right;
     animation.CrossFade("fps_back");
     }
         if(Input.GetButton("left")){
     transform.position += transform.forward;
     animation.CrossFade("fps_strafe_left");
     }
         if(Input.GetButton("right")){
     transform.position -= transform.forward;
     animation.CrossFade("fps_strafe_right");
     }
 
     if(Input.GetButtonDown("Jump")){
         animation["fps_jump"].speed = 0.5;
     transform.position += transform.up * jumpSpeed * Time.deltaTime * 15;
     animation.Play("fps_jump");
     }
     transform.Rotate(0, Input.GetAxis ("Mouse X") * rotateSpeed, 0);
     
     }
     
     
     
     //rotate around y - axis
     
     
     function OnCollisionEnter(col : Collision){
     if(col.gameObject.tag == "missleP2"){
     Health -=10;
     }
     if(col.gameObject.name == "LavaPlatform"){
         Debug.Log("You Are Now Dead");
     Health -=100;
     }
     if(col.gameObject.name == "fallout"){
     Debug.Log("You Are Now Dead");
     Health -=100;
     }
     }
     function OnGUI(){
     GUI.Label(Rect(1890,15,200,100), Health.ToString());
     }
     function Respawn(){
     Health = 100;
     transform.position = GameObject.Find("spawn1").transform.position;
     
 }

Thanks in advance!

Comment
Add comment · Show 3
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 uberokeer · Mar 21, 2013 at 04:56 PM 0
Share

Still having the problem, Anyone?

avatar image roojerry · Mar 21, 2013 at 06:06 PM 0
Share

I would guess your characters pivot is not in the middle. $$anonymous$$aybe try rotating around the character's mesh's center. i.e. Renderer.bounds.center

avatar image uberokeer · Mar 21, 2013 at 06:10 PM 0
Share

Okay thank You alot. One question though is how would I go about rotating my character with that?

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by robertbu · Mar 21, 2013 at 06:12 PM

As @brainruggieri suggests, your pivot is likely in the wrong place. Possible fixes:

  • Reset the center in your modeling program

  • Use the script SetPivot script to reset the pivot.

  • Use an empty game object as the pivot. You can then either use Transform.RotateAround() to do the rotation, or make the character a child of the empty game object and rotate the empty game object.

  • Use Transform.RotateAround() and Renderer.bounds.center as @brianruggieri suggests.

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 uberokeer · Mar 21, 2013 at 07:50 PM 0
Share

Thank You!

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

11 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

Related Questions

Character Controller rotate unity 1 Answer

Character Axes Rotation Problem 3 Answers

Rotate cube in two direction not working 1 Answer

How to lock Y Rotation 3 Answers

2D : Rotation of Object With x-y Axis 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