Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 396 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Tight arch #458373
03/07/16 13:15
03/07/16 13:15
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Hi, I use this code to make a smooth rotation for the enemy:

Quote:

vec_diff(temp_dir, camera.x, my.x);
vec_to_angle(offset_angle, temp_dir);
my.pan += ang(offset_angle.pan - my.pan) * 0.2 * time_step;


The enemy rotates smoothly to the camera, after detecting the player.

This is fine. But, if the enemy is currently going on a path or only straight forward, the enemy is rotating to the player while walking in a bow.

This is also fine. But this arch is not tight enough. Is it possible to make that arch or bow tighter?

I will try to describe it with a little sketch.

P = player
E = Enemy

1: Enemy is on path or straight forward, walking away from player.

|
|
E


P


2: Enemy has detected player and is turning with the quoted code. You can see the way of the enemy on the line. (Please forget the points. They show only the distance) Watch only the line.

.___
/....\
E....|

P

But this way/arch is too wide.

It should be like:
.__
/..\
E..|

P

The turning bow is tighter.



Any idea to reach this goal?

Thanks.

Re: Tight arch [Re: Logitek] #458374
03/07/16 13:23
03/07/16 13:23
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Something like

my.pan += clamp(ang(offset_angle.pan - my.pan) * 0.5, -25*time_step,25*time_step);

maybe? If the last bit of turning should be smoother again, take the "time_step" out of the clamp instruction again and put it at the end of the line.

Alternatively or on top of that, you can separate move direction and the actual pan value. I do that every now and then, too, when I for example want to move an enemy plane on a rather tight path but still want it to look smooth. Something like this:

my.skill10 += clamp(ang(offset_angle.pan - my.skill10),-25,25)*time_step;
my.pan += ang(my.skill10-my.pan)*0.2*time_step; // or some other clamp thingy too
vec_set(temp,vector(15*time_step,0,0)); // the move speed
vec_rotate(temp,vector(my.skill10,0,0));
c_move(me,nullvector,temp,...);


"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: Tight arch [Re: Superku] #458375
03/07/16 13:40
03/07/16 13:40
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Hi, okay thank you for the fast reply and the hints. I will try that and will leave a feedback laugh

Re: Tight arch [Re: Logitek] #458379
03/07/16 16:51
03/07/16 16:51
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Thank you, it is working fine!

Re: Tight arch [Re: Logitek] #458382
03/07/16 17:28
03/07/16 17:28
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Good, and you are welcome!


"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

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