Game Development Reference
In-Depth Information
Engage Thrusters
Now, we will begin coding the CharacterCamera script:
1. Type the parameters script as follows:
//Make sure that we have CharacterControl included in this
gameobject
@script RequireComponent(CharacterControl)
//Angular smooth
public var smoothTime : float = 0.1;
public var maxSpeed : float = 150.0;
public var heightSmoothTime : float = 0.1;
public var distance : float = 2.5;
public var height : float = 0.75;
private var f_heightVelocity : float = 0.0;
private var f_angleVelocity : float = 0.0;
private var v3_velocity : Vector3;
//Transform
private var target : Transform;
private var cameraTransform : Transform;
private var f_maxRotation : float;
//Character Control
private var c_characterControl : CharacterControl;
//Target
private var f_targetHeight : float = Mathf.Infinity;
private var v3_centerOffset = Vector3.zero;
Using the preceding code, we created all the parameters to use in this script.
2. Next, we will set up the parameters by using the Awake() funcion:
public function Awake () : void {
//Get Our Main Camera from the scene
cameraTransform = Camera.main.transform;
target = transform;
c_characterControl = GetComponent(CharacterControl);
//Get target center offset
var characterController : CharacterController = target.collider;
 
Search WWH ::




Custom Search