Jump to content

Can't teleport my Gaia player


aldaluin
Go to solution Solved by Bryan,

Recommended Posts

Hi,

I'm using a stock gaia first person controller, with an added script to change position and rotation in Start(), so I can have a random spawn point.  Unity 2020.3.37f1 and Gaia Pro 3.3.0-c5.  When I start the scene, the player immediately snaps back to the position set in the inspector.  Sometimes I can see a frame or so where I want him, so I know my (pretty simple) code is working.  Moving the relocate to a coroutine and having it wait a second or two doesn't help.  

Thanks.

Link to comment
Share on other sites

  • Solution

The stock player is just the standard assets mixed with some things that Gaia runtime elements needs. 
I would say that the script itself is not done correctly. I would check that custom script. 
 

Link to comment
Share on other sites

On the one hand, I've missed the obvious before.  On the other hand, it's kind of hard to screw up "source.position = destination.position;".  Guess its time to trace some controller code. 

 

Link to comment
Share on other sites

Hi @aldaluin, the problem is that the FPS controller uses additional components like a character controller and a rigidbody, the logic / simulation in those components does not know about the rapid position change and therefore continue the simulation with the player in its original spot. This thread discusses this issue:

https://answers.unity.com/questions/1587400/first-person-player-teleportation.html

I did try to reproduce the issue, and the following worked for me:

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;

public class MovePlayer : MonoBehaviour
{

    public Vector3 destination;

    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(TeleportCharacter(destination));
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public IEnumerator TeleportCharacter(Vector3 newLoc)
    {
        GetComponent<FirstPersonController>().enabled = false;
        transform.position = newLoc;
        yield return new WaitForEndOfFrame();
        GetComponent<FirstPersonController>().enabled = true;
    }

}

 

Link to comment
Share on other sites

  • 2 weeks later...

Thanks @Peter.  Once I put it on the FPSController instead of the Gaia Player (Doh!) it worked as advertised.  Problem is, it looks just like what I was trying to do.  So I'm off to track down the differences.

 

Thanks, too, @Bryan.  I had not noticed you grabbed the standard controller instead of growing your own. 

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...