playMaker

Author Topic: Making a fully functional working bullet shooting  (Read 2304 times)

Avascar

  • Playmaker Newbie
  • *
  • Posts: 45
Making a fully functional working bullet shooting
« on: June 16, 2013, 08:30:07 PM »
I'm attempting to create an enemy to shoot a gameobject at the player in a 2d platformer game and if the player ever touches it he dies. I have not succeeded in any of the parts except creating the gameobject.

The bullet gameobject has a box collider, rigidbody, Character Controller, and Character Motor. The Character Motor and Character Controller is there so if the bullet touches the ground it disappears (although the problem is that the first bullet that touches the ground and dies, no bullets spawn anymore).

The script I put in the bullet is a custom action that tells if the Motor is Grounded (it seems to be much more accurate and responds faster than Character is Grounded), and if so it destroys itself ("Destroy Self").

Another FSM within the bullet is a Add Force action. It's the only state there and it's set as "Every Frame". The Position I put in is the position of the Player that updates every frame (I used Get Position in the player to get this).

Now, whenever I play the game the bullet just falls down through everything and I lag out (this was before I added Motor is Grounded) even with the Use Gravity is unchecked in the Rigidbody Inspector. After that, if a bullet touches the ground and destroys itself, no other bullets spawn (I think I removed the prefab itself with Destroy Self).


If you didn't understand any of that (there was a lot to explain and I have other things to do in my schedule) then just tell me how to make a fully functional bullet that attempts to hit the player in a 2d game. Also, make sure to let it do something after it hits the player.

Thanks~