Moving model stuck with non-move model

Posted By: Frederick_Lim

Moving model stuck with non-move model - 06/05/09 17:22

I have this question for long time, but not able to get rid of it.

What is the best approach to handle collision when moving model collide with a non-moving model? Why model collision is not as smooth as glide over map enitity?

I use c_move, c_rotate for movement.
Posted By: mpdeveloper_B

Re: Moving model stuck with non-move model - 06/05/09 19:51

In PreVa, we counteracted this by using this code:

Code:
entity* ent1;

function phys_move(e1, &reldist, &absdist, mode_)
{
	var ab;
	ent1 = e1;
	ab = c_move (ent1, reldist, absdist, mode_);
	if (ab <= 0)
	{
		vec_diff (temp, target, my.x);
		vec_inverse (temp);
		vec_normalize(temp, 0.2);
		if (you) { if (you.push >= my.push) { vec_add(my.x,temp); } } //move us away from you
		else { vec_add(my.x,temp); }
	}
}


It could be modified for A7 if any code is different there. All you have to do is replace all your c_move instructions with phys_move, this code makes it where you can use actual pan, tilt, and roll. It also makes it where you can do some light physics with it (pushing boxes, etc).
Posted By: Frederick_Lim

Re: Moving model stuck with non-move model - 06/06/09 04:15

My player entity is a vechicle. Is it good for player if user control entity is collide to a station entity the player entity automatic turn left or right and move to avoid the station entity? Will this control too frustrate to player?
Posted By: mpdeveloper_B

Re: Moving model stuck with non-move model - 06/06/09 04:20

just try replacing your c_move with it and see if it's what you need, it keeps you from being stuck in stuff. For instance:

c_move (me, vector(5,0,0), nullvector, glide);

would be changed to:

phys_move (me, vector(5,0,0), nullvector, glide);

so all you need to do is copy that code to near the top of your lines in your main script and change the red part in your c_move functions:

c_move (me, vector(5,0,0), nullvector, glide);

the phys_move function I gave you is a replacement for c_move, it keeps you from getting stuck in walls, nothing more.

It would be helpful if you would post the code in question. smile
Posted By: Tobias

Re: Moving model stuck with non-move model - 06/06/09 05:14

Originally Posted By: Frederick_Lim
What is the best approach to handle collision when moving model collide with a non-moving model? Why model collision is not as smooth as glide over map enitity?

I use c_move, c_rotate for movement.

Reason is that by default, models use non polygonal collision detection and map entities use polygonal collision detection. For collision to glide along a model just like a map entity, set the POLYGON flag for that model in WED, or in script.

Then models and map entities behave exactly the same on collision, at least in my projects there is no difference.
Posted By: Frederick_Lim

Re: Moving model stuck with non-move model - 06/06/09 10:28

mpdeveloper_B
Thanks for your code, but the code does not work well with my movement code, as I am using down force in relative movement as well. But that insprire me some idea to use later. I also found c_move also return bounce vector, maybe I will base on your code to make my own bounce effect.

Tobias
Yeah after set the POLYGON flag the collision behaves like map entity now, thanks for the hint.

Thank you all smile
© 2024 lite-C Forums