- Home /
Draw to follow
I want to make a game like this: http://www.youtube.com/watch?v=dkp9pxYts_w&feature=player_embedded How to draw path for an object to follow? Can give me some tutorial or suggest,please! thanks!!
i have edited the script. list of updates : the Sphere now moves in normal time, not how fast or slow the mouse was dragged; the Sphere now moves as soon as dragging is started; fixed errors from if mouse button was down or released during moving.
$$anonymous$$y next step is to only move the sphere if it is clicked on first. I shall let you know when more is working.
This is what I am up to :
http://www.alucardj.net16.net/unityanswers/Aircraft1-1.html
As there has been some interest in this, I am going to write a guide on how I made this. I shall let you know when I have something ready.
I am trying to access http://www.alucardj.net16.net/unityanswers/Aircraft1-1.html and http://www.alucardj.net16.net/unityanswers/ScriptFollowAfterDrag.js but these links are broken. Can you help? Thanks!
Same here. Could you provide us with an alternate website if one exists? I'd really like to learn how to make this.
Thanks!
mmm, i have a problem, now, when the aircraft is moving,i touch the aircraft again and move it, the aircraft will move another path , the old path and path$$anonymous$$arker will destroy. Can give some idea?
Answer by AlucardJay · Mar 27, 2012 at 08:35 AM
Just like @rutter has layed out. Here is my first answer and script :
http://answers.unity3d.com/questions/231349/object-follow-the-mouse-path.html
Edit : While it is not encouraged to write full scripts for people on this 'site, I have made a guide for this, following the steps I took to make this. Just keep in mind that I am a noob, this is just to help out other noobs :)
Make a Simple AirCraft Controller Game in Unity
Here is the link for the player following after mouse has been dragged script :
http://www.alucardj.net16.net/unityanswers/ScriptFollowAfterDrag.js
@Bunny83 - Thankyou for the thought and comment =]
hi alucardj can you tell, How to equidistant create path Thank you!!
I thought of 3 methods to equally place the path markers. 1/ have a separate gameObject draw the path, 2/ put a counter in the script to place a marker to a time-step, 3/ learn how to use Trail Renderer. $$anonymous$$ethod 2 would be tidy in keeping everything on the one script, $$anonymous$$ethod 3 I want to learn how to do. But I have been busy on other projects, when I get back to this I shall post my updates.
Ok,Thank you!!Can I ask a question?How to drawing path the finished then when onmouseup ,Players move?Players is 3d Object. Like:http://www.youtube.com/watch?v=kv-_9$$anonymous$$fwJt8
this script should help you : http://www.alucardj.net16.net/unityanswers/ScriptFollowAfterDrag.js
Hi,alucardj,thank you for your help. $$anonymous$$y Camera set Position (168.3342, 215.449, 95.12489) Rotation (59.10774,-90,1.525879e-05).$$anonymous$$y player is 3D object.When I use script no response. And how can player move speed Isokinetic ,because I use mouse drawing slow ,player move is slow,drawing fast,player is fast,and I want to when hit player ,player to move.Please tell me how to do.
Answer by rutter · Mar 16, 2012 at 04:57 PM
Break a big problem into smaller problems:
Map finger touches to points in world space
Create a "path" structure, which tracks those points
Create objects that can follow the path
Create objects that can draw the path
Mapping touch to location is one of the most common questions on this board.
At the very least, you'll want to track the touch positions with some kind of list. You may want to run some sort of smoothing on user input, but that can get rather complicated.
There are many ways to follow a path. The simplest is probably Vector3.Lerp()
or something similar.
For drawing paths, you'll want a line renderer or something similar.
Your answer
Follow this Question
Related Questions
OnDrag Draw Line For Pathfinding... 1 Answer
Aim preview for projectile trajectory 1 Answer
Drawing with mouse on GUI or world texture 1 Answer
650+ DrawCalls, Mesh.DrawVBO 1 Answer