Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by cpthorse · Oct 30, 2020 at 06:31 AM · scripting problemunityeditorwalljump

How can my wallrun script double wallrun ?

so i have this player controller script ``` using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityStandardAssets.Characters.FirstPerson; public class PlayerController : MonoBehaviour { public float drag_grounded; public float drag_inair;

 public DetectObs detectVaultObject; 
 public DetectObs detectVaultObstruction; 
 public DetectObs detectClimbObject; 
 public DetectObs detectClimbObstruction; 


 public DetectObs DetectWallL; 
 public DetectObs DetectWallR; 

 public Animator cameraAnimator;

 public float WallRunUpForce;
 public float WallRunUpForce_DecreaseRate;

 private float upforce;

 public float WallJumpUpVelocity;
 public float WallJumpForwardVelocity;
 public float drag_wallrun;
 public bool WallRunning;
 public bool WallrunningLeft;
 public bool WallrunningRight;
 private bool canwallrun; 

 public bool IsParkour;
 private float t_parkour;
 private float chosenParkourMoveTime;

 private bool CanVault;
 public float VaultTime; 
 public Transform VaultEndPoint;

 private bool CanClimb;
 public float ClimbTime; 
 public Transform ClimbEndPoint;

 private RigidbodyFirstPersonController rbfps;
 private Rigidbody rb;
 private Vector3 RecordedMoveToPosition; 
 private Vector3 RecordedStartPosition; 
 void Start()
 {
     rbfps = GetComponent<RigidbodyFirstPersonController>();
     rb = GetComponent<Rigidbody>();
 }

 
 void Update()
 {
     if (rbfps.Grounded)
     {
         rb.drag = drag_grounded;
         canwallrun = true;
     }
     else
     {
         rb.drag = drag_inair;
     }
     if (WallRunning)
     {
         rb.drag = drag_wallrun;

     }
     
     if (detectVaultObject.Obstruction && !detectVaultObstruction.Obstruction && !CanVault && !IsParkour && !WallRunning
         && (Input.GetKey(KeyCode.Space) ) && Input.GetAxisRaw("Vertical") > 0f)
    
     {
         CanVault = true;
     }

     if (CanVault)
     {
         CanVault = false; 
         rb.isKinematic = true; 
         RecordedMoveToPosition = VaultEndPoint.position;
         RecordedStartPosition = transform.position;
         IsParkour = true;
         chosenParkourMoveTime = VaultTime;

         cameraAnimator.CrossFade("Vault", 0.1f);
     }

     //climb
     if (detectClimbObject.Obstruction && !detectClimbObstruction.Obstruction && !CanClimb && !IsParkour && !WallRunning
         && (Input.GetKey(KeyCode.Space) || !rbfps.Grounded) && Input.GetAxisRaw("Vertical") > 0f)
     {
         CanClimb = true;
     }

     if (CanClimb)
     {
         CanClimb = false; 
         rb.isKinematic = true; 
         RecordedMoveToPosition = ClimbEndPoint.position;
         RecordedStartPosition = transform.position;
         IsParkour = true;
         chosenParkourMoveTime = ClimbTime;

         cameraAnimator.CrossFade("Climb", 0.1f);
     }


     
     if (IsParkour && t_parkour < 1f)
     {
         t_parkour += Time.deltaTime / chosenParkourMoveTime;
         transform.position = Vector3.Lerp(RecordedStartPosition, RecordedMoveToPosition, t_parkour);

         if (t_parkour >= 1f)
         {
             IsParkour = false;
             t_parkour = 0f;
             rb.isKinematic = false;

         }
     }


     
     if (DetectWallL.Obstruction && !rbfps.Grounded && !IsParkour && canwallrun) 
     {
         WallrunningLeft = true;
         canwallrun = false;
         upforce = WallRunUpForce; 
     }

     if (DetectWallR.Obstruction && !rbfps.Grounded && !IsParkour && canwallrun)  
     {
         WallrunningRight = true;
         canwallrun = false;
         upforce = WallRunUpForce;
     }
     if (WallrunningLeft && !DetectWallL.Obstruction || Input.GetAxisRaw("Vertical") <= 0f || rbfps.relativevelocity.magnitude < 1f) 
     {
         WallrunningLeft = false;
         WallrunningRight = false;
     }
     if (WallrunningRight && !DetectWallR.Obstruction || Input.GetAxisRaw("Vertical") <= 0f || rbfps.relativevelocity.magnitude < 1f) 
     {
         WallrunningLeft = false;
         WallrunningRight = false;
     }

     if (WallrunningLeft || WallrunningRight)
     {
         WallRunning = true;
         rbfps.Wallrunning = true; 
     }
     else
     {
         WallRunning = false;
         rbfps.Wallrunning = false;
     }

     if (WallrunningLeft)
     {
         cameraAnimator.SetBool("WallLeft", true); 
     }
     else
     {
         cameraAnimator.SetBool("WallLeft", false);
     }
     if (WallrunningRight)
     {
         cameraAnimator.SetBool("WallRight", true);
     }
     else
     {
         cameraAnimator.SetBool("WallRight", false);
     }

     if (WallRunning)
     {

         rb.velocity = new Vector3(rb.velocity.x, upforce, rb.velocity.z); 
         upforce -= WallRunUpForce_DecreaseRate * Time.deltaTime; 

         if (Input.GetKeyDown(KeyCode.Space))
         {
             rb.velocity = transform.forward * WallJumpForwardVelocity + transform.up * WallJumpUpVelocity; 
             WallrunningLeft = false;
             WallrunningRight = false;
         }
         if (rbfps.Grounded)
         {
             WallrunningLeft = false;
             WallrunningRight = false;
         }

         
     }


 }

}

and i think the problem comes from the bool canWallRun, i tried to change it several times to double wallrun but i couldn't

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

322 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Error building Player: CommandInvokationFailure: Failed to re-package resources. 0 Answers

Unity won't build my scripts 0 Answers

Resolve 'UnityEditor' error 1 Answer

How to run a function after every X minutes in Unity Script? 1 Answer

Hold mouse to move camera doesn't work 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges