How do I stop motion_add?[SOLVED]

L

LotosPro

Guest
So basically I want to stop motion_add so it happens only once or are there any alternatives beacuse I want to push player from guns rotation so how do I stop it or is there any other way to do it. Thanks in advance!
 
L

LotosPro

Guest
Sadly this doesnt work it just has the same effect as motion_set(I apply speed = 0 after 1 frame if there are any other solutions to how to do it) it basically doesnt stop it.
 

kburkhart84

Firehammer Games
If you only call it once, it will only happen once. I'm guessing you don't want it to stop, rather you are only wanting it to stop adding more speed to it. If you post code, maybe we can figure out what you should change to make that happen. You may also want to better explain exactly what is happening, and explain exactly in good detail what it is that you are wanting to happen instead.
 
L

LotosPro

Guest
If you only call it once, it will only happen once. I'm guessing you don't want it to stop, rather you are only wanting it to stop adding more speed to it. If you post code, maybe we can figure out what you should change to make that happen. You may also want to better explain exactly what is happening, and explain exactly in good detail what it is that you are wanting to happen instead.
Here we go(explanation included)!
 

kburkhart84

Firehammer Games
Future reference, it is better to place both the code and the explanation here instead of in a pastebin. We have code tags so it can even maintain the spacing for you.

Looking at the code, it doesn't seem like the call to motion_add() should be happening multiple times without multiple mouse clicks. You are using the "pressed" version of the function to check the mouse click so it isn't repeating...and you ARE setting the "hasFired" variable back to false after doing the motion_add(). The trick is that you have multiple hasFired variables...one in oShotgun, and one in the player. Notice how you are using the oShotgun.hasFired first to check if you shot. But, when you set it false, you did not put the "oShotgun." part, so you created a variable on the object that is running the code, which is the player. Meanwhile, the if statement continues checking the variable on the shotgun object that never got set back to false.
 
L

LotosPro

Guest
Future reference, it is better to place both the code and the explanation here instead of in a pastebin. We have code tags so it can even maintain the spacing for you.

Looking at the code, it doesn't seem like the call to motion_add() should be happening multiple times without multiple mouse clicks. You are using the "pressed" version of the function to check the mouse click so it isn't repeating...and you ARE setting the "hasFired" variable back to false after doing the motion_add(). The trick is that you have multiple hasFired variables...one in oShotgun, and one in the player. Notice how you are using the oShotgun.hasFired first to check if you shot. But, when you set it false, you did not put the "oShotgun." part, so you created a variable on the object that is running the code, which is the player. Meanwhile, the if statement continues checking the variable on the shotgun object that never got set back to false.
Thanks! Combining it with the code that on collision it stops it works like butter. It works since it just bounces off on collision. Thanks!
 
Top