Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Advanced search

1404719 Posts in 68420 Topics- by 62073 Members - Latest Member: HWinsen

February 05, 2023, 03:29:55 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Need help with flocking
Pages: [1]
Author Topic: Need help with flocking  (Read 1864 times)
Ivan Dooray

View Profile
« on: January 06, 2021, 04:24:21 AM »

I have a window application where entities (pigs) float across the screen. http://cpp.sh/9bu7e
Problem is that I don't know if my flocking implementation is correct since they all act like only cohesion is taking place. https://gyazo.com/a73b38a30d714510b9d6711520126bef
They do not seem to act natural and I feel like the forces are not correctly implemented.
Would be great if I could get a screen share session with someone over any application to help me out with my school project so I can show all the code and explain everything a bit better.
« Last Edit: January 06, 2021, 05:11:39 AM by Ivan Dooray » Logged
Level 0

View Profile WWW
« Reply #1 on: February 02, 2021, 12:03:43 PM »

Be careful or your attraction force and repulsion force will cancel each other out.  Think about how they could behave differently to support your desired behavior.

Debugging suggestions:
Make a simple case with few entities.
Draw the individual force vectors as colored lines emanating from the middle of the entity (where line length = vector length).
Test the forces one at a time to make sure each one behaves as you expect.
Only run the update code on one entity so the others don't move.
What is the desired behavior and what forces would make that happen? (draw out a diagram of the forces in sample scenarios)
Look up the specifics of how other flocking systems work.

Pages: [1]
Jump to:  

Theme orange-lt created by panic