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 / mouse movement and strafing DBC

Author
Message
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 17th Oct 2006 02:43
I would like some help with strafing. I'm not entirely sure on what code i need to use (object 1). Also i wanted to have movement with the mouse so it controls a limb. Is this possible. My code is below



if con is the opposite of pro, than is congress the opposite of progress?
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 17th Oct 2006 12:30 Edited at: 18th Oct 2006 03:13
Nenohum,

FPS style movement has always been a favorite of mine to program in DBC. Therefore, I have typed up a runnable code segment, which is thouroughly commented, to try and help you out. However, if you have any questions regarding the code, please do not hesitate to ask.



[EDIT]
I'm not too sure what you mean when you talk about rotating a limb. Maybe you can help me understand so that I could try to helpl you.
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 18th Oct 2006 00:25
thanks for the help. I'm going to anaylze the code a bit, but from what i saw it looked like it was just the camera that moved so can you detect collisions with the camera? or do i need to make and object and have the camera on it. Also for my first post for the particular code i wanted the limb to move like the camera like "If you point up then the limb also points up" But looking from your code it looks like i might be going at this at the wrong angle.

if con is the opposite of pro, than is congress the opposite of progress?
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 18th Oct 2006 03:28
Nenohum,

Yes, just position and rotate the dummy object and the camera with the player variables, and then use the dummy object for collision detection. I believe that this would be a good way to go about it.

For the offset of the weapon, I have not quite experimented with that enough. However, I will see what I can come up with tonight.
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 18th Oct 2006 03:49
evidently i'm doing something wrong. i've delete my movement for right and left kept my foward and back wards and added your code in the main loop. Befor
i added
Everything works but i can't strafe now. I must of made a mistake somewhere. Is it possible to adhere an ojbect to the camera.....if so than it would solve my problem i just need to know the code.

if con is the opposite of pro, than is congress the opposite of progress?
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 18th Oct 2006 05:16
Nenohum,

Post your new code so I can see exactly what is going on. Thanks.
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 18th Oct 2006 05:25
here it is. I left your part exactly how it is for the code.



if con is the opposite of pro, than is congress the opposite of progress?
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 18th Oct 2006 17:59 Edited at: 18th Oct 2006 18:13
Nenohum,

Here is your code freshly edited.



There were a few important variables I failed to mention to you about.



These are 'easy-initialization' variables. The first two are the player's up and down look barrier values. The uplook value must be negative, or the player will be stuck looking down. The downlook must be a positive value, as shown in the image below.



mouseSpeed# might be better known as playerLookSpeed#. A larger value will make the mouse more sensitive, and will rotate the camera a greater distance when the mouse is moved.

playerObject assigns a specific object to the camera to be used as the collision object.

playerSpeed# determines how fast your character walks(in relation to the size of the scene).

playerY# is there to be able to simply adjust the player's height for now.

Any other variables are there just to make the code easier to undertand. For instance, instead of using...



...I use...



Just set true to equal a value of 1 at the top of your program. I try to implement a variable in place of a number value:
1. It takes down the confusion of seeing so many numerical values within your code
2. It helps to make your code more clear and easier to understand your intentions for each line of code.
3. A single variable can be used to set several different parts of your program, or even just one, simply and without having to sort through your code to find out where 'that darn!' variable is, so that you can change it's value...hehe.

By the way, though I could be wrong, you might want to down size your objects some. I beleive that the larger an object is, the more memory and processor it takes to get it to the screen. Just make sure to readjust the playerY# variable when resizing the scene.

I wasn't quite sure which object was the player collision object. However, just set that with the 'easy-initialization' variable named playerObject. There was a 2nd position camera command directly above the sync command. It was causing the scene to flucker from position to position. So, set playerObject, and you will be set for player collision, using that object.

I have done away with the move object command, and have stuck with the angle variables. There is no need for the move object comomand here.

Well, that's about it. Study the code to understand it more and ask me if you have any questions.

[EDIT] Well, the weapon limb code is stil a WIP. I should be finnished soon though.
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 19th Oct 2006 05:36
thanks again. I've been working on the limb problem as well but i think i will study the new code more before trying to mess with it.

I will diffently take your advice

some mornings, it just doesn't pay to gnaw through those leather straps
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 20th Oct 2006 04:25 Edited at: 20th Oct 2006 04:31
Here's some other, shorter code if you like



Ummm...
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 22nd Oct 2006 11:08
Sixty Squares,

Nice.
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 26th Oct 2006 02:00
i was thinking for know i should make a Doom type of game but you can point the mouse instead of moving. SO don't worry about the limb thing anymore

some mornings, it just doesn't pay to gnaw through those leather straps
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 26th Oct 2006 04:07
okay quick problem. Probaly something simple. i have
added to the above code
and it's not doing anything. but if i put it like this
i can only shoot once. I'm trying to delay shooting so any help would well..help.

