Unity 3D Teleporting. Player Position Reset. Intro To Unity 3D Lesson06

Опубликовано: 13 Октябрь 2024
на канале: DIGA Hub
2,808
42

Unity 3D Teleporting. Player Position Reset. Intro To Unity 3D Lesson06
[Important Note] Due to an update in the newer version of Unity 3D, the First Person Controller's Transforms (positions) can not be manipulated by the Teleporting script (or any other script that has a similar function). To fix it, go to Edit - Project Settings - Physics and then check the box “Auto Sync Transforms”, and the script will work like a charm.



[Ideas contributed by former students:]
[Teleporting]
Connor Bradt: The teleporting script can be used in a multiplayer game to go across the map to gain an advantage or avoid the enemy.

Joe Ducker: The Teleporting could be useful for a fast travel system to get around a large map quickly. Another idea is that the character has teleporting powers and can use this ability to travel over a gap they cannot jump across


[Full Script]
---------

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class Teleporting : MonoBehaviour {

public Transform teleportTarget;
public GameObject thePlayer;



void OnTriggerEnter (Collider other)
{
thePlayer.transform.position = teleportTarget.transform.position;
}

}