I have two gameobjects. They are seperate and do not have a child/parent relationship. One of the objects rotates on its local y-axis with a slider (at 215 degrees in the screenshot). How do i make the other gameobject rotate the same amount but with the same axis so it turns with the object? In the screenshot it is stationary and hasnt turned 215 degrees with the first object?
My code so far:
public enum ArmBlock {A,B,C}
public class ArmController : MonoBehaviour
{
public ArmBlock Arm;
public GameObject Predecessor;
public GameObject SizeInput;
float Sizeval;
// Update is called once per frame
void Update()
{
switch(Arm){
case ArmBlock.A:
break;
case ArmBlock.B:
transform.position = new Vector3(Predecessor.transform.position.x-0.5f,Predecessor.transform.position.y+Predecessor.transform.localScale.y/2,Predecessor.transform.position.z);
//transform.RotateAround (new Vector3(5,2 ,0), new Vector3(1,0,0),90*Time.deltaTime);
break;
case ArmBlock.C:
break;
}
}
public void ModifySize(){
Sizeval = float.Parse(SizeInput.GetComponent<Text>().text);
gameObject.transform.localScale = new Vector3(transform.localScale.x,Sizeval,transform.localScale.z);
transform.position = new Vector3(transform.position.x, Predecessor.transform.position.y + Sizeval/2, transform.position.z);
}
public void Rotate(float position){
transform.eulerAngles = new Vector3(transform.eulerAngles.x, position, transform.eulerAngles.z);
GameObject.Find("A rotation value").GetComponent<Text>().text = position.ToString();
}
}
This script is attached to each object. The first object is A, the second B (the one im trying to rotate with A). Predecessor holds the previous object so this script on B it holds A and for A it holds nothing.

