Search Unity

Need help with VR Game I am creating

Discussion in 'VR' started by Mikeramczyk1977, Sep 17, 2020.

  1. Mikeramczyk1977

    Mikeramczyk1977

    Joined:
    Jul 12, 2020
    Posts:
    58
    Hey guys, I am making a VR Game with spherical worlds and faux gravity.

    I have two issues.

    1. IF I add Spin to the planets, my player controller can no longer move around.

    I can Jump, but not move. I know I have to be a child of the planet that is spinning in order for me to spin with it, I get that. And If I want to teleport to another planet, I have to switch parentage to that planet in order to be able to be locked into a gravity spin with the planet. But, Right Now, my Player Controller doesn't support the spherical world if it is spinning, and I really need the world to spin to make the game function the way it was intended, and for overall aesthetics. So, how do I make this code or tweak my current code in order for my player controller to allow me to move around on a spherical world that is spinning? Also, my teleportation rays get all screwed up, and I can't move about if the planet is spinning.

    2. How do I go about making an AI Enemy wander about and attack me on a spherical world?

    I haphazzardly got through some coding, ( I don't know what the hell I am doing ) I created a VR Rig by watching Valem on Youtube, I tweaked the VR Rig and gave myself the ability to jump on the Spherical world. I took a really dumb approach to limit my ability to jump to 1 x, by using an OnCollision script. I created a Faux Gravity Switch to, and some cool teleporters. I stumbled my way through and created a start menu, and a pause menu, and about 4 levels. I have added a skeleton in one part that chases me and shakes his arms at me, I have teleporters to go from level (Scene) to Scene, I have a lightsaber, some Swords, some cool environments, But I need some help on these two issues.

    Any Collaborators out there?


    1.Here is the Code for the Enemy to follow me that doesn't work because I am on 1 of multiple spherical worlds.
    [code =Csharp]
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PlayerController : MonoBehaviour
    {
    private float moveSpeed = 15;


    public Vector3 moveDir { get; private set; }

    void Update()
    {
    moveDir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized;
    }

    private void FixedUpdate()
    {
    GetComponent<Rigidbody>().MovePosition(GetComponent<Rigidbody>().position + transform.TransformDirection(moveDir).normalized * moveSpeed * Time.deltaTime);
    }
    }
    [/code]
     
  2. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Hi,

    What happens if your planet are still, and you just add a rotation to it in the editor, for example 45 degrees.
    Does your move script work then, in the new fixed planet rotation?