some mornings, it just doesn't pay to gnaw through those leather straps
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 27th Oct 2006 03:32
okay so in addtion to the code before i still need some more help
i added
But it doesn't work. I think it might be because of the camera. Do i need to move the camera because i can't get it. And for your code creampie i don't see where it puts the cube with the camera and the limb is automatically hidden which is a bonus but why

some mornings, it just doesn't pay to gnaw through those leather straps
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 29th Oct 2006 07:25
Nenohum,

I am so sorry for the delay in a response to your last 3 posts. Although, I don't have a moment right now, I am just letting you know that I should have a chance to continue this thread tommorow morning when I wake up.

By the way, did you give up on the limb...because you shouldn't settle for less just because it takes a little more time to figure out. Also, I just thought of a solution for the problem. I'll post as soon as I have more time.
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 31st Oct 2006 04:36 Edited at: 1st Nov 2006 01:50
yeah..i haven't been doing much. But i haven't given up on the limb problem. I'm just compensating untill i figure it out. By the way
won't work here will it. It points the center of the object,...right? Any way thanks for the help


((Edit))
okay figured out the shot delay problem. Took me a while to relize
Any way the jumping problem is still at hand.

some mornings, it just doesn't pay to gnaw through those leather straps
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 1st Nov 2006 01:52
By the way,... in case nobody has figured out i'm just converting Ruccus tutorial for fps into DBC.

some mornings, it just doesn't pay to gnaw through those leather straps
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 1st Nov 2006 06:17
Nenohum,

You're correct about point object. About jumping, it's not too tricky. Below is my updated code, fresh with a jumping sequence. I don't have time to explain now, but I added a few more initialization variables and some more constants for the player. Make sure to look at these so that you may understand the code.

Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 1st Nov 2006 23:28
thanks for all the code. I understand most of what you did. But why wasn't my jump code working? It seemed like it should of....And my guess is that the sphere will eventually be a weapon that i will load on. But can i still detect object collision. or will it have to be with the sphere. I didn't see any make object for the player. s

some mornings, it just doesn't pay to gnaw through those leather straps
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 2nd Nov 2006 11:01 Edited at: 4th Nov 2006 12:00
Nenohum,

Quote: "But can i still detect object collision. or will it have to be with the sphere. I didn't see any make object for the player. s"


No, I have not made an object for the player yet, because I have not yet incorporated collision into the code. However, just make a sphere and place it at the camera's position, or vice-versa. Then, use it for collision checking.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Nov 2006 21:27 Edited at: 2nd Nov 2006 21:33
@Creampie

You can save yourself some trig math in your strafing (and general movement) by using the newxvalue() and newzvalue() functions.




Enjoy your day.
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 4th Nov 2006 11:56 Edited at: 4th Nov 2006 11:58
Latch,

Thanks for the input. However, I do know about the newvalue functions. Though it may be unwise on my part...I don't know for sure, I have used the trig maths for a while and I continue to more enjoy using them. Who knows though, I may find I like the functions more if I were to use them again.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Nov 2006 17:13 Edited at: 4th Nov 2006 18:00
@Nenohum
Sorry for stepping on your thread, but this applies a little bit...

@Creampie
The NEWXVALUE etc. have the trig already built in. But if you are already comfortable using the actual trig math, there may not be a reason to use it.

If the program speed was an issue, I know trig functions slow down processing - it's usually better to create a lookup table (array) of the sin or cos values and then just reference them by an index. I don't know if NEWXVALUE etc. would help speed up processing, I've never tested it. I think I will, just to see...

[EDIT]
For what it's worth, I wrote a version of the example I posted but used sin and cos instead of NEWXVALUE... I timed each program over 5000 loop iterations. Because of my own inconsistancies with using the keyboard to move the cube around (how and when I press the key actually affects the time test) I had to average out the results and take them with a grain of salt. Basically, the trig functions were about 5 to 10ms faster than NEWVALUE. But, again I didn't run the experiment for a long period of time, and my keypresses weren't exactly the same each time. There's not enough processing going on in my example to get any real usable results.

Enjoy your day.
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 5th Nov 2006 05:04
thanks i didn't know the newvalue command was trig. Either the turorials didn't say that or i just wasn't reading carefully. Either way i had a question. Should i keep the collision with the sphere or should i actually shoot stuff, like spheres but at a fast speed? just wondering

some mornings, it just doesn't pay to gnaw through those leather straps
Nenohum
18
Years of Service
User Offline
Joined: 21st Sep 2006
Location: In a galaxy far, far, away.....
Posted: 10th Nov 2006 00:58
Should i use an object for collision or just shoot objects. If you may a game like a fps can you tell me what you used.

some mornings, it just doesn't pay to gnaw through those leather straps

Login to post a reply

Server time is: 2024-09-25 11:24:27
Your offset time is: 2024-09-25 11:24:27