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.

Newcomers DBPro Corner / Problem with point object command...

Author
Message
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 17th Feb 2004 20:41
ok so i am making a FPS game right...so i loaded a model of an m4a1 machine gun, and tweaked out some controls for the game a bit, and i wanted to add the feature of using the mouse to aim, like in counter-strike / battlefield 1942, etc. so, i just used the point object cammand, for the coordinates, i used the mousex() and mousey(), but, the gun points toward the ground!! is there any way where i can specify the part of the gun which should do the 'pointing'? thanks a lot...
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 17th Feb 2004 20:56
Mousex() and mousey() commands refer to the position of the mouse cursor on the screen, not in 3D. To point a gun, you have to make a crosshair object, and position that releative to the player, then point the gun object to the coordinates of the crosshair. For example (will probably not work, but gives you the idea)



Something like that...If you need any help, just ask

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 17th Feb 2004 21:44
oh ok dude thanks i don't really understand all of it as im not that good at darkbasic, and all that cos and sin stuff...but i dunno, ill just paste it into my game and see...thanx a lot
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 17th Feb 2004 22:11
It also helps to understand the difference between screen coordinates and world coordinates.

Screen coordinates start in the upper left corner at 0,0 and increase as you go down and to the right. Left/Right is the mouse X axis and ranges from 0 to screen width(). Up/Down is the mouse Y axis and goes from 0 to screen height(). Any value that is less than zero or greater than the width/height of the screen is off the screeen and may not be visible. Screen coordinates are integer values.

World coordinates start at 0,0,0 and represent three directions. Negative values are perfectly acceptable and all three values can be floating point numbers.
--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 17th Feb 2004 23:07
yeah dude i know dat...im in a 10th grade geometry class
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 17th Feb 2004 23:11
well actually, i would have thought that 0,0,0 would be at the BOTTOM left corner...i dunno.
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 17th Feb 2004 23:17
hey bolt in the thrid line of code...
'angle#=wrapvalue(angle#+mousemovex())' - what exactly is "angle#?"
Emperor Baal
20
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 17th Feb 2004 23:50
angle# is a real variable.

Lets move the mouse, shall we:

"angle# = wrapvalue( angle# + mousemovex() )"

angle# = 0
mousemovex()=5

"5.0 = wrapvalue( 0.0 + 5 )"

angle# = 5.0
mousemovex()=-40

"325.0 = wrapvalue( 5.0 + -40 )"

From the darkbasic helpfile:

WRAPVALUE()
This command will return a value that does not exceed the range of 0 to 360. Where a value is specified that exceeds this range, the command will wrap the value around to bring it back within the range. This command is best understood by using the number of a clock as a mental picture of how a number wraps. If the clock hand points to 11 and is then advanced 2 hours, the number has to wrap from 12 around to 1 to keep the cycle going. The parameter should be specified using a real number.



Quote: "
Amd 2500+ | 1024mb pc2700 | A7N8X-X | Geforce4 ti 4200 128mb
"
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 00:02
um ok sorry but i dont really get it...i sorta do. thx emperor i get that part of it, but i just dont get the rest...ok im just gonna attach the whole code for my game (or at least the part of it that matters for this), and could someone just tell me what to do, or just change it? thanks

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 00:02
oops sorry about that...

zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 18th Feb 2004 00:12
Try

point camera object position x(15),object position y(15),object position z(15)

so your gun and camera are looking at the same thing.

zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 18th Feb 2004 00:19
Quote: "well actually, i would have thought that 0,0,0 would be at the BOTTOM left corner...i dunno."


World coordinates have no relationship to screen coordinates. Cameras have a field of view setting. FOV determines the camera's frustrum which is the pyramid shaped region that a camera looks at. When you use the POINT CAMERA command, you're orienting the camera so that the point of focus is in the center of the frustrum.
--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 00:21
well ya i guess that would work, but i mean its not exactly.... well u get it
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 00:28
hey! that actually might work!
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 00:28
thx a lot dude
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 02:02
im having some trouble... it keeps on giving me "object does not exists at line whatever! heres my code, can someone PLEASE go though it and see wut's wrong? thanks

and also, when i try loading the crosshair.bmp, it comes into view for like 1 second then it disappears!

spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 18th Feb 2004 02:11
You are loading crosshair as image 15 but pasting image 1
You need to paste image 15 but inside main loop so it is drawn every frame
What is object 15 supposed to be. You never load or create one.

I think you are getting confused with image 15 and object 15

Image 15 is a 2D object and can not be placed at a 3D location like an object.

