May 23, 2012, 12:36:13 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Camera control in vehicle script  (Read 951 times)
Spaz
Full Member
***
Posts: 109


View Profile
« on: February 19, 2009, 08:11:02 PM »

I'm trying to modify the camera in the vehicle_4wheel script so that I have a first-person driver's point of view.  I've got it pretty close, but I can't figure out what to alter so that the camera will stop sliding backwards as the car accelerates and sliding forward as the car slows down. (I rarely sit in the back seat to drive fast and move to the front seat to drive slow. Wink

The script looks like it should have something to do with the FOV based on vehicle speed, but I've commented out those lines and it still does the same thing. 

Anybody know what else I should be looking at?
Logged
Ron
Sr. Member
****
Posts: 326


View Profile
« Reply #1 on: February 19, 2009, 11:39:10 PM »

Your post convinced me to try it (its been on my list for awhile now).

I'm getting the same, gonna keep pokin around see if I can see what it is.
Logged
Ron
Sr. Member
****
Posts: 326


View Profile
« Reply #2 on: February 19, 2009, 11:45:46 PM »

Look like if you change

camera.SetTransition( 0.5);

to

camera.SetTransition( 0.0);

it works.

I'm changing over to the new vehicle script too, so your not alone in the growing pains. I do love the way it 'drives' though
Logged
Spaz
Full Member
***
Posts: 109


View Profile
« Reply #3 on: February 20, 2009, 10:36:05 AM »

Sweet, Ron.  Thanks!  I'd changed several other setTransitions in the file (I've added several different camera angles), but hadn't seen that one at the bottom (because I'd added so many).

And I agree, the cars behave much more realistically with this new script.

Can I ask you to take a look at something else, too?  I've got it worked out so that my camera can look left and right with the mouse from the first-person driver's point of view.  It can also look down and as far up as level, but I can't get it to look up.  I'm sure it's something to do with the camDir and pitchAngle, but I'm not sure what.

Code:
float vehicleAngle = lastVehicleAngle;
            if (object.GetInterpMatrix().YAxis.y > 0.005)
            {
                float zy = object.GetInterpMatrix().ZAxis.y;
                if (zy > -0.99 && zy < 0.99)
                {
                    vehicleAngle = atan2( -object.GetInterpMatrix().ZAxis.x, -object.GetInterpMatrix().ZAxis.z);
                    lastVehicleAngle = vehicleAngle;
                }
            }

            if (cameraAngle > vehicleAngle + 180)
                cameraAngle -= 360;
            if (cameraAngle < vehicleAngle - 180)
                cameraAngle += 360;

            cameraAngle += (vehicleAngle - cameraAngle) * 0.1;

            Vector focus = object.GetInterpMatrix().T + CAMERA_TARGET;

            Matrix mtx;
            mtx.SetRotate( cameraAngle + headingAngle, 0, 0);

            Vector camDir = mtx.ZAxis; // * cos( pitchAngle);
            camDir.y -= sin( pitchAngle);
         
            Vector cameraPos = (object.GetInterpMatrix().Project( 0.25, 1.3f, -0.7));
         
            camera.SetFocus(cameraPos + camDir); //mtx.ZAxis);
            camera.SetPosition(cameraPos);
            camera.SetUp( 0, 1, 0);
            camera.SetTransition( 0.0);

Oh, one more thing I'll be looking at soon but if you happen to see while you're messing around with the script I'd be grateful for - the car, if on any angle at all, will roll even if you're not in it.  Do you see how to put it in "park"  if you're not in it or once you've slowed to a certain speed?

Thanks.
Logged
Ron
Sr. Member
****
Posts: 326


View Profile
« Reply #4 on: February 27, 2009, 02:22:30 PM »


Oh, one more thing I'll be looking at soon but if you happen to see while you're messing around with the script I'd be grateful for - the car, if on any angle at all, will roll even if you're not in it.  Do you see how to put it in "park"  if you're not in it or once you've slowed to a certain speed?

Thanks.

Finally got something figured out that may help... its still needs some teaking though. When I crash and have the brakes on, it make the vehicle look like slow motion.

Code:
if (leftSideForce == 0 && speed < 1  && speed > -1 && handbrakePressed >= 0.5f)
{
collideBase.SetLinearVelocity( Vector( 0, 0, 0));
collideBase.SetAngularVelocity( Vector( 0, 0, 0));
}
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #5 on: February 27, 2009, 04:10:25 PM »

Getting the vehicle to stop rolling can be a bit of a tricky one, considering you won't want it to not roll down a steep hill. You'll probably want to disable the vehicle based on both no driver aswell as a downward raycast to detect the ground plane's angle. For now, just test that you can disable it when no driver.
Logged
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #6 on: March 01, 2009, 09:23:07 AM »

could you set mass to infinite when not inside it? Would that make it not roll? But then again it can't be bumped or anything
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #7 on: March 01, 2009, 02:11:22 PM »

Yes, I think that would be the case. You could set the mass to infinite (0) and it would basically be a static object, unable to move at all. However, you could alter the mass again upon collision and keep it temporarily active based on a timer or its linear velocity...though this can again keep it moving forever. There's also air resistance, but this appears to be a global setting (all objects at once)...which ruins its versatility in my eyes.
Logged
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #8 on: March 01, 2009, 05:05:36 PM »

There is one problem as I said and that is if you have cars in a slope and you want to be able to run into them and they move then it can't be set to zero. Isn't there some kind of friction thing that can be increased?
Logged
Ransom
Full Member
***
Posts: 132



View Profile
« Reply #9 on: March 02, 2009, 09:12:18 AM »

You can turn on/off collisions, but (unless its been added recently) you can't dynamically alter the mass of an object.
Logged
Spaz
Full Member
***
Posts: 109


View Profile
« Reply #10 on: March 11, 2009, 03:57:26 PM »

Yeah, I was guessing friction was the way to go.  It at least needs some lateral friction control because the cars not only roll, they slide sideways.
Logged
Pages: [1]
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!