Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: KozTheBoss on July 18, 2013, 03:47:15 PM

Title: Mouse Lock - Resets mouse position to screen center?
Post by: KozTheBoss on July 18, 2013, 03:47:15 PM
Hi guys - simple question here!

When i lock my mouse cursor and then unlock it again, the mouse appears at the center of the screen =/ Is there any way to change it so it re-appears at the position it was at when it was locked to begin with? I know i can get the mouse X and Y position, but i can't seem to figure out how to set the position when it's unlocked again

any help is recieved with virtual hugs <3
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: jeanfabre on July 28, 2013, 12:37:01 PM
Hi,

 not possible from what I can gather on the web. What's the problem you are having with this current behavior?

 if you are using absolute positioning to move elements on screen, then you'll to refactor to take in account relative movement of the mouse, to stop relying on the absolute position.

bye,

 Jean
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: KozTheBoss on July 28, 2013, 04:41:37 PM
Hi Jean! That's a shame =(

I am making a top-down shooter, where the character always looks at the mouse-pick position. By holding right click, the mouse will lock, and the player can rotate the camera. Upon releasing right click, it unlocks the mouse again which then appears in the center of the screen and makes the character rotate to look in a random direction. This fixes itself as the player can move the mouse to where he wants the character to look again, but it's just an annoying piece of functionality that makes it feel very annoying to turn the camera around, since it will change the rotation of your character as a result and you have to move the mouse back in the direction you want to face again =(
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: jeanfabre on July 28, 2013, 04:47:16 PM
hi,

 yes, so here, typically, you should simply have you rlook at system take this in consideration instead of trying to work against how unity handled cursor lock.

When you unlock, fire a event to your look at system, and reset its values so that it looks straight ahead. is that possible?

 else, definitly look for working out a system based on relative movements of the mouse instead of an absolute screen position.

bye,

 Jean
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: KozTheBoss on July 28, 2013, 05:01:58 PM
that makes sense with the looking forward after releasing, but that would still probably change the characters rotation after releasing right-click which is what i want to avoid entirely

So far, when you right click, it stops updating the mouse-pick position so when you hold down right-click, the character will keep looking at the point where you had the mouse before you pressed right-click, even if you move the character around using WASD, but when you let go it just snaps to a position that could be forward as you suggest, but the sudden snapping to a different rotation just makes it all feel so "meh"
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: jeanfabre on July 28, 2013, 05:04:35 PM
Hi,

 do you have a web publish I could play with to see exactly what you mean?

bye,

 Jean
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: KozTheBoss on July 29, 2013, 09:21:44 AM
sure, I will upload one in a few minutes

EDIT:

I just made some changes to it - when you right-click to move the camera, it will now reset the character's position to 0, 0, 0 so it looks straight forward. This works better, however i could still use any advice you would have on making this feel as good as possible:

https://dl.dropboxusercontent.com/u/19886152/Public.html (if you get an error, give it a minute to synch the data file)

Thanks in advance:

PS: Left-click shooting is just a test at the moment, will be replaced soon.

Buildings are enter-able, and that's pretty much the extend of the functionality in the game right now.
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: jeanfabre on July 29, 2013, 10:39:08 AM
Hi,

 right click brings the untiy webplayer context, is that normal?

bye,

 Jean
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: KozTheBoss on July 30, 2013, 07:13:40 AM
that's weird! Are you sure you have the game focused first? so left-click the game and make sure you can move around etc, and then right click should unlock the camera for movement

Works fine for me =(
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: jeanfabre on July 30, 2013, 08:02:53 AM
Hi,

Yeah, I am totally moving and controlling the character, so I am focused. I am on mac if that could be the issue.

bye,

 Jean
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: KozTheBoss on July 30, 2013, 11:30:38 AM
Yes, it might have something to do with the input. I don't know if mouse input is different on mac than on PC but it sounds like that could be the issue. I will take a look at it at some point and bump this thread in a few days :) thanks for your time!
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: markfrancombe on August 02, 2013, 06:22:45 AM
Hi Koz

Bit old thread, so Im sure you have fixed this now, just thought I would comment that your game looks very nice so far, I enjoyed walking about your environment.

In regards to your question, I think you have a slightly wrong way of controlling this anyway. Your character walks the direction from input keys not the mouse, that only handles the direction the character is facing. Once you have an animation working this will be obvious (he needs to face the direction of the key commands not the mouse)or he will slide sideways.
BUT this will make shooting impossible wont it? When he is walking (facing) one direction, THEN you click the mouse will he turn imediatly to the mouse and shoot? not good.
Maybe you should change it so that he DOES walk towards the direction of the mouse, (so hes always facing the right way for shooting) and your keys are simply forward and backwards commands?
OR another way would be to use a more 3rd person view, where you use WASD to move (and aim) and the camera just follows from behind, therfore not requiring a right click to re-orient the view (except for tilt perhaps?)

Jean needed to go into fullscreen view to test BTW, as he said in window mode it just brings up right click web window (where he should have selected fullscreen)!

Anyway, looking good, would like to see new versions!

MArk
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: KozTheBoss on August 02, 2013, 06:47:49 AM
Hi Mark! :)