Boo!
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 02:52
ohh right right thanks a lot dude.
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 03:45
Quote: "Image 15 is a 2D object and can not be placed at a 3D location like an object."

ok, but look at bolt's post a long way up. i just listened to him...i assumed he meant a 2d crosshair, but mayeb he meant a 3D crosshair!?!? i know that a 2d object can't have like a z value,so... im just really lost...and my game doesnt work anymore either
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 06:34
ok u know what i think ill just start a new thread...
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 08:22
i still need help ppl
i made a little thing called crosshair.3ds, which i loaded into my program...now it stays in front of the gun when im strafing (which is good), but now how do i do the mouse look thing? i just do not get it...can someone just post the exact code which i should add, and where? i am attaching my code so far...
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 18th Feb 2004 15:20
try

point camera object position x(3),object position y(3),object position z(3)

also, didn't you used to have some mouse control of the crosshair?

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 21:20
ya well those were screen coordinates... bolt said that screen coorindates were different from world coordinates...i didnt knowit mattered...but it stilll worked...ok thanx zircher ill just do that...
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 18th Feb 2004 21:28 Edited at: 18th Feb 2004 21:28
Sigh, those were mouse movements converted into world coordinates. They used changes in screen coordinates to create relative changes in the world coordinates of the cursor/crosshair.

Here are two lines from some of Bolt's code:

cursorheight#=cursorheight#-mousemovey()
angle#=wrapvalue(angle#+mousemovex())

What these two lines are are doing is using the relative mouse movement to make make changes to height and angle. Moving the mouse up and down changes the cursorheight and moving the mouse left and right changes the angle.
--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 22:16
ok... so now here's my code.

the camera just goes crazy when i move the mouse... are you guys sure you know exactly what i'm trying to do? i'm try to get it so the aiming system is exactly like or very similar to counterstrike/battlefield 1942/call of duty (i think).
what happens in these games is, when u move the mouse, it looks around and the crosshair is ALWAYS IN THE MIDDLE OF THE SCREEN. i just don't know how to do that
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 18th Feb 2004 23:09
Heh, it looks like a mish-mash of advice. I'll clean it up and post some code later this afternoon. The one thing that you should get out of this is that there are MANY ways to do this. There is no single 'code' or method.
--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 18th Feb 2004 23:29
ya...thanks a lot . In the mean while, i'll work on bullets
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 19th Feb 2004 00:03
Give this a try and see if you understand the logic. Get ground height seems a little flaky, but it is something that I don't use that often. I used a simple blox and plane since I did not have your models.



Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 19th Feb 2004 00:58 Edited at: 19th Feb 2004 01:04
ok thx but there's one problem:
X# = camera position x()
Z# = camera position z()
it says 'start range must be between 1 and end range'
are you using dark basic classic or dark basic pro? there were also a few other minor errors before that which i corrected... but the wierdest thing is, i never had this problem with the 'camera position z' command!
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 19th Feb 2004 01:54
Heh, I'm a DBP only user. Sorry if that confuses some things. Given the nature of the debugger DO NOT look at the line that it says, but the lines around it. With that error message, look at the set camera range command.
--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 19th Feb 2004 02:06 Edited at: 19th Feb 2004 05:52
how do i change the starting value of the camera? cuz when i load the gun, the camera is really close to the gun ...
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 19th Feb 2004 05:29
DBC has only one camera then? So change it.
--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 19th Feb 2004 05:54
which one??
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 19th Feb 2004 06:09
i added this bit of code to the main loop

so that the camera stays a bit above and to the left of the gun... but what happens is the view is fine, but the gun keeps on moving backwards...
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 19th Feb 2004 15:13
In the version I wrote, the camera is the central player. Perhaps it would be better to move the gun relative to the camera rather than moving the camera relative to the gun.
--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 19th Feb 2004 21:07
ya ok never mind i got it...i just forgot to post. Thanks a lot zircher, I really really appreciate it !
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 20th Feb 2004 21:24 Edited at: 20th Feb 2004 21:40
Quote: "Perhaps it would be better to move the gun relative to the camera rather than moving the camera relative to the gun."


lol, thats what i thought also, but its ok...i got 1 more question tho (still assuming camera is the central player). ok so when i move the mouse more than about 45 degrees to either side, the gun goes out of view. what i mean is that when it is rotated, u can only see the tip of the gun. in working on this problem rite now and i think i got it fixed so... i just thought it might be helpful if u knew a better way...
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 20th Feb 2004 22:32 Edited at: 20th Feb 2004 22:33
It is because you are using fixed offsets that do not take into account the player's facing. Like a 3D HUD, you need to place objects in front of the camera regardless of the camera's orientation.

