I am trying to prevent a player cube from falling through the plane (Battleground) in Unity, but after adding Mesh collider to both the cube and plane, as well as adding a rigidbody, nothing seems to work. The only way I can prevent this from happening is by locking the y axis of the cube, but this is a problem because I am adding in a jumping ability, and the player needs to be able to fall of the map. Is this something I can do within the Unity editor, or do I need to make a script that does that.
To verify, all 3 colliders have "Is Trigger" Enabled, the platform is not designed to be moved, so the X, Y and Z of both the plan's rotation and position are locked, and the material for the colliders are all default. Each of the cubes and the plane's material are custom (Not the collider's material). The X, Y and Z of the cube's rotation are locked. Both cubes have the tag 'player'
The code for player movement is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMove : MonoBehaviour {
private Rigidbody rb;
// Use this for initialization
void Start() {
rb = GetComponent<Rigidbody>();
}
//Update is called once per frame
void FixedUpdate() {
float h = Input.GetAxis("Horizontal") * 5;
float v = Input.GetAxis("Vertical") * 5;
Vector3 vel = rb.velocity;
vel.x = h;
vel.z = v;
rb.velocity = vel;
}
}
```