Quantcast
Channel: Questions in topic: "attach"
Viewing all articles
Browse latest Browse all 168

Attaching objects on collision

$
0
0
I have a script that on the collision of two 'parts' one is parented under the other. If I drag the parent object, both objects are moved, but if the child is dragged, only the child moves. I don't know how I can fix this, as I want both objects to remain attached no matter if the parent of child is moved. Here is my script: using System.Collections; public class ObjectAttach : MonoBehaviour { void Start() { } void OnCollisionEnter(Collision collision) { if(collision.gameObject.tag=="Part") { collision.transform.parent = transform; } } }

Viewing all articles
Browse latest Browse all 168

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>