|
Rotate toward an object with collision ....
#354375
01/18/11 02:10
01/18/11 02:10
|
Joined: Jul 2010
Posts: 129
bk9iq
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 129
|
Hello everybody, This is probably the most noob question ever but I still can't get it to work... I am using this to make my enemy rotate toward the player however I want to add collision so that it doesn't go through the walls when turning:: vec_to_angle(my.pan,vec_diff(NULL,player.x,my.x)); I tried c_rotate but didn't work: vec_to_angle(pan_enemy.pan,vec_diff(NULL,player.x,my.x)); c_rotate(my,pan_enemy.pan, NULL); Any ideas please...
Last edited by bk9iq; 01/18/11 02:17.
|
|
|
Re: Rotate toward an object with collision ....
[Re: bk9iq]
#354379
01/18/11 02:29
01/18/11 02:29
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
I tried c_rotate but didn't work Please... always tell what did not work and why you did not like the result... c_rotate(my,pan_enemy.pan, NULL); will add the pan_enemy angles to the current my.pan orientation. You would have to calculate the angle difference (f.i. with ang_diff) or do it as follows: c_rotate(my,vector(ang(pan_enemy.pan-my.pan)*time_step,0,0), NULL); //or remove time_step, depends on your situation
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Rotate toward an object with collision ....
[Re: Superku]
#354384
01/18/11 03:45
01/18/11 03:45
|
Joined: Jul 2010
Posts: 129
bk9iq
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 129
|
Thanks Superku for the reply .... I tried that and It makes the enemy changes its pan only and I couldn't make it change its Tilt .... (( However doesn't c_rotate take angle rather than vector... why do u use vector?? )) I tried using ent_turnto which is included in entmove.c in A8 however it also makes the enemy rotate with no collision detection thus useless for my case...
Last edited by bk9iq; 01/18/11 03:45.
|
|
|
Re: Rotate toward an object with collision ....
[Re: Superku]
#354570
01/20/11 04:09
01/20/11 04:09
|
Joined: Jul 2010
Posts: 129
bk9iq
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 129
|
Thanks again Superku... I am sorry for asking too much but it still doesn't work... the enemy which is a turret gets stuck and points randomly and not toward my player .... here's what I am using exactly ::
action turret()
{
ANGLE pan_enemy;
c_setminmax(me);
my.Health = 100;
while(my.Health>0)
{
vec_to_angle(pan_enemy.pan,vec_diff(NULL,player.x,my.x));
c_rotate(my,vector(ang(pan_enemy.pan-my.pan)*time_step,ang(pan_enemy.tilt-my.tilt)*time_step,0), NULL);
wait(1);
}
}
I don't know what is going wrong!!!
|
|
|
|