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 / rolling camera

Author
Message
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 28th Jan 2009 02:10
hi i have had a bit of a search but havent really found anything useful, im trying to rotate the cameras angle when pressing the right key (rotate right) but the angle always resets itself how would i make to keep adding to the angle if it is help in and not go back to the first angle settings?



i have also tried a couple of other questions.

any help is appreciated
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 28th Jan 2009 11:20
ok i have gotten a rolling effect and pitch effect working but when using it it will always jump to a close position not the exact one.

here is the edited code


If anybody can get precision movements working in it please tell me how to do it...
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 28th Jan 2009 11:57
Try declaring your variables as floats, or appending a # to all of them.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 28th Jan 2009 12:09
i added the hash just after al the variables and it did nothing.
how do i declare them as floats?
Gatorules
15
Years of Service
User Offline
Joined: 17th Dec 2008
Location:
Posted: 29th Jan 2009 03:34
you declare them as float by saying float in front of them instead of int when declaring them
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 29th Jan 2009 05:35
Why don't you just ditch the variables xA and zA altogether? It works perfectly without them. You can replace your entire main loop with something like this:



And if you really need the variables for something later on, you can just add something like this to the loop:



I recommend storing all three camera angles, as all three of them change when pitching and rolling the camera. And, I recommend using floats. If you don't explicitly declare a variable as a float by doing this,
, you can do it implicitly by appending "#" to the end of the name (xA#), as Pillarofire mentioned.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 29th Jan 2009 09:45
ok tahnks heaps that actually worked and i learnt a few things.

now im trying to implement a turn velocity, i have begun by doing



thats what i have so far but it needs some refining..
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 29th Jan 2009 12:30
ok i have been working smoothing out moevement when the roll and pitvh speed is lower but for some reson it will only do it for one roll and one pitch not both, heres some code to look over if more is needed to see the actual problem ingame i can provide it



it seems that only the last roll an pick if work for it, i want them both to be able to change the variable.

Any help will be appreciated...
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 29th Jan 2009 22:48
Here, I think this is what you're trying to do:



Feel free to ask questions.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 30th Jan 2009 01:02
i have tried it and it worked perfectly, i even added in a Thrust Velocity to go forward and backward but now im trying to implement a full stop (decelerates or accelerates until ThrustVelocity#=0 when keystate 12 is pressed(esc key)

this is what im using but i think im using the wrong syntax/commands.


if somebody could explain to me what im doing wrong pease do...
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 30th Jan 2009 04:00
Well, I really see no reason you couldn't just do something like this:



I mean, the camera wouldn't actually be moving at all in the time you were decelerating to 0, would it? You have that whole section closed off inside a while loop. (while loops end in endwhile)

Don't think too hard.

But if you didn't want the stop key to just kill the thrust movement so suddenly like that, you could have it increase ThrustDeceleration# while the key was being pressed.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 30th Jan 2009 04:44
ok i have the code working but not the exact way im after



I need the fullstop key to be pressed only once and it will keep decelerating until its velocity is 0.

sorry to keep bothering you anyway...
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 30th Jan 2009 05:17 Edited at: 30th Jan 2009 05:19
Hah! Don't worry about bothering me. What else, exactly, would an 18 year-old high school dropout be doing with his time?
I'm glad to help where I can.

Here's what I came up with:



When key 207 is pressed, ThrustDeceleration# just needs to be set higher than ThrustAcceleration# so the user can't hit the stop key and continue accelerating in the direction they're traveling.

Edit: Oops, I got my variable names flipped around. It's fixed now.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 30th Jan 2009 05:29
ok changing it to that caused it to constantly decelerate not when the end key is pressed and i coulndt reverse the thrusters
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 30th Jan 2009 05:39
Hm.. Did it? We've most likely set things up differently..

It works fine with my setup. Here's how I fit it into the code:



I don't know what keys you mapped to thrust forward and backward, but I just mapped W and S.

Using the code I posted, the camera accelerates and decelerates as normal and then when I tap the end key, it decelerates constantly until its velocity reaches zero. After that, movement can continue like normal.

Maybe I misunderstood what you were trying to do?
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 30th Jan 2009 05:46
ok thats working a little better, the only thing it is doing wron is slowing down when the w key isnt being pressed, what i want is it to stay constantly there until i tell it to do so by pressing S or End....
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 30th Jan 2009 05:52
Oh, I see. I just figured you wanted it to work out like the rolling and pitching. But in that case, you could just change the line before the main loop where ThrustDeceleration# is defined and the one near the end of the main loop inside the if/endif block where the variable is set again, to:



That should do it.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 30th Jan 2009 06:19
omg that works perfectly thanks...

ok if i have any other questions related to the movement ill ask away

but if i wanted to ask about something else but still with this program then i would have to start a new topic right..
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 30th Jan 2009 08:38
alright me again i tried doing a little modifications
1. I tried adding in something that will do the reverse of the fullstop by doing


but i miserably failed, any more help is welcome by miles

2. i tried modifying th cap code to have max forward and max reverse it worked and all but i am trying to display the Thrust velocity on screen and it has lots of numbers when dealing with decimal points, is there any way to restrict the amoutn to 1 or 2 decimal places?, thankyou

p.s. i changed the forward cap to 2 and reverse cap to 0.6..
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 30th Jan 2009 16:31
Hey, sorry about the time shift from here to there. It was midnight and I needed some sleep.

I did some reworking of the program structure to make things a little easier. I've included the forward and backward velocity caps along with the home key acceleration. I also wrote a rounding function to display a certain amount of decimal places. I don't know if there's an easier way built into DBPro, but a quick search turned up nothing.



I don't know if the home key works exactly as you envisioned it, but currently, if pressed, the camera will accelerate until it has reached the velocity cap for the direction in which it was traveling. Pressing the home key while stationary causes an automatic acceleration in the forward direction. Also, any forward or backward movement from the user cancels any acceleration. I'm sure changes could be easily made if this isn't what you had in mind.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 31st Jan 2009 06:10
Sorry for a delayed reply but my laptop of wich i use mainly has stopped working properly..

i have just added all that in to the current rework of my code and it all works fine, thanks heaps.

Do i have your (kira) permission to add this source as a snippet to the site?

here is what i have done to it (reformatted)
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 31st Jan 2009 08:18
Glad I could help.

And yes, you have my permission.

Login to post a reply

Server time is: 2024-09-28 02:30:24
Your offset time is: 2024-09-28 02:30:24