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
-2
Question by matei123 · Feb 03, 2012 at 01:22 AM · walkleftrightauto

Auto walk

Hi. I want to make an android game on unity with a character who walks automatically run and when I press right to go to the right and when I press left to go to the left. I tried to modify character controller (fps) but i failed.

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 rabbitfang · Feb 03, 2012 at 03:34 AM 0
Share

That's great. Do you have a question that we can answer for you?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Khrome83 · Feb 03, 2012 at 03:03 AM

Can you post any code for how you are handling the character?

It sounds like what you want to do, is play a looping walk animation, while making the character continue to translate in a direction.

I don't know the android inputs, but it would be something like this -

  var speed:float;
  function Update() {
     // Test for Left Input - Else Assume Right
     if(left){
         transform.rotation(0,180,0);
         animation.Play("walk");
         transform.Translate((Vector3.forward * speed) * Time.deltaTime);
     } else {
         transform.rotation(0,0,0);
         animation.Play("walk");
         transform.Translate((Vector3.forward * speed) * Time.deltaTime);
     }
 }

All of this is assume this is in the script attached to the object, the player. As well as the Y axis being vertices, rotating 180 if not facing that way currently. I haven't tested this, there might need to be some additional checks, like if the character is already rotated, or if the animation is currently playing. This also assumes that Vector3.forward will give you the direction the model is facing, assuming it was imported right and the prefab was created right. If it was imported wrong, you can rotate the object inside the prefab after making it a child of a empty game object. The Time.deltaTime will make sure it translates forwards at a constant speed regardless of frame rate. Everything is inside of the Update function so that it runs every frame to keep the character moving. You will need to add conditionals to break out of this action if the character - jumps, stops or any other action.

Everything above is in JavaScript

Without code posted, it is hard to answer these questions. Good Luck.

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 jhakestylez · Oct 05, 2014 at 09:38 AM

what he's trying to explain is the animation similar with the running game genre such as temple run, subway surfer. etc

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using Accelerometer to move and rotate a 3d cube from left to right 0 Answers

How to turn your object left and right 1 Answer

Rigidbody2d Moving up and Down but not left and right 1 Answer

Skybox - Left and Right is swapped, needs fixing. 1 Answer

Pay animation if joystick pushed to left and another if joystick is pushed to right 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