4 registered members (M_D, AndrewAMD, Quad, Ayumi),
806
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
PhysX movement
#387299
11/16/11 22:24
11/16/11 22:24
|
Joined: Dec 2009
Posts: 53
Vyshess
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2009
Posts: 53
|
Hi @ all! I started my next game and want to use the physic-engine. everything works good except the player movement. at first I was giving the player a box collision but that doesn`t works because, by running the skript, the player disappears suddenly or falls through the test-level(a hollow block),not sure what exactly happens. So I was trying the capsule collision.at first it looks good.I see the player and can walk around..but there is something strange. I set the foots of the player exactly on the ground but if I push one of the movement-keys, the player model is suddenly a bit over the ground. apart from that the movement works very good. thx for help my player-code:
action hero()
{
var anim_percentage;
pXent_settype(my, PH_CHAR, PH_CAPSULE);
set(my,SHADOW);
wait(1);
my.emask |= ENABLE_SCAN; // make the player sensitive to scanning
player = my; // I'm the player
while(players_health > 0)
{
//player movement//
movement_speed.x = 10 * (key_cuu - key_cud) * time_step; // move the player using "cuu" and "cud"
movement_speed.y = 10 * (key_cul - key_cur) * time_step; // move the player using "cur" and "cul"
pXent_movechar(me, movement_speed, NULL, 0);
///////////////////
//player animation//
if(key_cuu || key_cud)
{
if(movement_speed.x > 0){my.pan = 0;} // turn player to right
if(movement_speed.x < 0){my.pan = 180;} // turn player to left
anim_percentage += 7 * time_step;
ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation
}
if(key_cur || key_cul)
{
if(movement_speed.y > 0){my.pan = 90;} // turn player to right
if(movement_speed.y < 0){my.pan = -90;} // turn player to left
anim_percentage += 7 * time_step;
ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation
}
if (key_cuu + key_cud + key_cur + key_cul == 0) // none of the movement keys are pressed?
{
anim_percentage += 1.2 * time_step;
ent_animate(my, "idle", anim_percentage, ANM_CYCLE); // play the "stand" animation
}
/////////////////////
on_l = plant_bomb;
wait(1);
}
}
A8 Commercial A5 Standart --------------- created games: - Bomber Maniacs
|
|
|
Re: PhysX movement
[Re: Pappenheimer]
#387452
11/18/11 20:26
11/18/11 20:26
|
Joined: Dec 2009
Posts: 53
Vyshess
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2009
Posts: 53
|
Thanks guys! Problem solved!!
A8 Commercial A5 Standart --------------- created games: - Bomber Maniacs
|
|
|
Re: PhysX movement
[Re: 3run]
#387493
11/19/11 19:15
11/19/11 19:15
|
Joined: Dec 2009
Posts: 53
Vyshess
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2009
Posts: 53
|
@ 3run: oh sure! i forgot to post the answer, sorry ^^ i used Roal`s advice and it works very well!
action hero()
{
my.scale_z = 0.1; //makes me smaller for a smaller hull
pXent_settype(my, PH_CHAR, PH_CAPSULE);
my.scale_z = 1.0; //get back my original size
...
}
Last edited by Vyshess; 11/19/11 19:18.
A8 Commercial A5 Standart --------------- created games: - Bomber Maniacs
|
|
|
Re: PhysX movement
[Re: Vyshess]
#388055
11/27/11 18:12
11/27/11 18:12
|
Joined: Dec 2009
Posts: 53
Vyshess
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2009
Posts: 53
|
hi! i had another problem! can someone tell me how to use "pXent_addexplosion" correctly? my player can place bombs. and this bombs should be blow away a box. i give the box this action:
action ph_box() // simple physics-based box
{
pXent_settype(my, PH_RIGID, PH_BOX); // this entity behaves like a box
}
and the bomb has this function:
function bomb_behavior()
{
VECTOR bomb_pos;
while(explo_time > bomb_wait_time) //after some seconds, the bomb explode
{
explo_time -= time_step/16;
pXent_settype(my, PH_RIGID, PH_SPHERE); // this entity behaves like a ball
pXent_setfriction(my, 100);
pXent_setelasticity(my, 10);
pXent_setdamping(my, 100,40);
bomb_pos.x = my.x; //get the actually position of the bomb
bomb_pos.y = my.y;
bomb_pos.z = my.z;
... //the rest of the code (explosion anim etc.)
wait(1);
}
pXent_addexplosion( my, bomb_pos, 1000,500); //values ok???
wait(-2);
ent_remove(my);
}
i spend some hours with that addexplosion and the values but it doesn`t work.the box doesn`t move. sometimes the box disappears or flys to another dimension, not sure what happend there.
A8 Commercial A5 Standart --------------- created games: - Bomber Maniacs
|
|
|
Re: PhysX movement
[Re: HeelX]
#388115
11/28/11 14:37
11/28/11 14:37
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Its tooo much. My explsoion vars for a nade: pXent_addexplosion(me,nullvector,200,300);
Last edited by Ch40zzC0d3r; 11/28/11 14:37.
|
|
|
Re: PhysX movement
[Re: Ch40zzC0d3r]
#388152
11/28/11 19:10
11/28/11 19:10
|
Joined: Dec 2009
Posts: 53
Vyshess
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2009
Posts: 53
|
i know that 1000 is too much. in my desperation, i was trying some crazy values. i set the force to 10 to see whats going on. the bomb flys like a rocket to the sky...okay maybe i misunderstand the "VECTOR*vPos" part. so i replaced "bomb_pos" with "nullvector". and now it seems that the bomb is hit by an explosion an flys to a random direction. but the box is still uneffected...even by a radius with 2000!
A8 Commercial A5 Standart --------------- created games: - Bomber Maniacs
|
|
|
|