- Home /
Fermare la Main Camera quando colpisce un muro 3D
Premessa: sono alle prime armi Nel mio gioco 3D in prima persona, la Main Camera è il player, ma quando colpisce un qualsiasi oggetto, ci passa attraverso; sia nella camera che nell'oggetto ho inserito Rigidbody. Ecco il codice C# che fa muovere il mio player:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerMovement : MonoBehaviour {
float Speed;
void Start ()
{
Speed = 4;
}
void Update ()
{
transform.Translate(Input.GetAxis("Horizontal") * Time.deltaTime * Speed, 0, Input.GetAxis("Vertical") * Time.deltaTime * Speed);
}
}
Your answer
Follow this Question
Related Questions
How can the player position updates randomly when the player isn't movingl? 0 Answers
Unity 5 Sphere Rigidbody getting weird behaviour while moving around in a tiled mesh collider scene 1 Answer
Collision with world object and object in Hand 0 Answers
How can I apply a force to an object in the opposite direction of the object it's colliding with? 2 Answers
Player getting stuck in corners 0 Answers