An imported asset penetrate the terrain when I hit the play button in Unity

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…

Does the ground have a rigidbody on it?
If not try to add it and set the rigidbody as static.

@Mango97 Thank you so much for the response. Is “set the rigidbody as static” something like make the object non-moveable? Also, I can add the rigidbody but not sure how to make it static. I found some articles for set the rigidbody 2D to static but I didn’t see for the rigidbody 3d…

Additionally, do you know why only the imported asset (in this case it’s a train) starts penetrating the terrain? The wooden rails and other game objects won’t sink, so I’m also confused with that.

Hi Yuya,

Basically, by not adding a Rigidbody or setting the Rigidbody to static, you are telling the simulation that this object is not supposed to move. If you move it anyway, that could have a negative impact on the performance. Unline the Rigidbody2D, you cannot set the Rigidbody to “static”. However, you could tick the “static” at the top of the Inspector of a game object and remove the Rigidbody. Then the object will be treated as “non-moveable” within the simulation.

Additionally, do you know why only the imported asset (in this case it’s a train) starts penetrating the terrain?

Have you already checked the shape of the collider? Meshes are just “decoration” within the scene, and they are invisible to the physics simulation. The simulation handles the colliders and collision events.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms