Turning my character

BlitzMax Forums/BlitzMax Programming/Turning my character

Sollidified(Posted 2015) [#1]
I've been trying to make a 3rd person platformer recently, and right
now I'm trying to make my character move in the direction of the camera, but I need help.

Here's my code:

Graphics3D 800,600,64
SetBuffer BackBuffer()

warrior = LoadMesh("warrior.3ds")

vx#=0
vy#=0
vz#=0

cam = CreateCamera()
MoveEntity cam,0,15,30

plane = CreatePlane()
PositionEntity plane,0,-10,0

player_pivot = CreatePivot()
EntityParent player_pivot,warrior
MoveEntity player_pivot,0,10,0

cube = CreateCube()
PositionEntity cube,0,0,-100
EntityColor cube,255,0,0

fps = CreateTimer(30)

speed#=.4

While Not KeyDown(1)

mxs# = mxs# + MouseXSpeed()
mxy# = mxy# + MouseYSpeed()

If mxs# > 360 Then mxs# = 0
If mxs# < 0 Then mxs# = 360

If mxy > 80 Then mxy# = 80
If mxy < -80 Then mxy# = -80

If KeyDown(31) RotateEntity warrior,0,0,0 MoveEntity warrior,0,0,speed

If KeyDown(17) MoveEntity warrior,0,0,-speed

If KeyDown(32) RotateEntity warrior,0,EntityZ(cam)-110,0

If KeyDown(30) Then
For i = 1 To 90
TurnEntity warrior,0,i,0
Next
EndIf

PointEntity cam, player_pivot
MoveEntity cam,0,0,(EntityDistance#(cam,player_pivot)/30.0) - 1
PointEntity cam,warrior

MoveMouse 800/2,600/2

WaitTimer(fps)

RenderWorld
Flip
Wend

End

I tried a few things, but I put it back to what I had before I tried them. (None of them worked ;-;)


Xerra(Posted 2015) [#2]
You should probably post or move this into the Blitz3d forum as this is for Max.


videz(Posted 2015) [#3]
afaik, you should just create a pivot for that or parent the camera with your model.