Hi! I am trying to shoot a shell from a cannon and play with the drop, but I dont know how to make the Xample2 image efect, becase I cant modify the center of mass.
Xample1 is the efect that I have now in Unity.
I was trying to use this code but doesnt works.
public class Center_Of_Mass : MonoBehaviour
{
public Vector2 CenterOfMass2;
public bool Awake;
public float AngularSpeed;
protected Rigidbody2D r;
// Start is called before the first frame update
void Start()
{
r = GetComponent();
}
// Update is called once per frame
void Update()
{
r.centerOfMass = CenterOfMass2;
r.WakeUp();
Awake = !r.IsSleeping();
}
private void OnDrawGizmos()
{
Gizmos.color = Color.red;
Gizmos.DrawSphere(transform.position + transform.rotation * CenterOfMass2, 0.1f);
}
}


I tried to use another code, but I do not reach my objetive.
The new code rotate de Shell / time, but it doesnt work with the distance or angle of the shoot. The shell rotate at the same speed, doesnt matter the other features.
I have reached a similar effect, but it is far to be perfect:
public class P1_Mover : MonoBehaviour
{
public float speed;
public Rigidbody2D rb;
public float turnSpeed;
// Start is called before the first frame update
void Start()
{
rb = GetComponent();
rb.velocity = transform.right * speed;
//Vector2 force = new Vector2(speed, 0);
//rb.AddForce(force);
}
private void Update()
{
transform.rotation = Quaternion.Euler(Vector3.forward * rb.velocity.y * turnSpeed);
}
}
The problem:
This is the effect I want to reach
Why are you multiplying by velocity.y?
Just set ‘transform.forward’ to ‘velocity.normalized’.
I want to reach the curve drop efect. [Example2]
In the video I am showing that I have reached a similar effect, but it is far to be perfect.
