Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Mouse Look in FPS

Author
Message
Steveotronic
9
Years of Service
User Offline
Joined: 8th Feb 2015
Location: Leicestershire
Posted: 20th Feb 2019 01:10 Edited at: 20th Feb 2019 01:36
Hello everyone,

I have searched this already on the forums and couldn't find anything of much help for me, so I'm hoping someone can shed some light.

I am attempting an FPS style camera and am coming up with an issue to do with the mouse look. I followed an old Youtube tutorial from Retrogamebloke that implemented a simple first person camera, I copied everything exactly but it would not work for me, so I have fiddled around and read up on a few bits and got it working to an extent, but whenever I try and do any mouse look code it won't go past the edge of the laptop screen.

Im on Mac, so It could be something to do with the other thread here https://forum.thegamecreators.com/thread/221905

but it was in march last year so hopefully someone can tell me what Im doing wrong.

Thanks in advance.

Steve.

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Feb 2019 01:39 Edited at: 20th Feb 2019 04:40
Vision is -90 to + 90 along y axis and -90 to +90 along x axis
I think not setting your virtual resolution has something to do with it.
I have used a slightly different approach


EDIT: Just realized i was rotating the PLAYER around the x axis and i should only rotate the CAMERA around the x axis. Code has changed

Steveotronic
9
Years of Service
User Offline
Joined: 8th Feb 2015
Location: Leicestershire
Posted: 20th Feb 2019 12:46
Hi Blink,

Thanks for the reply, I really appreciate the speedy answer. I tried your code but ran into an error with these two lines:



so I changed GetWindowWidth() to GetDeviceWidth and Height respectively but I still had the same problem, so I then tried hard coding GetWindowWidth and height as integer values, again no luck.

my last resort was GetVirtualWidth and height but these also offer the same issue, the mouse will stop once it gets to the edge of the laptop screen.

Im starting to think it is related to the other post I linked originally, and might be another Mac OS problem.

anymore ideas anyone.

Thanks again Blinks and also thanks in advance.

Steve
Qube_
10
Years of Service
User Offline
Joined: 21st Oct 2014
Location: Omnipresent
Posted: 20th Feb 2019 13:02
You can write mouse look code which works fine on Windows but on Mac will fail when your mouse pointer is at the end of the screen. This is still an issue and has never been addressed.
Steveotronic
9
Years of Service
User Offline
Joined: 8th Feb 2015
Location: Leicestershire
Posted: 20th Feb 2019 16:19
Qube,
thanks for the clarification. Glad to know I’m not going mad.

Any AppGameKit devs available to clarify if it’s on the to fix list, or have a look into it please.

Thanks again in advance.

Steve
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 20th Feb 2019 17:44 Edited at: 20th Feb 2019 17:46
Get the amount the mouse moved and reset the mouse position to center each frame.

Update the camera rotation by the amount moved.

You will never hit the edge of screen
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Feb 2019 19:53
Using Ortus excellent idea. You can adjust the movement by increasing/decreasing the scale variable

chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 20th Feb 2019 20:18
Hi there ... my two cents

I'm not a grumpy grandpa
Qube_
10
Years of Service
User Offline
Joined: 21st Oct 2014
Location: Omnipresent
Posted: 20th Feb 2019 20:41 Edited at: 20th Feb 2019 20:44
Quote: "Hi there ... my two cents"

Same as usual on a Mac.. When the mouse hits the edge of the screen it stops.

*EDIT* - Also using the mouse reset example above results in no movement at all.
puzzler2018
User Banned
Posted: 20th Feb 2019 20:46 Edited at: 20th Feb 2019 20:46
Try

From



To

Tier 1 Developer
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Feb 2019 20:57 Edited at: 20th Feb 2019 20:58
Quote: "Same as usual on a Mac.. When the mouse hits the edge of the screen it stops."


Did you try my latest example. If your mouse gets anywhere near the edge of the screen it would be flying
Qube_
10
Years of Service
User Offline
Joined: 21st Oct 2014
Location: Omnipresent
Posted: 21st Feb 2019 03:36
Quote: "Did you try my latest example. If your mouse gets anywhere near the edge of the screen it would be flying"

With your example the mouse stays smack bang in the middle of the screen, never moves and the coordinates don't budge an inch either.

The whole point of AppGameKit is code that works on Windows should work on Mac and Linux. For the most part it does which is brilliant but for some strange reason the mouse side on Mac acts completely different than on Windows. I've tried multiple versions of mouse look code which work fine on Windows but always stick on Mac.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 21st Feb 2019 05:30 Edited at: 21st Feb 2019 05:47
Quote: "The whole point of AppGameKit is code that works on Windows should work on Mac and Linux. For the most part it does which is brilliant but for some strange reason the mouse side on Mac acts completely different than on Windows. I've tried multiple versions of mouse look code which work fine on Windows but always stick on Mac."


I'd have to agree. I've done some testing tonight and there seems to be 2 main issues:

SetRawMousePosition to recenter the mouse each frame only works if the mouse cursor is hidden. If the mouse ever leaves the bounds of the window it becomes visible and this doesn't recenter it properly. When visible, it can hit the edge of the screen problems. This seems to affect both mac and windows though and can be resolved by setting it to hidden again each frame.

More importantly for mac, if SetRawMousePosition is called every frame, it prevents all mouse movement entirely. On windows it allows you to capture the amount that the mouse moved from the center during the frame.

