I’m trying to make a shooter like Enter the Gungeon (a shooter with 8 direction), but the Gamepad Extension only have 4 direction on each joystick (UP/DOWN/LEFT/RIGHT)
I tried to make add a simple new condition DOWNLEFT in the switch for the direction function but it doesn’t seem to work.
Thanks in advance !
Could you show me the event where you are calling the function?
Hello thanks for you response ! here is the events :
I use the rotation of the hitbox which is a box placed on the character sprite to determine the animation based on it’s angle.
For the mouse i just angle the hitbox toward the mouse position and each time the angle is in a certain range the sprite animation is changed so i can move in any direction and face in another independently so the player can walk backward like in Enter the Gungeon.
I try to have 8 direction for the stick movement so i can rotate directly the hitbox based on an angle to be in the range of the animation change but there is only 4 stick direction that’s where i have a problem ^^
I hope it is not too much confusing !
Your current one isn’t working because it’s trying to rotate to two directions at the same time (you may know that already.)
What you can try is add a rotation value to a variable, and also check if 2 directions are being pressed. For example:
First event, reset a variable called HitboxRotate = 0 and DirectionsPressed = 0 (no condition, this should happen every frame)
Then, add the appropriate degree amount to HitboxRotate depending on direction the stick is pushed. Basically like this one in your picture, but add it toward the HitboxRotate variable instead (Right = 0, Down = 90, etc…). Add + 1 to DirectionsPressed on each event.
Third event, check if DirectionsPressed > 1 (more than 1 direction being pressed), and if true, divide HitboxRotate by 2.
Fourth event, add condition to check if player is moving, then if true, Rotate the HITBOX object using the HitboxRotate variable (like in the picture, but 1 event only).
Hopefully you can understand that English!
You might also want to check this wiki page about Finite State Machine, so your code will not conflict with each other:
Hello ! Thanks for you response Cat ! I tried your solution but the sprite didn’t rotate on somes sides and there was no automatic switch between mouse/gamepad like in Enter the Gungeon.
Here are the events :
I use two objects TARGET_G which moves based on the joystick with TopDownMovement behavior (so it moves in every directions no more limited by 4 joystick direction) and TARGET_M with its position based on the mouse X and Y.
If TARGET_G is moving the HITBOX rotate towards it and if it is not moving it rotate toward TARGET_M.
I just need now find how to move the mouse position/TARGET_M on the last position of TARGET_G so the player direction didn’t change suddenly when TARGET_M is one corner of the screen and TARGET_G in another !
Found the solution !! It just needed two more events (after moving TARGET_M setting the positions of TARGET_G on it’s last position and the same in mirror after moving TARGET_G for TARGET_M) here is the complete events for the targeting/player movements :