How to have objects rotate around a given point that are scripted to face the player
This script is designed to be used with a user in VR.
The script below makes objects with the component turn to face the user, so no matter where they are standing the objects turn to face them. They are used on disk shaped objects so that the flat-circle face is always facing the user.
I plan to add multiple disks in a given point of different sizes to represent chemicals (I uploaded an example image below). However, in the scripts current state, when they rotate they rotate into each other. The disks are created and based on their order, their distance is altered a bit so they come forward in front of the previously added disk. Is there a solution to this so that the disks with distance added rotate around a given origin point based on the script I already have?
Notes: - The cone seen in the example image is the parent of the disks. - The disks only rotate around the Y axis
I'd appreciate any help! Thank you!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BenWeidner.LeapMotion
{
public class FollowFacingCamera : MonoBehaviour
{
// Update is called once per frame
void Update()
{
var fwd = Camera.main.transform.forward;
//fwd.y = 0;
transform.rotation = Quaternion.LookRotation(fwd);
}
}
}
Answer by tormentoarmagedoom · Aug 07, 2018 at 12:20 PM
Good day.
Or i did not understood, or the aolution i so easy..
Change its pivot point to decide the "center of rotation". Or make them childnofnothee objects and make this orher objects rotate.
Bye
Not sure if I understand. How would I change it's pivot point to decide the center of rotation? The disks are the children of the cones.