Forums > MaxMSP

Cosm – having agents following each other in cosm

May 1, 2011 | 8:25 pm


I am using the Cosm library, and I have a few agents with randomly fluctuation colors. I want agents to follow each other based on if they are the same color, at any given moment

I am getting the XYZ world coordinates from each one – and am using (ZL Compare) and (gate) to check if agents match and send coordinates to the other same-colored agent – but when I send them through (pak position f f f) and to (cosm.nav) of the other agent, the only thing that happens is that the agent is positioned in the middle of the world.

In other words; they dont follow each other but are only repositioned in the place the start when the patch is loaded

If anyone has been building algorithms to have agents chaise eachother It would be much appriciated if you could show me how you have done it.

Best regards

May 1, 2011 | 8:50 pm

The best example are in the cosm example patcher in the Camera Follow subpatch. But I think you have to send the position xyz to the object directly.

The proper way to do this I think though is a little trickier. Will investigate.

– Pasted Max Patch, click to expand. –
May 1, 2011 | 9:02 pm

Thanks :)

October 17, 2011 | 11:43 pm

I am trying to use the camera follow subpatch above

It works fine for a while (about a minute) but after that, the camera sets on a certain trajectory and stops following the given agent??

seems like a bug

Also, when this happens the W,A,S,D buttons stop working ( they work until this "bug" starts its thing)

Any good ideas of what might be causing this to happen ?

All the best.

October 19, 2011 | 5:11 pm


There could be a bug in the camera tracking patch; maybe the quaternion is not being normalized (small differences can accumulate over time, leading to bizarre results), or maybe its an issue with measuring the distance in the toroidal space. I’m sorry that with the Max 6 release workload we probably won’t have time to look into this now.

Try changing the speed at which the camera follows (slow it down) or vary the distance to the followed object – might not fix it, but might make it take longer to become apparent. Sorry I can’t be more helpful right now.


October 19, 2011 | 5:55 pm

Thanks grrrwaaa

Yeah if I jerk the rotation control of each agent – then it starts working again but stops working after the same time interval, after that

I have yet to test if changing speed will affect it in any way

I am trying to get agents to follow each other like a flock and I would actually like the following-patch to be faster than in the above example

I understand that many Max-ers are busy with Max6 coming out, but if you have any other examples (or can point me to) of agent following patches or methods, it would be much appriciated

(also if you have any more documentation or examples than is on the cosm website/download I would be very interested.)

Thanks alot for the response

Best regards.

Viewing 6 posts - 1 through 6 (of 6 total)