When I jump into a wall, and hold the button in the direction of the wall, my rigid body character can hold/stick to the wall for a bit. Here is my code (And no switching to character controller is not an option)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Controller : MonoBehaviour {
public float moveSpeed;
public float jumpSpeed;
public float hitDistance;
public bool isGrounded;
public float airTime;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void FixedUpdate ()
{
transform.rotation = Quaternion.identity;
transform.Translate (Input.GetAxis ("Horizontal") * moveSpeed * Time.deltaTime,0f, 0f);
if (Input.GetAxis ("Horizontal") != 0) {
if (moveSpeed < 10) {
moveSpeed += 0.1f;
}
}
if (Input.GetAxis ("Horizontal") == 0) {
if (moveSpeed > 5) {
moveSpeed -= 1;
}
}
if (Input.GetAxis ("Jump") == 1) {
airTime += 1;
}
if (Input.GetAxis ("Jump") == 0) {
if (airTime > 0) {
airTime = 0;
}
}
if (airTime < 60)
{
transform.Translate (0f, Input.GetAxis ("Jump") * jumpSpeed * Time.deltaTime, 0f);
}
}
}
if someone could fix this it would make my week!
↧