3rd-Person Camera

Blitz3D Forums/Blitz3D Beginners Area/3rd-Person Camera

Mattizzle(Posted 2007) [#1]
www.thewyldturkees.com/game/3rd-Person_Camera.zip

Hello all! I'm testing my abillity to make a 3rd person view. For this test I'm using the makbot.x that comes with blitz3d.(I've included it in the download though.) So anyways, when the WASD keys are pressed I want the character to move left, right, forward, and backward relative to the camera's view. Unfortunately, something about the way I have this set-up just simply isn't working. I have stumped myself as to why it's doing what it's doing and have come to you geniouses for help. :-P

Problem: Key 'A' makes the makbot go backwards when it should be going left. Key 'S' makes the makbot go left when it should be going backwards. Key 'D' also makes the makbot go left when it should be going right.

Thanks,
Mattizzle


thelizardking(Posted 2007) [#2]
Remember, movement is relative to the direction faced.
(But that codes pretty cool!)

	If KeyDown(17) = 1 And KeyDown(31) = 0
		RotateEntity(player, 0,EntityYaw(camPivot),0)
		MoveEntity(player, 0,0,-playerspeed)
	EndIf
	If KeyDown(31) = 1 And KeyDown(17) = 0
		RotateEntity(player, 0,EntityYaw(camPivot)-180,0)
		MoveEntity(player, 0,0,-playerspeed)
	EndIf
	If KeyDown(32) = 1 And KeyDown(30) = 0
		RotateEntity(player, 0,EntityYaw(camPivot)-90,0)
		MoveEntity(player, 0,0,-playerspeed)
	EndIf
	If KeyDown(30) = 1 And KeyDown(32) = 0
		RotateEntity(player, 0,EntityYaw(camPivot)+90,0)
		MoveEntity (player, 0,0,-playerspeed)	
	EndIf



Mattizzle(Posted 2007) [#3]
Dang I'm a retard. lol. Thanks!

EDIT: I have now optimized the movement to use the same variables. (I've re-uploaded it)

Ps - Everyone is welcome to use this code. It might be a good for a beginner to check out. The only thing that's difficult is the mouse movement.


Avrigus(Posted 2007) [#4]
The link seems broken, could someone supply a new link please?


Mattizzle(Posted 2007) [#5]
No. I only keep what's active here, on my bands website. If you need the code though, I've now got it on the code archives: http://blitzbasic.com/codearcs/codearcs.php?code=1980

Happy Copy n' Pasting :-P
Matt