68 lines
2.0 KiB
C#

using UnityEngine;
namespace CreatureControl {
/// <summary>
/// A creature with six legs
/// </summary>
public class Insect : Creature {
public InsectRig insectRig;
public float forwardSpeed = 1;
public float rotationSpeed = 1;
public InsectHead head;
public Transform thorax;
public Transform abdomen;
public Leg leftFrontLeg;
public Leg leftMiddleLeg;
public Leg leftHindLeg;
public Leg rightFrontLeg;
public Leg rightMiddleLeg;
public Leg rightHindLeg;
public bool updateAnimations = false;
#region Init
public override bool CheckTargetRig() {
bool anythingChanged = base.CheckTargetRig("InsectTargetRig");
if (anythingChanged || this.insectRig == null) {
this.insectRig = this.targetRig as InsectRig;
return true;
}
else
return anythingChanged;
}
#endregion Init
#region Update
public override void UpdateModel() {
base.UpdateModel();
if (this.insectRig == null)
return;
if (this.insectRig.leftFrontLeg != null)
this.insectRig.leftFrontLeg.UpdateBones(this.leftFrontLeg);
if (this.insectRig.leftMiddleLeg != null)
this.insectRig.leftMiddleLeg.UpdateBones(this.leftMiddleLeg);
if (this.insectRig.leftBackLeg != null)
this.insectRig.leftBackLeg.UpdateBones(this.leftHindLeg);
if (this.insectRig.rightFrontLeg != null)
this.insectRig.rightFrontLeg.UpdateBones(this.rightFrontLeg);
if (this.insectRig.rightMiddleLeg != null)
this.insectRig.rightMiddleLeg.UpdateBones(this.rightMiddleLeg);
if (this.insectRig.rightBackLeg != null)
this.insectRig.rightBackLeg.UpdateBones(this.rightHindLeg);
}
#endregion Update
}
}