How Can I Make Space Invader Like Enemy Movement?

Discussion in 'How Can I...?' started by MarcG, May 23, 2020.

  1. MarcG

    MarcG Boxer

    Joined:
    May 10, 2020
    Messages:
    35
    Likes Received:
    9
    I have an enemy that moves across the screen and when it reaches a limit, it moves down the screen a little and reverses direction similar to space invaders.

    Similar to space invaders I want several enemies to move together, so if the first enemy reaches the limit the n the second and third enemy move down the same amount as the first enemy and reverse direction.

    So how can I make one enemy control update properties of the other two?
     
  2. MarcG

    MarcG Boxer

    Joined:
    May 10, 2020
    Messages:
    35
    Likes Received:
    9
    Actually I can't even achieve this! I figured it would be straightforward to have something move left until it collided with a wall and reverse its direction until it hits the wall on the right and again reverses.
     
  3. Leighton

    Leighton Avid Boxer

    Joined:
    Jan 31, 2018
    Messages:
    373
    Likes Received:
    182
    Connect the enemies to a parent object.
    Use position animation for left, right and downwards.
    Set up so its switches for the left to the right and back again :)
     
  4. MarcG

    MarcG Boxer

    Joined:
    May 10, 2020
    Messages:
    35
    Likes Received:
    9
    Thank you. That seems to be getting me closer, but not quite having the desired effect:

    So just trying to get one enemy to go left and right...

    I have a move x -3 setup when the game starts and the enemy moves towards the left wall.

    I added an 'if collides' so when it hits the left wall it fires the 'position animation' which seems to make it bounce off the wall at a greater speed than it was going, and then depending on the value I put in x it moves right for a while before moving left. How do I keep it going right without it reverting? And is it possible to keep its speed as it is?

    I'd then add a collides to the right wall with another position animation to send it back.
     
  5. MarcG

    MarcG Boxer

    Joined:
    May 10, 2020
    Messages:
    35
    Likes Received:
    9
    All I'm really trying to do is when an enemy collides with a wall object is update its Move X value and position Z value as follows:

    Move X= Move X * -1
    Position Z = Position Z + 1

    Sounds simple, but I'm beginning to feel needs to be coded and I wouldn't know where to start.
     
  6. Leighton

    Leighton Avid Boxer

    Joined:
    Jan 31, 2018
    Messages:
    373
    Likes Received:
    182
    L = Left X -0.2
    R = Right X 0.2
    then the others are for downward travel Y -0.5 & Y 0.5
     

    Attached Files:

    • 1.PNG
      1.PNG
      File size:
      59.8 KB
      Views:
      9
    MarcG likes this.
  7. MarcG

    MarcG Boxer

    Joined:
    May 10, 2020
    Messages:
    35
    Likes Received:
    9
    Thank you! That gets me very close to the desired effect.

    Not sure I'd have ever come up with that on my own.
     
    Leighton likes this.

Share This Page