You are on page 1of 5

}

if(collisionInfo.transform.name == "CompleteLevel")
{
collisionInfo.collider.enabled = false;
//Debug.Log("you win");
Invoke("WinFunction", 0.5f);
}
if (collisionInfo.transform.tag == "SlidePad")
{
IsSlidingBool = true;
}
if(collisionInfo.transform.tag == "BouncePad")
{
rb.AddForce(0f, bounceForce * 0.1f, 0f, ForceMode.Impulse);
}
}

private void Sliding()


{
if (IsSliding())
{
//Debug.Log("Slide");
if (IsPressed)
{
slideForceMax = 40f;
slideForce = 10f;
rb.AddForce(0f, 0f, slideForce * 0.1f, ForceMode.Impulse);
rb.velocity = Vector3.ClampMagnitude(rb.velocity, slideForceMax);
return;
}
rb.AddForce(0f, 0f, slideForce * 0.1f, ForceMode.Impulse);
rb.velocity = Vector3.ClampMagnitude(rb.velocity, 4);
}
else
{
IsSlidingBool = false;
}
}

private void WallRunningPhysics()


{
//Debug.Log(IsJumped);
rb.useGravity = false;
IsSlidingBool = false;
}
}

private void WallRunningPhysics()


{
//Debug.Log(IsJumped);
rb.useGravity = false;
Debug.Log("isjumped");
if (IsJumped)
{
if(WallRunningForce == 0f)
{
}
rb.AddForce(0f, 0f, slideForce * 0.1f, ForceMode.Impulse);
rb.velocity = Vector3.ClampMagnitude(rb.velocity, 4);
}
else
{
IsSlidingBool = false;
}
}

private void WallRunningPhysics()


{
//Debug.Log(IsJumped);
rb.useGravity = false;
Debug.Log("isjumped");
if (IsJumped)
{
if(WallRunningForce == 0f)
{
//rb.AddForce(rb.transform.TransformDirection(wallRunningSide *
-50f, 0f, 0f));
//rb.AddForce(transform.forward * WallRunningForce * 10f);
rb.velocity = Vector3.zero;
rb.AddForce(rb.transform.TransformDirection(wallRunningSide * 50f,
30f, 0f) * speed);
//return;
}
else
{
rb.AddForce(rb.transform.TransformDirection(wallRunningSide * 50f,
30f, 0f) * speed);

rb.AddForce(rayCastWallRunning.transform.TransformDirection(0f, 0f,
-WallRunningForce * speed));
}
*/

rb.AddForce(rb.transform.TransformDirection(wallRunningSide * -50f, 0f,


0f));
rb.AddForce(transform.forward * WallRunningForce * 10f);
Debug.Log("yes");
rb.velocity = Vector3.ClampMagnitude(rb.velocity, 30f);
}

private void WallRunning()


{
RaycastHit hit;
if (Physics.Raycast(transform.position,
rb.transform.TransformDirection(Vector3.left), out hit, 0.8f))
{
//Debug.Log("WallRunning");
if (hit.transform.tag == "WallRunPadNoSpeed")
{
rb.velocity = Vector3.zero;
WallRunningForce = 0f;
}
else if (hit.transform.tag == "WallRunPad")
{
//Debug.Log("left");
rayCastWallRunning = hit;
//Debug.Log(transform.eulerAngles.y);
//Debug.Log(rayCastWallRunning.transform.eulerAngles.y);
rb.velocity = Vector3.zero;

WallRunningForce = 10f;

IsWallRunning = true;
wallRunningSide = 1f;
Vector3 v = transform.rotation.eulerAngles;
Camera.rotation = Quaternion.Lerp(Camera.rotation,
Quaternion.Euler(v.x, v.y, -15f), 5f * Time.deltaTime);
if (Input.GetKeyDown(KeyCode.Space) && Input.GetKey(KeyCode.D))
{
IsJumped = true;
}
}
}
else if (Physics.Raycast(transform.position,
rb.transform.TransformDirection(Vector3.right), out hit, 0.8f))
{
if (hit.transform.tag == "WallRunPadNoSpeed")
{
rb.velocity = Vector3.zero;
WallRunningForce = 0f;
}
else if (hit.transform.tag == "WallRunPad")
{
//Debug.Log("right");
rayCastWallRunning = hit;
//Debug.Log(transform.eulerAngles.y);
//Debug.Log(rayCastWallRunning.transform.eulerAngles.y);

WallRunningForce = 10f;

IsWallRunning = true;
wallRunningSide = -1f;
Vector3 v = transform.rotation.eulerAngles;
Camera.rotation = Quaternion.Lerp(Camera.rotation,
Quaternion.Euler(v.x, v.y, 15f), 5f * Time.deltaTime);
if (Input.GetKeyDown(KeyCode.Space) && Input.GetKey(KeyCode.A))
{
IsJumped = true;
}
}
}
else
{
IsJumped = false;
wallRunningSide = 0f;
rb.useGravity = true;
Vector3 v = transform.rotation.eulerAngles;
Camera.rotation = Quaternion.Lerp(Camera.rotation,
Quaternion.Euler(v.x, v.y, 0f), 5f * Time.deltaTime);
IsWallRunning = false;
}
}

private void Crouch()


{
transform.localScale += new Vector3(0f, 0.3f, 0f);
IsPressed = false;
}
}
}

private void Move()


{
if (!IsWallRunning && !IsPressed)
{
//the hAxis is for horizontal axis, basically A,D
float hAxis = Input.GetAxisRaw("Horizontal");
//the vAxis is for vertical axis, basically W,S
float vAxis = Input.GetAxisRaw("Vertical");

if(hAxis != 0f || vAxis != 0f)


{
//Debug.Log("Move");
IsMoving = true;
}
else
{
IsMoving = false;
}

Vector3 movement = new Vector3(hAxis, 0f, vAxis) * speed *


Time.deltaTime;

Vector3 newPosition = rb.position +


rb.transform.TransformDirection(movement);

rb.MovePosition(newPosition);
}
}

private void Jump()


{
if (Input.GetKeyDown(KeyCode.Space))
{
//Debug.Log("Jump");
if (IsGrounded())
{
rb.AddForce(0f, jumpForce, 0f, ForceMode.Impulse);
}
}
}

private bool IsGrounded()


{
return Physics.Raycast(transform.position, Vector3.down, raycastDistance);
}

private bool IsSliding()


{asdasd
RaycastHit hit;
if (Physics.Raycast(transform.position, Vector3.down, out hit,
raycastDistance))
{
if(hit.transform.tag == "SlidePad")
{
return true;
}
}
return false;
}
}

You might also like