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 / first person shooter gun

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 21st Mar 2017 17:45 Edited at: 21st Mar 2017 17:51
here is code I have so far for moving with wasd using a 3dphyics character control





Some of this code is used from examples in AppGameKit, what I want to know though is how do I display a gun and rotate /position it in front of the camwith this code,so it looks just like a typical first person shooter, tried some stuff but cannot get it right!
here is a video of the 3D level editor I have been developing for ages, :



just got some light effects coded,namely flicker/pusate or blinking... but really need a gun now, the code so far has been real simple as I am no good at maths atall!
Hail to the king, baby!
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 21st Mar 2017 18:29
Cool nightclub simulator! I think it's better without the gun... but if you insist, then I'd try using the getcameraanglex/y/z and getcamerax/y/z commands to position the gun.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 21st Mar 2017 18:43 Edited at: 21st Mar 2017 18:44
No math needed.
The coffee is lovely dark and deep,and I have code to write before I sleep.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 21st Mar 2017 19:43 Edited at: 21st Mar 2017 19:52
ah,never new about the FixObjectToObject,this kinda does it apart from it is only followed turning the camera left and right,but not up/down!
Hail to the king, baby!
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 22nd Mar 2017 02:21
Create a box that is positioned and rotated at the camera and attach to that instead of the character.
The coffee is lovely dark and deep,and I have code to write before I sleep.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 22nd Mar 2017 07:48
Without seeing your code, I have used the FPS example to help. Load the 3D\3D-FirstPersonExample project that comes bundled with AppGameKit and add the following lines of code:

Just before the 'DO' of the main loop, add (this will create a crude gun object):



Just before the Sync() within the main loop, add:
rem position gun



This will set the position and angle of the gun to match the camera, and give a local offset so it appears at the bottom of the screen.

Hope it helps.

shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 22nd Mar 2017 11:02 Edited at: 22nd Mar 2017 11:28
it works in sorts, It rotates with the camera,havent put in the moveobjectlocal yet though as I am unsure where to put it, this is the way I had tried myself before with the same results before asking for help!!
So without the move commands I have this:

Had to build the level abit more in the video to see whats going on more,skip it half way if you wanna!
Ignore the other box,it is a gun from a previous run..hehe
Hope you dont mind the video posts... I am just finding it easier showing you rather than explaining, which I am crap at doing!
Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 22nd Mar 2017 22:35 Edited at: 22nd Mar 2017 23:57
ok, your code works fine CJB,tnx for that! I found I had to put the rotation bit into the if getpointerpressed() condition else it looked kinda jerky, aside from that,great! Here is the final result:

Hail to the king, baby!
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 23rd Mar 2017 09:46

Login to post a reply

Server time is: 2024-11-24 18:27:17
Your offset time is: 2024-11-24 18:27:17