SOLVED: How to perfrom Linear Acceleration in Unity?

Hello there! I’m new to these forums. I’ve been having some unexpected things happen with how the physics engine works in unity. First of all I’m using a custom script to move the plane upwards. I change the speed and the condition for if it’s moving or not during the video down below.

using UnityEngine;
using System.Collections;

public class PlaneController : MonoBehaviour {

    public float speed;
    public bool accelerating;

    void Update() {
        if (accelerating)
        transform.Translate(new Vector3(0, speed, 0)* Time.deltaTime);
    }
}

There are 3 different parts to the video down below. The first section shows when I don’t move the plane until the sphere is on top of it, and then move it, the plane seems to go through it while keeping it in the same spot until it goes through it completely and the ball drops. My question is why does this behavior happen? Is it possible to have a plane suddenly move upwards while moving anything on it?

The second section shows that if the plane is already moving when the ball collides with it, it will move along with the plane which is odd considering what happened in the first section. My question on this is why does it move along with it only if the plane is moving before the impact?

The third section shows that when the plane stops moving, so does the ball. However my goal is to make the ball fly into the air with the force that was previously on the plane and then fall back onto it with gravity. How would I accomplish this and why doesn’t it move fly upwards in the state it’s in now?

Thanks in advance.

Hi, welcome to the forums!

You should always use a Rigidbody component for objects that have physic interaction. As you’re moving the plane and want it to physically interact with other objects, you should add a Rigidbody to it, mark the “Is Kinematic” property, and move it via Rigidbody.MovePosition and Rigidbody.MoveRotation.

The “Is Kinematic” property tells the physic engine not to apply the movements (position / rotation) as result of physic interactions. The methods MovePosition and MoveRotation tell the physic engine to apply the specified transformations to the object, allowing interactions with other objects (collisions).

In general, is a bad idea moving or rotating physic objects by modifying their transform directly (as it’s already being modified by the physic engine).

Thanks for the Response Edy. I added rigibody’s to both and I’ve used Rigidbody.MovePosition and it seems to be working as I want. Thanks again!