objectReference: {fileID: 0}
- target: {fileID: 5143626018439341592, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
propertyPath: m_LocalPosition.x
- value: 0.23
+ value: -0.00999999
objectReference: {fileID: 0}
- target: {fileID: 5143626018439341592, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
propertyPath: m_LocalPosition.y
- value: 5.17
+ value: 0.73
objectReference: {fileID: 0}
- target: {fileID: 5143626018439341592, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
propertyPath: m_LocalPosition.z
{
// Try to grab (steal) the ball every n seconds.
InvokeRepeating(nameof(GrabBall), 0, 0.5f);
+ InvokeRepeating(nameof(ShootBall), 0, 2f);
}
private void GrabBall()
}
}
+ private void ShootBall()
+ {
+ if (!game.enemy.HasBall) return;
+ var hoopDistance = Mathf.Abs(transform.position.x - game.EnemyHoop.transform.position.x);
+ var playerHoopDistance = Mathf.Abs(player.root.transform.position.x - game.EnemyHoop.transform.position.x);
+ if (hoopDistance < 6f && hoopDistance > 2.5f && (Random.Range(0, 100) > 30 || playerHoopDistance > hoopDistance)) // Take the shot when in range. 70% chance he decides to if the player is standing between him and the basket.
+ {
+ game.enemy.Shoot(transform);
+ }
+ }
+
private void Update()
{
var movement = transform.position;
}
else // Otherwise, move toward the basket, and then once we get within range, take the shot.
{
- transform.position = new Vector2(Vector2.MoveTowards(transform.position, game.EnemyHoop.transform.position, speed * Time.deltaTime).x, transform.position.y);
- if (Mathf.Abs(transform.position.x - game.EnemyHoop.transform.position.x) < 5f) // Take the shot.
- {
- game.enemy.Shoot(transform);
- }
+ // How far the enemy tries to get from the hoop before shooting.
+ // Currently, it will try to shoot a 3pt. shot if down, but a 2pt. shot if up or tied.
+ var targetDistance = game.enemy.score < game.player.score ? 5f : 3f;
+ transform.position = new Vector2(Vector2.MoveTowards(transform.position, game.EnemyHoop.transform.position + new Vector3(targetDistance, 0, 0), speed * Time.deltaTime).x, transform.position.y);
}
movement -= transform.position;
- game.enemy.Move(transform.position + new Vector3(0f, BoxCollider.size.y / 2, 0f));
+ game.enemy.Move(transform.position + new Vector3(0f, BoxCollider.size.y * 3/4, 0f));
leftLeg.top.transform.localRotation = Quaternion.Euler(0, 0, maxLegAngle * Mathf.Sin(animationStep * legSpeed));
leftLeg.bottom.transform.localRotation = Quaternion.Euler(0, 0, maxLegAngle + maxLegAngle * Mathf.Sin(animationStep * legSpeed));
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 7946675803598422961}
- m_Position: {x: 200, y: 0, z: 0}
+ m_Position: {x: 260, y: 60, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
- m_AnyStatePosition: {x: 50, y: 20, z: 0}
+ m_AnyStatePosition: {x: 60, y: 10, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}