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 Anonymous 1 · Apr 16, 2011 at 08:57 AM · rotationmovementbeginnersidescroller

simple movement and rotate help!

hello i am trying to make a 2D platform , but i am a 3D artist so i am using 3D models with orthographic camera. I have wrote a script for moving my character left,right at X axis and up,down at Y axis. Similar to anyother side-scroller with difference that the character is flying so it can move up,down freely. Here is my script.

var speed : float; function Update () {

transform.Translate(Input.GetAxis("Horizontal") Vector3.right speed * Time.deltaTime);

transform.Translate(Input.GetAxis("Vertical") Vector3.forward speed * Time.deltaTime);

} what i want is to character rotate to -90 degrees when i press right button and when i again press left it is to rotate 90 degrees to show a kind of movement. Please help ,

Thanx in Advance

Anonymous

Again : what i wanted is when i press right it should turn -90 and then should move on the right side and when then i press left it should again rotate to 90 and move in the direction.

Comment
Add comment · Show 1
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 AngryOldMan · Apr 16, 2011 at 11:53 AM 1
Share

I think you mean turn 180 lol turning 90 degrees would make him face the background or the camera.

1 Reply

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

Answer by Joshua · Apr 16, 2011 at 01:48 PM

Put the variable at the top of your function, put the if statement in your update function. This is just of the top of my mind and untested code, so I hope it works.

var facingRight : boolean = true

if (Input.GetAxis("Horizontal") > 0 && !facingRight )

 transform.eulerAngels.x = 0;

if (Input.GetAxis("Horizontal") < 0 && facingRight )

 transform.eulerAngels.x = 180;

Comment
Add comment · Show 3 · 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 Anonymous 1 · Apr 16, 2011 at 02:21 PM 0
Share

it don't work please tell elaborate , i am a noob in scripting :(

avatar image Joshua · Apr 16, 2011 at 02:24 PM 0
Share

try this. edited answer.

avatar image Anonymous 1 · Apr 16, 2011 at 02:35 PM 0
Share

no luck :( , i think i should leave it

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

No one has followed this question yet.

Related Questions

Moving character relative to camera position. 1 Answer

Sidescroller, rotating via mouse control 0 Answers

Quaternion and rotation of object 1 Answer

Cant align players up vector to surface normal 0 Answers

Curve player movement 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