private void LaunchFishingRod() { if (hook == null && characterController.isGrounded && Physics2D.OverlapCircle(hookPosition.transform.position, 0.25f, whatIsGround) == null) { playerController.SetPlayerState(PlayerController2.PlayerState.DontMove); GameObject newHook = Instantiate(hookPrefab, hookPosition.transform.position, new Quaternion()); hook = newHook.GetComponent <HookBehavior>(); hook.LaunchHook(this, cableLength, cableSpeed); } }
public void HookCheck(Vector2 target, HookBehavior hoke) { hookHit = Physics2D.Raycast(transform.position, new Vector2(target.x - transform.position.x, target.y - transform.position.y), hookDistance, mask); if (hookHit) { joint.enabled = true; joint.connectedAnchor = hookHit.point; joint.distance = hookHit.distance; ropeTargets.Add(hookHit.point); rope.enabled = true; currentHook = hoke; SetCurrentState(ControlState.HOOKSHOT); } }
public void CancelFishingRod(GameObject hookedItem = null) { playerController.SetPlayerState(PlayerController2.PlayerState.Default); if (hookedItem != null) { hookedItem.transform.SetParent(null, true); PlayerController2 hookedPlayer = hookedItem.GetComponent <PlayerController2>(); if (hookedPlayer != null) { hookedPlayer.SetPlayerState(PlayerController2.PlayerState.Default); } } if (hook != null) { Destroy(hook.gameObject); hook = null; } }
void SpawnHook(Vector2 target) { HookBehavior hoke = Instantiate(hook); hoke.SetBehavior(transform.position, target, target - new Vector2(transform.position.x, transform.position.y), 15f); }