• 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 Chris12345 · Jul 02, 2013 at 06:49 PM · itweenfollowitween path

Itween follow path add gravity to game object following the path?

Hello i have a script that makes my player move and change paths but how can i have him be effected by gravity and still stay on the path? here is my code:

 using UnityEngine;
 using System.Collections;
 
 public class follow : MonoBehaviour {
     private float smoothing = 1.0f;
     private Vector3 targetPosition;
 
     public float runSpeed = 0;
 
     public Transform[] path0;
     public Transform[] path1;
     public Transform[] path2;
 
     private Transform[][] paths = new Transform[3][];
     private int iPath = 0;
 
 
     float percentsPerSecond = 0.02f; // %2 of the path moved per second
     float currentPathPercent = 0.0f; //min 0, max 1
 
     void Start () {
        paths[0] = path0;
        paths[1] = path1;
        paths[2] = path2;
     }
 
     void Update () {                   
            if (Input.GetKeyDown("a")) {
                 if (iPath == 2) iPath = 1; else iPath = 0;
 
            }
 
            else if (Input.GetKeyDown("d")) {
                 if (iPath == 0) iPath = 1; else iPath = 2;
            }
        currentPathPercent += percentsPerSecond * Time.deltaTime;
        iTween.PutOnPath(gameObject, paths[iPath], currentPathPercent);
        transform.LookAt(iTween.PointOnPath(paths[iPath],currentPathPercent+.05f));
     }
 
     void OnDrawGizmos(){
        iTween.DrawPath(path0);
        iTween.DrawPath(path1);
        iTween.DrawPath(path2);
     }
 }
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 Chris12345 · Jul 02, 2013 at 09:35 PM

sorry solved

Comment
Add comment · Show 2 · 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 aceleeon5 · Jun 24, 2014 at 02:07 AM 0
Share

what was the answer? haha. Did you figure it out?

avatar image christianstrang · Jun 14, 2016 at 11:40 AM 0
Share

Terrible answer

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 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

Related Questions

how to use float update for speed in itween,itween how to use float update 0 Answers

How can I save an iTween animation as a .anim file? 1 Answer

How could I follow a moving object with iTween? 1 Answer

Object appears on itween path? 1 Answer

How do you get iTween to properly implement PutOnPath command? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges