Image:
 Author: UnityDogGaming04 Group: Default Filesize: 6.56 kB Date added: 2021-10-08 Rating: 5 Downloads: 949 Views: 218 Comments: 1 Ratings: 1 Times favored: 0 Made with: Algodoo v2.1.0 Tags:
|
This scene contains a few static planets that pull in the player, as well as some fancy scripting that rotates the camera to put the nearest planet below the player!
The code checks on every running frame if planet 0 is closest, and if it is, align the camera to planet 0. It does the same with planet 1 and 2. I didn't like the sharp disorienting transition from one zone to another, so I added a lerp function to smoothen it out. However, on the west side of any planet, this caused an annoying rotation that wasn't necessary. This is caused by the fact that angles range from -pi to pi, and when crossing instantly between the two, the lerp works in the direction oppposite where it should go. So I set the transition value in the lerp to 1 and added a bend axle attached to a circle. This was sufficient to remove the sudden 360 rotation.
The code is not optimized; it could be more efficient, But since it only compares 3 elements in this case, it isn't that big a deal.
CONTROLS:
W - accelerate the player toward your mouse |
Last edited at 2022/04/03 19:27:45 by UnityDogGaming04
Please log in to rate this scene
|