Thanks for the kind words! I haven't really solved this yet, but your input is very much appriciated as I am not sure how i want the controls to be yet. I want them to feel good, and my first thought was to make it like a twin-stick shooter (the problem is indeed finding a good control scheme for mouse and keyboard). I have considered the problems that would occur with animations the way it is now, but changing it so W walks forward in relation to where the character is looking would feel very weird. Snapping the camera as a sort of 3rd person view isn't really something i would love to do, as it would take away from the top-down feel of the game, and I am not sure how you would control the character's rotation with the mouse then. (edit: I guess that could work, actually. Still use top-down view but parent the camera to the character model, and when moving the mouse left and right it would simply rotate the character controller? hmm, interesting, I will try making this and will update with a build to see if it feels better :)

The idea of having the character face the way you are walking with WASD except when shooting sounds like it could be a great way to do it, except that the rotation would snap as you mentioned when beginning to shoot =/ I am still twisting my brain to try and come up with a system that could make it work without the current top-down twin-stick feel being removed or diminished.

IF i was to keep the current control scheme, What i think could potentially work is if i put box colliders on the movement portion of the character (invisible GO that always faces same way as the camera, this is what has the WASD movements, and the character model is a child of it) one box on each side of it, and I could then raycast forward or backwards or whatever direction from the character model, and detect which box I am hitting and thereby know which way the character is facing compared to the WASD movement, and use that to play the correct animation depending on which way i am moving.

I havent delved too deep into that, was just an idea I had.

If you have any suggestions for a solution, or for another control scheme that could work, please let me know :) (I had planned on adding controller support, so it would have to work similarly to a controller-operated twin-stick shooter where left stick controls movement according to camera angle, and right stick controls rotation)

thanks again!

-Koz
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: markfrancombe on August 02, 2013, 08:16:35 AM
I suppose it throws up more questions than answers...

Do you want to be able to strafe? Run one way while shooting another? Then maybe WASD (or cursors) is just running direction... (you are right, on a top down, you need to configure WASD to be "points of the compass" directions NOT related to character related, I remember the first Silent Hill games, really annoying that if you are running towards the camera the left right controls were reversed!!!)
SO W needs to take the character UP screen, W left.. unrelated to the character.
Then maybe (just maybe??) The mouse could be for firing direction, so you would need to get into blending animations (or is it masks??) So that legs run one way while upper body swivels to point mouse direction, you would need some restraints here, would be good if you could get it right but I expect... tricky.

I suppose ACTUAL point an click is too childish for you? You know UFO style? click on some ground and he runs there?

Can be pretty cute?

It all depends on you game and audience and feel you want...

But.. hey controllers.. wow.. Aint they just the most tricky bit of the whole game making thing?
 
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: markfrancombe on August 02, 2013, 08:20:50 AM
Ahh.. I get your aim now, I have to admit that i didnt know the expression "Twin Stick Shooter" So I googled, now I do... I think my "swivel" idea is what you mean right?
Good discussion here, maybe you seen it?

http://www.gamasutra.com/view/feature/6323/a_guide_to_ios_twin_stick_shooter_.php?print=1
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: KozTheBoss on August 02, 2013, 04:42:04 PM
oh, that article looks interesting! I'll give that a read :) Yes, the ultimate outcome of this would be if the animations could work with the system that i have now - though maybe after not shooting for 2-3 seconds, the gun will be put on the character's back, and he will face the direction he is running instead of facing the mouse - and when the player clicks the mouse, he will put the gun in his hands and be ready to shoot in the direction the mouse is pointing, all while movement controls with WASD is relative to the camera angle.

The only difference being that with a controller, the character will rotate to face the direction you are pushing the right stick, instead of facing a point in the world (like the mouse cursor)

For now, I might just continue developing the more important aspects like shooting, AI, the world, crafting, leveling and ALL the other stuff :P and then maybe in a year when I'm at a good point i might be able to hire someone better than me (like jean or alex :P) to work their magic on the animations

My idea was originally inspired by Wasteland 2, actually. I wanted to make a post apocalyptic survival game (because i love the genre), and i thought that wasteland was taking an interesting look at it, using top-down (which isn't very common in the genre tbh) but i wanted to see if i could move away from the turn-based RTS aspect, and make it more real-time combat etc.

As you saw, I also changed the concept of the world to being a frozen wasteland (my idea for the story is that the world was hit by a giant astroid, wiping out most of the population, leaving most of the world behind as a toxic radioactive wasteland. On top of that, the impact knocked the earth out of orbit, moving it further away from the sun, ultimately leading to a huge climate change (maybe even on the brink of a new iceage or something like that)

I have plans for factions, towns, mutants, RPG elements, scavenging, crafting, vehicles & building (placing objects in the world, building your own base etc) I have a pretty big world as it is right now that also needs to be further designed. As a one-man team this is gonna take years probably, but I've promised myself to keep at it as one of many side-projects of mine while i study.

One thing that would be amazing would be if i could get co-op in there, but after trying to work with photon with playmaker, i've been completely scared off. It gave me a bunch of errors in the logs about missing actions etc, and even when that doesn't happen, photon just doesn't make shit sense to me at all lol :P Im too intimidated at this point, but maybe in the future :)
Title: Re: Mouse Lock - Resets mouse position to screen center?
Post by: markfrancombe on August 05, 2013, 05:31:07 PM
Keep going with the multiplayer thing, but tet photon out in a totally clean proj. Mine is Photon (and weirdly starts with an asteroid too, no ice age... just alien spores.. you know.. the usual.. Damn those spores! Photon is a Head ache, Im not there yet either, but getting there...