Is it possible to play your unity game in scene mode? - unity3d

Hi I'm working on a simple 2D unity game and it would be so much easier to figure out problems if I could play my game in scene mode so that I could check on every object's values as I go. Is it at all possible to play your game in scene mode?

That is not possible, as of now, in the Unity engine. You would need to handle it yourself. Take the Unity's Cinemachine package as an example. You can tweak the values of a cinemachine virtual camera in-game and store the values as you tweak them if you check the "Save during play". The package is designed in a way that it preserves its state, so when you stop playing, it doesn't lose the changes you made in play mode. Moreover, Cinemachine gives you gizmos that you can tweak the values through the game viewport, not only the inspector.
You would need to do such things for your game so when you start playing, you can, for example, click the gizmos on a puzzle object and change where it sits in the scene, and when you stop playing, the tweaked position would be preserved.

You can read Inputs while being in a custom editor with for example:
if(Event.current.type == EventType.KeyDown
&& Event.current.keyCode == KeyCode.W) {...}
You can read all your wanted inputs and pass it on to your default input scripts. You could make whole games in just the inspector window or whereever you want, but if you should is another question...

Related

turn sprite list images into single images for use

so trying to make this as simple as I possibly can (which is next to impossible)
so in the unity editor using the 2d platformer learning thing im trying to switch the player sprites with many sprite lists from https://aamatniekss.itch.io/fantasy-knight-free-pixelart-animated-character for the images I'm trying to make the images into a new sprite animation
I hope I made this straight forward enough.
Use this BRACKEYS TUTORIAL
You need to make sprite sheets or create the animations in the Unity animation system and then trigger them by code or state machine.
https://www.youtube.com/watch?v=87cF8jqVpBA
i found it myself so anyone who needs to know here you go
make sure the sprite isnt in single but multiple.

Why do certain sprites ,look as if they're further back in the window?

I am learning how to make games using unity, i have used free sprite packs from unity's store.
i have selected each individual sprite and changed its z position to 0, but when the game runs it looks completely different to how it looks in the editing window.
please help.
Here is a video I recorded.
https://youtu.be/2hb9m01PQBk
Are your sprites on a prefab, or children of another game object? The Transform of the parent object affects the transform of all children.
It looks like this is a camera problem. Your camera is set to perspective, it is possible to do parallax backgrounds with a perspective camera and you may have already accomodated for it, but that is the first thing I would check.
You can modify this by going to your Main Camera and selecting Orthographic from the Projection drop-down menu.

UE4 - Changing ADS Camera when using a different weapon

I'm very new to Unreal Engine 4 and have been following an fps guide online!
Currently have an AK and M4 in the game and can switch between the two using 1 / 2 on the keypad. I had to setup the first aim down sights camera to the AK and it works well! However if I equip the M4 and aim down sights then the camera is no longer in the correct spot and it doesn't line up at all with the ironsights. So I added another camera called M4A1 ADS Camera, but can't figure out how to switch to that camera when aiming down sights then going back to the AK camera if using that weapon.
Is there a better way of doing this or any tutorials / tips to help with the process for the future?
If I want to try and answer your question I'd say that you should add a switch case or make branches to check wich weapon is equipped at the time.
But I'd say a better way to do this would be to add a camera to your weapon blueprint then you could access the camera from the weapon directly (assuming you have a master weapon class). This way you would configure 1 ADS camera per weapon and align it properly in it own blueprint.
you can use "Set View Targent With Blend" function to change your cameras, it is very good for changing speed, and blending other things.
I know this is old but even cleaner than Deimos's suggestion would be to have an ADS camera component on your character and attach it to a socket you create on each of your weapons. You can adjust the socket position and rotation on each weapon's skeleton and then all you do from the character side is attach the camera to the weapon any time you equip one.

Unity 2D - low fps in editor, 60+ fps in build

we are developing platformer game in Unity engine. Currently in our scene are 15 npc, movement is animation based, they are navigated via scripts, they can talk to player, fight etc. Rigid body does not handle collisions, it just detects ground as a trigger. When build is created, all is nice and smooth 60fps, in editor it is 25 to 30, sometimes a lot lower which makes us sometimes a lot of problems. Do you have any experience how to make a game run smooth in editor? Thank you
if your editor is very slow you can go to the unity icon right click on it and select properties and in the target add -force-opengl in the end.
you can also increment the fps by
void Start()
{
//increase of fps
Application.targetFrameRate = 300;
}
for more info go to https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html
try to logout to unity becuase sometimes the login can make the editor running slow
Two top things are check that the profiler is not running and that the scene view is not open. These are the two most common causes (in my experience) of slow down in the editor.
You can also make sure there isn't any light baking going on, shouldn't be for 2D but worth checking.
Another thing to check is any editor only scripts, i.e. namespace UnityEditor.* usages (#if UNITY_EDITOR).
If you want an uncapped frame rate, go to project settings -> quality -> vsync mode, and turn off vsync.
Another option may be to turn off Gsync(Vsync) on your monitor and graphics card control panel
Try using Unity 2022.1.24f1, I get more fps in that build and also you can try using this free asset to get more fps.
https://assetstore.unity.com/packages/tools/utilities/frame-rate-booster-120660

Having multiple unity scenes open simultaneously

I've been developing a board-style game in Unity3D. The main scene is the board, and has the data about each player and the current (randomly-generated) board stored within it.
I intend to add minigames into the game, for example when landing on a particular space on the board. Naturally, I would like to code the minigame in a separate scene. Is there a way I can do this without losing the instance of the current scene, so that the current scene's state is maintained?
Thanks in advance :)
Short answer: no, but there may be another way to do what you want.
A basic call to Application.LoadLevel call will destroy the current scene before loading the next one. This isn't what you want.
If your minigame is relatively simple, you could use Instantiate to bring in a prefab and spawn it far away from the rest of your scene. You can even use scripts to switch to another camera, toggle player controls and other interactions in the scene, and so on. Once the minigame is done, you can destroy or disable whatever you brought in, and re-enable whatever needs to be turned on in the main scene.
You could create a separate scene and call Application.LoadLevelAdditive to load that scene without destroying the current one. As above, you can then use scripts to manage which cameras and scene behaviors are active.
If you're careful, you don't really need two separate scenes. It may be enough to "fake" a scene switch.
Hard to give a complete answer without code, but you should look into the following things either with the unity documentation or youtube:
PlayerPrefs, this is one way of saving data, although i believe it isn't entirely secure i.e. being able to edit from a text file.
Serializable, this is apparently better than playerprefs.
DonDestroyOnLoad, can carry over information to multiple scenes.
Static variables, again not sure if this will help your particular problem.