Physik Objekt Lenken usw.

Posted By: janerwac13

Physik Objekt Lenken usw. - 08/29/10 08:48

Hi,
Ich habe einen Schlitten als Physik Objekt, aber er soll auch lenken. Mit my.pan bekomm ich es nicht hin wie mit einem noramlen Charakter.
Posted By: Progger

Re: Physik Objekt Lenken usw. - 08/29/10 08:56

Vector speed;
here you go

if(key_s)
my.pan+=1;

if(key_a)
my.pan-=1;

if(key_w)
{
speed.x = 10; speed.y = 0; speed.z = 0;
vec_rotate(speed,my.pan);
phent_addvelcentral(my,speed);

}
Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 08:59

action sledge ()
{
var walk_percentage;
var death_percentage;
player = me;
Kamera();
phent_settype (my, PH_RIGID, PH_BOX);
phent_setmass (my, 1, PH_BOX);
phent_setfriction (my, 10);
phent_setdamping (my, 5, 5);
phent_setelasticity (my, 0, 0);
ph_setgravity (vector(0, 0, -386));
while (1)
{
if(key_w)
{
ent_animate(my,"paddeln",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 12 * time_step; // 3 = animation speed for "walk"
}

if(key_s)
{
ent_animate(my,"bremsen",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 12 * time_step; // 3 = animation speed for "walk"
}
if(key_d)
{
ent_animate(my,"rechtslenken",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 8 * time_step;
}

if(key_a)
{
my.pan-=1;
ent_animate(my,"linkslenken",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 8 * time_step; // 3 = animation speed for "walk"
}
wait (1);
}
}
Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 10:26

Das lenken funkt trotz dem nicht !
Trotz dem Danke Progger ! wink
Posted By: Progger

Re: Physik Objekt Lenken usw. - 08/29/10 10:28

Code:
Vektor speed;
action sledge ()
{
var walk_percentage;
var death_percentage;
player = me;
Kamera();
phent_settype (my, PH_RIGID, PH_BOX);
phent_setmass (my, 1, PH_BOX);
phent_setfriction (my, 10);
phent_setdamping (my, 5, 5);
phent_setelasticity (my, 0, 0);
ph_setgravity (vector(0, 0, -386));
while (1)
{
if(key_d)
{
my.pan+=1;
ent_animate(my,"rechtslenken",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 8 * time_step;
}

if(key_a)
{
my.pan-=1;
ent_animate(my,"linkslenken",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 8 * time_step; // 3 = animation speed for "walk"
}


if(key_w)
{
speed.x=100; speed.y=0; speed.z=0;
vec_rotate(speed,my.pan);
phent_addvelcentral(my,speed);
ent_animate(my,"paddeln",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 12 * time_step; // 3 = animation speed for "walk"
}

if(key_s)
{
speed.x=-100; speed.y=0; speed.z=0;
vec_rotate(speed,my.pan);
phent_addvelcentral(my,speed);
ent_animate(my,"bremsen",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 12 * time_step; // 3 = animation speed for "walk"
}

wait (1);
}
}


this should work
WFG Progger
Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 10:33

Danke Progger aber es funkt immer noch nicht !
Das lenken mein ich und die Bremse ist zwar gut nur dann geht es rückwerts
Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 10:34

action sledge()
{
VECTOR speed;
var walk_percentage;
var death_percentage;
player = me;
Kamera();
phent_settype (my, PH_RIGID, PH_BOX);
phent_setmass (my, 1, PH_BOX);
phent_setfriction (my, 10);
phent_setdamping (my, 5, 5);
phent_setelasticity (my, 0, 0);
ph_setgravity (vector(0, 0, -386));
while (1)
{
if(key_d)
{
my.pan+=1;
ent_animate(my,"rechtslenken",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 8 * time_step;
}

if(key_a)
{
my.pan-=1;
ent_animate(my,"linkslenken",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 8 * time_step; // 3 = animation speed for "walk"
}


if(key_w)
{
speed.x=-5; speed.y=0; speed.z=0;
vec_rotate(speed,my.pan);
phent_addvelcentral(my,speed);
ent_animate(my,"paddeln",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 12 * time_step; // 3 = animation speed for "walk"
}

if(key_s)
{
speed.x=5; speed.y=0; speed.z=0;
vec_rotate(speed,my.pan);
phent_addvelcentral(my,speed);
ent_animate(my,"bremsen",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 12 * time_step; // 3 = animation speed for "walk"
}

wait (1);
}
}
Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 10:38

ok it works now!
i hope you can also help me with tehe camera.
the camera follow the player, but doesn't rotate.
i tried with vec_set(camera.pan,Player.pan); but it doesnt work !
Posted By: Progger

Re: Physik Objekt Lenken usw. - 08/29/10 10:45

here you go (:
Code:
action sledge()
{
VECTOR speed;
var walk_percentage;
var death_percentage;
player = me;
Kamera();
phent_settype (my, PH_RIGID, PH_BOX);
phent_setmass (my, 1, PH_BOX);
phent_setfriction (my, 10);
phent_setdamping (my, 5, 5);
phent_setelasticity (my, 0, 0);
ph_setgravity (vector(0, 0, -386));
while (1)
{
if(key_d)
{
my.pan+=1;
ent_animate(my,"rechtslenken",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 8 * time_step;
}

if(key_a)
{
my.pan-=1;
ent_animate(my,"linkslenken",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 8 * time_step; // 3 = animation speed for "walk"
}


if(key_w)
{
speed.x=-5; speed.y=0; speed.z=0;
vec_rotate(speed,my.pan);
phent_addvelcentral(my,speed);
ent_animate(my,"paddeln",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 12 * time_step; // 3 = animation speed for "walk"
}

if(key_s)
{
speed.x=5; speed.y=0; speed.z=0;
vec_rotate(speed,my.pan);
phent_addvelcentral(my,speed);
ent_animate(my,"bremsen",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 12 * time_step; // 3 = animation speed for "walk"
}
camera.x = player.x - 200 * cos(player.pan); // 200 = distance

camera.y = player.y - 200 * sin(player.pan); // same value here

camera.z = player.z; // above the player

camera.pan = player.pan;

camera.tilt = 0; // look down at the player

camera.roll = 0;

wait (1);
}
}


Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 10:51

function Kamera()
{
var rot_angle = 0;
var rot_height = 0;
while(me != NULL)
{
vec_set(offset,vector(0,-150,100));
camera.pan = 90;
camera.tilt = -20;
vec_set(camera.x,my.x);
vec_add(camera.x,offset);
wait(1);
}
}
Posted By: Progger

Re: Physik Objekt Lenken usw. - 08/29/10 10:58

does it work now?
Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 11:01

the camera doesnt rotate with the player !
This is my code, write in the lines for the camera rotation please !
function Kamera()
{
var rot_angle = 0;
var rot_height = 0;
while(me != NULL)
{
vec_set(offset,vector(0,-150,100));
camera.pan = 90;
camera.tilt = -20;
vec_set(camera.x,my.x);
vec_add(camera.x,offset);
wait(1);
}
}
Posted By: Progger

Re: Physik Objekt Lenken usw. - 08/29/10 11:07

first you need to put the function in the main

funtion main()
{
Kamera();
}
why you dont use this for ur camera?
camera.x = player.x - 200 * cos(player.pan); // 200 = distance

camera.y = player.y - 200 * sin(player.pan); // same value here

camera.z = player.z; // above the player

camera.pan = player.pan;

camera.tilt = 0; // look down at the player

camera.roll = 0;
Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 11:09

it doesnt work how i want !
before i can use your code i must edit it !
Posted By: LemmyTheSlayer

Re: Physik Objekt Lenken usw. - 08/29/10 11:15

there is an example in the lite-c workshops
Code:
function camera_follow(ENTITY* ent)
{
   while(1) {
     vec_set(camera.x,offset);
     vec_rotate(camera.x,ent.pan);
     vec_add(camera.x,ent.x);
     vec_set(camera.pan,vector(ent.pan,-10,0));
     wait(1);
   }
}


Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 12:23

funtzt net !
Posted By: Progger

Re: Physik Objekt Lenken usw. - 08/29/10 12:25

then try my ca
mera script it does exactly what you want
Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 12:30

i tried but it doesnot work how i want !
thanks.
Posted By: janerwac13

Re: Physik Objekt Lenken usw. - 08/29/10 17:59

Progger: I'm sorry you're right !
Thanks for your help !
Posted By: Progger

Re: Physik Objekt Lenken usw. - 08/29/10 18:03

No Problem (:
Posted By: Sajeth

Re: Physik Objekt Lenken usw. - 08/29/10 18:04

you cant modify tilt/pan/roll and x/y/z of physic objects.
Posted By: Progger

Re: Physik Objekt Lenken usw. - 08/29/10 18:28

Sure u can laugh
Posted By: WretchedSid

Re: Physik Objekt Lenken usw. - 08/29/10 18:37

He can, yes, but the physics engine saves the position and orientation of the object in the simulated world. Every time the physics engine makes a frame, it will recalculate the objects position depending on its saved data. A7 will then take the calculated values and applies them to the object.

To make a long story short: You can set a position of an physics object, but it's a waste of CPU cycles.
© 2024 lite-C Forums