C# FlockAgents steer softly towards Surface

Dear users,
I am not sure what code to add in order for the flocking agents to “steer softly” toward a surface.

The flocking simulation is based on Long Nguyen’s 2017 C# scripting for Grasshopper workshop.(https://www.youtube.com/watch?v=5R2yx6ruNJI&t=7669s)

The instructions I have been given for the agents to steer softly towards are as follows: create an additional vector that goes from the current position toward the nearest point on the surface and add this vector to the desiredVelocity vector (This should also takes not more than 3-4 extra lines of code in the “ComptueDesiredVelocity() Method).
Unfortunately I have been able to achieve this till now, so I thought to reach out for help. You can observe the code as I have attached the file to this message.

I would be grateful for any help.
Wishing you all a good day.

  • Nico

FlockingSimulation.zip (356.4 KB)