Jump to content


Photo

Move out of the way


  • Please log in to reply
6 replies to this topic

#1 souptardd

souptardd

    GMC Member

  • GMC Member
  • 34 posts

Posted 09 October 2011 - 09:44 AM

So I have a large crowd of people moving in a certain direction but I'm having trouble with two things.
First I need them to maintain a certain distance from each other, meaning they can't go farther or closer to each other.
Second I need it so if another object I have moves into the crowd, that they will move out of the way to maintain the same distance from him as they do each other.

I can't really figure this one out so any code help would much much appreciated.

Thanks,
  • 0

#2 Logfan200

Logfan200

    GMC Member

  • GMC Member
  • 177 posts
  • Version:GM5

Posted 09 October 2011 - 09:47 AM

I guess you could try with:
create event:
n = instance_nearest(x,y,obj_crowdpeople);
step:
n = instance_nearest(x,y,obj_crowdpeople);
if distance_to_point(n.x,n.y) < 3 {
move_away_code_here;
}
Probably not the best way, but it should work if you play around with it a little bit.
  • 0

#3 souptardd

souptardd

    GMC Member

  • GMC Member
  • 34 posts

Posted 09 October 2011 - 09:56 AM

I guess you could try with:

create event:
n = instance_nearest(x,y,obj_crowdpeople);
step:
n = instance_nearest(x,y,obj_crowdpeople);
if distance_to_point(n.x,n.y) < 3 {
move_away_code_here;
}
Probably not the best way, but it should work if you play around with it a little bit.


The move_away_code_here bit is what concerns me. How do I get it so they always move in the opposite direction to the other people.
  • 0

#4 Logfan200

Logfan200

    GMC Member

  • GMC Member
  • 177 posts
  • Version:GM5

Posted 09 October 2011 - 10:04 AM

Well, uhm. One way you can do, is just change the direction of 180 when it's to near another person. But yeah, that will look kind of ****ed up. Doesn't really know how you can do it to look realistic. Probably should let somebody else answer your question.
  • 0

#5 Toxic Tom

Toxic Tom

    GMC Member

  • New Member
  • 58 posts
  • Version:GM8

Posted 09 October 2011 - 10:08 AM

You could try moving towards the nearest person with a negative speed.
  • 0

#6 souptardd

souptardd

    GMC Member

  • GMC Member
  • 34 posts

Posted 09 October 2011 - 07:53 PM

You could try moving towards the nearest person with a negative speed.


That sound good I'll give that a go.

The only thing is though is that I have a big piece of code making all the people move in the average direction in the step event. How do I make them do this at the same time?
  • 0

#7 Toxic Tom

Toxic Tom

    GMC Member

  • New Member
  • 58 posts
  • Version:GM8

Posted 10 October 2011 - 03:07 PM

Errrm, not sure. Just play about with it a bit.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users