 Ajay Ramachandran

# Repository

https://github.com/ajayyy/VosterCoasterVR/

# What is Voster Coaster?

Voster Coaster is a VR game where you build roller coasters. I plan on making it a theme park tycoon game in the future as well.

# Made the height of track pieces uniform for turns

Before, the inside turn would be scaled to the correct height: Now, the outside turn is: This is much more useful, as it makes the total height uniform, and will help when combining turn pieces with normal pieces.

# Fixed issue with track pieces becoming misaligned at certain angles

For angle of 27 degrees before the change: After: ### How?

To fix this, I had to think of the track piece as one section of a full circle Then, I can use SOH CAH TOA to know that the Cos of the angle B (in this case 90 - 27 as shown in the diagram above), is equal to the adjacent divided by the hypotenuse.

This means sinB = O/H, cosB = A/H, tanB = O/A (These are the lengths of the sides, Opposite and Adjacent of the angle, and the Hypotenuse).

The angle is determined from the total angle of this track piece, but then it has to be `90 - that angle`, as shown in the image above. The known angle is angle A, and angle A is equal to `90 - B`.

The hypotenuse side is the radius of the circle.

``````//calculate the full angle this track piece gets to
float totalAngle = 90 - adjustmentAngle.y * 9f;

//radius of the outside circle (SOH CAH TOA, cosA = a/h, h = a/cosA)

Now, the proper radius is calculated instead of just assuming that the full height is the radius (as that would only work for a 90 degree turn). This was done by creating a function to reset the track completely. This makes it so that you can modify it again.

This works, but is very inefficient, requiring the whole mesh to be reset every frame just to be adjusted again.

So, I later changed it again. Now, when adjusting the mesh of the track, it does not do any math relative to the positions (`transform.localPosition *=`) but instead sets it to the default (`transform.localPosition = defaultBonePosition *`).

This, along with setting the angle instead of adding to it, and saving the original size to attempt to scale all track pieces too removes the need to reset the track piece every frame when changing the angle.

# GitHub Account

https://github.com/ajayyy/