- Home /
question on using waypoints and an arrow to guide a player.
OK so in an effort to guide the player through this huge level I built. I built an arrow in 3ds max and set it to look at and point towards an empty game object. How can I get it to "point" to the next way point once the player reaches it. I need to guide the player towards a temple and using the arrow seems like the best way. I originally had it looking at the temple, however, it would lead the character over mountains that they can't climb. so I figured by setting several empty game objects as "way point" I could move the player in the right direction, but once you reach a way point I can't get it to move on to the next one.
Answer by jester · May 10, 2010 at 04:24 PM
You could put the empty gameobjects in an ordered list and everytime the player gets to an arrow, iterate to the next arrow in your list.
yeah that's what I was thinking, but how do you code that. All I have right now is the arrow pointing to the game object via the default smooth look at script. I'm definitely not a coder.
Basically I need 3 way points to achieve what I want. Say I name the objects waypoint01 waypoint02 and waypoint03. how would I implement that via code.
sorry about not replying sooner. i've been distracted by my non-game coding day job. glen has the right setup below for the array of waypoints. as for implementing a switch between them, you could have a trigger on each waypoint and a number for it's array position. every time a waypoints trigger is hit, use that number + 1 for setting the arrow to point to the next waypoint from the array. that waay, if a player somehow missed a waypoint and got to the next one, it would still point them to the next one in the array and they wouldn't get out of order or anything.
Answer by glewis · May 10, 2010 at 05:00 PM
How about something like this?
private var waypoints : Array;
function Start() { waypoints = new Array(); waypoints.length = 3;
var waypoint1 = GameObject.Find("Waypoint1");
var waypoint2 = GameObject.Find("Waypoint2");
var waypoint3 = GameObject.Find("Waypoint3");
waypoints[0] = waypoint1;
waypoints[1] = waypoint2;
waypoints[2] = waypoint3;
}
-- Glenn
That might just work. Will try it out tonight and report back if it works or not. thanks.
Your answer
Follow this Question
Related Questions
Problem with NPC rotating around a waypoint 3 Answers
audio for moving platforms 1 Answer
Waypoint problem 2 Answers
GameObject rolls towards Waypoint 2 Answers
Pathfinding 0 Answers