PDA

View Full Version : How to rotate a custome camera?



JockinaFrock
07-14-2014, 08:54 PM
Hi all,

I'm new to the track editor, and slowly finding my feet. I have a loop-the-loop in my track, and I want a custom camera to fix to the player as he goes around the loop. I want the camera to bank through 360 degrees during the loop.

I'm sure I've seen this done (can't recall if it was a RL track or a user track).

Any pointers?

Zorsselsson
07-14-2014, 09:25 PM
Make a custom camera follow the bike with an Object Position Event. Add something to the position and angle values so it stays in the relative position and angle you want. Or just have it stay in one spot and only update the cameras angle. Then activate a Camera Event from an Area Trigger, switch to that camera, and then switch back to the original once you clear the loop.

and you only need the Object Position Event active during the loop part.

JockinaFrock
07-14-2014, 09:55 PM
Cheers, Megamanne, I'll look at that :)

xDEAD_EXITx
07-14-2014, 11:16 PM
Easier way is to use a physics joint set to point to point.
Target 1 is the bike/rider
Target 2 custom cam with physics on.
Uncheck enable on the camera & use state events to turn it on/off.
Done. :)

Zorsselsson
07-15-2014, 05:28 AM
Easier way is to use a physics joint set to point to point.
Target 1 is the bike/rider
Target 2 custom cam with physics on.
Uncheck enable on the camera & use state events to turn it on/off.
Done. :)

Didn't recommend that because it adds a tiny weight to the weight of the bike/rider, but now that I think of it, why would it matter anyways :) I change my recommendation to this method

Reaper392
07-18-2014, 01:12 AM
If you want to do this with object position events on the camera, rather than by mounting a camera to the bike, then the inverse tangent function will be very helpful for working the angle that the camera needs to be rotated to.

I have no idea how good your maths is, so I'll try to make this as easy to follow as I can. It also involves a little bit of trial and error to get a couple of the constants you will need, so I suggest applying the object position event to another object as well as the camera while you are testing to help work out the values you need. if you really can't work them out I'll have a look myself later this week or early next week

Method:

Get the banking value of the camera:
1. Place a dummy object in the centre of the loop, on the driving line (doesn't have to be exact, but the closer you can get it the better).
2. Get this dummy object's X, Y and Z position
3. Get the bike's X, Y and Z Position. If you can select multiple parts of the bike go for something near the centre.
4. Find the distance between the X, Y and Z coordinates of the bike and this dummy object (ie. Xbike - Xdummy, Ybike - Ydummy, Zbike - Zdummy)
5. Use Pythagoras to extract the 'horizontal' distance from the X and Z distance worked out in the previous step. Horizontal distance = √(Xdistē + Zdistē) (if there is no squared function, use the "pow" or "power" function from the two input operator, set operand 1 to the Dist and operand 2 to 2)
6. Vertical distance is just the Y distance.
7. Add a two input operator and set its function to "ArcTan2".
8. Select operand 1, and use pick value object and pick the horizontal distance value that has been calculated. select operand 2 and use pick value object and pick the vertical distance value that has been calculated.

This will give you the 'bank' angle that the camera needs to be. You may need to add 90, 180 or 270 degrees to this value depending on how camera angles work in trials.

Get the Yaw angle of the camera:
You could just use a constant for the yaw angle of the camera. however, a better way would be to get the yaw angle of the bike, and add 0, 90, 180 or 270 to it. I genuinely cant remember which you will need, but a bit of experimenting should get the right value.

Get the Pitch value of the camera:
The Pitch value can be left as a constant. I believe the default is 180, but it may be 0. You can find this out by attaching an object position data source to a camera you haven't rotated yet and seeing what the Y angle is.

Get the X, Y and Z position of the camera.
There is a complex way of doing this so that you can adjust the camera's position up, down, left or right from the bike. If you want me to go through this then let me know and I will do so later, but for now I will just go through the method to adjust the camera's distance from the bike, keeping the bike in the centre of the camera.

1. Get the bike's yaw value. add 90 or 270 to this value (experimenting time again, sorry)
2. Use the single input operator sin function on this value, then divide it by a constant.
3. Do the same as in step 2, but with the cos function. Use the same constant. (there's a small chance that i may have sin and cos the wrong way round, but this should be pretty easy to see after a trial run)
4. Calculate xPositionBike + value calculated in 2. This is the camera's X position.
5. Calculate zPositionBike + value calculated in 3. This is the Camera's Z position
6. The Y position of the camera is the same as the Y position of the bike.

The object position event
Attach the relevant X, Y and Z position and rotation values to an object position event. set rotation values to set and global. This object position event will need to be activated by an impulse every tick.


Hopefully that helps. Let me know if you want me to work out any of the things I said I could add later.