Can you move your player automatically after certain event in VR mode?
Hello,
I made e basic VR Shooter Game, where zombie spawn and you have to shoot them. My map is 'S' shaped and I want to be able to put my main camera in the bottom corner to start the game and have enemies spawn there - after shooting 3-4 mobs, I want my main camera/player to sort of move in a walking animation towards the corner and take the corner, and then stop there where new zombie spawn, and after shooting all of them, again move forward to the next corner where a new pack of zombie spawn.
My problem is that I don't know how to make my camera move like that after a certain event has been done.
Has anyone dealt with this or knows a trick to do this for VR?
Thank you!
Answer by kyuubid0 · Jul 04, 2017 at 02:30 PM
For everyone out there who still struggles to find a solution for this problem, I will update with the code I used to make my character move.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VRLookWalk: MonoBehaviour {
public Transform vrCamera;
public float toggleAngle = 30.0f;
public float speed = 3.0f;
public bool moveForward;
private CharacterController cc;
// Use this for initialization
void Start () {
cc = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update () {
if(vrCamera.eulerAngles.x >= toggleAngle && vrCamera.eulerAngles.x < 90.0f)
{
moveForward = true;
}
else
{
moveForward = false;
}
if (moveForward)
{
Vector3 forward = vrCamera.TransformDirection(Vector3.forward);
cc.SimpleMove(forward * speed);
}
}
}
Hope this is still useful for you :)