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 / AGK First Person Camera

Author
Message
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 1st Oct 2014 21:16
I have worked alot with first person shooter type games in darkbasic and agk for PC only with much success. I am now starting my next game which is a first person shooter for Android and IOS and I'm just having a problem porting my code over for the camera rotation. I have no problems with the movement (move up & down, strafe left & right) using a virtual joystick. Just a problem when swiping across screen to rotate.

The old rotate code was using the mouse and I'm just not sure if it should work the same on devices because its not.

Any help appreciated:

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 1st Oct 2014 22:51
by any chance.... do you mean to use getrawmousex() instead of pointer?

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Oct 2014 22:54
instead of hard codes sizes u should use
GetVirtualHeight()
GetVirtualWidth()
at floats better use .0 after a value without decimals.
Speed# = 20 / FPS#
=
Speed# = 20.0 / FPS#

at handy with touch screen, at no touch i would use rot speed 0 = stop.
never use SetRawMousePosition in a loop because u can not get correct mouse speed. at pc its better to set the mouse once in the middle if the
mouse near the border.

i try your example now.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 1st Oct 2014 23:06
Quote: "i try your example now."


Thank you!
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 1st Oct 2014 23:07
Quote: "by any chance.... do you mean to use getrawmousex() instead of pointer?"


Trying that now...
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Oct 2014 23:20
i think your problem is that u click/touch the virtual stick is same
hold mouse down.
i think u should split in 2 screen touch.
left screen movement forwand/back left right, rigth screen turn & pitch
SetRawTouch... commands at help/input

other mouse look:


AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 1st Oct 2014 23:58 Edited at: 2nd Oct 2014 00:11
Markus:

Your optimized code works better than mine but the rotation movement is very slow and doesn't stop rotating when the screen isn't being touched.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Oct 2014 00:44 Edited at: 2nd Oct 2014 00:46
yes,
that i wrote before but i think u need replace universal pointer with SetRawTouch...

try this, that means no touch, but at virtual stick u have touch/hold down.
if GetPointerState()=0
mx#=0.0
my#=0.0

the screen input i had made use -1 to 1 just multiply with a value.
mx# = mx# * 2.0 '< factor
my# = my# * 2.0
or
mx# = mx# * 5.0
my# = my# * 5.0

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 2nd Oct 2014 02:48
Just did some valuable Google searching on FPS games on handheld devices and though many games utilize the screen swipe to rotate the camera it is noted that this is a very unpredictable and uncomfortable approach across various platforms. It was also noted that when other buttons (ex. shoot button) are on screen that swiping the screen to rotate the camera is just not recommended.

For nice visual appearance reasons you can hide these virtual buttons until the user/player touches the corner where the respective virtual buttons are located and then make them reappear as needed.

I have added a second virtual button to take care of the camera rotation and if anybody else is interested heres the code.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Oct 2014 03:54
i don't like the VirtualJoystick from agk.
also the left,top edge did not gave a value -1,-1

yes, at touchscreen u need think different,
the finger and hand is over the display and can hide big parts
of your screen.

with your problem i think i would try everything until it feels good to play.

the touch event commands are very good, u can get the speed for swipe.
http://www.appgamekit.com/documentation/Reference/Input/GetRawFirstTouchEvent.htm

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 2nd Oct 2014 16:30
Attention: PAUL

With the anticipation of 3D animations being implicated in AGKv2 most of my games are first person shooters and even with the much appreciated help of Markus in previous posts, I just can't get the camera rotation right when ran on a touch device.

There are several good youtube videos on FPS movement by RetroGamebloke:
https://www.youtube.com/watch?v=xJJOct7Tbx8
https://www.youtube.com/watch?v=dhss-7yegFY
https://www.youtube.com/watch?v=MSVx9UO556M

These tutorials run perfect on a PC or MAC but the camera rotation
when ran on touch devices just don't work.

I have seriously tried and googled before posting without any success. Maybe a basic FPS tutorial for touch devices can be implemented by TGC and put into the example projects folder as this may be helpful for many others! (Especially when 3D animations are done.)

Thank You.
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 2nd Oct 2014 16:59
why dont you try using 2 virtual joysticks instead?

also its not that difficult to get the screen swipe look around for an fps.... would you like me to code you a sample? I will hafta dig out my android tablet....

aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 2nd Oct 2014 17:25 Edited at: 2nd Oct 2014 17:29
Quote: "why dont you try using 2 virtual joysticks instead?"


I actually have only got it to successfully work perfect with your idea of using 2 virtual joysticks.



Quote: "would you like me to code you a sample?"


SoftMotion3D if you have time to show me some code on how you achieved using swiping for the rotation I will highly appreciate it. I am satisfied with 2 virtual joysticks but I just feel defeated the other way and I'd like to get it right because when AppGameKit finally supports 3d animation I have big plans for it! Thank You
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 2nd Oct 2014 17:34
no problem...ill get coden the example....

btw: @paul i found a glitch with agkv2.. if i set the mouse to not visible and then back to visible it does not re-appear on the agk app (stays invisible). Has anyone else encountered this?

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Oct 2014 18:17 Edited at: 2nd Oct 2014 18:18
today i try with 2 touch events but the return values from
TouchEvent commands gave me not what i expected ...



AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 2nd Oct 2014 18:27 Edited at: 2nd Oct 2014 18:29
here is what ya need.... just know that i didnt code a restriction to the speed of the movement on the touch screen.


press escape on the keyboard to free the mouse lock for the keyboard/mouse test

the touchscreen is setup so if a touch event occures x<200 it will be a touch movement+strafe... anything greater it becomes a look around.

edit lol! skip the chunk function that says oldcode as i had just copied what you had online to modify.... delete that function completely as its not processed.

Attachments

Login to view attachments
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 2nd Oct 2014 18:29
Quote: "today i try with 2 touch events but the return values from
TouchEvent commands gave me not what i expected ..."


Thanks again for trying Markus as this topic is very important to me. I have been trying very hard also and just going nuts trying to get it right. Gonna wait to see what SoftMotion3D comes up with.
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 2nd Oct 2014 18:31 Edited at: 2nd Oct 2014 19:00
ask anymore questions regarding 3d.... im fairly good at it

if ya missed it i posted the download 2 posts up.

regarding animation... i almost have an animation editor ready. Also im using agk v2.

edit: oh also typo as i forgot to change the comment here


i actually ment to say i changed it to look at x instead of y... so if x<200 then it becomes a move/strafe command instead of a look

Login to post a reply

Server time is: 2024-11-25 10:24:12
Your offset time is: 2024-11-25 10:24:12