Hello everyone,
I tried all possible configurations, but either the player jitter or the camera(What only causes this on the Agents).
If I switch camera in LateUpdate, Agents work well, BUT, something I do not understand! When I shoot at them with projectiles and I’m in motion, the player remakes jiterring -_-’
The 3 scripts:
Player
if (IsMove == true) {
if (SaveLoadDeleteScript.Keyboard == 0) {
float h = Input.GetAxisRaw ("Horizontal");
float v = Input.GetAxisRaw ("Vertical");
Movement.Set (h, 0f, v);
if (IsConveyorBelt == false) {
Movement = Movement.normalized * SaveLoadDeleteScript.MovementSpeed * Time.deltaTime;
} else if (IsConveyorBelt == true) {
ConveyorBeltSpeed = SaveLoadDeleteScript.MovementSpeed / 2;
Movement = Movement.normalized * ConveyorBeltSpeed * Time.deltaTime;
}
playerRigidbody.MovePosition (transform.position + Movement);
if (SaveLoadDeleteScript.Keyboard == 0) {
if (Movement != new Vector3 (0, 0, 0)) {
TimerUntilPlayerFirstMovement = 1;
TimerUntilPlayerFirstMovementSpeed = 5;
if ((Input.GetKeyDown (KeyCode.Space)) && (IsDashReady == false) && (IsOppositeInput0_1 == false) && (IsOppositeInput0_2 == false)) {
Dash();
PlayerDashSFX.Play ();
}
}
} else if (SaveLoadDeleteScript.Keyboard == 1) {
if (Movement != new Vector3 (0, 0, 0)) {
TimerUntilPlayerFirstMovement = 1;
TimerUntilPlayerFirstMovementSpeed = 5;
if ((Input.GetKeyDown (KeyCode.Space)) && (IsDashReady == false) && (IsOppositeInput1_1 == false) && (IsOppositeInput1_2 == false)) {
Dash();
PlayerDashSFX.Play ();
}
}
}
if ((PlayerFirstMovement == false) && (Movement != new Vector3 (0, 0, 0))) {
PlayerFirstMovement = true;
PlayerFirstMovementSFX.Play ();
}
}
Camera
/*-----------------------------------------------------*/
void Start () {
Offset = new Vector3 (transform.position.x - Target.position.x, 45, transform.position.z - Target.position.z);
Offset2 = new Vector3 (transform.position.x - Target.position.x, 90, transform.position.z - 36.8f - Target.position.z);
}
/*-----------------------------------------------------*/
void FixedUpdate () {
if (IsZoomOut == true) {
Vector3 TargetCamPos = Target.position + Offset;
transform.position = Vector3.Lerp (transform.position, TargetCamPos, Smoothing * Time.deltaTime);
if (Scan == false) {
Scan = true;
this.GetComponent<CameraFilterPack_3D_Scan_Scene> ().enabled = false;
this.GetComponent<CameraFilterPack_3D_Scan_Scene> ()._Distance = 0;
}
}
if (IsZoomOut == false) {
Vector3 TargetCamPos = Target.position + Offset2;
transform.position = Vector3.Lerp (transform.position, TargetCamPos, Smoothing * Time.deltaTime);
this.GetComponent<CameraFilterPack_3D_Scan_Scene> ().enabled = true;
}
}
Agents
void Update () {
if (PlayerLifeScript.IsDead == false) {
if (IsFollow == true) {
Agent.enabled = true;
Agent.SetDestination (Player.position);
}
}
}
Thanks guys
Alexandre