I have a question.
I'm trying to make a runner game with 2 characters not one. I've done the movement and the camera related stuff.
Now I'm trying to add the Game Manager.
The problem is that my Game Manager isn't able to accesss the PlayerMotor of both characters.
I found a tutorial on Youtube that uses a singleton but it accesses only one player character which is obvious cause it's a singleton. So can you help me out guys? Unfortunately I'm not a programmer so I can't figure it out.
How can the Game Manager access both of their PlayerMotor instances to start the game?
From: Unity - Scripting API: Object.FindObjectsOfType
You can retrieve your Playermotor scripts by using FindObjectsOfType like that:
var playersMotor = Object.FindObjectsOfType<Playermotor>(); // find Playermotor scripts in your scene and store it in playersMotor
Or:
var playersMotor = Object.FindObjectsOfType(typeof(Playermotor));
Related
To preface this, my problem is almost exactly the same as this. I have a game which utilizes Unity Mirror for multiplayer and FizzySteamworks as the transport. When I launch the game I can go through the game as expected, until I wish to leave the lobby. When I try to press my leave lobby button, it calls Manager.StopHost() which then takes me to my offline scene. However when I try and start a new lobby/game, I get the error: InvalidOperationException: Steamworks is not initialized.
Now as I understand, because my NetworkManager is in my offline scene, when I switch back to the offline scene, something (SteamManager maybe or NetworkManager or something else, I havent found what) destroys my old NetworkManager as to prevent having duplicates, which makes sense. The problem is that the new one/one from the offline scene is not the one I should be using/isn't being initialized causing the error.
The fix described in the similar post does not work for me as Persist Network Manager To Offline Scene is no longer an option in the Mirror NetworkManager. I have tried finding where the old one is destroyed (No luck), as well as trying to reset/re-initialize steam in some way, also to no avail.
Are there any recommendations on how I can either fix either destroying the old NetworkManager or fix the steam initializiation failure? Thanks in advance.
I'm developing a project using WEBGL and I was wondering if it is safe to use a private key directly in the code.
Let's say that I have a private key called DB_KEYS.
I must use this private key in the source code.
When I deploy the game, are the users able to see the source code of my game and so the DB_KEYS variable?
Thank you in advance, have a nice day.
So I'm having a frustrating issue currently with Unreal where players spawn won't spawn the packaged version but will in the editor. I think I've managed to pin the issue down, but I still have no idea why it's occurring. For context, I am working on a multiplayer battle arena game. I have a player handler blueprint that stores relevant metadata/info about a character.
Handler getting Relevant Info
When the handler is first created, it's assigned a character name and costume/colour variant index from the game instance.
Getting the correct character from the data asset table
It then checks a character data asset table to see which class/mesh/material it should be set to.
This is the data table
The data table references data assets. From my testing this seems to be where the issue lies, that the game can access the data tables in the PIE, but not in the build. Does anyone know why this may be? Is there something I've overlooeked?
My partner in game dev are looking at Unity. I dynamically loaded an asset using Resource.Load() and he used AssetDatabase.LoadAssetAtPath(). They both seem to work so which one should be used? Why have 2 different ways to dynamically load assets?
AssetDatabase.LoadAssetAtPath() vs Resource.Load() ...They both
seem to work so which one should be used?
None of them.
Your partner will end up with a game that he cannot build because he used AssetDatabase.LoadAssetAtPath(). The AssetDatabase.LoadAssetAtPath() function came from the UnityEditor namespace which is only used to make Editor plugins. It won't work outside the Editor and it won't even let you build your game at-all.
You using Resource.Load is fine but Resource.Load requires the use of the Resources folder which is known to cause slow down loading time of the game.
AssetBundles is the recommended way. You can put those files in the StreamingAssets folder then use the WWW or AssetBundle API to load it during run-time. You can learn more about how to use AssetBundles here
I have the basic Google Cardboard Unity application loaded and working great.
I want to utilize a few sensors on my phone that aren't available in Unity. For example, I want to get access to the STEP_DETECTOR sensor.
I created my own UnityPlayerActivity, and without Cardboard, it seems to work well. My problem is that I have no idea how to use my custom UnityPlayerActivity WITH cardboard.
From what I can tell, the cardboard demo uses a "UnityCardboardActivity" class as the main activity. I took a look at UnityCardboardActivity.jar and it looks like the UnityCardboardActivity class inherits from CardboardActivity, NOT UnityActivity.
So my guess is that UnityCardboardActivity is manually starting the default UnityPlayerActivity somewhere in its code, but I can't change that to start my own custom UnityPlayerActivity in any way that I can tell.
Is there any way to get that sensor data without using a UnityPlayerActivity?
I tried making my activity extend UnityCardboardActivity instead, but for some reason I don't have access to the "getSystemService" method when do that, so I can't get access to any sensors.