top down shooter, rotation with mouse.

For questions about using Classic.

Post » Mon Mar 18, 2013 10:08 pm

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?clodius6662013-03-18 22:17:59
B
4
S
2
G
2
Posts: 109
Reputation: 1,318

Post » Thu Aug 08, 2013 5:32 pm

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!
B
4
S
2
G
2
Posts: 109
Reputation: 1,318

Post » Thu Aug 08, 2013 7:05 pm

What exactly do you mean?

Something like

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

?

Cheers,
The Colonel
Image
B
13
S
4
G
1
Posts: 113
Reputation: 1,712

Post » Thu Aug 08, 2013 8:27 pm

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.clodius6662013-08-08 20:29:24
B
4
S
2
G
2
Posts: 109
Reputation: 1,318

Post » Thu Aug 08, 2013 9:05 pm

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
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Aug 09, 2013 1:07 pm

nice to see you again, tulamide!

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
B
4
S
2
G
2
Posts: 109
Reputation: 1,318

Post » Fri Aug 09, 2013 5:14 pm

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

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.
I hope to see it sometime...tulamide2013-08-09 17:20:25
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sat Aug 10, 2013 2:55 pm

once again, thats exactly what i was looking for, thanks

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
B
4
S
2
G
2
Posts: 109
Reputation: 1,318

Post » Sat Aug 10, 2013 7:33 pm

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
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sat Aug 10, 2013 8:06 pm

incredible, as always!
if i had any money, id be throwing them at the screen right now out of gratitude

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..

again, sorry, its been long since i last worked with construct. i swear this was my last question about this shooter issue
B
4
S
2
G
2
Posts: 109
Reputation: 1,318

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests