private void Initiate() { if (!playerTransform) { playerTransform = GameObject.FindGameObjectWithTag("Player").transform; } if (!movement) { movement = GetComponent <AIMovement>(); } if (!ps) { ps = GetComponent <PlatformerPhysicsSim>(); } if (!rb) { rb = GetComponent <Rigidbody>(); } if (!hitInfo) { hitInfo = GetComponentInChildren <RaycastHitInfo>(); } damageDealer = GetComponent <DamageDealer>(); // attack range to be <= to chase distance attackRange = Mathf.Min(attackRange, chaseDistance); InitiateAIBrain(); }
private void CalculateMoveDirection() { moveDirection = GetInputMoveDirection(); slopeAngle = CalculateSlopeAngle(out hit); if (slopeAngle > maxTraversableSlopeAngle + 90f || slopeAngle == 90f) { return; } if (moveDirection != Vector3.zero) { if (ps.IsGrounded) { moveDirection = Vector3.Cross(hit.normal, -transform.right); } else { if (RaycastHitInfo.HitWall(transform, out hit, distanceToWall, wallLayer)) { moveDirection = PlatformerPhysicsSim.WallHorizontalParallelDirection(transform, hit.normal, moveDirection); } } } }
private void Start() { ps = GetComponent <PlatformerPhysicsSim>(); mass = ps.Mass; heightPadding = ps.GroundDistance; fixedDeltaTime = Time.fixedDeltaTime; }
private void Start() { if (!ps) { ps = GetComponent <PlatformerPhysicsSim>(); } mass = ps.Mass; fixedDeltaTime = Time.fixedDeltaTime; }
// Start is called before the first frame update private void Start() { if (!hitInfo) { hitInfo = GetComponentInParent <RaycastHitInfo>(); } if (!ps) { ps = GetComponentInParent <PlatformerPhysicsSim>(); } if (!movement) { movement = GetComponentInParent <Movement>(); } //angleMultiplier = Mathf.Tan(bounceAngle * Mathf.PI / 180); }
private void MoveToward() { ps.UseGravity = false; if (hit.transform) { distanceToHookPoint = Vector3.Distance(hit.transform.position, ps.transform.position); } if (RaycastHitInfo.HitWall(ps.transform, out wallHit, wallCheckDistance, grappleLayer)) { //moveDirection = (angleMultiplier * Vector3.up - hit.normal).normalized; //moveDirection = PlatformerPhysicsSim.WallVerticalUpParallelDirection(ps.transform, hit.normal, moveDirection); moveDirection = PlatformerPhysicsSim.WallVerticalUpParallelDirection(ps.transform, hit.normal, directionToHookPoint); float value = maxHeightForGrapple - hookPoint.y; ps.Velocity = moveDirection * (bounceSpeedBoost + value); canMove = false; ps.UseGravity = true; } else { float speed = 0; directionToHookPoint = (hookPoint - ps.transform.position).normalized; if (distanceToHookPoint > constantSpeedDistance) { speed = distanceToHookPoint * distanceToAccelerationMult; ps.Velocity = speed * directionToHookPoint * Time.deltaTime; } else { speed = constantSpeedDistance * distanceToAccelerationMult; ps.Velocity = speed * directionToHookPoint * Time.deltaTime; } ps.Velocity = Vector3.ClampMagnitude(ps.Velocity, maxMoveSpeed); } }