Stopping spawned characters...?

allc1865allc1865 Member, PRO Posts: 777
How would I stop spawned characters at a certain point. So, the spawned enemies are coming at the player, but I want them to stop a certain distance from the player and still shoot at him. Any ideas would be great. Thanks :)

Best Answer

  • jamie_cjamie_c ImagineLabs.rocks Posts: 5,772
    Accepted Answer
    Here's an update for you. I turned off your check of the magnitude and just used the enemies Y location to allow or stop movement. Check it out:

Answers

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    Kind of depends on how your game and player are working. If you're player is stationary at a certain X or Y coordinate you could stop your enemies at a certain distance from that point, for example.

    If your game is like space invaders and your player is always 'locked' at a Y coordinate of 50, you could tell your enemies not to move past the Y point of 100 with a rule like:

    if (enemies) Y location is greater than 100, move the enemy closer.


    But if your game is more complex and the player moves all around you'd probably need to use the Magnitude Function to keep track of the distance between the player and enemies.

  • allc1865allc1865 Member, PRO Posts: 777
    @jamie_c, Thanks for your reply!
    I have that set up, but the last rule on the enemy: attribute > self.distanceFrom is less that 150 > accelerate towards...I want him to stop accelerating or spawning, which I'm not sure how to do...
  • -Timo--Timo- Member Posts: 2,313
    replace accelerate with move to player positions?
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited October 2013
    If you are using an Accelerate to move, you'll need to change the enemies acceleration to 0 to stop it.

    Can you post your rules?
  • allc1865allc1865 Member, PRO Posts: 777
    Sure, I can post my template. You can find it here:
    https://www.dropbox.com/s/x3ulcfxk23anebx/enemies spawn and shoot .zip

    Thanks, guys
  • allc1865allc1865 Member, PRO Posts: 777
    That makes a difference. Thanks so much for your help.
    Just a quick thought: If I wanted him to stop coming from the side, I would just use his X location?
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    If you wanted to stop the enemies at an X AND Y distance I think you're better off using Magnitude, I've attached an updated sample showing that. I've also edited the player so it can move anywhere on screen and also the enemies chase after the player.

    If you are only concerned with stoping your enemies from moving in the X OR Y direction, I think the previous sample is fine.
  • allc1865allc1865 Member, PRO Posts: 777
    This helps. This new file is exactly what I needed! I needed them moving along with the actor.
    Thank you very much :)
    I guess I just have another question. I have a minimap in my game, and I placed the rules from the template you gave me into my game, and the enemies aren't shooting anymore. I've tried to figure this out myself, though, but I'm not sure what the problem is.
    I think it's because I have constrain attributes in the dots on the map; that may be messing with the enemies.
  • allc1865allc1865 Member, PRO Posts: 777
    Here's the link if you want to take a look at it.
    https://www.dropbox.com/s/p6tp39255s3yz8e/My actor game.zip
  • allc1865allc1865 Member, PRO Posts: 777
    Thanks very much for your help! It works ;) I got it figured out :) Thanks again! :)
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    Great, glad you got it worked out. You're welcome! :)
  • allc1865allc1865 Member, PRO Posts: 777
    @jamie_c, Hi. Using the template you gave me, how could I make the spawned actors not overlap? I was watching tshirtbooth's video on it, but I wouldn't think I could use it because he's having them appear at certain places using tables.
    Thanks.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    Could you just add a Collide behavior to them setting it to collide with itself?
  • allc1865allc1865 Member, PRO Posts: 777
    I did....I just thought there was another way I should be doing it...

    Thanks for all your time :) ! :-bd
  • allc1865allc1865 Member, PRO Posts: 777
    That's simple enough, anyway. ;)
Sign In or Register to comment.