spawning actors
gpoppi
Member, PRO Posts: 47
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?
is it possible?
Comments
In the actor that was spawned, whatever you use for random movement, use the random function there.
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
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
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?