playMaker

Author Topic: 2D bullet going backwards  (Read 2316 times)

PapaSjeff

  • Playmaker Newbie
  • *
  • Posts: 3
2D bullet going backwards
« on: August 13, 2016, 03:38:24 AM »
Hey guys,

I am new with playmaker and am trying to create a 2d platformer.

My character has a gun that can shoot bullets and additionally it can be aimed up and down (rotation of the gun). Now That all works and the bullet is also flying the right way. The only problem i have is when i walk back. When i walk back (to the left) and shoot, the bullet still fly the other way (right).
I flip my player(the whole game object) by scaling it with -1 for left and back to 1 for right.

I move the bullet with "I Tween Move Add" and adding a value to the vector (x in this case).

Could someone help me?

Thanks in advance

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: 2D bullet going backwards
« Reply #1 on: August 13, 2016, 06:54:12 AM »
Hi and welcome to the forum!

I have never used iTween move add (or any iTween). Im not sure i would make a bullet this way, but what works for you depends on the rest of your setup I guess.

As for reversing the bullet, try to enter the same value but negative. So if x is 4 to fire right, make it -4 when you want it to fire left .

Just a guess, but hopefully should work.

Good luck with it!

PS: check out this tutorial: (this is the part about making attacks - including a ranged attack- but starting from part 1 may be useful for you generally as youre making a 2d platformer).
« Last Edit: August 13, 2016, 06:59:23 AM by Zeldag »

PapaSjeff

  • Playmaker Newbie
  • *
  • Posts: 3
Re: 2D bullet going backwards
« Reply #2 on: August 14, 2016, 10:19:36 AM »
Hi and welcome to the forum!

I have never used iTween move add (or any iTween). Im not sure i would make a bullet this way, but what works for you depends on the rest of your setup I guess.

As for reversing the bullet, try to enter the same value but negative. So if x is 4 to fire right, make it -4 when you want it to fire left .

Just a guess, but hopefully should work.

Good luck with it!

PS: check out this tutorial: (this is the part about making attacks - including a ranged attack- but starting from part 1 may be useful for you generally as youre making a 2d platformer).

Thank you for your reply!

I didn't want to make an exception for firing left since the other 3 directions do work.

I will check out this tutorial, i followed it partly but didn't know they where doing ranged attacks so will definitely check it out!

Thanks again!

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: 2D bullet going backwards
« Reply #3 on: August 14, 2016, 05:53:25 PM »
Hi,

No problem! Just wanted to say though, I hope youre not too disappointed with the ranged attacks in that tutorial, as it does not go too much into ranged attacks, like it does not make them shoot up or down, just straight.

But as I was saying, I would probably never use a tween for firing a bullet anyway. So overall if you dont mind (like if it works for the rest of your setup), you could get rid of the tween action and just create it the way it is done in the tutorial - then it will be much easier to work out how to make it shoot up and down, as left and right already work :) (It was a while ago that I did it, so cant even remember how they even do it).

Good luck with it.

(edit to add: ) This just popped into my head. If you are really set on using the tween action you used and just really dont want to make an exception in the same FSM that fires the bullets (or moves the bullets), I may have a workaround.

You could make the 'x value' that you use  in the tween action a global variable (in my previous post I used 4 as an example, so I will do that again). Just set the global variable to 4 (or whichever number you currently use) and then create an FSM on the character, in this FSM all you do is: get player's facing direction (however you already do it, but preferably by using a global variable you already saved it into elsewhere) and then check if it is left or right. If it is left, transition into another state and use an 'int operator' action to subtract 8 (or in your case, subtract double whatever number you use). Then get direction again and when it becomes right, go to another state that adds the same number back to the global variable and then transitions into the start state.

If the start state gets direction and it is right, do nothing and keep checking direction every frame.

Sorry for the ramble, hope it helps.
« Last Edit: August 14, 2016, 06:12:47 PM by Zeldag »

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: 2D bullet going backwards
« Reply #4 on: August 18, 2016, 08:56:32 AM »
Why do you use I Tween for bullets? Does the bullet move directly forward?
Available for Playmaker work

PapaSjeff

  • Playmaker Newbie
  • *
  • Posts: 3
Re: 2D bullet going backwards
« Reply #5 on: August 18, 2016, 10:26:03 AM »
@Zeldag

Just a quick update.
The tutorial was good and I tweaked it myself to work with my up and down system. Now it works like a charm.

Thanks again