Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CharacterHandleWeapon : CharacterAbility
- {
- //Recoil, pls work :( (when you press the A botton the is in use the +1 recoil for teleport the player +1, and when the D botton is pressed is in use the recoilRight for teleport the player -1, according with the animations of the character)
- public Vector3 recoilLeft = Vector3.zero;
- public Vector3 recoilRight = Vector3.zero;
- public Vector3 recoilRight2 = Vector3.zero;
- //Drag and drop the world collider here
- public BoxCollider2D worldCollider;
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.A))
- {
- recoilRight = recoilLeft;
- Debug.Log("'A' button");
- return;
- }
- if (Input.GetKeyDown(KeyCode.D))
- {
- recoilRight = recoilRight2;
- Debug.Log("'D' button");
- return;
- }
- if (Input.GetKeyDown(KeyCode.W))
- {
- Debug.Log("'W' button");
- return;
- }
- }
- public virtual void ShootStart()
- {
- // if the Shoot action is enabled in the permissions, we continue, if not we do nothing. If the player is dead we do nothing.
- if (!AbilityPermitted
- || (CurrentWeapon == null)
- || (_condition.CurrentState != CharacterStates.CharacterConditions.Normal)
- || (_movement.CurrentState == CharacterStates.MovementStates.LadderClimbing))
- {
- return;
- }
- //This is where the player will be after the recoil.
- Vector3 positionAfterRecoil = transform.position + recoilRight;
- /*
- //If we are outside the left side of the box, snap to the left side of the box
- if (positionAfterRecoil.x < worldCollider.bounds.min.x)
- {
- positionAfterRecoil.x = worldCollider.bounds.min.x;
- }
- //if we are outside the right side of the box, snap to the right side of the box
- else if (positionAfterRecoil.x > worldCollider.bounds.max.x)
- {
- positionAfterRecoil.x = worldCollider.bounds.max.x;
- }
- */
- //This is for teleport the player -1 or +1, depenging the values entered on the inspector
- //Move the player to the modified position after recoil
- transform.position = positionAfterRecoil;
- Debug.Log(recoilRight);
- CurrentWeapon.WeaponInputStart();
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment