Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by amritkparmar · Nov 23, 2015 at 11:44 PM · movement scriptmove an objectwaypointwaypoint system3dmodel

how to make moving gondolas in unity?

how to make the gondola move from one tower to the other tower? It needs to go from one end to the other and then go back to the other side.

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 ZefanS · Nov 24, 2015 at 02:49 AM 0
Share

You're going to need to be a bit more specific for anyone to be able to help you.

avatar image Tom01098 · Nov 24, 2015 at 09:10 AM 0
Share

Please try and make it more specific, however this document may help

avatar image amritkparmar · Nov 24, 2015 at 05:12 PM 0
Share

@ZefanS and @$$anonymous$$01098 Thank you,

I have two stations where the gondola needs to go, and i have 5 towers in between. So I need it to go from station 1 to station 2 and then back to station 1.

This is the script that I am using. I put waypoints on each tower and station so that the gondola knows where to go. But the gondola does not recognize the intial position and starts from somewher else. I hope this makes more sense. $$anonymous$$aybe you guys can figure out where I am making the mistake?

using UnityEngine; using System.Collections; using System.Linq; using UnityEditor;

public class VehicleGo : $$anonymous$$onoBehaviour {

 GameObject[] wpObj;

 // Rotation vars
 //private int rotationSpeed = 10;
 //private Quaternion lookRotation;
 //private Vector3 direction;
 //public float rotCorrectionFactor;

 // Speed: 
 public float speed = 10;

 int currentWaypoint = 0;

 // Executed at the start of the script
 public void Start()
 {    
     // Get all Waypoints in a sorted array
     wpObj = GameObject.FindGameObjectsWithTag("wpm");
     Debug.Log (wpObj);
     wpObj = sortWaypoints();
 }

 void Update()
 {
     // Only move car if it is not yet at its last waypoint
     if (currentWaypoint <= (wpObj.Length - 1))
     {

         if (Vector3.Distance(this.transform.position, wpObj[currentWaypoint].transform.position) < 1)
         {
             currentWaypoint++;
         }
             
         carGO(currentWaypoint);
         Debug.Log(wpObj[currentWaypoint].transform.position);
     }
     else
     {
         this.transform.position = wpObj[0].transform.position;
         //this.rotate(wpObj[1], 200);
         currentWaypoint = 0;

     }

     //Debug.Log("Current Waypoint: " + currentWaypoint);

 }

 public void carGO(int currentWaypoint)
 {
     float step = speed * Time.deltaTime;
     //this.rotate(wpObj[currentWaypoint], rotationSpeed);
     transform.position = Vector3.$$anonymous$$oveTowards(transform.position, wpObj[currentWaypoint].transform.position, step);
 }

 private GameObject[] sortWaypoints() {
     return GameObject.FindGameObjectsWithTag("wpm").OrderBy(go => go.name).ToArray();

 }

 private void rotate(GameObject target, int rotationSpeed)
 {
     // find vector pointing from our position to the target object
     //direction = (target.transform.position - this.transform.position).normalized;

     // create needed rotation
     //lookRotation = Quaternion.LookRotation(direction);
     //lookRotation.y -= rotCorrectionFactor;
     //this.transform.rotation = Quaternion.Slerp(this.transform.rotation, lookRotation, Time.deltaTime * rotationSpeed);
 }


}

0 Replies

· Add your reply
  • Sort: 

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

36 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 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

Why the loop in waypoints in not working when set to true? 0 Answers

Object moves through the position of another object 0 Answers

Making 2d grid movement 0 Answers

Search very large waypoint-like system 1 Answer

how to make your object move from point A to point B? 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