collision with a rotating entity

Posted By: Denn15

collision with a rotating entity - 01/11/14 12:47

im trying to make an obstacle consisting of a rotating blade that will hurt you if you get hit by it, but i cant seem to get it to work. ive managed to make it work when the player is moving as well,but if the player stands still and the blade hits him, nothing happens.
how do i make something happen when the player stands stil and get hit?
Posted By: rayp

Re: collision with a rotating entity - 01/11/14 13:47

Use the EVENT_ENTITY. This should work.
Code:
void _event_hit(){
   if (event_type == EVENT_ENTITY){
      ...
   }
}
action ObstacleBlade(){
   my.emask = ENABLE_ENTITY;
   my.event = _event_hit;
   ...
}
action thePlayer(){
   my.emask = ENABLE_ENTITY;
   ...
}

Does it work with ENABLE_ENTITY ?

If not u could use
Code:
c_scan

or
Code:
vec_dist



cheers
Posted By: Reconnoiter

Re: collision with a rotating entity - 01/11/14 13:58

You will want to look into event_type / entity events. Than you have a few options; e.g. letting the blades detect the player through c_scan or c_trace. Best to use c_trace here cause it is more precise here I think.

See this tutorial for c_trace lite-c AUM tutorial.

First get two outer points of the blades where you want that if the player is between the 2 points, it is damaged (e.g. through vec_for_vertex). Than let the c_trace line begin on one end of the blades and let it end on the other side of the blades.

Something like this (I am in a hurry so could be that I missed something or made a mistake);

Code:
action blades ()
{
VECTOR vec_point_bladeleft;
VECTOR vec_point_bladeright;
....
while (1) {
vec_for_vertex(vec_point_bladeleft, my, 1); //check for the right vertex number the model in MED (the yellow dots)
vec_for_vertex(vec_point_bladeright, my, 2); //see above
c_trace (vec_point_bladeleft.x, vec_point_bladeright.x, SCAN_FLAG2); // trace between the blades on the right and on the left of the trap
if (you) {
if (you == player) you.HEALTH -= 2 * time_step;
} 
....
}
....
}



Ps; vec_dist is better if you don't need the trap/blades code to be very precise.


Posted By: Denn15

Re: collision with a rotating entity - 01/11/14 17:35

ENABLE_ENTITY only works if both entities move also.

however by using c_trace as reconnoiter showed works like a charm. thanks for the help! laugh
Posted By: Reconnoiter

Re: collision with a rotating entity - 01/12/14 11:04

Glad I could help laugh.
© 2024 lite-C Forums