- Home /
Need Help with WallRunning,I'm trying to make a Park-Core game, but I can not get the Wall-Running to work
I'm trying to make a 3d parkour game and am having trouble with Wall-Running
right now it is sticking to the wall like Spiderman but REALLY glitchy
and if I run in between to walls I get flung very far away
Here is my code see if you could help or know another way
//wallrun public LayerMask whatisWall; public float WallrunForce, MaxWallrunTime, MaxWallspeed; public bool isWallLeft, isWallRight; public bool isWallRunning; public float maxWallrunCameraTilt, WallrunCameraTilt; public float wallrunSpeed;
private void WallRunInput()
{
//startwallrun
if (Input.GetKey(KeyCode.D) && isWallRight) WallRunStart();
if (Input.GetKey(KeyCode.D) && isWallLeft) WallRunStart();
}
private void WallRunStart()
{
isWallRunning = true;
if (rb.velocity.magnitude <= MaxWallspeed)
{
rb.AddForce(orientation.forward * WallrunForce * Time.deltaTime);
if (isWallRight)
{
rb.AddForce(orientation.right * WallrunForce / 5 * Time.deltaTime);
}
if (isWallLeft)
{
rb.AddForce(-orientation.right * WallrunForce / 5 * Time.deltaTime);
}
}
}
private void WallRunStop()
{
rb.useGravity = true;
isWallRunning = false;
}
private void WallRunCheck()
{
isWallRight = Physics.Raycast(transform.position, orientation.right, 1f, whatisWall);
isWallLeft = Physics.Raycast(transform.position, -orientation.right, 1f, whatisWall);
if (isWallLeft && isWallRight) WallRunStop();
}
private void Update() { WallRunCheck(); WallRunInput(); runonWall(); }
private void runonWall() { if (isWallRunning == true) { rb.AddForce(orientation.forward Time.deltaTime wallrunSpeed); } } ,I have it so I know when my player is on a wall but it just sticks like Spiderman and when I start on the edge of the wall I ether: lose all gravity, be able to fly, for get slingshoted 2000 miles away
please help here is my code for wall running
//wallrun public LayerMask whatisWall; public float WallrunForce, MaxWallrunTime, MaxWallspeed; public bool isWallLeft, isWallRight; public bool isWallRunning; public float maxWallrunCameraTilt, WallrunCameraTilt; public float wallrunSpeed;
private void WallRunInput()
{
//startwallrun
if (Input.GetKey(KeyCode.D) && isWallRight) WallRunStart();
if (Input.GetKey(KeyCode.D) && isWallLeft) WallRunStart();
}
private void WallRunStart()
{
isWallRunning = true;
if (rb.velocity.magnitude <= MaxWallspeed)
{
rb.AddForce(orientation.forward * WallrunForce * Time.deltaTime);
if (isWallRight)
{
rb.AddForce(orientation.right * WallrunForce / 5 * Time.deltaTime);
}
if (isWallLeft)
{
rb.AddForce(-orientation.right * WallrunForce / 5 * Time.deltaTime);
}
}
}
private void WallRunStop()
{
rb.useGravity = true;
isWallRunning = false;
}
private void WallRunCheck()
{
isWallRight = Physics.Raycast(transform.position, orientation.right, 1f, whatisWall);
isWallLeft = Physics.Raycast(transform.position, -orientation.right, 1f, whatisWall);
if (isWallLeft && isWallRight) WallRunStop();
}
private void runonWall() { if (isWallRunning == true) { rb.AddForce(orientation.forward Time.deltaTime wallrunSpeed); } }
and these are in void Update() { WallRunCheck(); WallRunInput(); runonWall(); }
Thanks
Your answer
Follow this Question
Related Questions
Why can't it find the item in game, but knows what it is in script? 1 Answer
Need to get physics info on gameObject just before OnCollisionEnter2D 1 Answer
Shooting Script which don't works: 1 Answer
Generic Triggers and Actions 0 Answers
I cant add scripts to my weapons,i can't add Scripts to my weapon 1 Answer