Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AbrahamR, wdlmaster, 7th_zorro, dr_panther, 1 invisible), 764 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Rotate toward an object with collision .... #354375
01/18/11 02:10
01/18/11 02:10
Joined: Jul 2010
Posts: 129
B
bk9iq Offline OP
Member
bk9iq  Offline OP
Member
B

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::

Quote:
vec_to_angle(my.pan,vec_diff(NULL,player.x,my.x));



I tried c_rotate but didn't work:
Quote:
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 Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
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
B
bk9iq Offline OP
Member
bk9iq  Offline OP
Member
B

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: bk9iq] #354410
01/18/11 15:14
01/18/11 15:14
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The functions usually work with both ANGLE and VECTOR.

c_rotate(my,vector(ang(pan_enemy.pan-my.pan)*time_step,ang(pan_enemy.tilt-my.tilt)*time_step,0), NULL);

Or use ang_diff and the like, as I've already suggested.


"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] #354570
01/20/11 04:09
01/20/11 04:09
Joined: Jul 2010
Posts: 129
B
bk9iq Offline OP
Member
bk9iq  Offline OP
Member
B

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 ::

Code:
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!!!


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1