Z61
Some times our saints are sinners
Retired
(Not really a bug)
I'm working on prototyping a simple teleportation system and it's working decently well, but I want to see if I can make it more smooth.
Image of it in action:
Current layout:
Parent Teleport Object(Holds two teleporters or more)
Teleporter Object Code:
Parent Object Code:
If you can think of any ways to smooth it, let me know.
I'm working on prototyping a simple teleportation system and it's working decently well, but I want to see if I can make it more smooth.
Image of it in action:
Current layout:
Parent Teleport Object(Holds two teleporters or more)
Teleporter - can be entrance or exit
Teleporter - can be entrance or exit
When the user collides with either it sends them to that other one and they can't teleport again for a little while.Teleporter - can be entrance or exit
Teleporter Object Code:
C#:
// The A child teleporter (actual object the user collides with.
void OnTriggerEnter(Collider collision) {
if (collision.gameObject.tag == "Player") {
//Debug.Log (type.ToString() + " collided with player.");
if (type == TeleporterType.Mixed || type == TeleporterType.Entrance) {
teleportToPartner();
}
}
}
void teleportToPartner() {
SendMessageUpwards ("doTeleporter", partner);
}
C#:
public class TeleportParentController : MonoBehaviour {
public float timeSinceTeleported = 0f;
GameObject Player;
// Use this for initialization
void Start () {
Player = GameObject.FindGameObjectWithTag ("Player");
}
// Update is called once per frame
void Update () {
}
void FixedUpdate() {
timeSinceTeleported += Time.smoothDeltaTime;
}
void doTeleporter(GameObject location) {
if (timeSinceTeleported > 0.4) {
Vector3 pos = location.transform.position;
Player.transform.position = new Vector3 (pos.x, pos.y, pos.z );
timeSinceTeleported = 0;
}
}
}
If you can think of any ways to smooth it, let me know.