Posted By: burning_devil
Camera and Player Control - 03/20/08 11:37
Does anyone know a code where the controls of your player change, depending on what position the camera is facing.
Posted By: RyuShinji
Re: Camera and Player Control - 03/21/08 13:31
If i understand your question, here's some code from the khmovement tutorial that does just that!
FUNCTION handle_movement() {
temp.x = -1000;
temp.y = 0;
IF (key_w == 1) { temp.x = camera.pan; }
IF (key_s == 1) { temp.x = camera.pan + 180; }
IF (key_a == 1) { temp.x = camera.pan + 90; }
IF (key_d == 1) { temp.x = camera.pan - 90; }
IF (temp.x != -1000) { temp.y = 15 * time; }
my.move_x = fcos(temp.x,temp.y);
my.move_y = fsin(temp.x,temp.y);
c_move(my,nullvector,my.move_x,use_aabb | ignore_passable | glide);
}
hope that helps...
Posted By: JokeSpeaker
Re: Camera and Player Control - 03/22/08 11:55
sry for taking this thread, but my problem is akin.
I write the code, that Ryu posted and use it for my physics.
temp.x = -1000;
temp.y = 0;
if(key_w == 1) { temp.x = camera.pan; }
if(key_s == 1) { temp.x = camera.pan + 180; }
if(key_a == 1) { temp.x = camera.pan + 90; }
if(key_d == 1) { temp.x = camera.pan - 90; }
if(temp.x != -1000) { temp.y = 15 * time_step; }
ball_speed.x = fcos(temp.x,temp.y);
ball_speed.y = fsin(temp.x,temp.y);
ball_speed.z = 0;
phent_addcentralforce(ball, ball_speed);
But the Ball don't move...
What I writed wrong?
The code is in the while of the main function.
I use A7 Commercial