Hi all,
I'm having a little trouble finding a solution to this anywhere online. Basically I need to have a 2D platform that catches objects falling onto it, but I need those objects to follow the platform with 100% friction, so I think using AddForce to move the object with a mouse might help.
Right now I have the following script attached to the platform:
void Update () {
float distance_to_screen = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
Vector3 pos_move = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance_to_screen));
transform.position = new Vector3(pos_move.x, transform.position.y, pos_move.z);
}
I know there is a method that uses parenting, but I'd like to avoid that, since the objects will be able to land on each other and I don't want an endless list of parents and children and I'd also like them to be able to fall off of the platform too so I don't think parenting is the way to go.
Any suggestions/help would be greatly appreciated! Thanks!
↧