is there a way to make the gun launch you in the opposite direction your pointing it? I tried but it isn’t that good. platformer engine 2.2.51-3-2023_8-16-56.wick
Try changing the xv & yv values of the player (x velocity & y velocity) rather than the actualy x and y position of the player to have the gun push you in the opposite direction.
Code
var i =10;
if (gun.rotation > 90) {
player2.yv = -i
player2.xv = -i
}
if (gun.rotation > 0) {
player2.xv = -i
}
if (gun.rotation < -90) {
player2.yv = -i
player2.xv = i
}
if (gun.rotation < 0) {
player2.xv = i
}
You can also shorten your code by replacing the mouseclick script with the code below, which won’t work exactly the same, but should have similar results
var i=15;
player2.xv = i*(player2.x>mouseX?1:-1);
player2.yv = i*(player2.y>mouseY?1:-1);
you can also probably use trigonometry to get more accurate results (im not at my computer now but let me know if you want the formulas)
thanks this really helps
though now I ran into another problem, now I want the character to stay in place when you hold space AND are on the ground so that you can aim and fire without being launched away but the character cant move with a and d like he’s holding onto the ground. I tried doing this but I cant get it to work right.
edit: I got the not being launched thing to work, now I just need a and d to be disabled. platformer engine 2.2.51-3-2023_15-41-59.wick (btw before you say anything, your not able to jump on purpose because in the game you aren’t sopposed to be able to jump, your gun allows you to get higher up.)
I added an ammo system so you can’t fly away infinitely platformer engine 2.2.51-3-2023_16-17-28.wick
I got some stuff working but now I cant get it to only let you stay in place on the ground, it works in the air and stops you from falling normally which I don’t want, I need it to only let you use space if your on the ground, platformer engine 2.2.51-4-2023_8-24-20.wick
edit: nevermind I fixed it.