2 registered members (AndrewAMD, 1 invisible),
1,395
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Orbit Camera
#337135
08/08/10 18:48
08/08/10 18:48
|
Joined: Dec 2008
Posts: 222
janerwac13
OP
Member
|
OP
Member
Joined: Dec 2008
Posts: 222
|
Ich möchte gerne ein Camera die man mit der Muas um den Spieler rotieren lassen kann auch noch oben und unten. Der code aus AUM 93 hat leider nbicht gefuntzt. DAs ist der Player aus meinem Spiel: action ball() { VECTOR ball_speed; var soundtrack_handle; ENTITY* ball; ball = my; ph_setgravity (vector(0, 0, -386)); // set the gravity phent_settype (my, PH_RIGID, PH_SPHERE); // set the physics entity type phent_setmass (my, 3, PH_SPHERE); // and its mass phent_setfriction (my, 80); // set the friction phent_setdamping (my, 40, 40); // set the damping phent_setelasticity (my, 50, 20); // set the elasticity while (1) { ball_speed.x = 25 * (key_cur - key_cul); // move the ball using the cursor keys ball_speed.y = 25 * (key_cuu - key_cud); // 25 sets the x / y movement speeds ball_speed.z = 0; // no need to move on the vertical axis if (key_p) { freeze_mode = 1; set(pause_pan,VISIBLE); mouse_mode = 2; } phent_addtorqueglobal (my, ball_speed); // add a torque (an angular force) to the ball camera.x = my.x - 300; // keep the camera 300 quants behind the ball camera.y = my.y; // using the same y with the ball camera.z = my.z + 100; // and place it at z = 1000 quants camera.tilt = -10; wait (1); } }
Last edited by janerwac13; 08/09/10 14:00.
|
|
|
Re: Orbit Camera
[Re: janerwac13]
#337144
08/08/10 21:33
08/08/10 21:33
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
probier mal so was hier:
...
rot_angle += mickey.x * 4;
rot_height = clamp(rot_height + mickey.y * 2,0,45);
VECTOR offset;
vec_set(offset,vector(-300,0,100));
vec_rotate(offset,vector(rot_angle,rot_height,0));
vec_set(camera.x,my.x);
vec_add(camera.x,offset);
camera.pan = rot_angle;
camera.tilt = -rot_height;
...
kurze erklärung: rot_angle: eine var, die angibt, von welcher Position auf der xy-ebene rot_height eine var, die die höhe angibt begrenzt von 0° bis 45° (änderbar) offset: das camera-offset ... camera.pan = rot_angle; camera.tilt = -rot_height; ... Die Camera schaut immer auf den Ball Note: Der Code is frei, ohne getestet zu sein, sollte aber im Prinzip gehen
|
|
|
Re: Orbit Camera
[Re: MasterQ32]
#337200
08/09/10 13:28
08/09/10 13:28
|
Joined: Dec 2008
Posts: 222
janerwac13
OP
Member
|
OP
Member
Joined: Dec 2008
Posts: 222
|
funtzt net ! meinst dz rot_amgle stat rot_height ?
Last edited by janerwac13; 08/09/10 13:58.
|
|
|
Re: Orbit Camera
[Re: janerwac13]
#337205
08/09/10 14:01
08/09/10 14:01
|
Joined: Dec 2008
Posts: 222
janerwac13
OP
Member
|
OP
Member
Joined: Dec 2008
Posts: 222
|
[quote]action ball() { VECTOR ball_speed; var soundtrack_handle; VECTOR kick_speed; ENTITY* ball; SOUND* ball_wav = "ball.wav"; ball = my; var rot_angle = mickey.x * 4; var rot_height = clamp(rot_angle + mickey.y * 2,0,45); VECTOR offset; var jumptimer = -1.5; ph_setgravity (vector(0, 0, -500)); // set the gravity phent_settype (my, PH_RIGID, PH_SPHERE); // set the physics entity type phent_setmass (my, 3, PH_SPHERE); // and its mass phent_setfriction (my, 80); // set the friction phent_setdamping (my, 40, 40); // set the damping phent_setelasticity (my, 50, 20); // set the elasticity while (1) { ball_speed.x = 40 * (key_d - key_a); // move the ball using the cursor keys ball_speed.y = 40 * (key_w - key_s); // 25 sets the x / y movement speeds ball_speed.z = 0; // no need to move on the vertical axis if (key_p) { freeze_mode = 1; set(pause_pan,VISIBLE); mouse_mode = 2; } phent_addtorqueglobal (my, ball_speed); // add a torque (an angular force) to the ball vec_set(offset,vector(-300,0,100)); vec_rotate(offset,vector(rot_angle,rot_height,0)); vec_set(camera.x,my.x); vec_add(camera.x,offset); camera.pan = rot_angle; camera.tilt = -rot_height;
if (key_space) { phent_addvelcentral(my,vector(0,0,1000*time_step)); wait(-1); // Wartet bis man wieder springen darf } wait (1); } } [quote]
|
|
|
Re: Orbit Camera
[Re: janerwac13]
#337207
08/09/10 14:10
08/09/10 14:10
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
ne, du hast mich falsch verstanden mein code geht, du musst die beiden zeilen in der schleife lassen:
rot_angle += mickey.x * 4;
rot_height = clamp(rot_height + mickey.y * 2,0,45);
du must die variablen nur mit null deklarieren:
action ball()
{
VECTOR ball_speed;
var soundtrack_handle;
VECTOR kick_speed;
ENTITY* ball;
SOUND* ball_wav = "ball.wav";
ball = my;
var rot_angle = 0;
var rot_height = 12;
VECTOR offset;
var jumptimer = -1.5;
ph_setgravity (vector(0, 0, -500)); // set the gravity
phent_settype (my, PH_RIGID, PH_SPHERE); // set the physics entity type
phent_setmass (my, 3, PH_SPHERE); // and its mass
phent_setfriction (my, 80); // set the friction
phent_setdamping (my, 40, 40); // set the damping
phent_setelasticity (my, 50, 20); // set the elasticity
while (1)
{
ball_speed.x = 40 * (key_d - key_a); // move the ball using the cursor keys
ball_speed.y = 40 * (key_w - key_s); // 25 sets the x / y movement speeds
ball_speed.z = 0; // no need to move on the vertical axis
if (key_p)
{
freeze_mode = 1;
set(pause_pan,VISIBLE);
mouse_mode = 2;
}
phent_addtorqueglobal (my, ball_speed); // add a torque (an angular force) to the ball
rot_angle += mickey.x * 4;
rot_height = clamp(rot_height + mickey.y * 2,0,45);
vec_set(offset,vector(-300,0,100));
vec_rotate(offset,vector(rot_angle,rot_height,0));
vec_set(camera.x,my.x);
vec_add(camera.x,offset);
camera.pan = rot_angle;
camera.tilt = -rot_height;
if (key_space)
{
phent_addvelcentral(my,vector(0,0,1000*time_step));
wait(-1); // Wartet bis man wieder springen darf
}
wait (1);
}
}
|
|
|
Re: Orbit Camera
[Re: janerwac13]
#337213
08/09/10 14:41
08/09/10 14:41
|
Joined: Dec 2008
Posts: 222
janerwac13
OP
Member
|
OP
Member
Joined: Dec 2008
Posts: 222
|
Nun ist nun ein problem auf gefallen !
Last edited by janerwac13; 08/09/10 14:44.
|
|
|
Re: Orbit Camera
[Re: janerwac13]
#337215
08/09/10 14:47
08/09/10 14:47
|
Joined: Dec 2008
Posts: 222
janerwac13
OP
Member
|
OP
Member
Joined: Dec 2008
Posts: 222
|
Nun wenn ich die kamera drehe ist nun hinten vorne und umgekeht ! Ich messe mich an dem Xbox Arcade game Marble Blast was ich parallel laufen hab um meins mit diesem zuvergleichen. Dort ist es so egal wo hin ich die cam dreh vorne bleibt vorn also wenn ich die cam nach hinten dreh ist dort von der tastertur trotz dem vorne. ich hoffe ihr versteht was ich meine und nun muss ich das irgendwie ergänzen. ich hoffe ihr helft mir da bei auch !
|
|
|
Re: Orbit Camera
[Re: janerwac13]
#337243
08/09/10 17:51
08/09/10 17:51
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
action ball()
{
VECTOR ball_speed;
var soundtrack_handle;
VECTOR kick_speed;
ENTITY* ball;
SOUND* ball_wav = "ball.wav";
ball = my;
var rot_angle = 0;
var rot_height = 12;
VECTOR offset;
var jumptimer = -1.5;
ph_setgravity (vector(0, 0, -500)); // set the gravity
phent_settype (my, PH_RIGID, PH_SPHERE); // set the physics entity type
phent_setmass (my, 3, PH_SPHERE); // and its mass
phent_setfriction (my, 80); // set the friction
phent_setdamping (my, 40, 40); // set the damping
phent_setelasticity (my, 50, 20); // set the elasticity
while (1)
{
ball_speed.x = 40 * (key_d - key_a); // move the ball using the cursor keys
ball_speed.y = 40 * (key_w - key_s); // 25 sets the x / y movement speeds
ball_speed.z = 0; // no need to move on the vertical axis
vec_rotate(ball_speed,vector(camera.pan,0,0)); //Die Zeile rotiert deinen Bewegungsvektor mit der Kamera
if (key_p)
{
freeze_mode = 1;
set(pause_pan,VISIBLE);
mouse_mode = 2;
}
phent_addtorqueglobal (my, ball_speed); // add a torque (an angular force) to the ball
rot_angle += mickey.x * 4;
rot_height = clamp(rot_height + mickey.y * 2,0,45);
vec_set(offset,vector(-300,0,100));
vec_rotate(offset,vector(rot_angle,rot_height,0));
vec_set(camera.x,my.x);
vec_add(camera.x,offset);
camera.pan = rot_angle;
camera.tilt = -rot_height;
if (key_space)
{
phent_addvelcentral(my,vector(0,0,1000*time_step));
wait(-1); // Wartet bis man wieder springen darf
}
wait (1);
}
}
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|