Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 831 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
collision avoidance #325338
05/26/10 05:51
05/26/10 05:51
Joined: Mar 2009
Posts: 25
kholis Offline OP
Newbie
kholis  Offline OP
Newbie

Joined: Mar 2009
Posts: 25

entity C is a player. entity A and entity B will follow player movement in any formation.

if player keep moving straight, i want to make entity A turn left and walk in same direction of cube side without touching yellow area. entity B is also the same but he will turn right (according to the obstacle in front of him)

need some help.

thanks

Re: collision avoidance [Re: kholis] #325366
05/26/10 10:05
05/26/10 10:05
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
Do you move them by clicking to a location (like in an RTS)
Or by moving the player directly (like in a 3rd person game)?

In the case of an RTS, the position within the formation
are calculated first, and the Units move toward their target-points.
In the case the targetpoints are in an inpassable area, you need
a function to look for a point closest to the targetpoint, wich
can be accessed. (you could try that out by looking around
in a "circle", until the new targetpoint is on a passable terrain),
and set this as new targetpoint.

--

In the case of a 3rd person game, its more tricky,
as the units will move constantly relative to the players
position, and their favorable formation position.

I would simply first develop a normal obstacle avoidance
(such as using traces to the front, and turn the unit when
a fronttrace gets too close to a wall)
Such that the unit first tries to walk to the position in
the formation, and in the second step rotates to avoid
getting too close to a wall)

After a timeinterval (like 2 seconds) the unit tries to turn and
walk towards the formation-position again.

This way the units will head towards the formation position,
but avoid obstacles as long as needed.
But on a free terrain, they will exacly follow the formation then.

Good would be for the unit to constantly turn towards the
formation-target (every frame), but once the
avoidance-trace hiths a wall in a savety-distance, the
unit will stop turning towards the formation.target every frame,
and rather rotate sidewasy, until the trace does not hit a
wall. (it continious walking, as long as it does not get
too far away from the player)
The unit checks then every 2 seconds if a trace towards
the formation-target is possibe.
If yes, it switches back to the normal state.

Instead of turning before an obstacle, you can also
let the units step sideways, and keep turning towards to
formation-target.
You should use traces to the side then as well.
(its really mainly testing out wich works best)

Re: collision avoidance [Re: Damocles_] #325544
05/27/10 04:46
05/27/10 04:46
Joined: Mar 2009
Posts: 25
kholis Offline OP
Newbie
kholis  Offline OP
Newbie

Joined: Mar 2009
Posts: 25
@Damocles:
thanks for the answer.
i move the player directly (like in a 3rd person game)

Re: collision avoidance [Re: kholis] #325696
05/27/10 17:56
05/27/10 17:56
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Man, can I ask you to upload the result of what you've done? I also need collision avoidance laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: collision avoidance [Re: 3run] #327550
06/07/10 04:53
06/07/10 04:53
Joined: Mar 2009
Posts: 25
kholis Offline OP
Newbie
kholis  Offline OP
Newbie

Joined: Mar 2009
Posts: 25
what function better i use to detect collision? c_scan or EVENT_BLOCK? or any other?


is there any function can be used to determine entity hit angle (α) from obstacle?


Last edited by kholis; 06/07/10 04:55.
Re: collision avoidance [Re: kholis] #327552
06/07/10 06:43
06/07/10 06:43
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
I think 'c_trace' is a faster solution. When the trace hits a surface the 'normal' variable is set to the normal of the hit surface. The angle you require is the arc-cosine of the dot-product of the normal and trace direction.

Re: collision avoidance [Re: kholis] #327952
06/09/10 14:21
06/09/10 14:21
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline
Member
paracharlie  Offline
Member
P

Joined: Mar 2009
Posts: 146
USA
You could use c_content. This is some code that George wrote in aum88 for unanswered questions. It uses c_content for obstacle avoidance and it does work very well. You could adapt this in your code and just play with the settings, to get them set the way you want.

Code:
// the road is clear? then rotate the enemy towards the player

                       if (c_content (content_right.x, 0) + c_content (content_left.x, 0) == 2) 

                       {

                               vec_set(temp, player.x); 

                               vec_sub(temp,my.x); 

                               vec_to_angle(my.pan, temp); // turn the enemy towards the player

                       }

                       if (vec_dist (player.x, my.x) > 500)

                       {

                               vec_set(content_right, vector(50, -20, -15));

                               vec_rotate(content_right, my.pan);

                               vec_add(content_right.x, my.x);

                               if (c_content (content_right.x, 0) != 1) // this area isn't clear?

                               {

                                       my.pan += 5 * time_step; // then rotate the enemy, allowing it to avoid the obstacle

                               }

                               vec_set(content_left, vector(50, 20, -15));

                               vec_rotate(content_left, my.pan);

                               vec_add(content_left.x, my.x);

                               if (c_content (content_left.x, 0) != 1) // this area isn't clear?

                               {

                                       my.pan -= 5 * time_step; // then rotate the enemy, allowing it to avoid the obstacle

                               }

                               c_move (my, vector(10 * time_step, 0, 0), nullvector, GLIDE);

                               ent_animate(my, "run", run_percentage, ANM_CYCLE); // play the "run" animation

                               run_percentage += 6 * time_step; // "6" controls the animation speed

                       }




A8 Commercial
Re: collision avoidance [Re: paracharlie] #327957
06/09/10 15:11
06/09/10 15:11
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
@paracharlie:
From the manual:
c_content, works only without mesh-levels and AABB collisionsystem. Don`t use it in new projects (A7) !!!!

Re: collision avoidance [Re: Widi] #327962
06/09/10 15:51
06/09/10 15:51
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I used c_content to make AI, works great, and yep, I work with level blocks only. but turning bots pan till c_content touches something is not that good way, better make bot strafe or even better to make a counter, so when one of the contents touches anything, and bots pan turns, just switch on the counter, and till counter will be equal to some number (60 for example), bot will not turn to player, that way it'll looks more realistic.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

Moderated by  HeelX, Spirit 

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