- Home /
How to move object using Vector3.Cross?
using UnityEngine;
using System.Collections;
public class Balance : MonoBehaviour {
public float startDistance;
public float newDistance;
private Vector3 Line1;
private Vector3 NewVector;
void FixedUpdate () {
newDistance = Vector3.Distance(transform.position, Vector3.zero);
Line1 = Vector3.Lerp (Vector3.zero, transform.position, 0f);
NewVector = Vector3.Cross (Line1, Vector3.up);
if (newDistance<startDistance) {
float random = Random.Range (0, 3);
if (random == 1)
//move to one side
if(random == 2)
//move to another side
}
startDistance = newDistance;
}
}
I need to move object in NewVector axis. How to? I guess i already have NewVector axis, but how to move object in it?
Comment