Hello, I’m really new to Unity & C# world and I’m currently having trouble with my imported asset starts penetrating (or sinking) the terrain once I play the game.
I add this free asset to my project.
Before I press the play button, the scene is like this.
But once I hit the play button, the object starts sinking forever. Something like the image below.
And it penetrates the terrain and I’m not able to see the train after a few seconds.
I added the Lightbody and movement script to the train.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movement : MonoBehaviour
{
Rigidbody rb;
[SerializeField] float speed = 10.0f;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
MoveObjectForward();
}
void MoveObjectForward()
{
if (Input.GetKey(KeyCode.Space))
{
rb.AddForce(transform.forward * speed);
}
}
}
As you can see, there is a cube on the left side of the train. But that object will not penetrate the terrain even after I hit the play button and I want the train to be the same as the object.
I stuck on this issue for an hour but could not find the solution, so if someone knows what I’m doing wrong, please let me know…