playMaker

Author Topic: Creating Bouncing Enemies - Need Help  (Read 1341 times)

PwnyMontana001

  • Playmaker Newbie
  • *
  • Posts: 1
Creating Bouncing Enemies - Need Help
« on: January 13, 2015, 01:18:24 PM »
Hi everyone,

I'm working on a 2.5D shmup-like game and I'm attempting to make enemies which contain the following behavior:

- Enemies move at a constant velocity

- If enemy touches wall or another enemy, it will bounce off them

- If the enemy touches the player, enemy dies and player takes damage. *I have this part working.

This seems like it should be a fairly simple thing to but after about an hour of research, I've been unsuccessful in creating the desired effect.

My latest effort involved initially designating the enemy's initial direction and velocity + having this value update every frame, then on a collision event, adding a value to the rotation of the object in order to turn it around so it will keep moving on its original course, but in a different direction. However, this created the following issues:

- This doesn't dynamically determine which way the object rotates upon hitting an object. Since I'm adding the same set number each time, this approach will fall apart down the road once more complicated angles are introduced to the environment.

- When the enemy hits the player now, it no longer is destroys itself + damages the player. Instead, it now bounces off the player. This means that the player cannot be damaged by the enemy if they're standing still; they will only take damage if they manually move into the enemy.

---

I'm at a loss right now and any help on the subject would be appreciated. Also, I'm totally okay completely ditching my previously-stated hacky attempt to make this work and going down a new/better path.

Thanks!