Hello,
I have a rigid body which I moving with linear velocity. The Camera is follow this object and you can rotate the camera with the mouse. Now I want that the rigid body moving in the direction which the camera is.
_movement:
lin_x = phy get rigid body linear velocity x(spieler)
lin_y# = phy get rigid body linear velocity y(spieler)
lin_z# = phy get rigid body linear velocity z(spieler)
// Lineare Bewegungen | Linear movement
if upkey() then phy set rigid body linear velocity spieler, 0, lin_y#, walkspeed#
if downkey() then phy set rigid body linear velocity spieler, 0, lin_y#, -walkspeed#
if leftkey() then phy set rigid body linear velocity spieler, -walkspeed#, lin_y#, 0
if rightkey() then phy set rigid body linear velocity spieler, walkspeed#, lin_y#, 0
// 45° Bewegungen \ 45° movement
if upkey() and leftkey() then phy set rigid body linear velocity spieler, -walkspeed#, lin_y#, walkspeed#/2
if upkey() and rightkey() then phy set rigid body linear velocity spieler, walkspeed#, lin_y#, walkspeed#/2
if downkey() and leftkey() then phy set rigid body linear velocity spieler, -walkspeed#, lin_y#, -walkspeed#/2
if downkey() and rightkey() then phy set rigid body linear velocity spieler, walkspeed#, lin_y#, -walkspeed#/2
//endif
// Springen 90° \ Jump 90°
if spacekey() and jy# = 0
phy set rigid body linear velocity spieler, lin_x#, 9.8, lin_z#
jy# = 9.8
walkspeed# = walkspeed# * 1.2
endif
if jy# > 0 then dec jy#, 0.1
if jy# < 0 then jy# = 0
if object collision(spieler,0)>0
jy# = 0
walkspeed# = 3
endif
OldCamAngleY# = CameraAngleY#
CameraAngleY# = wrapvalue ( CameraAngleY# + mousemovex ( ) * 0.4 )
// SET CAMERA TO FOLLOW X, Y, Z, Angle, Distance, Height, Smooth, Collision
set camera to follow object position x(spieler), object position y(spieler), object position z(spieler), CameraAngleY#, camdist, camheight, 5, 1
phy update
return
Can someone help me with this problem please?