Draw the path??
BramHoddssd
Member Posts: 414
Hey guys, I want to make a game where you draw the path the character can walk on. Do you know if you can do that?
Comments
How do I make an actor follow the mouse?
If you want the actor to follow a drawn path, here are some options:
Drawing Path for Actors
Or, you can look at ORBZ's wonderful demo:
ORBZAMPLE: Waypoints
I've experimented with this idea a bit myself and this is what I came up with:
Breadcrumbs (experiment)
This isn't perfect -- nowhere close -- but I didn't have time to continue this. (Ironically, the longer and more complicated you make the path, the better it performs. Try it.)
Basically, I did this:
1) Every 0.01 seconds, I spawn an actor, path, at the position of the user's touch. This actor captures the game time in an attribute called born. The beginning time and end time of the drawing is also captured to global attributes.
2) After the user lifts his/her finger, I have an interpolate behaviour that goes from the beginning time to the end time.
3) If the path's born attribute equals the time being interpolated, it sends its x- and y-coordinates to global attributes which the player actor follows.
If I had time to work on it a bit more, I wouldn't use interpolate to recreate the time. Rather, I would have the actor move every 0.01 seconds to the next waypoint.
It would be great if someone could follow-up on this and make it work.
Cheers!
1) Capture the x- and y-coordinates, when mouse (button) is down. This is your beginning point.
2) Capture the x- and y-coordinates when the mouse is up (released). This is your end point.
3) Interpolate between your first set of coordinates and your second.