Hello,
I'm trying to activate and deactivate a script that is on another gameObject.
To situate you, I have a script on my Character that when it meet some conditions it must deactivate or activate a specific script on the Main Camera.
Thank You.
Adding the scripts
This is CameraActivate situated on the Character.
var Cspeed = 2;
var Camera : GameObject;
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
var horizontalVelocity : Vector3 = controller.velocity;
horizontalVelocity = Vector3(controller.velocity.x, 0, controller.velocity.z);
// The speed on the x-z plane ignoring any speed
var horizontalSpeed : float = horizontalVelocity.magnitude;
// The speed from gravity or jumping
var verticalSpeed : float = controller.velocity.y;
// The overall speed
var overallSpeed : float = controller.velocity.magnitude;
if (overallSpeed > Cspeed){
Camera.GetComponent(CameraFocus).enabled = false;
}
}
this is the CameraFocus situated on Main Camera that need to be controlled through CameraActivate
var target : Transform;
var Distance = -50;
var xsmoothTime = 0.5;
var ysmoothTime = 0.5;
private var xVelocity = 0.0;
private var yVelocity = 0.0;
function Update () {
var newX : float = Mathf.SmoothDamp(transform.position.x, target.position.x, xVelocity, xsmoothTime);
var newY : float = Mathf.SmoothDamp(transform.position.y, target.position.y, yVelocity, ysmoothTime);
transform.position = Vector3 (newX, newY, Distance);
}