Hey guys,
I am working on VR items and must admit I am a little perplexed about how to proceed.
I am want to have put unity game objects over real-world objects with matching dimensions. Dragging the game object can be tedious and not very friendly to new people. So I am going to figure out how to use little orbs (game objects) at key points on the item then have the game object use the average position of the points to overlay the item.
I have managed to get positioning correct, but I am having an issue with the object’s rotation. The lookat command has given me a little success but it not a complete success. Right now it uses 3 points (1 on the front, 1 on the back((these 2 get the position correct)), and 1 for the look at command). I am a self taught programmer so I am trying to figure out how to get it to be able to affect all the rotation axis. Any advice or tips would be greatly appreciated.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoxLocatin : MonoBehaviour {
public Transform Front;
public Transform Back;
public Transform Mini;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
var Width = this.transform.position.x;
var Height = this.transform.position.y;
var Depth = this.transform.position.z;
Width = Front.transform.position.x + (Back.transform.position.x - Front.transform.position.x ) / 2;
Height = Front.transform.position.y + (Back.transform.position.y - Front.transform.position.y ) /2;
Depth = Front.transform.position.z + (Back.transform.position.z - Front.transform.position.z) / 2;
this.transform.position = new Vector3(Width, Height, Depth);
this.transform.LookAt(Mini);
}
}