spawning actors

gpoppigpoppi Member, PRO Posts: 47
edited November -1 in Working with GS (Mac)
hi people , I'm trying to get actors to spawn in random places within a certain parameter and get them to move randomly in the same parameter.
is it possible?

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    In the actor that spawns your randomly placed actor, use the random function in the expression editor for the X/Y coordinates.

    In the actor that was spawned, whatever you use for random movement, use the random function there.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Codemonkey is going to hate me for throwing out an idea that doesn't use math (sorry but I know I am not alone when it comes to math)

    You could spawn an actor in a certain area and give it velocity with a random angle. To constrain it you could create invisible rectangular actors and use 4 of them to make a "fence" around the actor with random motion. Set the boundaries to only collide with the actors they are constraining. You could even create a rule that says when the constrained actor collides with the "fence"- velocity with random angle (this means every time it collides with the fence it should bounce off at new random angle).

    I'm sure codemonkey will have a good reason why math is better, but for us mathphobes I thought I would throw this out
  • gpoppigpoppi Member, PRO Posts: 47
    ok thx a lot
  • JGary321JGary321 Member Posts: 1,246
    less actors on screen = better performance.

    less rules = better performance

    one small rule spawn actor random(0,320) will run a lot better.

    they both 'work'. but keep in mind you want every scrap of performance you can get =)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Damn! I shouldn't have slept through math class!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Before I give up my mathless ways...

    In my game I have a rather large mazelike world. My player needs to find the bad guys and destroy them. I want the bad guys to move around but I don't really want them to pace back and forth as described in the wiki. I want them to bounce around. If I use a constrain behavior wouldn't I need separate actors for each bad guy? With my mathless way of just "fencing" them in I can make them stay in a separate area and they bounce all around in there own area as they collide with the fences. If I used the constrain behavior wouldn't I need separate x coordinates for each bad guy? And wouldn't I then need 20 different actors for 20 bad guys? If so, would that use more memory?

    In other words what is worse - 20 unique actors or 20 copies of the same actor?
Sign In or Register to comment.