Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (7th_zorro), 927 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
vec_rotate problem #413056
12/07/12 08:49
12/07/12 08:49
Joined: Dec 2009
Posts: 82
D
Denn15 Offline OP
Junior Member
Denn15  Offline OP
Junior Member
D

Joined: Dec 2009
Posts: 82
i have a ball in my level that you can control using the asdw keys and i would like to make the controls relative to the camera so that when you for example press w it wil move forward in the direction of the camera.
ive tried to use vec_rotate for this but the ball acts all weird when i do that. when i roll backwards the ball floats up in the air and when i roll forward the ball slams into the ground and other times the ball just moves really slow.
im guessing that the vector is pointing in a wrong direction but i cant figure out how to fix it.


Code:
var campan;
var camtilt = - 5;
var camx;
var camy;

while (1)
	{
		ball_force.x = (key_d-key_a)*30*time_step; 
		ball_force.y = (key_w-key_s)*30*time_step; 
		ball_force.z = 0; 
                vec_rotate (ball_force, camera.pan);
		pXent_addtorqueglobal (ball, vector(ball_force.x, 0, 0)); //spin the ball x axis
		pXent_addtorqueglobal (ball, vector(0, ball_force.y, 0)); // spin the ball y axis
		camera.x = ball.x - 500 * cos(-camx) * cos(camy); 
		camera.y = ball.y - 500 * sin(-camx) * cos(-camy); 
		camera.z = ball.z - 500 * sin(camy); 
		camera.pan = - campan;
		camera.tilt = - camtilt; 
		ball_move.x = (key_w-key_s)* 1400 * time_step;
		ball_move.y = (key_a-key_d)* 1400 * time_step;
                vec_rotate (ball_move, camera.pan);
		pXent_addforcecentral( ball, ball_move);
		camx = camx + mouse_force.x;
		camy = camy + mouse_force.y;
		campan = campan + mouse_force.x;
		camtilt = camtilt - mouse_force.y;
		wait (1);
	}


Re: vec_rotate problem [Re: Denn15] #413058
12/07/12 10:15
12/07/12 10:15
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

That is the normal behaviour grin . If you want the ball to move only depending on the camera pan, change
Code:
vec_rotate (ball_force, camera.pan);

with
Code:
vec_rotate (ball_force, vector(camera.pan, 0, 0));


Re: vec_rotate problem [Re: 3dgs_snake] #413062
12/07/12 10:33
12/07/12 10:33
Joined: Dec 2009
Posts: 82
D
Denn15 Offline OP
Junior Member
Denn15  Offline OP
Junior Member
D

Joined: Dec 2009
Posts: 82
awesome thanks grin


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1