Hot answers tagged

14

The term "scene" in the context of Godot is kind of a misnomer. What a "scene" actually is in Godot is a reusable object template you can instantiate multiple times. You can edit the instances to give custom properties to each of them or you can edit the scene itself to change the properties of all these objects together. If you are ...


5

Don't hard-code it, or it'll indeed end up very messy. You need to script the NPCs daily routines into some data file (XML or other). Something along the lines of: <npc name="george"> <schedule start="0:00" end="8:00"> <sleep at="home"/> </schedule> <schedule start="8:00" end="9:00"> <walk leave="home" ...


5

Like many optimization questions, the answer here is "it depends." Having separate scenes for each version probably won't increase your game size by much, since the bulk of the storage usually goes to content both scenes can share via sharedassets#.assets files in your built data (textures, meshes, sound & music tend to be the biggest hogs), so in many ...


5

In Scene view. For Windows: To enter fast zoom mode hold Alt + move mouse holding Right Mouse Button. Press F to Focus on Game Object. Press Shift + F to Focus on Game Object and follow it automatically. Hold Right Mouse Button and move with WASD - the more time you spend doing it the faster speed of movement you will get. Note, that the more you zoom you ...


4

This is the difference between the UI and the in world objects. Your main menu is a screen space UI, the rest of your objects are in world objects, likely sprites. The reason they're vastly different sizes is just how the editor displays their size. The main menu (UI) has its size based on pixels. Maybe something like 1080x1920. The world objects have their ...


4

The nomenclature here is definitely odd. I at first thought you were talking about something lower level (like the scenegraph or screen manager for organizing logic flow and/or rendering). I then realized you are talking about what I would refer to as game state. Scenes are a popular term for it now with Unity, so I could see why you would call it ...


4

All you need to do is double-click the object you wish to get close to, in the Hierarchy view. This will rapidly advance the camera to that object's position. You can then use mouse wheel to adjust zoom. Other than this, I don't believe there is anything like hotkey-assigned zoom levels, unfortunately.


4

