Unity almost do not know, I play about. I want to create and push an object in the right direction, normally, using physics, and not by changing the coordinates of the script.
1 answer
To create an object in unity, use the Instantiate method. In this case, you can create a prefab, make a field in the public GameObject myObj script, and drag the prefab to this field through the inspector. Well, in the code to write: Instantiate(myObj, ...) .
Physical body in unity - a GameObject with a RigidBody or RigidBody2D on it to simulate 3D and 2D physics, respectively.
To transfer momentum to the physical body , use the RigidBody.AddForce or RigidBody2D.AddForce . The first parameter is the force / momentum vector, and the second is the enum ForceMode , which can take the values Force , Impulse , etc.
Help: https://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html
Of course, you first need to get the RigidBody or RigidBody2D the body using GetComponent .