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 ElementalVenom · Dec 04, 2015 at 02:48 AM · c#pathfindingfirst-persontower-defensecubes

Move a object along a fixed path.

Hey guys me again. I am making a first person tower defense game. I have everything setup accept theres one problem; I have a path witch is pretty much a brown cube zig-zagging across the map. I would like to make a object move from the starting point to the end point of the map(And rotate accordingly, For exsample, if the path turnes). I thought about just using a animation and animating the position but it would be kinda wonky and i would like to add towers that slow/daze the enemy so that wouldnt work out to well. Any ideas?

Comment
Add comment · Show 2
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 jmgek · Dec 04, 2015 at 03:23 AM 0
Share

So I don't know what your skill level is at but I would guess you are new to unity? I hate to say "You need to learn how to code it" but you kind of do.

What advice I can give is to learn how nav meshes work if you dont like that `you is you could easily make a 2D array that stores tower positions and also paths for enemies, each enemy could translate to each 2D index you set and once it gets there just get another index in the array for the enemy to translate to, repeat until they reach the end or some other spot.

So unless you know what I mean when I say 2D array, translate, index it's really hard to give an answer without telling you the entire process. Would you like me to explain it a little more?

avatar image ElementalVenom jmgek · Dec 04, 2015 at 03:25 AM 0
Share

Nah ive been using it a few years but i just couldnt think of a way to tackle this particular project. Ive decided to use a navmesh agent and just try to get it to not give me problems. But that gives me a new problem described here:

http://answers.unity3d.com/questions/1107452/navmesh-and-boxcolliders.html

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Salanyel · Dec 04, 2015 at 10:54 AM

I may have an other solution for you : 1) Create a gameobject that contain all "Checkpoint" from the begin of the enmies spawn to the end of the map (For a cube, you'll have 1 at the beginning, 2 for the cube and 1 at the end). This gameobject contain all checkpoints in an array Like :

 List<GameObject> m_paths = new List<GameObject>();

2) When you instantiate a new enemy, it gets the path saved in the scene. Then you use the method "MoveTo" with the coordinate of the first point.

3) When you reach the point, you go to the next one.

4) Remember to use a circle around the point. If you don't the enemy may just try to reach the exact point and bug at the same position.

Hope it helps you.

Comment
Add comment · Show 3 · 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 ElementalVenom · Dec 04, 2015 at 10:01 PM 0
Share

Is there a way to make then always go the same speed? The $$anonymous$$oveTo Command moves a distance in a set number of seconds. So if lets say path1s goal is 10 feet it will get there in 3 seconds. And if path2s goal is 50 feet it will get there in 20 seconds. See what i mean? Or am i totally wrong here?

avatar image jmgek ElementalVenom · Dec 04, 2015 at 10:16 PM 0
Share

I would use a constant speed http://docs.unity3d.com/ScriptReference/Transform.Translate.html

avatar image Salanyel · Dec 04, 2015 at 11:03 PM 0
Share

You can calculate a speed based on the distance between the two points in the path. When you reach a new checkpoint, you calculate the distance between the current point and the next checkpoint and calculate the speed based on the one you want. I don't have the formula under my hand, but I can give it to you later.

avatar image
0

Answer by JusSumGuy · May 24, 2018 at 04:38 PM

I hate to say you need to learn code.... Sooo I wont. All you need to do is use the cinemachine. Under the cinemachine menu panel pick create a track. Then what ever object you want to move add a cart component to it. Assign the track to the cart. Then add points to your track and move them around to make your desired path. And on the cart option you can set the objects position on the track and the speed. And what do you know, no code needed. But learning calculus will make these things muchhhh more easier to the point where you'd be able to make your own waypoint system. So don't try to avoid learning code and math if you want to go far in this hobby/job/playground.

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 ElementalVenom · May 24, 2018 at 05:10 PM 0
Share

You necro'd a post from 2015.

avatar image JusSumGuy ElementalVenom · May 25, 2018 at 05:42 AM 0
Share

When I realized it was already to late :( . I felt the tingle of shame going down my spine.

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

35 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

Related Questions

Movement following the A* algorithm 0 Answers

Enemy AI using pathfinding to avoid obstacles 1 Answer

How to turn everything black except from certain objects in the scene in a first person camera view 1 Answer

A* all nodes within range 0 Answers

How do I make my A* script work with prefab enemies and make enemies move using the list created through A*? 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