How can i rotate all the child objects together at the same time ?
In general i can do it but it's working good for the first second or less then second and then each object scale is changing. They are all keep rotating at the same time but the scaling is change. And i want them to keep be in the same scale without changing.
This is a Screenshot1 showing my scene and hierarchy you can see the objects under Elevator: Platform, OnTop Detector, Button, and Platform1.
And you can see how do they are look like when i'm running the game and before rotate them with the mouse.
You can see also on the Inspector on the right that the script name: Object Rotate is attached to Platform1.
In this Screenshot2 it's after i used the mouse to rotate the Platform1 and it should rotate all the other objects under Elevator in same time but then the scale is getting messed you can see the Platform1 and the Button are not connected to the Platform as before like in the Screenshot1.
And i want that when i rotate the Platform1 with the mouse it will keep all the objects at the same position/scale like in Screenshot1.
This is the script i'm using on Platform1:
using UnityEngine;
using System.Collections;
public class ObjectRotate : MonoBehaviour
{
public float multiplier = 10f;
private GameObject go;
void Start()
{
if (GameObject.Find("Elevator") != null)
{
go = GameObject.Find("Elevator");
}
}
void OnMouseDrag()
{
RotateChildren(go.transform);
}
private void RotateChildren(Transform transform)
{
foreach (Transform child in transform)
{
child.Rotate(Input.GetAxis("Mouse Y") * multiplier, -Input.GetAxis("Mouse X") * multiplier, 0, Space.World);
RotateChildren(child);
}
}
}
Answer by Adam-Mechtley · Nov 22, 2016 at 08:40 PM
Although I can't see the Transform components in your screenshots, my guess here is that the parent object (Elevator) has non-uniform scale applied. Make sure that it's scale is uniform (ideally 1,1,1). If it has a mesh renderer on it that needs to be non-uniformly scaled, then just make it an empty game object and move that mesh renderer underneath it as a child (a sibling to e.g., Platform1)
Your answer
Follow this Question
Related Questions
"The associated script cannot be loaded." 0 Answers
Auto Set vs Manual Decrease (How to do both?) 1 Answer
Why the object using Vector3.MoveTowards is not moving down ? 1 Answer
I create material with script but it does not render right 0 Answers
How do I make somthing happen when the Player reaches a certain x, y, z position? 0 Answers