Select next and previous child gameobject on press key
Hi and thakn you for your attetion in my proyect now i have a gameobject which rotate around a center well it works perfect. The question is the center is the parent and what i need is to select the previous and the next child if you press q for example select previous child and the e the next child and to rotate them separate in this moment i have this:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Rotate : MonoBehaviour {
public GameObject centre;
public GameObject position;
SpriteRenderer otherObjectRenderer;
Vector3 vector = new Vector3(-3.4f, 4.0f ,0.0f);
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.Escape))
{
transform.RotateAround(centre.transform.position, Vector3.forward
, 90 * Time.deltaTime);
if(position.transform.position == vector) {
print("5600");
}
}
print(postion.transform.position);
}
//all of this is to rotate the gameobject and comparte to vector if the coordinates are ok its a puzzle
}
Thank for your atention and srry for my english im no native
Answer by tormentoarmagedoom · Jan 15, 2019 at 09:22 AM
Good day.
For find childs of an object you need to acces first the transform component.
Bye!
Your answer
![](https://koobas.hobune.stream/wayback/20220612185739im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotate an Object while moving forward using empty gameObject 0 Answers
Rotate an object around one of his childs in the self space (not the world space) 2 Answers
Rotate object arround other object, but always facing the camera 1 Answer
Rotating object relative to player to orient it center of camera regardless of direction. 0 Answers
How come when I rotate my spaceship, it also rotates on the two other axis's? Please help? 0 Answers