Sziasztok!
Unityben van egy karakterem, rajta Character Controller. Ez nagyon jó, de ha ugrik a karakter a collision a földön marad* és az nekem nem jó. Mi lenne a megoldás?
*Mármint valamennyire felugrik a collision, de maga az animáció magasabbra ugrik.
PlayerController.cs
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float walkSpeed = 2;
public float runSpeed = 6;
public float gravity = -12;
public float jumpHeight = 1;
[Range(0,1)]
public float airControlPercent;
public float turnSmoothTime = 0.2f;
float turnSmoothVelocity;
public float speedSmoothTime = 0.1f;
float speedSmoothVelocity;
float currentSpeed;
float velocityY;
Animator animator;
Transform cameraT;
public CharacterController controller;
void Start () {
animator = GetComponent<Animator> ();
cameraT = Camera.main.transform;
controller = GetComponent<CharacterController> ();
}
void Update () {
// input
Vector2 input = new Vector2 (Input.GetAxisRaw (\"Horizontal\"), Input.GetAxisRaw (\"Vertical\"));
Vector2 inputDir = input.normalized;
bool running = Input.GetKey (KeyCode.LeftShift);
Move (inputDir, running);
if (Input.GetKeyDown (KeyCode.Space)) {
Jump ();
}
// animator
float animationSpeedPercent = ((running) ? currentSpeed / runSpeed : currentSpeed / walkSpeed * .5f);
animator.SetFloat (\"speedPercent\", animationSpeedPercent, speedSmoothTime, Time.deltaTime);
}