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 uanmanarmy · Mar 16, 2014 at 07:39 PM · curved pathasset pathobject follow path

How to create a Path

Hey guys I need some Help here. How to create a path for example to make a path in form of an 8 and when I am moving my character it will go only on this path.

I don't want it to move automatic or to follow it, I just need to it make when I press D it will on this path and when I press A will move opposite direction.

My thought is to make an array of points, where this points will be the path but I don't know how to implement it, that's why I'm looking for your help.

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 robertbu · Mar 16, 2014 at 07:42 PM

The easiest solution is to use iTween (free in the AssetStore). If you want to roll your own, search UA for 'waypoint' answers or 'spline' answers. Code for both has been published many times.

Note iTween has a free path editor:

http://pixelplacement.com/2010/12/03/visual-editor-for-itween-motion-paths/

You can use iTween's built in functions to move along the path or you can use iTween.PutOnPath() and/or iTween.PointOnPath() and manage the movement in your own code.

Comment
Add comment · Show 10 · 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 uanmanarmy · Mar 16, 2014 at 07:58 PM 0
Share

This is my version of doing with iTween but by now i just managed to make it follow automatic . This is my code .

 public float maxSpeed = 10f;

 public Transform[] waypointArray;
 float percentsPerSecond = 0.1f; // %2 of the path moved per second
 float currentPathPercent = 0.0f; //$$anonymous$$ 0, max 1



 void Update () 
 {
 
      Vector3 move = Vector3.zero ;

     //Get the acceleration from x,y by accelerometor
      move.x= Input.acceleration.x;
      move.y = Input.acceleration.y;

     //Apply Transation to the gameObject,
     //Space.World - Applies transformation relative to the world coordinate system.
      transform.Translate(Vector3.right * (move.x * maxSpeed) * Time.deltaTime,Space.World);
      transform.Translate(Vector3.up * (move.y * maxSpeed) * Time.deltaTime,Space.World);

     currentPathPercent += percentsPerSecond * Time.deltaTime;
     iTween.PutOnPath(gameObject, waypointArray, currentPathPercent);

}

avatar image uanmanarmy · Mar 16, 2014 at 07:59 PM 0
Share

Can you help me to make it move not automatic? but when I am moving my device?

avatar image robertbu · Mar 16, 2014 at 08:14 PM 0
Share

Your use of this 'acceleration' hints that you want a more complex motion than your specific question. And your 'Translate' calls will be overridden by your 'PutOnPath()' call. You are attempting to use both x and y of the acceleration, but a path only as two directions...forward and backward. And your acceleration will measure changes in velocity, so you cannot easily map that into a direction since the values will always balance out and return to zero. So I'm not sure what you want here. $$anonymous$$aybe you want the gyroscope ins$$anonymous$$d?

avatar image uanmanarmy · Mar 16, 2014 at 08:21 PM 0
Share

No, it must be with acceleration. alt text

Here is a quick pic of what I am doing. The particles are showing my path.

https://copy.com/TPVpNpCrDZbp

avatar image uanmanarmy · Mar 16, 2014 at 08:23 PM 0
Share

Isn't gyroscope used for rotation only?

Show more comments

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

20 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Physics2D and curved movement 1 Answer

Partner follow the player 0 Answers

Select all materials using a specific shader? 0 Answers

Curving a Path Around an Obstacle 0 Answers

Help me please im stuck here Assets/MeleeSystem.js(12,38): UCE0001: ';' expected. Insert a semicolon at the end. 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