top down shooter, rotation with mouse.

This forum is currently in read-only mode.
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • hi all.

    ive been trying to make some sideproject,small top down shooter. not like the ghost shooter example, but one where the player is located at the bottom of the screen, always facing up, with a crosshair on top of the screen. my issue is with rotation. i know how to do rotation with key commands, but how about mouse rotation, when you have a fixed crosshair?

    i almost got it working with magicam, but theres an annoying constant rotation even when not moving the mouse.it always rotates to either left or right,so i guess im missing some kind of a treshold here. is there any good examples on how to make mouse rotation, or could someone have some great ideas?

    EDIT: just to clarify, id like the rotation to be like in traditional 3d shooters, think doom played with a mouse. is this possible?

  • sorry about the bump, folks. i just wanted to see if anyone has any good ideas or solutions for this?

    havent been able to solve it by myself yet and after a long break from construct i decided to give this one another shot, because it would really kickstart this little project and ive always kinda wanted to make a fast paced arcade top down shooter with more or less precise mouse aiming(rotation).

    any help is appreciated!

  • What exactly do you mean?

    Something like

    Always -> Set PlayerSprite angle to angle (PlayerSprite.X , PlayerSprite.Y, MouseX, MouseY)

    ?

    Cheers,

    The Colonel

  • hi and thanks for replying!

    well my issue is rather simple and straightforward:

    the player sprite is always locked,facing up, so when you rotate the player sprite(by moving mouse either left or right), the whole view rotates, and movement would be the traditional WASD movement,W and S being forward and backwards, A and D for strafing.

    so,assign mouse movement to the "camera" rotation. meaning: when you move mouse right, screen/aim rotates right. and same for left obviously. basically just the same as in any 3d shooters (or anything with mouse controlled camera),just with a top down perspective. i just cant seem to figure out how to do this.

    just to be a little clearer, compared to the ghost shooter demo (and also most top down shooters: in ghost shooter the view is fixed and only the player sprite rotates, i would want the view to rotate as well so that the player sprite is always facing up.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just calculate every angle regarding the player (the player sprite(s), the weapons, the bullets from his weapons, etc.) relative to the current screen rotation. Here's an example you can build upon. Refine it by making the rotation less direct, add ease-in/out, etc.

    3D Shooter Control in 2D Topdown.cap

  • nice to see you again, tulamide! <img src="smileys/smiley41.gif" border="0" align="middle" />

    about the .cap..

    actually thats pretty much where i hit the wall myself. well my code was a little more primitive, but it did the same thing pretty much. problem is, that you cannot continuously move the mouse to either side, since the mouse cursor is blocked by the program or the screen borders, thus preventing you from rotating freely to either direction. i guess i wanted to see if theres a way to get the raw moving data from the mouse and completely ignore the mouse cursor since the aiming reticle would be fixed in place and there would be no need for the cursor.

    as it is, i lack the knowledge and skill to go on from that .cap, unfortunately. i have some alternatives in mind though but again, i lack the knowledge. you know like resetting the cursor to the middle of the screen when it hits the screen border or something like that. this got more complicated that i thought it would <img src="smileys/smiley36.gif" border="0" align="middle" />

  • Thank you, clodius666 but this is one of the rare exceptions. My music is pretty much all I invest time for here on the forums <img src="smileys/smiley4.gif" border="0" align="middle">

    You didn't say a word about mouse movement instead of position data.

    EDIT: Actually you did, but I just yet discovered it. I don't know why I didn't recognize it the first time. Sorry!

    Else I might have led you to the following link, with one of lucid's last plugins for CC: new miniplugin (mouse movement)

    That should break the last barrier for your shooter. <img src="smileys/smiley2.gif" border="0" align="middle">

    I hope to see it sometime...

  • once again, thats exactly what i was looking for, thanks <img src="smileys/smiley4.gif" border="0" align="middle" />

    although, it turned out that apparently i have downloaded that plugin ages ago, i just didnt know (or forgot)how to find the expressions lol

    i guess i was too caught up with the mouse cursor position and stuff.

    im still kinda lost with how to operate with this.. im sure that its just a simple math problem again, but im a little confused how to convert the mouse.X to the player rotation. would i have to make a variable like for example ?mouselastX? to detect and compare that the mouse is moving on X axis?

    also, how would it translate to actual action?

    and i still get blocked by the cursor so the mouse X movement isnt infinite.

    aaaand, that miniplugin isnt really an object, right? just a few expressions?

    im sure im making things more complicated than they should be, but im still pretty much stuck with this hurdle, the rest of the prototype tests ive managed to get working, but the aiming/rotation is still the most difficult task lol.

    funny since i could make the xbox controller work without problems, i think, but i want to prefer the mouse in this case <img src="smileys/smiley16.gif" border="0" align="middle" />

  • In my attempt of finding a relatively easy solution to your problem, I made another approach. r2 of the cap, this time using the plugin "Input System". It has a nice expression called "Get relative mouseX", which keeps working even on the screen borders.

    Hopefully this one is closer to your vision?

    3D Shooter Control in 2D Topdown (r2).cap

  • incredible, as always!

    if i had any money, id be throwing them at the screen right now out of gratitude <img src="smileys/smiley36.gif" border="0" align="middle" />

    works flawlessly, with only ONE thing remaining:

    how do i invert it?

    sorry this must be really anoying and overall primitive question, but now its: move mouse right, screen turns left and vice versa.. <img src="smileys/smiley9.gif" border="0" align="middle" />

    again, sorry, its been long since i last worked with construct. i swear this was my last question about this shooter issue <img src="smileys/smiley4.gif" border="0" align="middle" />

  • ...but now its: move mouse right, screen turns left and vice versa..Hmm, that's weird. I programmed it to turn clockwise when mouse moves right, and counter-clockwise when mouse moves left. Anyway, it's pretty simple to invert it.

    Replace this:

    + System: InputSystem.RelMouseX Different to 0

    -> System: Add InputSystem.RelMouseX * 2 to global variable 'curRelAngle'

    with:

    + System: InputSystem.RelMouseX Different to 0

    -> System: Add InputSystem.RelMouseX * -1 * 2 to global variable 'curRelAngle'

    By multiplying RelMouseX with -1, the values invert. -5 becomes +5, 3 becomes -3, etc.

    You could use a variable that you set to +1 or -1 dependent on some user option, to let the gamer decide how to rotate.

    i swear this was my last question about this shooter issue <img src="smileys/smiley4.gif" border="0" align="middle" /> We'll see... <img src="smileys/smiley17.gif" border="0" align="middle" /> <img src="smileys/smiley4.gif" border="0" align="middle" />

  • happy happy joy joy <img src="smileys/smiley32.gif" border="0" align="middle" />

    now i have the foundation to build upon. cant thank you enough, really.

    ive done a lot of ground work for this project already, sprites, art and stuff, so its nice to move it from the "eternal project" category to "somewhat possible to finish" category. as long as i can keep things simple and my ambitions low <img src="smileys/smiley36.gif" border="0" align="middle" />

    oh and by the way, i clearly said:

    "i swear this was my last question about THIS shooter issue"

    <img src="smileys/smiley15.gif" border="0" align="middle" />

    clumsy english FTW...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)