detection of movement can be forced by adding a minimal delay to the positioning, but this then creates a pause which prevents smooth mouse looking and isn't really a solution.



after some further testing, looks like you need at least 200ms between calls to set the mouse position in order to detect any mouse movement from that position, at least on my machine, which is terrible for camera handling.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 21st Feb 2019 19:54
This actually seam to be an issue on Linux also ….
I have one that purchased pixelstein on Linux and he have working mouselook but yeerky.
Steveotronic
9
Years of Service
User Offline
Joined: 8th Feb 2015
Location: Leicestershire
Posted: 22nd Feb 2019 23:28
Glad this has bought about some discussion, any chance TGC is looking into it?

Nice to know its not just Mac, although it sounds like its at least working in some way on linux.
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 24th Feb 2019 17:16
Hi Steveotronic,

If you got GameGuru Loader you can rip it from there , it works perfectly on Mac,

In main.agc search for:


The code from that line in the "else" to the ending "endif" is the control. It use a average of the last 4 inputs , and wait until you get closer to the edges before setting the raw mouse position , and last make the rotation slowly stop.
Subscribe and checkout great AppGameKit video's here: Videos click here
Latest GameGuru Loader news: News click here
Get GameGuru Loader PBR version here: Steam click here
best regards Preben Eriksen,
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 24th Feb 2019 20:20
Here you go, try this:



Not tried on a MAC, but works fine on a PC. You can set the pointer invisible if that works.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 24th Feb 2019 21:44
Quote: "Not tried on a MAC, but works fine on a PC. You can set the pointer invisible if that works."

I think that's the issue. It's not working on a mac
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 24th Feb 2019 22:20 Edited at: 24th Feb 2019 22:32
Why, this isn't reliant on the mouse potition, as that resets it to 100 x 100 every frame.

Is that command not working on MAC?

Quote: "detection of movement can be forced by adding a minimal delay to the positioning, but this then creates a pause which prevents smooth mouse looking and isn't really a solution."


If the above doens't work, can't you check every second frame then divide the movement by 2?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 24th Feb 2019 22:43
I think ortu addressed this in this post. It has specific implications for mac
Quote: "
SetRawMousePosition to recenter the mouse each frame only works if the mouse cursor is hidden. If the mouse ever leaves the bounds of the window it becomes visible and this doesn't recenter it properly. When visible, it can hit the edge of the screen problems. This seems to affect both mac and windows though and can be resolved by setting it to hidden again each frame.

More importantly for mac, if SetRawMousePosition is called every frame, it prevents all mouse movement entirely. On windows it allows you to capture the amount that the mouse moved from the center during the frame.

detection of movement can be forced by adding a minimal delay to the positioning, but this then creates a pause which prevents smooth mouse looking and isn't really a solution.
"


I think the overall conclusion is that this should be solved by AGK. The whole idea of the product is that these commands should work the same across all devices.
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 26th Feb 2019 11:44 Edited at: 26th Feb 2019 11:48
I believe this is a long standing issue, which was first brought to my attention by Qube. He pointed to a thread dating from 2017:
https://forum.thegamecreators.com/thread/220725

I posted a reminder, but it was not answered (or seen?) by AppGameKit team.
https://forum.thegamecreators.com/thread/221905

But as Preben says it *does* work in the code from GGL then perhaps could be we're using it in an unintended way on the Mac?
Of course would be preferable if worked same across all platforms as blink0k said..
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 26th Feb 2019 12:30
Or Preben could jist share the code foem GG loader. Lol.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 26th Feb 2019 19:31
Its plausible. He mentioned taking an average of the last 4 movements before setting it back to center, without testing, this should in theory continue to provide a value to use during the delay after setRawMousePosition before it can begin detecting movements again which would reduce the stutter, and will provide enough time between calls to the command that movement remains possible.

It's been a busy week, but I should have some time to play around with this tonight

Moved 3 (avg 0,0,0,3 = 0.75)
Moved 2 (0,0,3,2 = 1.24)
Moved 4 (0,3,2,4 = 2.25)
SetRawMouse
Moved 0 (cant detect) (3,2,4,0 = 2.25)
Moved 2 (2,4,0,2 = 2)
Moved 3 (4,0,2,3 = 2.25)

And so on. Produces built in easing and the fluctuation once it is going due to the slipped detection should be minor over the average.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 26th Feb 2019 21:28
I think it needs to be addressed at the AppGameKit level. Commands not working the same across platforms makes development a nightmare
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 26th Feb 2019 22:42 Edited at: 26th Feb 2019 22:46
Agreed. I don't know why we don't just have mouseDeltaX/Y commands to begin with... we have Z

Long experience with DBpro taught me not to wait on language fixes if a work around can be found. A work around isn't the "right way" to handle it, but it will keep you moving forward and making progress instead of waiting for a fix that may never happen
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Scary Little Rabbit
15
Years of Service
User Offline
Joined: 4th Aug 2009
Location: Chelyabinsk, Russian Federation.
Posted: 27th Feb 2019 14:06
Quote: "I don't know why we don't just have mouseDeltaX/Y commands to begin with... we have Z"

exactly!
error #1:
'too many stars, too many stares. disembody.'
Lone Star Dive: Fears of Mars

Login to post a reply

Server time is: 2024-11-05 23:11:58
Your offset time is: 2024-11-05 23:11:58