Hello everyone,
First I want to thank everyone who has answered my previous posts. One of the things I like best about Blitz3D is the community support. I hope to someday be able to give advice to others, too! Well here's my question: I am trying to make an entity that follows another. I must make the enemy face the player entity and follow it. However, if I use PointEntity all enemy entities will be on top of the player quite fast. I want to make the enemy make a gradual rotation until it faces the player. I tried to this with AlignToVector, but maybe I misunderstood what this function does.
I thought AlignToVector made the Entity's axises point the specified location in 3d space. So if the axises point to the player, making the pitch, yaw and roll come down to zero should do the trick, right? It doesn't, however. Does anyone know any other way how this might be accomplished?
Here's my code:
While Not KeyDown(1)
If KeyDown(200) ;up
MoveEntity cube2,0,0,1
End If
If KeyDown(208) ;down
MoveEntity cube2,0,0,-1
End If
If KeyDown(203) ;left
MoveEntity cube2,-1,0,0
End If
If KeyDown(205) ;right
MoveEntity cube2,1,0,0
End If
AlignToVector cube,EntityX(cube),EntityY(cube),EntityZ(cube),1,1
AlignToVector cube,EntityX(cube),EntityY(cube),EntityZ(cube),3,1
AlignToVector cube,EntityX(cube),EntityY(cube),EntityZ(cube),2,1
If EntityRoll(cube) >0 Then TurnEntity cube,0,0,-1
If EntityYaw(cube) >0 Then TurnEntity cube,0,-1,0
If EntityPitch(cube) >0 Then TurnEntity cube,-1,0,0
UpdateWorld
RenderWorld
Text 0,0,Str(EntityPitch(cube))
Text 0,20,Str(EntityYaw(cube))
Text 0,40,Str(EntityRoll(cube))
Flip
Wend
First I want to thank everyone who has answered my previous posts. One of the things I like best about Blitz3D is the community support. I hope to someday be able to give advice to others, too! Well here's my question: I am trying to make an entity that follows another. I must make the enemy face the player entity and follow it. However, if I use PointEntity all enemy entities will be on top of the player quite fast. I want to make the enemy make a gradual rotation until it faces the player. I tried to this with AlignToVector, but maybe I misunderstood what this function does.
I thought AlignToVector made the Entity's axises point the specified location in 3d space. So if the axises point to the player, making the pitch, yaw and roll come down to zero should do the trick, right? It doesn't, however. Does anyone know any other way how this might be accomplished?
Here's my code:
While Not KeyDown(1)
If KeyDown(200) ;up
MoveEntity cube2,0,0,1
End If
If KeyDown(208) ;down
MoveEntity cube2,0,0,-1
End If
If KeyDown(203) ;left
MoveEntity cube2,-1,0,0
End If
If KeyDown(205) ;right
MoveEntity cube2,1,0,0
End If
AlignToVector cube,EntityX(cube),EntityY(cube),EntityZ(cube),1,1
AlignToVector cube,EntityX(cube),EntityY(cube),EntityZ(cube),3,1
AlignToVector cube,EntityX(cube),EntityY(cube),EntityZ(cube),2,1
If EntityRoll(cube) >0 Then TurnEntity cube,0,0,-1
If EntityYaw(cube) >0 Then TurnEntity cube,0,-1,0
If EntityPitch(cube) >0 Then TurnEntity cube,-1,0,0
UpdateWorld
RenderWorld
Text 0,0,Str(EntityPitch(cube))
Text 0,20,Str(EntityYaw(cube))
Text 0,40,Str(EntityRoll(cube))
Flip
Wend