I am implementing some simple steering behaviors like: follow the leader, separation, cohesion and flee(from the leader when he walks in our direction - aka spread the group for him).
I am having issues with design of this system. I know how each of this behavior works separately but I simply can't do it with "if ladder" (as I did up to know). Can someone lead me on how to concatenate/normalize/multiply the forces and how to join them in one resultant force ?
EDIT
What I am exactly talking about is: for now I have something like so :
if(leaderGoingAtMe)
makeSpaceForhisMovement()
else if(followTheLeader)
goto(positionBehindLeader)
if(separation)
addSeparationForce()
if(cohesion)
addCohesionForce()
if(velocity > maxSpeed)
clamp(velocity, maxSpeed)
Which is EXTREMELY bad in my opinion but I have no idea how to improve it.