- Home /
Camera Transform.Position (teleport)
Hey guys, I am have my player practically ("Teleporting) into an Interior Scene. (like Zelda games)
That works fine and dandy. But the way I have it is, I just stuck the interior scene UNDER the terrain, under the building, (If there is a better way let me know)
However, when I hit the trigger to go back UP to the ground, I have the Smooth Follow script on it, so even when I re-enable the Smooth Follow script, it still smoothly transitions from Underground to the top, is there a way to just have it teleport back up?
Here is my script for going back to the TOP of the ground.
using UnityEngine;
using System.Collections;
public class BackToWorld : MonoBehaviour {
//CAMERA VARIABLES
public Camera Main; // THis is PLAYER CAMERA
public Camera Secondary; // THIS IS THE CAMERA WE CHANGE TOO OR DISABLE.
public GameObject SpawnPoint;
void OnTriggerEnter(Collider col){
if (col.gameObject.tag == "Player") {
Secondary.enabled = false;
Main.GetComponent<SmoothFollow>().enabled = false;
col.gameObject.transform.position = SpawnPoint.transform.position;
Main.GetComponent<SmoothFollow>().enabled = true;
Main.enabled = true;
}
}
}
I've even tried attaching a Parent empty to the Camera, but I've realized recently that Cameras are hard to work with when you try to get them to do something outside their norms of just floating around lol.
Any help be much appreciated, thanks guys!
Answer by Tourist · Oct 06, 2014 at 07:09 AM
If you have a complex vast environnement (like Zelda games), I would recommend you to split to other scenes the interior and the exterior, at least for the dungeons.
For your problem, maybe when you teleport the player, get the Smooth script and tell it there was a teleportation.
I was honestly thinking about doing Scenes like that, just wasn't sure on how loading times would be for when the game got bigger. But from my tests and stuff, I have darn near instantaneous loading times for everything so far.
That maps aren't exactly like Zelda, they are more so like Banjo $$anonymous$$azooie, just didn't see a point in making the Interior a whole new scene, but I'm thinking that may be the best choice.
I have sort of found a hack towards it, I don't like doing what I have just done, but it does work.
I just made it into a Co-Routine for 1.5 seconds or something, then it reneables it, (screen fades black and back) kinda of thing. But I don't like doing that, in this case it's perfectly fine, however, on certain maps, what if an enemy is near? He can walk up and get you while transitioning lol. But I can prob fix that with a simple bool towards the health.
But thanks for the ideas, I'll definitely look into it buddy!
Answer by FlamingVorpalCow · Oct 31, 2014 at 04:27 PM
Let me see i got it straight:
The problem is that the camera does a smooth transition from secondary camera to the main, and you expected to switch from one to the other without smoothing, right?
maybe you can make the smothing ocurr with a 1 frame delay, after you have sitched cameras:
On the on triggerEnter() remove the enabling of the SmoothFollow component, and create a flag set to true; on update make a check, if (flag), enable the SmoothFollow Component.
that way you don't get delay or that black screen, and the follow is there from the get go, but right after you started rendering with the main camera.
Hope this helps...