My "Basic" ai code has a problem
Blitz3D Forums/Blitz3D Beginners Area/My "Basic" ai code has a problem
| ||
;move enimie if Dist=5 and spotted$="True" PointEntity terror,camera MoveEntity terror,0 ,0 ,0.05 endif Ok the problem with this code is that when the enmey object Begins to move towards the player, it also tilts At unwanted angles (the camera Angle) How Can i stop The Object From Tilting As it Moves? |
| ||
reset its roll?RotateEntity terror, EntityPitch(terror), EntityYaw(terror),0 EDIT: Also, shouldn't you check if Dist is less than a certain value rather than equal? |
| ||
ok Thanks |
| ||
No it still tilts Im not to sure why. |
| ||
Show your new code. |
| ||
reset its pitch? |
| ||
Create a pivot for the camera with the same y as the enemy so that the pivot follows the cam and point the enemy to the pivot instead the camera. ------------------------------------------- http://www.moonworx.de |
| ||
Sorted it (Reset the Pitch and yaw to zero each loop) ;move enimie If Dist<5 And spotted$="True" PointEntity terror,camera MoveEntity terror,0 ,0 ,0.05 EndIf RotateEntity terror, 0, 0,0 TurnEntity terror,0,camera,0 The only problem now is i cant get the right side of the enemy to face the camera. |
| ||
The only problem now is i cant get the right side of the enemy to face the camera. Duh. You are telling it to point at 0,0,0.And your TurnEntity terror,0,camera,0bit of code is actually totally screwed up. The reason is because you are setting the entities Yaw rotation to equal the cameras HANDLE (which could be ANYTHING), not the cameras yaw rotation. In order to set it to the cameras yaw rotation, you would type it in like: TurnEntity terror,0,EntityYaw(camera),0. But anyways, how your code should have looked should probably have been like so: ;move enemy If Dist<5 And spotted=True PointEntity terror, camera RotateEntity terror, EntityPitch(terror), 0, 0 ;no yaw rotation nor roll rotation MoveEntity terror,0 ,0 ,0.05 EndIfNote that I changed your spotted variable to an integer. This is not necessary but is good programming practice since integers are much faster to use than strings. By the way, What are the forum codes? |