I’m trying to get a Dual Stick Shooter going, however one thing I’m noticing is that directions are sent in 8 ways on a controler. Is this a limitation of the Xbox controller or the engine? My main issue is you don’t get 1:1 control over direction on the Sticks. If anyone has tried working around this I’d love to know what you did here.
What Blueprint nodes are you using?
The Gamepad Right/Left X/Y nodes give you a value ranging from 0 to 1 -exactly what you would need to compute your movement!
I actually don’t think I’ve tried the Game Pad X/Y yet. That seems like that would solve that issue easily.
The other question I had was translating that same style of game play to Mouse and Keyboard. WASD for movement would work just fine, but I played around with trying to track my mouse movement and I managed to KINDA get my character to rotate based on where my mouse was on screen. I use the Mouse World Location / Direction node to make a Yaw rotation and fed that in to the Set Actor Rotation node. However it isn’t very accurate and I’m not sure if more math is required. I’ll have to post an example later when I’m at home so it makes sense. The result is that the character doesn’t always fully rotate towards the mouse. It also doesn’t rotate based on my X or Y position reletive to my character position on the screen (hes always center). If my mouse is directly south, and I move the mouse up towards the character it will flip before it reaches the character. My expectation (or my desired result) is that it flips after it is above the character.
So for right now I’m focusing on controller movement and shooting. Gamepad Right/Left X/Y worked great for player movement. Now I’m trying to get the shooting to work with the Right stick. I know I need to spawn a projectile but thats about as far as I’ve gotten. The issue I’m having is what to set in the Transform node on Spawn Object. I figure I’ll spawn it at my character, but I don’t know how to determine how to fire based on the Right Stick direction. Any thoughts?
I have a twin stick shooter movement function working, blueprint incoming
EDIT: added blueprint
You may need to play with the float multipliers depending on where you camera is in your scene to make the pawn actually move the correct way
What do you have your “deadzone” variable set to in this example?
Deadzone for me is 0.0
Cool this seems to work for me. Anyway you could brake down the math thats going on here? I spent the better part of today trying all kinds of things to see if I could get this to work, and none of them look like your example haha. I guess the questions I have are 1) Why do you multiply the axis value of X and Y by -1? 2) what dose “Normalize” do this situation?
I’m not a master of this stuff, I’d google what normalizing does as I was advised to put it in much like yourself. As for the multiples, I believe its to do with where your camera is in relation to the x,y and z of the game world. so whilst in normality its x for left and right and y for forwards and back (z controls the up and down) I have my camera facing in a way that makes my values different and therefore I need to change the values back through multiplying for the game to control normally.
Thats probably a terrible explanation. Maybe someone else can shed some light, but thats the way I understood it
I played around with the math (took out all the x -1) and it seemed to do what you mentioned. “up” is basically “Right” without the multiplication happening to the floats and the rot. Thanks for your help! The only thing that I think I need to change is where the object is spawned. Right now its dead center of my character. If I make an offset it simple puts it in one direction away from character. I need to figure out how to make the spawn point “orbit” my character in sync with the rotation so that it spawns just on the outside of the collision box for my character.