Prevent changes in scale when parenting rotated child

Ok so am building a game where objects need to be re parented from one platform to another. The platform’s and the player’s scales are both set to 1,1,1 and those scales are never changed in code. However, as soon as the child is parented to the platform, the child x and z scales are set to 0.2 without visually changing the scale. At this point, rotating the child causes it to scale and skew wildly.

It seems like unity is trying to update the local scale without compensating for the local rotation…How do I prevent this? Why does the scale of my player change? Or is this a bug?

Do it like this :

        transform.SetParent(ParentTransform, false);

the “False” means it wont be affected by the parent;

Actually. In my case I simply screwed up and was parenting to the wrong object. I had some old logic that I forgot was there that was parenting to the visual platform (a re scaled cube) instead of the logic of the platform which was an empty with no scaling.

Hi there! I figure out this solution :smiley:

At the FixeScale set up the size of your child you need and at the parent set your parent model.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FixedScale : MonoBehaviour {

 public float FixeScale =1 ;
	public GameObject parent;
	// Update is called once per frame
	void Update () {
		transform.localScale = new Vector3 (FixeScale/parent.transform.localScale.x,FixeScale/parent.transform.localScale.y,FixeScale/parent.transform.localScale.z);