How to make my player throw/shoot something enemies in a platformer?

dylanbelldylanbell Member Posts: 18

I'm creating a platformer game. How can I make my player throw an object at enemies while running and kill them?

Comments

  • frdfrd Member Posts: 191

    Have your player spawn the object, give the object the appropriate movement/velocity, and destroy the enemy actor when it collides with the object.

  • IceboxIcebox Member Posts: 1,485
    edited June 2016

    Here is one way to do it

    Create 2 bullet actors ( right and left)

    bullet1 (right)
    * put a change attribute ( change attribute self.motionlinearvelocity x to 400(+ speed (right) ) )
    * Rule if self.time > 5 or collides with enemies ( destroy )

    bullet2 (left)
    * put a change attribute ( change attribute self.motionlinearvelocity x to -400(- speed(left) ) )
    * Rule if self.time > 5 or collides with enemies ( destroy )

    In your player actor

    In your movement you will have him going right or left , depending on your image you will probably use flip horizontaly to flip the image when going right/left

    if key is pressed ( choose the key you want)
    Put this rule inside
    if flip horizontally is true
    spawn actor (bullet1)
    otherwise
    spawn actor ( bullet2)

    In your enemy Actor
    If overlaps or collides with actor bullet1 or bullet2 (use tags if you want)
    destroy

  • dylanbelldylanbell Member Posts: 18
    edited June 2016

    @frd @Icebox thanks

Sign In or Register to comment.