Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 12:52:18 AM

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


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
poohshoes
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.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic