/// <summary> /// Initializes values upon awake /// </summary> /// <param name="owner"> The sate machine used by the script</param> public override void Initialize(StateMachine owner) { this.owner = (CowSM)owner; OwnerPhysics.SetAirResistance(0.95f); FollowSprite.SetActive(false); PatrolSprite.SetActive(false); }
/// <summary> /// Sets values upon initialization /// </summary> /// <param name="owner"></param> public override void Initialize(StateMachine owner) { this.owner = (GiantSM)owner; OwnerPhysics.SetAirResistance(0.95f); PatrolSprite.SetActive(false); AttackSprite.SetActive(false); ChaseSprite.SetActive(false); //patrolPointCenter = owner.transform.GetComponentInParent<Transform>().transform.position; //giants kommer ha en parent som är mitten av dess patrolpoint }
/// <summary> /// Controlls the time interval and % chance for the game object to activate the ScareCow event. /// </summary> public override void Update() { OwnerPhysics.SetVelocity(AIagent.velocity); ShoutTimer += Time.deltaTime; if (ShoutTimer >= ShoutCooldown && Random.Range(1, 10) > 5) { ScareCowEventInfo scei = new ScareCowEventInfo { scarySoundLocation = Position.position }; EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.ScareCow, scei); ShoutTimer = 0; } }
/// <summary> /// Assigns values to variables on initialization. /// </summary> /// <param name="owner"> Reference to the object the <see cref="GnomeStateMachine"/> is attached to</param> public override void Initialize(StateMachine owner) { this.owner = (GnomeStateMachine)owner; OwnerPhysics.SetAirResistance(0.95f); AIagent.speed = Speed; }
private void InheritVelocity(Transform collideObject, ref Vector3 normalForce) { PhysicsComponent physics = collideObject.GetComponent <PhysicsComponent>(); if (physics == null) { return; } normalForce = normalForce.normalized * (normalForce.magnitude + Vector3.Project(physics.GetVelocity(), normalForce.normalized).magnitude); Vector3 forceInDirection = Vector3.ProjectOnPlane(AIagent.velocity - physics.GetVelocity(), normalForce.normalized); Vector3 friction = -forceInDirection.normalized * normalForce.magnitude * OwnerPhysics.GetStaticFriction(); if (friction.magnitude > forceInDirection.magnitude) { friction = friction.normalized * forceInDirection.magnitude; } AIagent.velocity += friction; }
public override void Initialize(StateMachine owner) { this.owner = (WolfSM)owner; OwnerPhysics.SetAirResistance(0.95f); }
protected void setVelocity() { OwnerPhysics.SetVelocity(AIagent.velocity); }