For example, each loop you could position the gun and rotate it to match the camera. You can then move it relative to that facing. Try the ROLL OBJECT RIGHT, MOVE OBJECT LEFT, and ROLL OBJECT LEFT commands. That would allow you to move the gun say .5 meters to the right and down at a 20 degree angle. The first roll sets the direction for the move. The second roll levels out the gun, if desired. Since this all happens before the sync, the player only sees the final position and not the jinking to get there.
--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 20th Feb 2004 23:05
um ok i sort of get it but how exactly would i code that...here ill just attach my code and maybe u could just describe what i could do...


are you sure u know what's going wrong? the problem is that, when i move the mouse a little too much to one side, the gun rotates, but u can't really see it ...
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 20th Feb 2004 23:37 Edited at: 20th Feb 2004 23:38
Try this, but you may have to tweak the actual values to get the offset that you like.

Replace this:



With this:



That should sync the gun to the camera and then move it down and right a half meter.

Quote: "are you sure u know what's going wrong? the problem is that, when i move the mouse a little too much to one side, the gun rotates, but u can't really see it ... "


Thanks for the vote of confidence. See this line?

position object 10, X#,Y#-2,Z#+8

This ONLY works when you face one direction. As you turn, the gun pivots but does not reposition to stay at a constant bearing. Turn 180 degrees and the gun will move from your right side to your left.

--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 20th Feb 2004 23:39 Edited at: 21st Feb 2004 01:08
ok so i substituted the code, but now, i cant even see the gun! it's just, nowhere! also, there's no such command as 'move object right' in dbclassic. instead, i just did

position object 10, gx#+.5, gy#, gz#

gx is object position x, gy is object position y...etc.

again, are you SURE you know what the problem is? because i dont really get what the roll object thing does...
Lord Helmet
21
Years of Service
User Offline
Joined: 30th May 2003
Location:
Posted: 21st Feb 2004 01:53
The way your doing this is harder than another possibility ill give you but the way you're slowly learning is the proper way in most real games. And you learn alot more about 3d space.

there are 2 commands called mousemove X/Y(), this retrives how much the mouse has moved. just pitch or turn the camera accordingly. use the same command set to point your gun. just not as much, it looks more real that way.

Also Zircher not only knows exactly what is going on with your program but I'm sure he knows what your going through. He's been extremly patient whith a very frustrating thing to teach! (not that you aren't picking it up quickly for a 10 grader) I would say thankyou.

It will make it easier for you if you learn a little Trig, it helps you visualize 2d/3d and how they work together.
Lord Helmet
21
Years of Service
User Offline
Joined: 30th May 2003
Location:
Posted: 21st Feb 2004 01:54
By the way, Zircher should be a Mod I think
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 21st Feb 2004 01:58
Quote: "
ya ok never mind i got it...i just forgot to post. Thanks a lot zircher, I really really appreciate it"


ok so i'll try the mousemove x and y thing...
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 21st Feb 2004 05:57 Edited at: 21st Feb 2004 05:59
Drat, I keep forgetting that you're using DBC. Well, move object right is simply turn object right 90 degrees, move object, turn object left 90 degrees. A few more commands, but the relative motion is the same. Relative turning and motion are important unless you want to learn trig.
--
TAZ

Lord Helmet, thanks for the kind words. I don't know if I'm ready for the Mod hat though.

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 21st Feb 2004 06:03
ok thx zircher i think it works now but theres one problem: its backwards ! like when i move mouse left, the thing goes right? can your DB highness remedy this please ? thank you
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 21st Feb 2004 06:08
That's an easy one, swap the plus/mius signs or turn left instead of right. Give it a try, you need to hone those trouble shooting skills if you don't want to go insane.
--
TAZ

Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 21st Feb 2004 06:20 Edited at: 21st Feb 2004 06:32
ya but then...o ok i see leeme try

[edit]
i tried everything and it still did the same thing ?? what gives? heres my code


i tried making the turn object left values negative, and i changed it to right also!! what gives!?!?
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 21st Feb 2004 20:00
anyone ....?
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 21st Feb 2004 22:24 Edited at: 22nd Feb 2004 00:53
hellooooo come on zircher lord helmet rpgamer ANYONE pleaseeee im a desperateeeeeeeeee!!!!!!!!!!!!!!

Login to post a reply

Server time is: 2024-11-26 05:41:30
Your offset time is: 2024-11-26 05:41:30