Unity already has a built-in event for doing exactly what you want: EditorSceneManager.sceneSaving Usage: EditorSceneManager.sceneSaving += OnSavingScene; private void OnSavingScene(UnityEngine.SceneManagement.Scene scene, string path) { //do some stuff here }


3

Number 3 is easiest if you have an image that is tileable, meaning that if you put them next to each other you wouldn't be able to pick out the seam. Then you can draw the same image twice once on x,y and once on x+image.width,y. each frame you decrement x until x < -image.width where you add image.width to it. Adding details is easy by drawing some ...


3

Prefabs are the way forward. In my opinion, every single entity should be a Prefab, even if you're going to only instantiate it once into the scene hierarchy (like a management singleton class etc). This'll save you many headaches down the line. A change to the Prefab will propagate to every instance in the entire project. Additionally, take a look at the ...


3

Time.time returns the number of seconds since the start of the game. "Start of the game" refers to the moment the game was launched, not the moment the current scene was loaded. If you want this movement to start 60 seconds after a scene has loaded, use Time.timeSinceLevelLoad instead. This returns the time in seconds since the last level has been loaded. ...


3

Making sure your problem is a problem First I would just load everything in the same scene all at once and see if that's actually a problem. 500 triangles is tiny for the interior of a building in the context of a modern computer, are you using high-res textures or targeting super low end devices? You might realize everything can be loaded simultaneously and ...


2

You have plenty of options, and it really just depends on what your style is and the design of your game. One of the easier ways to handle this is with a simple scene manager. The first thing you need for scene manager is a script that persists between scenes. This can be done with a method called DontDestroyOnLoad. A very simple scene manager would look ...


2

Selecting the Camera Object and Ctrl+Shift+F seems to do the work in Unity5.


2

In your RespawnPlayer() method you are loading a scene at first. Then checking current position, then translating the player to the checkpoint. Upon loading a new scene, everything resets. In RespawnPlayer() after second line execution, the level manager restarts from Start() ignoring the current checkpoint and player translate codes in RespawnPlayer(). In ...


2

Unless you really have a good reason for having a pure virtual interface, I wouldn't bother. Nothing to do with performance, just the fact that with the interface setup, you have one extra class declaration that needs maintaining. If your scene objects are already encapsulated inside classes, there's no gain in having a virtual interface just to hide a ...


2

Singletons, PlayerPrefs and the DontDestroyOnLoad flag are already three ways to pass data between scenes. There is also a fourth one: static variables which do not use the Singleton pattern but are only available to the local class. There is also SceneManager.LoadScene ("play_scene", LoadSceneMode.Additive); which loads a new scene without destroying ...


2

The following worked for me using version 2020: Pressing the F key on a terrain object reset the mouse sensitivity.


2

You can just put the line in the Unity API of DontDestroyOnLoad() inside Awake() method and your object will not get destroyed when you load a new scene. This does mean that you need to manage the object separately or use a Find() method to find and access it in later scenes. Keep in mind that if you include this object in all your scenes, you will end up ...


2

I would keep track of the current scene in a global variable called current_scene and try something like this: func change_scene(scene_path): call_deferred("change_scene_deferred", scene_path) # waits until an idle period when nodes can be removed safely func change_scene_deferred(scene_path): # remove current scene current_scene.free() ...


2

Ok, After a lot of research, I finnalt got this to work: Transform objectPreview; //the transform to move Transform objectTouched = null; //the reference of the last object hit Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(worldRay, out hitInfo, Mathf.Infinity)) { if (...


2

The way I do it is to have events for the party members (except the lead character, since they'll already be represented by the player). In the event that triggers your conversation, first do a "gather followers", then "change player followers" set to off, followed by setting a switch to make all the individual character events visible, and start moving them ...


2

A screenshot is done at the hardware level. It only knows what is visible on your hardware screen. It is not camera dependent. What you are looking for is the camera rendering. Unity documentation provides us with a nice code snippet of how to do this: using UnityEngine; public class Example : MonoBehaviour { // Take a "screenshot" of a camera's ...


2

Rather than running this as a coroutine, ticking every frame waiting to see if the button is pressed, I'd just store the AsyncOperation and let the button give it a kick when the player finally presses it. public class ScenePreloader : MonoBehaviour { public string sceneName; AsyncOperation preload; void Start() { preload = ...


2

I'm unable to reproduce this problem. In my tests with this code, the first time I click the button I go to the "Intro" scene. Any subsequent run of the game, I go to the scene named in the SceneName variable. So, this is likely due to incorrect setup in your project/scenes/inspector. Things you can try: Verify that both scenes have been added to ...


2

Turns out there's EditorSceneManager.LoadSceneInPlayMode which does exactly what I'm looking for! Awesome. I had asked on the Unity Forum and found the answer there


2

When you change scenes, the camera gets destroyed Because the camera gets destroyed (and the new scene has a new one) your cam variable no longer points to the main camera. You can detect this and do the appropriate thing, void Update () { if(cam == null) cam = Camera.main float dist = cam.transform.position.x * parallaxEffect; transform....


2

You know what? I will be generous. Here is a a script made by unity that pretty much does this for you. Enjoy. using System.Collections.Generic; using UnityEngine; namespace UnityEngine.Rendering { [HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "Free-Camera" + Documentation.endURL)] [ExecuteAlways] public class ...


2

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does. Even if you could force the engine to immediately render the button (it will only want to do that for the next ...


2

This might not be the most elegant solution but it's certainly an effective one: What I have done in the past when using PUN for this is to use the PhotonNetwork.Instantiate() method for player instantiation. What you to avoid issues with multiple audio listeners and cameras is to write a NetworkPlayerManager script and add it to the player prefab. In ...


Only top voted, non community-wiki answers of a minimum length are eligible