-1

I'm creating a Vive VR Passive VR experience, where your in a space ship and without any controls, it moves passively through the whole solar system. It's not AI, there will be a predetermined destination.

My question: How to make on object move passively?(A.K.A Space Ship with cameras)

Mokrab
  • 55
  • 1
  • 7

2 Answers2

2

You have a starting point, and a destination point, then Lerp between them. The examle in the unity documentation has a example for your exact question.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Transform startMarker;
    public Transform endMarker;
    public float speed = 1.0F;
    private float startTime;
    private float journeyLength;
    void Start() {
        startTime = Time.time;
        journeyLength = Vector3.Distance(startMarker.position, endMarker.position);
    }
    void Update() {
        float distCovered = (Time.time - startTime) * speed;
        float fracJourney = distCovered / journeyLength;
        transform.position = Vector3.Lerp(startMarker.position, endMarker.position, fracJourney);
    }
}

You would attach that script to your "Spaceship" root object, you would then make the player a child of the spaceship so it will move with the ship as it goes along it's route.

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
  • The idea is to make the space ship "fly" in a arc type of movement. I will try using this, at least it will be a good start point. This is something like those VRs with roller coasters except on a spaceship in space. – Mokrab Nov 05 '16 at 05:30
  • In that case you may want to [use a animation](https://unity3d.com/learn/tutorials/topics/animation) to perform the movement. You can set each place you want to stop at as keyframes and let it figure out for you how to get between each location. – Scott Chamberlain Nov 05 '16 at 06:22
0

Path Magic on the Asset Store could do it all for you, and you probably don't have to code anything.

Chuck Savage
  • 11,775
  • 6
  • 49
  • 69