明らかに床についているのに、isGrounde君がfalseを出してきます、普通の球体オブジェクトで同じ処理を試したけっか、球体オブジェクトではうまくいきました。
いろいろと解決方法を探したのですが、全くわからず質問させていただきました。
ソースコード
using UnityEngine;
using System.Collections;
public class Character : MonoBehaviour {
public float spd = 0.1f;
public float JumpPow = 3.0f;
public int PlayType = 1;
private CharacterController col;
float jp;
Vector3 DefVectle;
private Animator animator;
// Use this for initialization
void Start () {
col = GetComponent<CharacterController>();
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update() {
Vector3 movevec=Vector3.zero;
if (jp > -3) {
jp -= 0.1f;
}
/*if (col.isGrounded != true) {
jp -= 0.1f;
} else if (jp < 0) {
jp += 0.1f;
}*/
if (PlayType == 2) {
if (Input.GetKey ("d")) {
movevec.x += 1.0f;
}
if (Input.GetKey ("a")) {
movevec.x -= 1.0f;
}
if (col.isGrounded && Input.GetKeyDown ("w")) {
jp = JumpPow;
print ("Jump");
}
}
if (PlayType == 1) {
if (Input.GetKey ("right")) {
movevec.x += 1.0f;
}
if (Input.GetKey ("left")) {
movevec.x -= 1.0f;
}
if (col.isGrounded && Input.GetKeyDown ("up")) {
jp = JumpPow;
print ("Jump");
}
}
if (col.isGrounded != true) {
movevec.y = jp;
}
col.Move (movevec*spd);
if (movevec.x != 0) {
movevec.y = 0;
DefVectle = movevec;
animator.SetBool ("is_moveing", true);
} else {
animator.SetBool ("is_moveing", false);
}
Quaternion q = Quaternion.LookRotation(DefVectle); // 向きたい方角をQuaternionn型に直す .
transform.rotation = Quaternion.RotateTowards(transform.rotation, q, 800 * Time.deltaTime); // 向きを q に向けてじわ~っと変化させる.
}
}
↓上手くいったオブジェクトの画像