Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class GridMove : MonoBehaviour
{
public bool Movement = true;
public float MaxDistance = 10f;
private float OneMove = 3f;
void Update ()
{
if (Input.GetKey (KeyCode.Space)) {
gameObject.transform.position += new Vector3 (0,OneMove * Time.deltaTime, 0);
}
if (Input.GetKey (KeyCode.LeftShift)) {
gameObject.transform.position += new Vector3 (0, -OneMove * Time.deltaTime, 0);
}
}
}
using System.Collections;
public class GridMove : MonoBehaviour
{
public bool Movement = true;
public float MaxDistance = 10f;
private float OneMove = 3f;
void Update ()
{
if (Input.GetKey (KeyCode.Space)) {
gameObject.transform.position += new Vector3 (0,OneMove * Time.deltaTime, 0);
}
if (Input.GetKey (KeyCode.LeftShift)) {
gameObject.transform.position += new Vector3 (0, -OneMove * Time.deltaTime, 0);
}
}
}
На объекте также стоит Character Motor, Controller, MouseLook, FPSInput Controller.
На сцене стоит куб с мешем, но объект проходит сквозь куб. Как сделать чтобы не проходил сквозь куб а врезался в него. Спасибо заранее.