playMaker

Author Topic: Direction of loot drop on being shot by enemy.  (Read 589 times)

OddButAwesome

  • Playmaker Newbie
  • *
  • Posts: 46
    • View Profile
Direction of loot drop on being shot by enemy.
« on: November 10, 2015, 09:29:25 AM »
Hi all,

Just wondering if anyone could point me in the right direction.

I am making a top down shooter (with 3D objects for art style).

I have a player, an enemy turret prefab, a bullet prefab and a loot item prefab. When the player gets shot with the bullet its HP reduces and it drops a loot item.

This all works well enough except that the item drops right in the middle of the player (Create Object action). This means that the player doesn't lose the loot but instantly picks it up again. I see it flashing quickly during testing. Gameplay would let the player chase the loot after being shot, but not instantly like it is now.

Is there a way to have it be ejected in the opposite direction from the enemy bullet that struck the player? i.e. enemy is shooting from top of the screen down at player - the loot is then ejected up (probably with some slight angle for variation).

Thank you. :)

KellyRay

  • Full Member
  • ***
  • Posts: 169
    • View Profile
Re: Direction of loot drop on being shot by enemy.
« Reply #1 on: November 10, 2015, 10:40:21 AM »
Certainly.

I think there are a few things you could do to make this happen. You could add a rigidbody to the item. Select a random vector 3. Add force to the item when its dropped. Then when it hits the ground, you can tell it to turn off the rigidbody and become pick-up-able.

OddButAwesome

  • Playmaker Newbie
  • *
  • Posts: 46
    • View Profile
Re: Direction of loot drop on being shot by enemy.
« Reply #2 on: November 11, 2015, 06:22:44 PM »
Thank you for replying @KellyRay! :)

I will try this out. Your mention of timed turning off of rigidbody is making think in a different direction.


KellyRay

  • Full Member
  • ***
  • Posts: 169
    • View Profile
Re: Direction of loot drop on being shot by enemy.
« Reply #3 on: November 11, 2015, 08:41:00 PM »
Excellent! Good luck!