Way Points

Blitz3D Forums/Blitz3D Beginners Area/Way Points

Chad(Posted 2005) [#1]
I need an example of moving a model across the screen using way points, what I plan on it being is a helicopter that flies over head, lands for a couple seconds, and then takes back off and continues in same direction. So if there's anyone that would like to provide an example so I could learn how it's done is the best way for me to learn.

Thanks,
Chad


WolRon(Posted 2005) [#2]
Pretty straightforward:
Graphics3D 800, 600
cam = CreateCamera()
RotateEntity cam, 90, 0, 0
MoveEntity cam, 0, 0, -15
CreateLight()

Dim WayPoint(10, 1)
CurrentWayPoint = 0

;load up array
For iter = 1 To 10
	Read WayPoint(iter, 0)
	Read WayPoint(iter, 1)
	;the following code is included just to display the waypoints
	wp = CreateCube()
	PositionEntity wp, WayPoint(iter, 0), 0, WayPoint(iter, 1)
	ScaleEntity wp, .1, .1, .1
	EntityColor wp, (20*iter+50), 0, 0
	;the above code is for test purposes only
Next

;create game objects
Copter = CreateCone()
RotateMesh Copter, 90, 0, 0

;gameloop
While Not KeyHit(1)
	xvector# = WayPoint(CurrentWayPoint, 0) - EntityX(Copter)
	zvector# = WayPoint(CurrentWayPoint, 1) - EntityZ(Copter)
	AlignToVector Copter, xvector, 0, zvector, 3, .03
	
	MoveEntity Copter, 0, 0, .05
	
	If Abs(EntityX(Copter)-WayPoint(CurrentWayPoint, 0)) < .5 And Abs(EntityZ(Copter)-WayPoint(CurrentWayPoint, 1)) < .5
		CurrentWayPoint = CurrentWayPoint + 1
		If CurrentWayPoint = 11 Then End
	EndIf
	
	RenderWorld
	Flip
Wend

;data
Data 5, 5
Data 2, -3
Data -4, -7
Data -1, 0
Data -9, 1
Data 2, 3
Data -2, 4
Data 8, -8
Data 9, 3
Data 10, 10



lo-tekk(Posted 2005) [#3]
Look there:

http://www.blitzbasic.com/codearcs/codearcs.php?code=968



-------------------------------
http://www.moonworx.de


jfk EO-11110(Posted 2005) [#4]
Some additional thoughts:
you may use bezier curves to smooth the way, esp. for a helicopter.
And it may be a good idea to add flight controls, so you can fly the way using manual controls, and record the position of the copter frequently, resulting in a list of waypoints that may be used by a bot pilot or waypoint system.