_id
int64
0
49
text
stringlengths
71
4.19k
0
How to make pathways corridors in a randomly generated dungeon? I am trying to make a random dungeon generator using Unity. I have been able to setup the rooms properly and connect them to each other using a minimum spanning tree algorithm. I have attached an image below where you can see what I have so far. The next step will be to create pathways corridors to connect the rooms together but I am having difficulty understanding how I am supposed to go about it. I want the corridors to be straight or form an 'L' shape when connecting to each other. So I was wondering if anyone could help me out with this. Any help is appreciated.
0
How does Unity call "update()" in the scripts? I understand that you can expose your C code to a scripting language such as ChaiScript. From this you can call code that you've made in C . In Unity, however, they have functions in the script, such as Update() that get called. In other words, how do I call script functions from C ?
0
How to make an Assert.IsNull test pass when the value is reported as ? I've just started using unity tests with the built in editor tests. After making my test and finding out that it constantly failed I debugged the code and found that a static object was set to a new game object when running the test while it is set to null when playing in the editor. Is there a way to force unity to treat the test the in the same way that it treats scripts at run time? Edit After changing some code around i get another strange error does anyone know why "null" isn't "null". The null objects are stored in an array, but that shouldn't make a difference right? Edit Edit (Edit 2?) Here is the code that has the issue public class StatCollector MonoBehaviour public static StatCollector running ensure that there is only one object running at the same time public void Awake () if(running null) DontDestroyOnLoad(gameObject) running this else if(running ! this) DestroyImmediate(gameObject) and here is the test Test public void SingleTest() create gameobjects GameObject collect new GameObject 2 collect 0 new GameObject("one") collect 1 new GameObject("two") collect 0 .AddComponent lt StatCollector gt () see if gameobjects were created correctly if (collect 0 null collect 1 null) Assert.Fail("failed to create game objects") test what happens when the second stat collector is added to the scene collect 1 .AddComponent lt StatCollector gt () collect 0 .GetComponent lt StatCollector gt ().Awake() collect 1 .GetComponent lt StatCollector gt ().Awake() Assert.IsNull(collect 1 ) I'm assuming that there is no way to keep Awake private which is why it is public (just so that the test case has access to it)
0
Saving total play time could be fine? I'm making a game that needs to save total played time into file (using JSON) for comparing amp resolving data conflicts between local and cloud. I will override outdated one. Currently, I'm just adding Time.realtimeSinceStartup, but is that okay? What if the time is really, really big and couldn't be handled in Unity anymore? Could that eventually happen? If so, what are some alternatives?
0
Unity Z position issue on gameobject with subcomponents I'm following this tutorial from Ryan Miller on how to create a rig of sorts from a sprite atlas sheet. My intention was to put the panda behind a bamboo, but this is what happened The bamboo's Z position has been set to 2, whilst the Panda's has been set to 6. Here's a 3D look at the problem How do I fix this?
0
MCS character mouth open is this mo cap animation problem? I have MCS Female Character where I can assigned Mocap to my character. I have downloaded mixamo animation and assigned this to the character but the problem is, the character mouth remains open. I am not 3d artist or animation guy, so here are my question. How can I solve mouth open problem in unity? What is the reason that mouth is open? Either mocap data has open the mouth or what else problem?
0
Editing attached component property in Unity (C ) This might be more of a general C programming query, but since it's game dev related, I'm putting it here. I am trying to randomise a property in a custom component (C script) across several Unity game objects. hostiles is a list of game objects, each with an attached Stats component. foreach (GameObject gO in hostiles) Randomise spawn area gO.GetComponent lt Stats gt ().AreaNo Random.Range(0, 3) Perhaps unsurprisingly, all of my objects end up with the same value for AreaNo. It seems as though I m reassigning some global version of Stats.AreaNo in my loop, rather than the individual instances. What am I missing? (Sorry in advance for the noobish question!)
0
pathFinding performance in Unity3d I am making Sniper game in unity 3d. In this game zombies will come randomly towards the sniper and sniper have to kill them. I am using RAIN(indie) for path finding. It works best when zombies are few . As I increase the Zombies( that is 10) the performance decrease a lot. The fbs drops to 25. I want to know is there any technique or steps so I can improve fps Any other technique algorithm that I can use for pathfinding weith good fps. PS I already remove Sensor component from AI. FPS of game without AI is 61
0
How can I instantiate enemies in a 2D game at a set Viewport Position before my camera enters the room? (Or alternative solution!) I'm currently working on a 2D game where I'm trying to pre populate my level with encounters, I want the enemies already in the room when the player enters. Right now the encounter is triggered upon entering the room when the camera bumps into the collider and the enemies are instantiated at the Viewport position, however because it does it while the camera is moving into the room the position is incorrect. Using hard values isn't an option because the maps could of course change and also I may want them randomly generated at some point. So I guess ultimately the problem is the camera not being in the right position when they instantiate and not wanting enemies to quot pop quot in once it is. Is there a way I can I instantiate an enemy at the same point on the screen regardless of resolution in each specific room at the start of the level? Encounters will have up to 3 enemies and they will always hold the same formation (with spots randomized to add diversity) Here is my instantiating code SerializeField public List lt GameObject gt levelEnemies new List lt GameObject gt () GameObject levelEnemy Vector3 enemyPosition Vector3 viewportPosition new Vector3(0.8f, 0.5f, 10f) Place on the screen I decided I want single enemies to appear Camera cam void Start() Debug.Log( quot Enemy Triggered quot ) cam Camera.main enemyPosition cam.ViewportToWorldPoint(viewportPosition) levelEnemy Instantiate(levelEnemies 0 , enemyPosition, Quaternion.identity) instantiate test enemy at the converted position navigation.DisableNavigation() Here is what my camera collider looks like (Room 1) and my enemy encounter collider looks like (Room 3) Here's what should be happening when the enemy is instantiated (triggered manually through the editor once camera has been moved fully) Here is what happens when the camera collider bumps into the encounter collider Any help in the right direction would be much appreciated or a workaround! Here is what my camera collider looks like (Room 1) and my enemy encounter collider looks like (Room 3)
0
Change texture settings for each object So I'm kinda new to Unity, but I've used it a couple of times before. Here's my issue I have two cubes with a random texture applied to them (drag'n'dropped something from the Asset Store). These cubes have different sizes, where one is a square and one is a rectangle. I want to set the tiling size to be different on them (because they are obviously stretched on the rectangle), but when I click on one and change it, the settings changes for both of them. This is how it looks right now http i.imgur.com JtubBle.png Is it possible to make these settings unique for each object somehow?
0
How to limit camera pitch (x rotation) between two angles I use this script rotate the camera on its local X axis float v verticalSpeed Input.GetAxis("Mouse Y") transform.Rotate( v, 0, 0) Right now this lets the player look up amp down without limit, wrapping around a full 360 degrees. How can I limit this so they can look only 90 degrees up or 90 degrees down from the horizon?
0
Uploading APK build to Google Play Console error "You uploaded a debuggable APK or Android App Bundle" I was trying to upload my andoid app apk build to my play console account and I keep getting this error You uploaded a debuggable APK or Android App Bundle. For security reasons you need to disable debugging before it can be published in Google Play. In accordance with the informations given at https developer.android.com studio publish preparing.html publishing configure and https answers.unity.com questions 1653647 you uploaded a debuggable apk or android app bundl.html Here are what I have done so far 1) I have gone to the root folder of my unity project, searched for AndroidManifest.xml, and I found multiple Manifest files, and changed the value of "android debuggable" to false for each of these manifest files that were generated by unity(and I did not edit the google generated manifest files). 2) I have scanned every c file on my project that contains the keyword "Debug" and I have either deleted or commented out the Debug.log lines except on the files generated by google(as a result of the integration of google play services into my game). And yet, I still have the same problem when I try to upload my apk to play console. What else am I missing? Should I also remove the Debug.log lines from google generated c script files?
0
SerializeField UntiyEvent not properly saving modifications in EditorWindow I'm making a node editor in Unity using an EditorWindow, I'm currently trying to make it so designers can add their own methods to a node using serialized UnityEvents but I haven't been able to get it to function properly. SerializedObject serializedObject new SerializedObject(selectedNode.NodeState) SerializedProperty property serializedObject.GetIterator() property.Next(true) while (property.NextVisible(false)) EditorGUILayout.PropertyField(property) serializedObject.ApplyModifiedProperties() serializedObject.Update() The above code runs through all necessary fields of the class so the user can modify them. Everything functions perfectly with the exception of UnityEvents. They almost do as I intend them to do, except they don't preserve the variable inputs of inserted object's method. If I keep working within the editor window they stay, but if I close the window and re open the inputted variable resets. I thought this may be caused by an issue somewhere else in my code, but all other fields work fine.
0
How to do collision detection in Unity between Character Controller, Rigidbody Collider and a NavmeshAgent? I would like to know more about how collision detection works in Unity especially when character controllers and NavmeshAgents get involved. For example, how can I detect collision between NavmeshAgent and a CharacterController? I have added a sphere collider to my NavmeshAgent, but it doesn't seem to detect a collision unless I set it to "IsTrigger". I have tried OnCollisionEnter(), OnControllerColliderHit() and OnTriggerEnter(). OnTriggerEnter() seems to be the only one that works and only when I enable "IsTrigger". How come the other two don't work? Shouldn't they? What if I didn't want to make the collider a trigger?
0
How to make unitypackage from allseen alliance's android sdk? Im making an offline multiplayer for Android device by Unity and I found only one way to do this is the allseenalliance sdk. After download its from here I found that to use it I need to create an .unitypackage file but I cant understand the tutorial they give gt Open a CMD window. gt Add the path to Unity.exe (the Unity IDE) to your PATH, if it is not there already. gt For example, set PATH PATH C Program Files Unity Editor gt CD to each quot unity quot folder in the SDK, and run the following command in each location gt Unity.exe batchmode nographics quit projectPath CD exportPackage Assets AllJoyn.unitypackage gt This command creates the AllJoyn.unitypackage file. Please give me a noob tutorial for this or the package file, thanks. p s Is there another way to connect mobile device without internet in unity3d?
0
Unity custom shaders and z fighting I've just readed a chapter of Unity iOS Essential by Robert Wiebe. It shows a solution for handling z figthing problem occuring while rendering a street on a plane with the same y offset. Basically it modified Normal Diffuse shader provided by Unity, specifing the (texture?) offset in 1, 1. Here's basically what the shader looks like Shader "Custom ModifiedNormalDiffuse" Properties Color ("Main Color", Color) (1,1,1,1) MainTex ("Base (RGB)", 2D) "white" SubShader Offset 1, 1 THIS IS THE ADDED LINE Tags "RenderType" "Opaque" LOD 200 CGPROGRAM pragma surface surf Lambert sampler2D MainTex fixed4 Color struct Input float2 uv MainTex void surf (Input IN, inout SurfaceOutput o) half4 c tex2D ( MainTex, IN.uv MainTex) Color o.Albedo c.rgb o.Alpha c.a ENDCG FallBack "Diffuse" Ok. That's simple and it works. The author says about it ...we could use a copy of the shader that draw the road at an Offset of 1, 1 so that whenever the two textures are drawn, the road is always drawn last. I don't know CG nor GLSL, but I've a little bit of experience with HLSL. Anyway I can't figure out what exactly is going on. Could anyone explain me what exactly Offset directly does, and how is solves z fighting problems?
0
Make a background Image to fit multiple objects? In the Hierarchy, I have a GameObject named "Buttons" to which I added an Image component. I would like that the ok sprite to cover (be background of) all the buttons START GAME, OPTIONS, CREDIT and EXIT. But the ok sprite is somewhere in the top left corner behind the START GAME button on its left side and is very small. This happened when I clicked in the Inspector in Image on Set Native Size. I want to make it big enough to cover all the buttons but I'm not sure how.
0
How do I find an object by type and name, in Unity, using C ? I know that in Unity you can find an object of a certain type, using myObject Object.FindObjectsOfType lt MyType gt (), but that only returns the first object in the scene it finds of that type. How do I make it find the object of a certain type and with a certain name?
0
How do I pause and unpause gameobjects on is own in the scene without pressing keys in unity3d I can't get my gameobject to pause or unpause in the scene in Unity3d. I need the game to pause for a couple of seconds maybe longer than unpause by itself. Here is my script using UnityEngine using System.Collections public class hu MonoBehaviour GameObject pauseObjects public bool isPaused void Start () pauseObjects GameObject.FindGameObjectsWithTag("Player") Update is called once per frame void Pause () if(Time.timeScale 1) Time.timeScale 7f else if (Time.timeScale 8f) Time.timeScale 1
0
I need to move a sprite from point A to point B. I have objX1, objY1, frames, and X2, Y2 I have a custom sprite class in Unity and I'm trying to make a method in where it moves from one point to another. Instead of using an Enumerator for time, I'm using real time game frames using static void methods inside of classes which inherit from a MainGame.cs script attached to the Main Camera, and this is called inside of MainGame's Update() method. So what I have in the end are the following values SpriteID OriginalX OriginalY MoveToX MoveToY CurrentFrames TotalFrames I'm not asking anyone to do the work for me, just that if there's a place I could be directed to in where I could find the math necessary to solve the problem that'd be a huge help. I'm not using any vectors here, just the raw math using only those variables. I don't know if someone has found an answer for calculating it based on update frames... public class Sprite MainGame public static int State 0 public static int CurrentFrames 0 public static int TotalFrames 0 public static void Move(int SpriteID, int OriginalX, int OriginalY, int MoveToX, int MoveToY, int TotalFrames) switch (State) init case 0 CurrentFrames 0 State 1 break run case 1 if (CurrentFrames lt TotalFrames) do math here CurrentFrames if (CurrentFrames gt TotalFrames) State 2 break end case 2 Reset values here Shut off State 3 break EDIT 10212016 456PM What I've figured out so far, now... if (CurrentFrames lt TotalFrames) DistanceX MoveToX OrigX MoveForwardXFloat (float)DistanceX (float)Frames OrigX (int)MoveForwardXFloat
0
Local avoidance together with any angle types of A Pathfinding Recently I have been implementing the Block A any angle path finding algorithm in a project I have, for which I need extremely efficient results due to the large number of NPCs. However, I still do not know exactly how to handle the problem of local avoidance between the NPCs moving at the same time in the same scene. So, my question is this what is the best method to implement local avoidance with any angle path finding? Just testing for LOS and steering to the tangent of the predicted encounter is a good enough solution or should a specific AI implementation be included within the pathfinding routine? I would highly appreciate references (academical or not) with state of the art implementations of local avoidance for me to explore the most recent developments in that field. Many thanks.
0
Is it possible to have FixedUpdate execute once every n frames? I'm currently building a small game, and I've created this simple character controller using FixedUpdate, which executes every frame. using UnityEngine public class PlayerMovement MonoBehaviour lt summary gt Check for a key press, and if that key is pressed, move in a specified direction if there are no obstacles. lt summary gt private void MovePlayerOnKey(KeyCode keyCode, Vector3 direction) Collider hitColliders Physics.OverlapSphere(this.transform.position direction, 0.1f) if(Input.GetKey(keyCode) amp amp hitColliders.Length lt 0) this.transform.position direction lt summary gt FixedUpdate is used to ensure that the player is moving in sync with the step of the Physics engine, and not executing a variable amount each frame. lt summary gt public void FixedUpdate() this.MovePlayerOnKey(KeyCode.W, new Vector3(0, 1f, 0)) this.MovePlayerOnKey(KeyCode.A, new Vector3( 1f, 0, 0)) this.MovePlayerOnKey(KeyCode.S, new Vector3(0, 1f, 0)) this.MovePlayerOnKey(KeyCode.D, new Vector3(1f, 0, 0)) While the code itself works, the player moves much too fast for my liking, and I can't change the step of the player either, it has to stay at 1 in order for other game mechanics to function properly. The only solution I can think of is changing how FixedUpdate runs by running it less often. Is it possible to make FixedUpdate run once every n frames?
0
Game build in unity3d project transfer from a previous developer Can someone help or give me some idea what are the necessary deliverables from a previous developer that I need to ask regarding the game project transfer? The situation is, there is a company that is developing our game in unity3d and it is already available in Apple store and Playstore. They developed it from scratch and on our part, we are just doing the game testing process. So now, we are going to ask them to transfer the entire project development to us. The company is in another country so we are just communicating thru emails, and we never done the communication by video calls. And That's it. what are the things they need to transfer to us? Thanks in advance.
0
NullReferenceException until tile is spawned I have a tile and tile has enemies spawn positions, and spawner script in it. Everything works fine when tile is spawned, my ray hits the collider in tile and enemies get spawned, but my spawn script is in tile my ray script is in my player so im reaching from my PlayerMove script to spawner script, but until my tile is spawned i get this error NullReferenceException Object reference not set to an instance of an object because tile is not spawned yet after its spawned error stops, but after tile is deleted it starts again how can i get rid of this error. PlayerScript private Spawner spawner private RaycastHit hit private void Update() spawner GameObject.FindGameObjectWithTag("Spawner").GetComponent lt Spawner gt () DrawRay() private void DrawRay() Ray ray Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)) if(Physics.Raycast(ray,out hit)) if(hit.collider.tag "SpawnerCollider") if(hit.distance lt 5) Destroy(hit.collider) spawner.Spawn() SpawnerScript public Transform spawnPos public GameObject fireBall public void Spawn() for (int i 0 i lt spawnPos.Length i ) Instantiate(fireBall, spawnPos i .position, Quaternion.identity)
0
Collisions and Colliders Does anyone know how to prevent a gameobject from colliding with another gameobject but can still register collisions? Like a ball that can bounce off of the wall or ground and can pass through the player himself. What I have tried Creating two Colliders on the ball(which has a rigidbody component) and making one of them bigger than the other (and turn on quot Is Trigger quot on the bigger collider). Then write code in the OnTriggerEnter and the OnTriggerExit functions to disable enable the smaller collider so that the ball could fly right through the player. But that is completely useless when the ball is not in motion and the player walks over it(because it'll fall straight down through the ground).
0
Camera that pivots in the direction that the player is moving I'm trying to recreate Rocket League's freeform (non ball locked) camera, which basically is a camera that follows the player but pivots to allows face the direction the player is moving in (not necessarily facing). Here's a video of Rocket League's implementation for reference https www.youtube.com watch?v RSpB6ocrIX8 amp t 37s What are the main things needed to accomplish this?
0
UV mapping Untextured faces? Im currently trying to texture a (transparent) cylinder. I want the texture image to wrap sideways around the cylinder but not the top and bottom faces, they are supposed to just stay untextured (so transparent, in this case). So what I did (in Blender) is UV unwrap only the side faces and leaving the top and bottom faces as they are. However, this method doesn't seem to work very well, because when I import the .obj in Unity the top and bottom faces are mapped to a "random" place in the texture and therefore have color. My current workaround is to map the top bottom faces to areas in my texture that are transparent, however, this only works when textures have a transparent place, which isn't always the case.
0
How do I use rigidbody2d.AddForce to apply a force in the direction the object is facing? I'm trying to create a thruster on a spaceship. It should add this thrust in the direction the thruster is facing, but I am at a loss on how to get that direction and send it to AddForce. Am I even heading in the right direction with this script? public float maxThrust FixedUpdate() float moveVertical Input.GetAxis("Vertical") maxThrust Vector3 heading rigidbody2D.transform.eulerAngles Vector2 thrust new Vector2(heading.normalized.x, heading.normalized.z) rigidbody2D.AddForce(thrust moveVertical) Maybe I'm not understanding something with EulerAngles or Vectors, but it sure seems like this would be a straightforward thing to do.
0
Load all materials with loadallassetbundles before objects? I have a lot of objects as assetbundles and they're growing. I didn't want to have the user to download the materials for every asset because they all share their materials. so I put all the materials in an assetbundle and load it by LoadAllAssets() in the Awake() function so they are present in the game for the assets to use. The problem is that asset load without materials. the ones that have material don't have shader. Is LoadAllAssets() not the answer? what should I do?
0
Something is preventing my NavMeshAgent from moving I apologize for the vague title. I really wish I could ask something more specific, but I can't. I had my click to move script working fine with the NavMesh. I showed it to my colleague earlier today, and must have accidenntally made a change and saved. Now the guy's not walking. There are no errors and my debugging leads me to believe all code paths are working as expected. When I click on a location, it checks that it is valid on the NavMesh, then updates the NavMeshAgent's destination I am not going to post the code because I don't think the problem resides there, but rather it was something I did in the editor. The character also turns in the correct direction, and starts the walk animation correctly, but it looks like something is blocking its movement, and I can't figure out what that is. The following screenshots will help clarify my situation. Note that the camera is shaking because its position is set to match the character's in Update. The character appears to be colliding with something, which makes it look like the camera is colliding too (note this is not a physics based game in any way). edit here's some more screenshots, showing the person slightly above the ground and their collider (it's the box near their feet). I disabled the collider on the floor so there are no colliders other than the player's.
0
Image looks GOOD on the editor but BAD (blurry) on the HTML5 export I have a red bar that looks good inside Unity editor, but when I export the build it looks very strange. Any idea on how to fix this? The image on the left is the one with the strange bad looking red bar...
0
How to move Character according to Camera's look direction? Vector3 newPosition new Vector3( horizontal, 0.0f, vertical) transform.LookAt(newPosition transform.position) transform.Translate(newPosition MoveSpeed Time.deltaTime, Space.World) I'm developing 3d mobile game, you can look around with hold amp sliding the right side of the screen and move with virtual joystick. Goal Moving character to camera's lookDirection Issue is When i push joystick up, character moves to the same direction (world related) And I'm not good at coding that's why i can't solve the problem myself, i would be glad if you help me
0
Workflow to have character look like Tokyo ghoul re Call to exist I am looking into a lot of different software and now that I got my head around most of them, I was asking mysel if someone knew what has been used to create the characters in the game I mentionned. Not specifically software if there is no information about it, but at least as it been modeld sculpted, etc. Thanks
0
How can I scale my UI elements to the lesser screen dimension in Unity 5? I want to create a custom mobile pad for my game. The mobile pad consists of two parts (both inside an ui canvas) The D Pad, which will be anchored to the bottom left side. The button group will be anchored to the bottom right side. I would like to resize the element on different resolutions, so that the element (in my case, the D Pad is an image) Has a size of 20 of the minimum of the width and the height. Has pivot of x 0.5, y 0.5. Having anchor of left bottom, its coordinates are (15 , 15 ) wrt the minimum of the width and the height. What I tried is to use an Aspect Ratio Filter in the D Pad image with ratio 1, but it did not work as intended (the coordinates led the image to an unexpected place). Note I am a n00b to Unity. I don't know whether it is right but my Canvas Scaler scales by Constant Pixel Size These images should illustrate what I want to achieve What should I do to make it work like in the pictures? Edit I attached this behavior, based on answer, to handle the change by runtime RequireComponent(typeof(UI.CanvasScaler)) class CanvasSmartScaler MonoBehavior private CanvasScaler scaler void Start() scaler GetComponent lt CanvasScaler gt () void Update() OMITTED CODE here I set the scale mode as in the Editor but right now i am in my mobile device and cannot remember the exact lines if (Screen.currentResolution.width lt Screen.currentResolution.height) scaler.matchWidthOrHeight 0 else scaler.matchWidthOrHeight 1 And attached that behavior to the canvas. However, for my debug exe (just for debug purposes) it always picks the 1 case regardless how do I resize the window. What am I missing?
0
How can I make 2D fog like in Graveyard Keeper? I really like Graveyard Keeper's fog effect but I can't work out how to make it. It's 2D, and made in Unity. The characters all seem to be 'under' the fog, but the tops of tall trees and buildings poke out. It looks like this The developer has given a bit of information about how it's made on Gamasutra http www.gamasutra.com blogs SvyatoslavCherkasov 20181023 329151 Graveyard Keeper How the graphics effects are made.php "As you see, the tops of houses and trees are seen from the fog. In fact, this effect is really easy to make. The fog consists of a great deal of horizontal clouds spread across all the picture. As a result the upper part of all the sprites is covered with a fewer amount of fog sprites " I used the information from this article, and one of the developer's tweets that included this picture I attempted to recreate it this fog effect. When the character moves up or down the screen, it flickers as it crosses each fog sprite What have I missed? All of the sprites are on the default sorting layer and have sorting order 0. The project, in Graphics Settings Camera Settings has the custom axis and sort axis (0,1,0). The tree and character are on the same z position, and the fog is spread out over several z positions
0
Unity how to save the number of successive wins? I'm making a trivia game on Unity, everything works fine and now I'm trying to save and retrieve the stats of a game. I have listed most of the stats (score, highscore, points) but now I would like to add the best series of consecutive correct answers, and I don't know how I can exactly set this value. In theory I know that during the game when a correct answer is given, a counter is triggered to record the number of consecutive correct answers and it stops at the wrong answer. Then at the next triggered series the method checks if the new count is the best. But, as I'm a beginner, I don't know how I can save this kind of streak. Could you help me please? In order to understand the context public class ansButtonScript MonoBehaviour public Text txt public Sprite im basic, im corr, im wrong region Pts amp Score public int points 1 string allPts "totalPts" static int totalPts static int score 0 string score "score" static int hiscore 0 string hiScore "hiScore" endregion public AudioClip sound win, sound loose public GameObject correctTxt, wrongTxt region Cache Refs public GameObject canvas, barInt private qManager qManagerCanvas private progBarScript progBarInt private countdownScript barCountdown endregion public void Start() totalPts PlayerPrefs.GetInt( allPts) qManagerCanvas canvas.GetComponent lt qManager gt () progBarInt barInt.GetComponent lt progBarScript gt () barCountdown barInt.GetComponent lt countdownScript gt () public void updateTxt(string str text) txt.text str text GetComponent lt Image gt ().sprite im basic public void SelectButton() if( qManagerCanvas.canPlay) progBarInt.barTimeStop() qManagerCanvas.canPlay false string reponse qManagerCanvas.reponse if(transform.Find("Text").GetComponent lt Text gt ().text reponse) good answer GetComponent lt AudioSource gt ().PlayOneShot(sound win) SFX Win vraiTxt.SetActive(true) animation Correct updateTrue() the answer is shown StartCoroutine(addPoints()) StartCoroutine(next question()) new question else wrong answer GetComponent lt AudioSource gt ().PlayOneShot(sound loose) fauxTxt.SetActive(true) updateFalse() the answer isn't shown StartCoroutine(next question()) new question barCountdown.ResetTimer() IEnumerator addPoints() yield return new WaitForSeconds(2.2f) playerStats.UpMoney points score set the nb of correct answers saveAllPts() save the nb of points PlayerPrefs.SetInt( score, score) save the nb of corr answers SaveBestScore() save best score IEnumerator next question() yield return new WaitForSeconds(3f) qManagerCanvas.tirage() barCountdown.ResetTimer() correctTxt.SetActive(false) wrongTxt.SetActive(false) public void updateTrue() GetComponent lt Image gt ().sprite im corr public void updateFalse() GetComponent lt Image gt ().sprite im wrong public void SaveBestScore() if (score gt PlayerPrefs.GetInt( hiScore)) PlayerPrefs.SetInt( hiScore, score) public void saveAllPts() totalPts points PlayerPrefs.SetInt( allPts, totalPts)
0
Unity Shadow shows on my Android device but NOT my Windows Mobile device Unity version 2017.1.1f1 Problem I'm using Directional Light. Shadow is not showing in my Windows Mobile device (Lumia 640 XL), but works fine when I run the exact same UWP project as PC (Local Machine) as well as Android. Attempted solutions 1) Quality Setting I even removed the rest of levels and left only 1 level of quality. 2) Both soft and hard shadows, 10 Shadow distance, Stable Fit of shadow projection, very high resolution, low resolution, No Cascade. 3) Tried realtime and mixed light mode. any idea? Thanks in advance for read my question. Screenshots Windows 10 Mobile (Lumia 640 XL) Android (Redmi Note 3)
0
Need help with a field of view like collision detector! I ran into a trouble while making a field of view for my character. I figured how to make it work with a Linecast, but what I really need is a cone shaped field, so that the character can detect objects or enemies if they get in that field of vision. It also needs to be intersectable by other objects, so OnCollisionEnter won't work. I suspect that Raycasting might solve the problem, but I couldn't quite understand it's workings, because I'm still new. I would really appreciate any ideas that might help to solve it. Here is what I need Here is what I have so far, but this detector is unsuitable, because it can only detect objects in a straight line public Transform sightStart, sightEnd Update is called once per frame public bool objectSpotted false void Update () Raycasting1 () void Raycasting1() Debug.DrawLine(sightStart.position, sightEnd.position, Color.green) objectSpotted Physics2D.Linecast (sightStart.position, sightEnd.position)
0
Voxel terrain engine Is there some voxel frameworks or extensions for game engines like Unity? I really need a system to dynamically generate voxel ruinable terrains.
0
Animation works well on preview but not when hitting play I'm using a simple animation where I want to move an sprite just a little bit bellow its current position, and this works well on preview mode in the Animation tab. But as soon as I hit play, the value I'm trying to animate is not the same as the one in the keyframe, the value is lesser than the one I setted. I don't know what I'm doing wrong... I'll append a clip showing this problem. I already tried turning on and off Apply Root Motion and some alike questions, but none of the solution worked for me so far...
0
Adding underwater shadow to 2D top down boat I have a boat hovercraft sprite in my game. It's topdown 2D view, but it's actually a 3D scene, for better lighting and other effects. I want to add a buoyancy effect, so that the hovercraft floats with the waves and has a little margin for going under water, like a real boat. So when idle or when going off a ramp, when landing in the water it will kinda "bounce" a bit under and then back up. But the problem is the water and boat sprites are on top of each other (because it's 2D). See this picture So it can not go underwater, because then the water will be on top. But I still want those edges of the vehicle to be a bit darker as it floats. I already have an effect that changes the Y value to make it float up and down. But now the edges have to become a bit darker to show they go underwater. I kinda have this idea to add a 3D capsule and make it move up and down through the sprite to simulate this So as the boat and the capsule go down with each wave, it could mask the sprite, and the visible part (marked with black lines in the image below) could be made darker. To simulate the "under water" effect. Later I will also add foam and stuff, but the first problem is the underwater part. So how could I mask my sprite inside this capsule, and more importantly, make the "outsides" (so the parts of the sprite not touching the capsule darker? Any help would be greatly appreciated! )
0
Fix Unity Line Renderer for pointer drawing a jaggy line I think I'm using the standard Oculus setup from the SDK using the OVRCameraRig. I've also got a LaserPointer. But inside VR on my Rift the line looks like this. Any idea what I'm doing wrong? It used to be straight. Now it's not. I don't know what I changed.
0
My camera does not rotate around player in 3d open world I want my camera to following behind the player at all times. When the player turns to the left, I would expect the camera would move behind the player while remaining focused on the player. My camera stays focused on the player. However, it does not rotate to stay behind the player. I tried following the directions from here, and here. Neither of which seems to help. Here's my code public class CameraFollow MonoBehaviour private GameObject player private GameObject mainCamera private Vector3 offset private float distance private Vector3 playerPrevPos private Vector3 playerMoveDir Use this for initialization private void Start() player GameObject.FindGameObjectWithTag("Player") mainCamera GameObject.FindGameObjectWithTag("MainCamera") Calculate and store the offset value by getting the distance between the player's position and camera's position. offset transform.position player.transform.position distance offset.magnitude playerPrevPos player.transform.position Update is called once per frame private void Update() private void LateUpdate() playerMoveDir player.transform.position playerPrevPos if (playerMoveDir ! Vector3.zero) playerMoveDir.Normalize() transform.position player.transform.position offset transform.LookAt(player.transform.position) transform.rotation Quaternion.Lerp(transform.rotation, player.transform.rotation, Time.deltaTime 1) mainCamera.transform.position player.transform.position offset mainCamera.transform.LookAt(player.transform.position) mainCamera.transform.rotation Quaternion.Lerp(transform.rotation, player.transform.rotation, Time.deltaTime 1) playerPrevPos player.transform.position I have done something a little different, per instructions from a online unity class. My main camera is a subobject of a rootobject, as shown in this picture. I have attached image of the game with the yellow line showing which way the player is facing. The camera is facing in a different direction. Any help would be appreciated. Thnx Matt Follow up from answers I cannot get either solution to work. alejandrodlsp solution doesn't compile (I've added a comment to the answer explaining why). If I do not set offset on Start (aka its always 0), then the camera rotates. The problem is that is at the feet the player and not behind like I wanted. Once I compute offset, then the camera never rotates behind the player.
0
How to force a custom component on every GameObject? I want to have a custom component which will have a drop down. I want this to be applied to ever GameObject in the project, which means every GameObject in the hierarchy and every GameObject prefab. Something like a transform component. It should not be removable, and it should be added by default when creating new GameObjects. In the drop down, I will select a few options, and I want to store those values in an array on that custom forced component for that GameObject. So if I have 2 new GameObjects in scene named XYZ and ABC, and the component is PQR, I should be able to do this ABC.GetComponent lt PQR gt ().someArrayVar whatever XYZ.GetComponent lt PQR gt ().someArrayVar anotherWhatever Anyone know how to do this? Any help appreciated. Thanks in advance )
0
How do I position a mesh just outside the camera view? I want to slide in an object into view, coming from the right of the screen. In order to achieve this, I need to position the object next to the camera view, so that it is still not visible, but close enough for a quick slide in. For example, placing the object at X 1000000 (so that it is surely outside the camera view) for safety wouldn't work as it couldn't slide in quickly enough. For a reasonable slide, I would need to have it really close next to the camera view. How could I calculate the object's position for that? Thank you. Edit Here is the script that I'm now using and which I'm still having problems with using System.Collections using System.Collections.Generic using UnityEngine public class NewBehaviourScript MonoBehaviour void Update() float fDist Mathf.Abs(Camera.main.transform.position.z this.transform.position.z) Bounds b BoundsFromTransform(this.transform) this.transform.position GetPointLeftOfCamera(Camera.main, fDist, b.size.magnitude 2) public static Bounds BoundsFromTransform(Transform uTransform) Bounds bounds new Bounds(uTransform.position, Vector3.zero) foreach (Renderer renderer in uTransform.GetComponentsInChildren lt Renderer gt ()) bounds.Encapsulate(renderer.bounds) Vector3 nOff bounds.center uTransform.position return new Bounds(nOff, bounds.size) public static Vector3 GetPointLeftOfCamera(Camera camera, float distance, float goDiameter) 1. var ray camera.ScreenPointToRay(new Vector3(0, camera.pixelHeight 2f, 0)) 2. var borderPoint ray.GetPoint(distance) 3. var leftPlane GeometryUtility.CalculateFrustumPlanes(camera) 0 var frustumLeft leftPlane.normal 4. var halfDiameter goDiameter 2f return borderPoint frustumLeft halfDiameter public static Vector3 GetPointRightOfCamera(Camera camera, float distance, float goDiameter) var ray camera.ScreenPointToRay(new Vector3(camera.pixelWidth 1, camera.pixelHeight 2f, 0)) var borderPoint ray.GetPoint(distance) var rightPlane GeometryUtility.CalculateFrustumPlanes(camera) 1 var frustumRight rightPlane.normal var halfDiameter goDiameter 2f return borderPoint frustumRight halfDiameter
0
How can I make Iridescence material In unity? One of the characters of the Dota2 that Is called Nyx Assassin has an interesting material effect If you look at the body and feet you can see this effect.It looks like poily polluted water.I like to know how can I make something like that In unity.
0
Sprite always starts flipped Everytime I start the game, or I swap animator controllers in the inspector (in runtime), the character is flipped in X axis until I start moving him. How do I prevent this to happen? This happens to me everytime I start a new project and I grow tired of this. Update 8 animations which are all idle ones of just 1 frame Down DownRight Right UpRight Up The last 3 have the Sprite Renderer's flipX enabled within their animations UpLeft Left DownLeft In the middle of the transitions, sprite remains flipped until it reaches 1 or 1. I recorded recently a video to display the issue. https www.youtube.com watch?v dC09snKvHAM Same as above but in 1080p and showing entire Unity window. https www.youtube.com watch?v Ww3GkUvb7bc 2nd update PlayerControls.cs using UnityEngine using System.Collections public class PlayerControls MonoBehaviour Rigidbody2D rb PlayerStats pStats Animator anim void Awake () rb GetComponent lt Rigidbody2D gt () pStats GetComponent lt PlayerStats gt () anim GetComponent lt Animator gt () void Update () if (Input.GetAxisRaw("Vertical") gt 0) rb.velocity new Vector3(rb.velocity.x, pStats.pMoveSpeed, 0) if (Input.GetAxisRaw("Vertical") lt 0) rb.velocity new Vector3(rb.velocity.x, pStats.pMoveSpeed, 0) if (Input.GetAxisRaw("Horizontal") lt 0) rb.velocity new Vector3( pStats.pMoveSpeed, rb.velocity.y, 0) if (Input.GetAxisRaw("Horizontal") gt 0) rb.velocity new Vector3(pStats.pMoveSpeed, rb.velocity.y, 0) if (Input.GetButton("Vertical") Input.GetButton("Horizontal")) anim.SetFloat("OrientationY", Input.GetAxisRaw("Vertical")) anim.SetFloat("OrientationX", Input.GetAxisRaw("Horizontal")) PlayerStats.cs using UnityEngine using System.Collections public class PlayerStats MonoBehaviour public string pName public string pClass public int pLevel public float pExperience public float pBasicDamage public float pMoveSpeed public string pClassList Animator anim public RuntimeAnimatorController animCtrl void Awake() anim GetComponent lt Animator gt () void Update() pLevel 1 (int)pExperience 240 if (!CheckAssignedClass()) pClass "Warrior" Debug.LogWarning("Player class not found. Using 'Warrior' as default.") if (Input.GetKeyDown(KeyCode.J)) SetClass(pClass) bool CheckAssignedClass() bool found false var i 0 for (i 0 i lt pClassList.Length i ) if (pClassList i pClass) found true break else found false return found void SetClass(string className) switch (className) case "Warrior" anim.runtimeAnimatorController animCtrl 0 break case "Archer" anim.runtimeAnimatorController animCtrl 1 break case "Mage" anim.runtimeAnimatorController animCtrl 2 break default anim.runtimeAnimatorController animCtrl 0 break
0
Decreasing distance for a Configurable Joint at run time Unity I have written a script that uses ConfigurableJoint to connect a ball to a hing so that it moves in a fixed circular path around the hinge. The problem is that I want to decrease the distance between hinge and ball with time. In other words, I wamt to reduce the radius of circular path on which the ball is moving. I have created a rough image to demonstrate what I'm trying to do And below is the code that I am using to create the joint joint gameObject.AddComponent lt ConfigurableJoint gt () joint.anchor transform.transform.InverseTransformPoint(closestHinge.position) joint.xMotion ConfigurableJointMotion.Locked joint.yMotion ConfigurableJointMotion.Limited joint.zMotion ConfigurableJointMotion.Locked
0
How to initiate manually an animation in Unity? I have a prefab and I want to control when an animation is initiated. I can't seem to figure out how to do that. I have already created the animation clip, the animator component for the prefab, and the animator controller. The animation works, when I enter play mode in the unity editor (it plays automatically), but I want to control when the animation occurs when providing input (such as pressing on the space bar or clicking on the prefab). How would I go about doing that?
0
How to change TPS camera angle in Unity I'm very new to Unity and this may simply be a failure of google fu but I hope someone here can help me out. I'm working through a series of tutorials on how to create an RPG in Unity, making small improvements and embellishments as I go to make sure I understand the concepts. I've built a player character with walk and run animations and a camera which follows the player around and stays aimed at the centre of the character model using the following code. using System.Collections using System.Collections.Generic using UnityEngine public class CameraFollowPlayer MonoBehaviour GameObject target Start is called before the first frame update void Start() target transform.parent.gameObject Update is called once per frame void Update() transform.LookAt(target.transform.position) The problem with this is the angle this leaves the camera pointing at in game is to acute, making it difficult to see what is ahead of the character. How can I adjust the target of the LookAt instruction to result in a shallower X axis rotation of the camera?
0
Issues with spine animation alpha in iOS We are seeing a ton of artifacts and strangeness with alpha on iOS for our spine animation assets. You can see an example of one of these grid like artifacts here, but we're also seeing pixelation etc. Does anyone know why this is happening, whether we need to make adjustments or change certain settings to address this issue?
0
Ball Speed is not increasing as per code I am working on small project , but now I have a problem . The problem is The Player speed (Ball speed) is not increasing as per the code . In the beginning ball speed increases , but as the time goes the speed becomes constant . I made Gravity as 50 in Y Axis . So here is the C Script attached to the ball using UnityEngine using System.Collections using UnityEngine.UI public class Ball Script MonoBehaviour Ball Physics Variables private Rigidbody Ball Rigid public float Ball Speed 10f private float Speed Change Time 1.0f UI Text public Text My Ball Speed Text public Text My Key Use this for initialization void Start () Ball Rigid GetComponent lt Rigidbody gt () My Ball Speed Text.text Ball Speed.ToString () " km h" My Key.text "No Key Pressed" Update is called once per frame void Update () Restart game if(transform.position.y lt 7.0f) Application.LoadLevel(0) Ball Automatic Movement script Starts here Speed Change Time Interval () Ball Rigid.AddForce (new Vector3 (Ball Speed 1 Time.deltaTime, 0, 0)) Ball Automatic Movement script Ends here if(Input.GetKeyDown(KeyCode.LeftArrow)) Ball Rigid.MovePosition(new Vector3(transform.position.x , transform.position.y , transform.position.z 1.0f)) My Key.text "Left Arrow Pressed" if(Input.GetKeyDown(KeyCode.RightArrow)) Ball Rigid.MovePosition(new Vector3(transform.position.x , transform.position.y , transform.position.z 1.0f)) My Key.text "Right Arrow Pressed" This Fixed update stops the ball from bouncing void FixedUpdate() Vector3 currentVelocity Ball Rigid.velocity if (currentVelocity.y lt 0f) return currentVelocity.y 0f Ball Rigid.velocity currentVelocity This function increases the ball speed in every 1 second void Speed Change Time Interval () Speed Change Time Speed Change Time Time.deltaTime if(Speed Change Time lt 0) Ball Speed Ball Speed 10 Speed Change Time 1.0f print(Ball Speed) My Ball Speed Text.text Ball Speed.ToString () " km h" Here FixedUpdate () stops the ball from bouncing and Speed Change Time Interval () function increases the ball speed in every second . But it works some extent . Then there is no change in speed of the ball . Here is the video of the game ( Recorded with Jing , so file is in .swf format . Sorry for that ( ) Link http www.mediafire.com download ibk4ffjm3y6i96y Ball Vid.swf File size 9.28 MB So what is the problem of this script . If my method is wrong not good please suggest me a good one ). Hope you will help me to figure it out . Thanks , Regards NB )
0
3D Unity characters without Maya I have been writing 2D iOS games for a while and I'm looking into getting into 3D. I want to know if Maya is required for making 3D sprites or if you can easily make your 3D sprites using just Unity 3D. They won't be detailed, just about the size shape and detail level of Crossy Road sprites
0
How to clip what is outside scroll view when using a custom UI element? I have created a custom UI element (that use CanvasRenderer). Here is code Mesh mesh new Mesh() Rect drawArea GetComponent lt RectTransform gt ().rect using (VertexHelper helper new VertexHelper()) helper.AddVert(new Vector3(drawArea.xMin, drawArea.yMin), Color.white, Vector2.zero) helper.AddVert(new Vector3(drawArea.xMin, drawArea.yMax), Color.white, Vector2.zero) helper.AddVert(new Vector3(drawArea.xMax, drawArea.yMax), Color.white, Vector2.zero) helper.AddVert(new Vector3(drawArea.xMax, drawArea.yMin), Color.white, Vector2.zero) helper.AddTriangle(0, 1, 2) helper.AddTriangle(2, 3, 0) helper.FillMesh(mesh) var canvas GetComponent lt CanvasRenderer gt () canvas.SetMesh(mesh) canvas.SetMaterial(Material, null) It creates a simple rectangle that is same size as rect transform. It works great. However if I put this inside a scroll view, everything that is outside scroll area viewport is rendered (while it should be clipped). The scrolling works as it should (rectangle get scrolled by changing position when scrollbar is used). I have tried to call canvas.EnableRectClipping(...) but without success.
0
NullReferenceException Error For Respawning I am making an infinite runner game, and I am having issues with killing and respawning the player. I have a coroutine setup on the GameMaster objec which is the respawn and on the player I have a method that calls that coroutine. But when ever the player hits an enemy I get a Null Reference Exception and I am not sure why this is happining. Here is the entire error NullReferenceException Object reference not set to an instance of an object Player.OnCollisionEnter2D (UnityEngine.Collision2D col) (at Assets Script Player.cs 32) Here is the line that when I double click on the error it goes to. This line is on the player. StartCoroutine(GetComponent lt GameMaster gt ().RespawnPlayer()) This is the method that the above line is in. This method is on the player. void OnCollisionEnter2D(Collision2D col) if (col.gameObject.tag "Enemy") Debug.Log("HIT") Destroy(col.gameObject) StartCoroutine(GetComponent lt GameMaster gt ().RespawnPlayer()) Here is the coroutine that the above method is trying to call. This method is on the GameMaster GameObject and this object never gets destoryed or setActive false. public IEnumerator RespawnPlayer() player.GetComponent lt SpriteRenderer gt ().enabled false player.GetComponent lt BoxCollider2D gt ().enabled false player.GetComponent lt movemnt gt ().enabled false yield return new WaitForSeconds(respawnDelay) adMenu.SetActive(true) If anybody can give any suggestions that would be great!
0
Drag Object to Collide Unity Please help, I am developing a 2D game for a school project and I want to drag the apple to the think box then when it collides, the apple will go back to the original position then it will add 1 point to the score. I'm just new to Unity. So please help
0
Jumping onto higher ground Collider issues What's the general solution to the following character animation problem (I'm using Unity)? You have a character with a capsule collider and a jump animation that allows you to jump onto higher ground (such s boxes, etc.). The character shouldn't be able to jump unrealistically high so she goes into a crouched posture while in the air and the collider is scaled accordingly in an animation curve. However when the character jumps onto the box to land, the character animation (and collider) want to extend back to wards the ground but there is not enough space and either collision detection fails and the character falls into the geometry or the collider starts a collision fight with the box and keeps bumping up and down, keeping the character in an airborne state. Please see screenshots to get a better idea... What would be a good way to work around this problem?
0
Unity3D Facebook login into the game Verification on Server Side I don't need to know the specific code required for that, but I want to understand at high level how can I implement that and what SDKs I have to use to achieve that. Facebook PHP SDKs Ok If I want to perform login with Facebook into my web page. Unity3D's Facebook SDK Ok If I want to perform login inside my App without a server (apart Facebook's servers of course). What I want to achieve is User login into facebook from the App (just once, and eventually the option to log out on request of user, or to relog if login data expires) Login is verified by my Server (actually a user should really have a facebook account) Do not embed stuff like Facebook App ID in my App source code. My server will store some data for each user and to identify users I need to be able to use some unique data provided by Facebook like session token etc. Of course the session token may change so I need anyway to be able to identify the user (to avoid losing memorized data).
0
How do I use playerprefs to make ui slider keep the sound settings? I have not use playerprefs before, I want to know how to keep the change of the audio when the player change it throughout the game.
0
How To Display a friend list Using Play fab? I m making a multiplayer game using playfab. One player send a friend request Second player then not display a player name?? I want the access(display) a player name??? see the referance, Code ListingPrefab.cs public class ListingPrefab MonoBehaviour public static ListingPrefab Instance public Text playerNameText FriendRequest.cs public class FriendRequest MonoBehaviour public GameObject listingPrefab btn public Transform panel parent Display Friend void DisplayFriends(List lt FriendInfo gt friendsCache) foreach (FriendInfo f in friendsCache) I think problem is here GameObject listfriend Instantiate(listingPrefab) ListingPrefab templisting listfriend.GetComponent lt ListingPrefab gt () templisting.transform.SetParent(panel, true) PlayerPrefs.GetString("PlayerName", ListingPrefab.Instance.playerNameText.text.ToString()) PlayerPrefs.SetString("PlayerName", ListingPrefab.Instance.playerNameText.text.ToString()) Debug.Log("playername " templisting.playerNameText friendsearch) Debug.Log("helloone" f.TitleDisplayName) templisting.playerNameText.text f.TitleDisplayName TitleDisplayName PlayFab unique username for this friend. void DisplayPlayFabError(PlayFabError error) Debug.LogError(error.GenerateErrorReport()) void DisplayError(string error) Debug.LogError(error) Getfriend List lt FriendInfo gt friends null public void GetFriends() you can call button click PlayFabClientAPI.GetFriendsList(new GetFriendsListRequest IncludeSteamFriends false, IncludeFacebookFriends false , result gt friends result.Friends DisplayFriends( friends) triggers your UI , DisplayPlayFabError) Debug.Log("Inside GetFriends") Add friend enum FriendIdType PlayFabId, Username, Email, DisplayName void AddFriend(FriendIdType idType, string friendId) var request new AddFriendRequest() switch (idType) case FriendIdType.PlayFabId request.FriendPlayFabId friendId break case FriendIdType.Username request.FriendUsername friendId break case FriendIdType.Email request.FriendEmail friendId break case FriendIdType.DisplayName request.FriendTitleDisplayName friendId break Execute request and update friends when we are done PlayFabClientAPI.AddFriend(request, result gt Debug.Log("Friend added successfully!") Add a friend , DisplayPlayFabError) string friendsearch SerializeField GameObject friendpanel public void InputFriendID(string inputfriendid) friendsearch inputfriendid public void SubmitFriendRequest() AddFriend(FriendIdType.PlayFabId, friendsearch) public void OpenCloseFriends() friendpanel.SetActive(!friendpanel.activeInHierarchy) Prerequisites SDK Unity The title ID is set in the PlayFabSharedSettings object (alaready i have) The project can successfully log in a user (alaready i have) The title has at least two registered users (alaready i have) image I have 15 Player. How To access a PlayerName??
0
Mesh fading to transparent I have a 2D Mesh object generated at runtime painted all with uniform color. I want that mesh to have its color fade to transparent color close to the edges. Despite I searched everywhere I could not find any solution. Unfortunately I'm not into Shader programming enough to build logically my solution. EDIT According to wondra's reply my mesh is not fan shaped. It has a non regular hole in it. How can I achieve this?
0
How to add user created data to drop down menu options So I'm trying to make it that I can have a dropdown that will have user created info appear in it. List lt engines gt engineList new List lt engines gt () public Dropdown engineSelect public class engines public string engineName public int featureNumber public int totalDevPoints public string optimizedGenre public engines(string name, int feature, int totalPoints, string opt) engineName name featureNumber feature totalDevPoints totalPoints optimizedGenre opt engines playerEngine new engines(engineName, numFeature, 0, whatGenre) Pretend player set engineName, numFeature, and whatGenre with text fields. I wanted to have it that the drop down would add in whatever new engines the player makes. How would I do that? I want to have it say select engine and then the player would pick from dropdown from engines they made(only saying engine names).
0
How to keep loading screen for minimum time? Making my first game and stuck at keeping the loading screen visible for some time. It shows for an instance and disappears. By using loadasync the previous scene runs in the background? Do i have to pause everything and then move to the next scene? Thank you! The code is as follows public void LoadNextLevel() StartCoroutine(LoadAsyncronously()) IEnumerator LoadAsyncronously() int nextSceneIndex SceneManager.GetActiveScene().buildIndex 1 loadingScreen.SetActive(true) AsyncOperation operation SceneManager.LoadSceneAsync(nextSceneIndex) float progress Mathf.Clamp01(operation.progress 0.9f) slide.value progress yield return new WaitForSeconds(2) SceneManager.LoadSceneAsync(nextSceneIndex)
0
Interpolation on Rigidbody2D not working I'm trying to achieve smooth movement for a ball. I seem to be failing to achieve this and now I've created a sample scene, which shows my setup from the game and the problem exists in that sample scene, as well. I've uploaded the sample project to github https github.com iQew PhysicsTesting (open Assets Scenes SampleScene) Here's a recording of the problem. It's a bit more extreme here than it is in the editor, but it shows the problem even better because of it https imgur.com a ByzwKlg Scenario I have a 2D mobile game (android) using Unity 2019.4.14f1 with URP. The camera does not move and will always have the same settings. The playfield consists of a certain area, which is blocked in by walls, which have a BoxCollider2D on them. The ball is a simple sprite with a CircleCollider2D, RigidBody2D and a Trail Renderer. I have deleted all quality settings except the quot Low quot one, which has VSync Count set to quot Don't Sync quot . In the Awake block of a controller script I set the Application.targetFrameRate to 60. In the Start block I use BallRigidBody2D.AddForce(new Vector2(1f, 10f), ForceMode2D.Impulse) to make the ball move. The RigidBody2D of the Ball has the following settings Body Type Dynamic Material DefaultBall (a Physics2D material with friction 0 bounciness 1) Simulated true Use Auto Mass false Mass 0.025f Linear Drag 0 Angular Drag 0 Gravity Scale 0 Collision Detection Continous Sleeping Mode Start Awake Interpolate Interpolate All other project settings are at default. When I launch the game, the ball starts moving as expected. Most of the time the movement is smooth, but there is stuttering every now and then. I am wondering, if there is a way to make this stuttering go away. The tutorials I found on the internet, which solve this exact problem set the Interpolation mode of the RigidBody2D to quot Interpolate quot , but I did that and there's no change. There are no other scripts interfering with the physics calculation at all. So, I assume this has to do with some kind of project settings? Using a smaller Fixed Timestep does not help, in fact it gets a lot worse, if I use 1 120 for example. Any help would be greatly appreciated!
0
added a pipeline and now my terrain is pink...how do I fix it? I needed to add a pipeline to my world because an asset required it. I was following the directions here. Since adding the pipeline, my terrain is pink. I found a references that stated the pipelines do not support terrain, there are problems with more than 4 textures (I have 1) etc...but this was a year ago. Is this fixable or am I at choice between no pipeline or buying pipeline enabled terrain (and hence redoing all of my scenes)? What is the solution? Thnx Matt
0
Simple Line Formation I'm working on the first formation for my game's troops. These should simply stand on land, facing the same direction. To achieve this, I tried to create offsets towards a pivot unit, that is approximately the unit in the center of the formation. The units are (temporary) elements of a squad list withing the Squad class. I divide the List by 2 and get the closest integer, that should be the pivot point of the formation. Now I generate offsets for all units on the left side (Unit 1 to pivot 1) and right (pivot 1 to last unit) based on the distance gaps. This is the code for the line formation. Sadly, the units are only forming a very stange line with no visually detectable system int count (int)(squadMembers.Count 2) pivot squadMembers count center pivot.transform.position switch (type) case FormationType.Line int space 5 for (int i 0 i lt squadMembers.Count i ) Unit tmp squadMembers i int dist 0 if (i gt count) dist (count 1) space center.x dist if (i lt count) dist (count 1) space center.x dist tmp.StartMove(center) break It also appears that this only works along the x axis, any idea how i can realize this with the walking facing direction ov the pivot? Is there any (obvious) error? How can I improve this script? PS Any idea, how I can transform this into a double line (2 Lines behind with half spacing)
0
How to get which gameobject the mouse is over in Unity? So I'm working on a simple drag n drop based trading card game for my own amusement. There is a card inspector included. What I want to achieve is to change values in the inspector (which has its own Inspector.cs, so I would change the variables in it) based on which card I hover over with my mouse. Each card has its own Card.cs attached from which I want to read the values of the current card. If I try to do this from within the Inspector.cs by something like this Name.text gameobject.GetComponent lt Card gt ().Name , then obviously it won't work, because using gameobject in the current context is not valid. So solution No1 would be to properly reference the gameobject over which the mouse is, which I don't know how to do. When I try to do the same from within Card.cs, I cannot use an event trigger OnPointerEnter and run the code through that, because I have to have a reference to the gameobject that contains that function. ( And I cannot do that in a prefab, only in gameobject already existing in the level.) So could anyone tell me how I could achieve what I want, please?
0
How to make a 2D sprite slowly vanish as it crosses a line as if disappearing behind a wall? ...Except there is no wall. Only one of its edges. Here is what I mean. Notice how the lines "sink" into the center square. I've been trying to do something very similar, in Unity. My approach is to detect when the lines come into contact with the center square (hexagon, in my case), and first initiate an animation that decreases the width of the lines, precisely timed via math to last exactly as long as needed. But there's a problem. The animation doesn't play. I've spent the last few hours debugging it, to no avail, and now have finally given up, because the problem is too complex to post here. Too many variables. Are there any better methods of achieving this? My own, even if it had worked, wouldn't have been perfect, because the width would've decreased on both sides (of the line running in the middle of the thick squares or hexagons that are to disappear), giving it a strange, swallowing effect, but I'd be satisfied, since it's just a practice project. So, I'm giving up on this approach. What are easier ways to do this? (Preferably in Unity, but I'll take anything.) Hasty edit Keep in mind that my "lines" are not sprites but line renderers, but I'm looking for ways to work on either.
0
Unity Capture And Display Live Camera Feed I want to display the video using the device camera on specific part of the screen on iOS, android and Editor. I was able to find the WebCamTexture which display the camera video on the Quad (3D Object). Now I want to record the video and save it on the disk. Is there are way to do that ? Or is there a better way to do that using unity or through plugin ?
0
When creating a game, what are some architectural desgin concepts I can use to be able to port my game from single to multiplayer? I am a software developer but, I mostly develop games in Unity. I have experience creating single player games as well as multiplayer games. I am at a crossroads where I am in the middle of development of a proof of concept or small demo and all of a sudden I am asked to turn it into a multiplayer game without prior knowledge of this I turn around and say it would add 50 to development time because I basically have to start over from scratch because I didn't necessarily take into account that later down the road they might want to change the experience from single to multiplayer. So with all of that out of the way, are there any different methodologies out there that would make it easier on the developer to port a game from single player to multiplayer? I have thought of a possible way of doing this by just setting the game up as single player, however, making my functions where they are easily able to wrap them using Commands and RPCs. But I find this may or may not help me and is only dependent on what the requirements are. My biggest time killer when it comes to porting these PoC's is typically the UI. Most of the time my requirements are so that the UI will be the same shared UI for all clients and having to update it for each action performed on it and dealing with handling ClientAuthority. (Any tips for dealing with this would be greatly appreciated too) Think of this as something like, making something with Legos in multiplayer and having shared instructions based on the step the user is on. Summary What are different ways that I can design a small demo concept where I can easily port it to multiplayer later on, or make my game where it is "multiplayer friendly" ? Or should I try to stay away from this type of thinking altogether and just develop a single player aspect and just develop a multiplayer aspect, arguments for and against this concept are sought after.
0
How can i make my soldier to patrol over the space stationin random? I mean i want to bake all the places in the space station and make the soldier to move automatic around the spaceship to random places. What i did so far is placing the soldier at a start point. Added a camera as child to the soldier. Added a nav mesh agent component to the soldier. Attached a script to the soldier It's not my script. I don't want the soldier for now to chase only to walk randomly around the space station. I didn't change any of the setting on the Nav Mesh Agent component in the inspector and i didn't Should i change anything in the nav mesh agent component and if so what ? How do select or set what areas to bake so the character will know to walk to this areas or if i want to select all the areas ? How do i tell the character when to turn right or left in case there is a wall ? Could be also random to turn left or right. Depending if there is left and right ways or maybe there is also straight way so that's 3 possible ways to move to. clicked the Bake button yet. I didn't write yet the script. using UnityEngine using System.Collections public class SoldiersPatrol MonoBehaviour
0
Relative vertical alignment of 3 Texts on Canvas This is a menu that appears if I press Enter on the RE4 inventory if an item is selected. I have drawn a thin red rectangle around it And here is a video that shows some of the menu's effects. I am familiar with a simple text canvas. I understand that I need to make each line a separate "Text" object so that I can scroll up and down through them. Here is what I have so far The problem that I'm facing now is that the Canvas will be scaled at runtime. I don't work with fixed values. This is a problem since I don't see how I could easily make it so that each TextLine object fills 33,3 of the canvas. Am I right to assume that I can only solve this by making a scripts that holds a reference to each TextLine object and which then calculates their position when the scale of Canvas is known? Or is there any easier solution? Thank you!
0
Creating a list of buttons dynamically in code I have a list of contacts. I need to create a scrollable list of buttons that are created dynamically so I can add each contact name as the button text. How would I do this all in code? My biggest concern is making sure the sizes stay consistent. I haven't had to do that in code before. EDIT And here is the code to add the buttons to this for (int i 0 i lt count i ) if (i gt 0) crt.sizeDelta new Vector2(crt.sizeDelta.x, crt.sizeDelta.y initHeight) GameObject contactButton Instantiate(Resources.Load("Contact Button")) as GameObject contactButton.transform.parent contactsList.transform contactButton.GetComponentInChildren lt Text gt ().text names i
0
How can I search for players in the same wifi in Unity? I am creating a game in Unity and I would like to create an ability for players to join the game that others have created on the same wifi. I would like it to be as effortless as possible(e.g. players don't have to find out their wifi, etc). The game is cross platform you could have one player on PC, other on Android device, etc. Now I know that there is a game that has similar mechanism to what I would like to achieve SpaceTeam. Basically you select whether you use BT or wifi, and wait for other players to join. How can I do this in Unity, or something similar that satisfies my needs?
0
Not able to find the constraints option in the Rigidbody component I am working on a game tutorial right now and I need to freeze constraints for a model prefab. I add a Rigidbody component and I want to freeze rotations on the x and z axes. However, I am not able to find the option in the component. Is there another way to access rotation constraints (I do not want to code the constraints at the moment)? Or is there something I am missing in the new version. Please do let me know. Thanks I am using Unity 5.6.7f1 Personal
0
Using points to unlock next scene in Unity Below is my code and I'm a beginning game designer trying to make my first game for art school teehee! ) I'm not sure how to unlock the next level with a scene I've already made called Rust Room Any ideas? o I also attached the error codes I'm getting! using System.Collections using System.Collections.Generic using UnityEngine.SceneManagement public class Example HUD hud int points const int ScorePrefix "Score " int score public void LoadLevel() if ("Score 45") load the nextlevel SceneManager.LoadScene(SceneManager.GetSceneByName(Rust Room)().buildIndex 1)
0
Unity 5 3rd Person Controller runs by default. How to change this? I have been working with the Third Person Controller of the Standard Assets (called Sample Assets in the beta versions) in Unity 5. When the player press the forward button, the character runs by default, and walks if you hold Left Shift, and I want to swap that. However, The controller makes use of Blend Trees, and have two scripts to manage movement and input and it's far too complex for me and so I need your help. How can I change the controller so that the player walks by default and has to hold Shift to run?
0
how do i make AI enemy in unity 2D? How do i make a AI enemy that go to player and if enemy arrives at collision (ex. stone collider) rotating to path , (unity 2D top view)? (Enemy has a face sprite and animator component) In this pic , I want to do ai enemy following player but when arrives to wall so it's face changes the path and following again . 2 if enemy 1 arrives to enemy2 so enemy face change the path for follow player
0
How to find position of the edge of an object? I have two planes and I want to put both planes one after another so that I can form a road. I set them from the editor and that was very easy but I wanted to do this from code. So in the code void Start() secondRoad.position firstRoad.position But this just set the second plane in the center of the first plane, kind of overlapping. But I want the second plane to be placed next to the first plane where it ends right the edge of the first plane. How will I do this?
0
"Overloading" GameObject? I would like to show weapons and health items in an inventory grid. The item can be rotated in the grid, and it occupies a certain region in the grid. Currently I store this information (where the item is located, if it is rotated, etc.) in an additional array. However, this is not elegant and error prone. I would therefore like to ask if it is possible to somehow store this additional information directly in the weapon or health GameObject. Ideally I would like to be able to do something like this Pistol.GridProps.Rotation 90 Pistol.GridProps.Row 5 Pistol.GridProps.Col 3 Is it possible to add something like "GridProps" to all my game objects? Thank you!
0
How do you rotate RigidBody2D along a given access using velocity and not transform? I am trying to rotate my player along the centre of the world in Unity3D. All the tutorials and references I have looked through till now have left me to this working code void MoveAlongCurve(bool moveClockwise) if (!moveClockwise) timeCounter moveSpeed Time.fixedDeltaTime else timeCounter moveSpeed Time.fixedDeltaTime float x Mathf.Cos (timeCounter) float y Mathf.Sin (timeCounter) transform.position new Vector3 (distFromCentre x, distFromCentre y,0) Also this seems to work fine as well transform.RotateAround (Vector3.zero,new Vector3(0,0,1),speed) Now my question is how do i move my player using velocity? I was forced to keep my body as 'kinematic rigidbody2D' however I want my player to be a 'dynamic rigidbody2D'. My reason for this is several 1. Movement via velocity makes it independent of the timeCounter. 2. Dynamic Bodies enable collisionDetection. Hence it is basically a requirement for my game. Thank you so much for taking the time to read this! Any suggestions or nudges in the right direction would be greatly appreciated and if you find anything wrong in my code or approach please comment!
0
How to read a data from multiple selected text files in unity This question is based off of a previous one. How to read a data from text file in unity But I cant get the code to work for my purpose. I want to be able to choose which CSV files needs to be edited instead of just assigning one file. Here is the code private void readData() TextAsset csvFile Resources.Load("Assets Resources Test1.csv") as TextAsset string records csvFile.text.Split(lineSeperater) foreach (string record in records) string fields record.Split(fieldSeperator) foreach (string field in fields) contentArea.text field " t" contentArea.text ' n' I want to access the file using a given link and then write to it. but for some reason it keep saying "Object reference not set to an instance of an object" referring to "string records csvFile.text.Split(lineSeperater) " I'm new to coding so it might be missing something silly. but as far as i know it should make sense? as csvFile is given the usl, but the url is not being found when its searching for csvFile.text, but then again, i might be completely wrong. Could someone maybe help me and guide me in the right direction?
0
Unity input manager use multiple keys Is it possible to use multiple keys so that they combined will do the action? Say for instance you want a jump attack that would require two buttons to be pressed at the same time. in this case space mouse 1 ? I tried creating that however it didnt seem to take my input. Does anyone know how this can be achieved?
0
Applying movement to a Rigid Body Isometric in Unity 3D I'm making an isometric dungeon crawler. I initially used transform to get isometric movement and things worked well, but I couldn't use collision which meant it was unsuitable. So I'm now trying to use Rigidbody and I'm having some weird issues. First of all, this is the code I currently have public class CharControllerRigid MonoBehaviour SerializeField private Rigidbody characterRigid private Vector3 inputVector void Start() characterRigid GetComponent lt Rigidbody gt () void Update() inputVector new Vector3(Input.GetAxis("Horizontal") 10f, characterRigid.velocity.y, Input.GetAxisRaw("Vertical")) transform.LookAt(transform.position new Vector3(inputVector.x, 0, inputVector.z)) private void FixedUpdate() characterRigid.velocity inputVector I have two issues First, how do I get the movement to work on an isometric plain? Second, how do I get the movement to work in all directions? Current when I move left and right the movement is good, but up and down are really slow in comparison.
0
How can I make the cursor avoid something completely? I wrote some code for a UI button that causes the mouse to avoid it. I realize this is kind of a weird thing to do in a game design wise, but this is a really weird game. I need a button that is not only unclickable, but also unhoverable. I got it mostly working, but I cannot seem to change the position before the mouse is drawn, probably because mouse movement is handled by the OS, unless there is a problem with my code that I missed. As a result, pushing the mouse against the button boundaries results in a stutter. The mouse briefly appears over the button before I can move it, so it is still possible to click the button. A demonstration of the button avoidance and stutter https youtu.be 7tgIrJ vMDg DllImport("user32.dll") public static extern bool SetCursorPos(int X, int Y) DllImport("user32.dll") public static extern bool GetCursorPos(out Point pos) ... void Update () var mousePos Input.mousePosition if (Application.isFocused amp amp isOver) Get the current mouse position from OS so we can change it Point cursorPos GetCursorPos(out cursorPos) if (oldMousePos.x gt xMin amp amp oldMousePos.x lt xMax) Coming from above or below. Figure out which one and move mouse accordingly if (oldMousePos.y gt uiPos.y) cursorPos.y (int)(rt.rect.height 2 (mousePos.y uiPos.y)) else cursorPos.y (int)(rt.rect.height 2 (uiPos.y mousePos.y)) else Coming from either left or right. if (oldMousePos.x lt uiPos.x) cursorPos.x (int)(rt.rect.width 2 (uiPos.x mousePos.x)) else cursorPos.x (int)(rt.rect.width 2 (mousePos.x uiPos.x)) Give new coordinates to OS to update mouse position SetCursorPos(cursorPos.x, cursorPos.y) else track the old position to know what direction they moved their mouse from so we can put it back oldMousePos mousePos I tried using the Cursor API to force it to software mode thinking that might fix it, but it still stutters, and I would prefer to use the default cursor anyway, and hardware mode if possible. Is there any way to work around this or remove the stutter?
0
Why the break point is not working with the unity3d editor? The visual studio version is 16.8.3 Visual studio community 2019 The editor version is 2019.4.15f1 personal On other project I have opened it's working fine. It also worked fine on this project but then something went wrong now not sure why the break point s are not working with this project ! In the editor I did double click on a script attached to gameobject and it opened the visual studio then I clicked on the left side to add a break point and did Attach to Unity but the break point on the left is broken with yellow warning. I tried to close and re open both visual studio and the editor. In the editor I did Edit gt Preferences gt External Tools and this is the settings I also clicked on the Regenerate project files. But nothing worked so far.
0
Some meshes are visible in game view while others are not I have a FPS character in unity. The FPS character is divided into a few different pieces (upper arm, lower arm, hand, fingers, etc). I exported it from blender, so I'm using the camera that got converted from the blender camera. For some reason, the mesh is not showing up in the game view camera vision. I did a little bit of testing and found out that If I move the camera away, the mesh shows up, so the mesh isn't invisible or anything I put a version of the character that I imported from blender earlier as a test(different rest pose and less animations attached to it) in the same location as the FPS character, and attached the same animator to it. When I did that, you can see the earlier version but not the newest one The same thing happens even if I change the camera The camera has a field of view of about 67, and a focal length of 18. Near is set to the lowest value possible. Both characters are visible in scene view, just not in game view.
0
Shader that "cuts" hole through all geometry How can I create a shader that "cuts" through all geometry, only rendering the clearing background in Unity? An example That's a prism in a huge white box shaped room. The surface of the prism is just rendering the skybox of the scene (a starry sky). I used multiple cameras, which is pretty inefficient... There must be a way with just shaders. How can I do this?
0
Facebook link gives "This game is not available for your phone" I am developing a game in Unity and have connected to FB using the plugin. I am able to login and send a request to another user with no problems. However, when I click on the notification I get the message "This game is not available for your phone". Everything is set up as it should be and both users are defined as developers for the app. The only thing is that I have not yet published the app in FB. Is that a requirement?
0
Changing text occurs error move initialization code to the Awake or Start function I have GameManager class that has Log method using UnityEngine using UnityEngine.UI public class GameManager MonoBehaviour public static GameManager Instance SerializeField private ScrollRect m GUIConsoleContainer SerializeField private UnityEngine.UI.Text m GUIConsole ... void Awake() Instance this ... public void Log(string message) m GUIConsole.text m GUIConsole.text message " n" GameManager class has static instance, so I can invoke Log method in anywhere like this GameManager.Instance.Log("Helloworld") However it works only first time. After invoke Log again, Unity gives me this error message get isActiveAndEnabled can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. UnityEngine.UI.Text set text(String) I assigned reference of m GUIConsoleContainer and m GUIConsole in inspector, but I don't get it what this means and why it happens. Just using Debug.Log() or print() works without any error. How should I avoid this error message? Using Unity 2018.2.1f1. p.s. Error coming from here, another class called NetworkManager void OnReceivedBytes(IAsyncResult result) try if(m Socket null) return int resultLength m Socket.EndReceive(result) if(resultLength 0) Shutdown() return Log("Received " m RecvBuffer 0 ) lt lt Error coming from here ... ... And this is where it call OnReceivedBytes using UnityEngine using UnityEngine.UI using System using System.Collections using System.Net using System.Net.Sockets public class NetworkManager MonoBehaviour private Socket m Socket void Start() m Socket new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) m Socket.Connect("localhost", 1337) if(m Socket.Connected) Log("Connected.") m Socket.BeginReceive( m RecvBuffer, 0, m RecvBuffer.Length, SocketFlags.None, new System.AsyncCallback(OnReceivedBytes), null ) else Log("Failed to Connect.") ...
0
Discoordinated Chromatic Aberration Effect The game Teleglitch heavily utilizes the CA effect with screen distortion. I am trying to achieve this effect. Issue 1. How to not apply the effect onto the floor? (solved) They render the screen then apply the CA effect. However, the floor is not rendered with the post processing effect. Issue 2. How to have discoordinated position for each rendered CA effect? Currently I have three offsets for each channel red, green, and blue. However, I cannot assign different offsets for the channels for certain areas only. What would be a way to have discoordinated positions?
0
Assigning script to multiple objects So I have multiple gameobjects that needs to be interactable and I've put them all in one gameobject container. But the thing is I still have to attach the script into each of the gameobjects that needs to be interactable for it to work and that seems kinda iffy when a scenario comes that I have to add more gameObjects. Is it possible to just put the script in the container object? I tried this on my container object and I'm pretty sure I'm doing something wrong. public GameObject spriteHandler GameObject sprite1 GameObject sprite2 GameObject sprite3 private void Start() sprite1 spriteHandler.transform.GetChild(0).gameObject sprite2 spriteHandler.transform.GetChild(1).gameObject sprite3 spriteHandler.transform.GetChild(2).gameObject void OnMouseDown() Debug.Log( quot Clicked quot )
0
What's the difference between UnityEngine.Random and System.Random? What's the different between this int randomNumber UnityEngine.Random.Range(0, 10) and this on top of the class private System.Random rnd new System.Random() inside a methode of the same class int randomNumber rnd.Next(0, 10) I know System.Random must always be initialized on the top of your class what's by UnityEngine.Random is not needed. I know also that System.Random works with a intern "clock" and the "random" number is based on that. My question is now are there some other difference between UnityEngine.Random and System.Random and witch code is better to use for an Unity project?
0
How to make UI text longer? I'm working on a menu that needs a wordy description, but I've noticed that it only shows 4 letters, then cuts off and this doesn't seem right. I right click, select UI text and again, it only displays 4 words, even though I can write a lot more there. Am I doing something wrong here? I'm not sure how to get past this and I want to ask if anyone knows how to get past this? It seems like such a strange limit to put on the UI canvas.
0
What is the reason that people avoid PlayerPrefs to store character data and coins etc? PlayerPrefs are easy to implement and i think it can be used to store important game data like selected character and coins and completed quests for small games, but i have read too much to make me ask this question that why not use it, and what is the other options for storing important game data in
0
How do I set horizonal Field of View by code as in Inspector? I have a camera that I have set to RenderType Base Projection Perspective FOV Axis Horizontal Field of View 75 Physical Camera False Clipping Planes Near 0.3, Far 1000 If I set Field of View values during gameplay in the Inspector, it works as expected. For example, I type 75, and the camera behaves as I think it should. I'm comparing with Resident Evil 4. It has a camera cheat, and if I select FOV 75 in this cheat, the Resident Evil 4 camera behaves like my Unity game camera. However, when I set the camera.fieldOfView to a 75 by code, the Inspector shows 104, and the code does not look as it looks when I type 75 in the Inspector. camera.fieldOfView however returns 75. What is going on here, and how do I fix it? Thank you!
0
Can I legally modify the Unity splash to fit the game's theme? I've been working on a retro game, and I was wondering whether I could change the Unity logo to make it fit the game's style (eg. pixelating the logo). I know how to do this, but my question is whether it is illegal, assuming I have a Plus, Pro, or Enterprise licence for Unity that allows me to edit this splash screen at all.
0
How is the density of a collider determined? I read here that, once determining the density of a Buoyancy Effector, "Colliders with a higher density sink, those with a lower density float, and those with the same density appear suspended in the fluid." However, I did not find a density field in my CircleCollider2D. What I found is that If I increase the mass of the attached RigidBody2D, then the body sinks into the fluid since apparently its density increases. If I keep the mass but decrease the size of of the circle collider, then again the body sinks into the fluid indicating that its density increases. So my conjecture is that the density is calculated by the mass of the rigid body, divided by the volume of the collider. But I did not find the formula in the Unity manual. Is this correct?
0
Multiple Input.GetKeyDown happens in low frame rate There is a code that needs to be invoke each time user pressed specific button in my game. So I used Input.GetKeyDown to achieve that, but some reason, that code invokes multiple times even I keep pressing the button. After some tests, I figured out this happens a lot when the game has low frame late. In a very laggy moment, GetKeyDown returns true very many times. void Update() if(Input.GetKeyDown(KeyCode.RightArrow)) print("Pressed") I saw a similar issue in here but couldn't find any related information. https forum.unity.com threads problems with input at low framerates.16828 My game is a very input sensitive game, so my code when the user each time pressed a specific button always invoke when they pressed. I checked my keyboard is something wrong, but there was no problem with my keyboard. Why does this happen? According to the Unity doc, it said Returns true during the frame the user starts pressing down the key identified by name If I used wrong way, then how do I check each time user pressed a button? Using Unity 2019.1.0f2.
0
Trying to find a solution for instant knockback in multiplayer game I'm making a server authoritative fast paced multiplayer game. I'm trying to implement wack hammers, they are a melee weapon that knocks close players, in other words, that sets their velocity to inverse of their mass to the direction aimed at the force of the hit. Even if the enemy player is only seen getting knocked after the client input gets processed on the server and after the enemy's position and velocity get sent back, I want to make it seem like your action appeared instantly. I've tried one thing when you knock a player, that player gets predicted for a short amount of time instead of being interpolated. That way, players appears to have been knocked out instantly, but there's an issue with that. When should I stop predicting? And how? When you think about it, the prediction is done on your own client time. The positions and velocities of other players are a few millisec old, so when you try to interpolate between your local quot futur quot predicted player position to the quot old quot server player position, you essentially move the other players back in time, and it looks real bad. I'm not quite sure what to try to hide this issue. I can't possibly predict the enemy player's position forward in time, its movement can get too chaotic. I've already watched the GDC talk from Overwatch's and Rocket League's netcode a million time, I'm not sure if they can help me with my issue. Edit I still haven t found the best solution yet but there s some useful information over at https forums.unrealengine.com development discussion c gameplay programming 1455487 responsive knock back in multiplayer game