Weird Stretchy Problem on Instantiate > SetParent with Prefabs
https://answers.unity.com/questions/868484/why-is-instantiated-objects-scale-changing.html
I encountered a strange stretching problem when objects were made using Instantiate/SetParent. It turns out this is a change in unity 5.5 where a bool is needed with SetParent.
Problem:
instance.transform.SetParent(transform);
No problem:
instance.transform.SetParent(transform, false);
Moving things to the player once they’ve stuck
Random.onUnitSphere doesn’t do what I want
It makes things crazy instead.
Physics.ClosestPoint seems to almost do what I want.
Now to only have it operate on things stuck to the player.
I added this to control attachment behavior:
using System.Collections;
using UnityEngine;
public class ThingToggler : MonoBehaviour {
public bool attached = false;
}
Now in PlayerController.DoPickup:
other.gameObject.GetComponent<ThingToggler>().attached = true;
Then in ThingCondenser:
if (!GetComponent<ThingToggler>().attached) {
return;
}
Finally, I attached ThingCondenser and ThingToggler to all of the flower prefabs, and we’re in business.
More things
Sticky microphones.
Microphone bowling.