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 /
avatar image
0
Question by unity_KXxxNHSz_BKpQg · May 19, 2018 at 08:50 AM · trajectoryflying

Visualize a trajectory of a drone flight?

Hello,

I am currently working on a real life drone project. As an example of a drone flight I am doing a visualization in Unity. What I want to do is to have a trajectory defined in an array (my guess is using Vector3), read the coordinates from the array and send the drone object to fly a certain path and follow the points from the trajectory array.

I am very new to the Unity environment and would be happy if you could give me some tips on how and where to start.

Thanks!

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

3 Replies

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

Answer by Happeloy · May 19, 2018 at 01:09 PM

There are a few ways to do this. Here's one way, using a coroutine. They can be seen as separate threads (although they are not, in most cases they behave like one).

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class TestScript : MonoBehaviour {
 
 
     public List<Vector3> positions;     //Your positions, set ininspector;
     public float speed;                 //Set in inspector to change speed.
  
 
 
     public Transform drone; //The object you want to move
 
     void Start () {
         StartCoroutine("MoveAlongPath");    
     }
 
 
     private IEnumerator MoveAlongPath(){
 
         int index = 0;
         Vector3 currentGoal = positions[index];
         drone.transform.position = currentGoal; //Set drone to start position.
 
         while (index < positions.Count)
         {
             currentGoal = positions[index];
             while(drone.transform.position != currentGoal){
                 drone.transform.position = Vector3.MoveTowards(drone.transform.position, currentGoal, Time.deltaTime * speed);
                 drone.LookAt(currentGoal); //make drone face towards goal.
                 yield return null; //Wait for next frame.
             }
             index++;
         }
     }
 }

   

And here's a image showing how this would be used in the inspector: alt text


screen-shot-2018-05-19-at-150556.png (102.2 kB)
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 Slastraf · May 19, 2018 at 11:38 AM

you can probably use a camera cutszene script from the workshop and jsut use the drone model instead of the camera

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 unity_KXxxNHSz_BKpQg · May 19, 2018 at 08:42 PM

Thank you so much, that is exactly what I need!

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

83 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 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 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 predict physics trajectory of a sphere 2 Answers

Predicting the path of a ball from it's forward vect 2 Answers

Unity3d:Projectile(Arrow of Bow) is not rotating as per trajectory. 2 Answers

How to predict orbit based on time? 1 Answer

Show trajectory of a bouncing ball 0 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