Posted By: Muhsin
how do i make my model turn toward the enemy model? - 02/24/10 19:31
Hi!
how do i make my model turn toward the enemy model?
I tried to use this code:
----------------------------------
vec_set(enemypos, enemy.x);
vec_sub(enemypos, my.x);
vec_to_angle(my.pan, enemypos);
my.tilt = 0;
------------------------------------
but when i try to run the level after writing that code, I get an error saying that the action crashed?
how do i do?
thanks!!!
- Muhsin Kaymak
Posted By: Quad
Re: how do i make my model turn toward the enemy model? - 02/24/10 19:43
make sure the enemypos,enemy and my is valid for that action
Posted By: alibaba
Re: how do i make my model turn toward the enemy model? - 02/24/10 19:51
you have to write "enemypos.x" .
Posted By: Quad
Re: how do i make my model turn toward the enemy model? - 02/24/10 22:49
enemypos could be a vector, in such case it doesnot really make a diffrence.
Posted By: Muhsin
Re: how do i make my model turn toward the enemy model? - 02/25/10 13:33
here is my code for the enemy:
-----------------------------
action enemy_dummy()
{
enemy = my;
while(1)
{
wait(1);
}
}
-------------------------------
and here is the code for the model:
--------------------------------
action player_machinegun_rotater()
{
my.group = 2;
VECTOR enemypos;
while(1)
{
vec_set(enemypos, enemy.x);
vec_sub(enemypos, my.x);
vec_to_angle(my.pan, enemypos);
my.tilt = 0;
set(my,PASSABLE);
wait(1);
}
}
------------------------------------------------
what am i doing wrong?
Posted By: Muhsin
Re: how do i make my model turn toward the enemy model? - 02/25/10 15:00
it still doesn't work... could it be something in my script, i didn't write correct??
Posted By: mikaldinho
Re: how do i make my model turn toward the enemy model? - 02/25/10 15:59
have you tried to make them face each other in the 1st place?
Posted By: Quad
Re: how do i make my model turn toward the enemy model? - 02/25/10 16:17
@mika, stop the stupid comments, you have no idea what you are talking about.
@muhsin, send me the project i will look in to this.
Posted By: Rei_Ayanami
Re: how do i make my model turn toward the enemy model? - 02/25/10 16:23
Well, pretty easy
He setted the enemy to the action "my"
That means the angle from me to me is not defined
Posted By: Quad
Re: how do i make my model turn toward the enemy model? - 02/25/10 16:24
me in enemy action and the me in the other action are diffrent me, and afaik even if they were the same it would not crash
Posted By: Rei_Ayanami
Re: how do i make my model turn toward the enemy model? - 02/25/10 16:29
Oh sorry...
But both actions would start in the same frame, so enemy would not be valid ...
Posted By: Quad
Re: how do i make my model turn toward the enemy model? - 02/25/10 16:31
yeah or he should check it like
while(!enemy) wait(1); before usint the "enemy"
Posted By: Muhsin
Re: how do i make my model turn toward the enemy model? - 02/25/10 17:02
I't works now i just added "while(!enemy) wait(1);" before while(1).
and now it works!
Thanks Quadraxas!
thanks!
- Muhsin Kaymak