_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
0 | Persist emitted particles in scene after particle system has ended destroyed? In Unity, is is possible to persist emitted particles in a scene after the system has ended or even possibly destroyed? I have a particle system attached to my player prefabs that does a rudimentary blood splatter, and I'd like for the emitted "blood" particles to stay in the scene for as long as the scene is active, even after the player prefab that originally emitted the particles is destroyed. |
0 | How to change 100 GameObjects' color without pushing RAM to hard? I'm developing a mobile game and one of the gamemodes has 100 gameobjects(basic cubes). And they all have same material. I need to know how to change their color one by one with script. I'm not very good at programing, so only idea that i have for this situation is declaring 100 objects to var, and then change their color one by one. But like a said it's a mobile game so i need to do it with simplest code so performance would be perfect. |
0 | Unity RageTools Performance Has anyone used RageTools for Unity? What do you know about the performance? Is it more performant than using raster, for example with "puppet 2d" or the other way? I'm developing mobile games, so performance is very important for me. Thank you! |
0 | How can I get the Launch dynamic link in Unity? I have integrated firebase dynamic link sdk in my app and it is working perfectly fine, I can generate dynamic links, and when clicked on them if the app is not installed it redirects me to the playstore and if installed open up the link in app. My question is how can I get that generated link when I open the app through it, I just could not able to find anything in docs the code I am using to listen for link clicks is as follows void Start() DynamicLinks.DynamicLinkReceived OnDynamicLink Display the dynamic link received by the application. private void OnDynamicLink(object sender, EventArgs args) var dynamicLinkEventArgs args as ReceivedDynamicLinkEventArgs Debug.LogFormat("Received dynamic link 0 ", dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString) Above line gets me the original base link, But I want the link which I clicked |
0 | How do I access objects that are in the next scene I'm loading? using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.SceneManagement public class HouseExit MonoBehaviour public Transform player public void Houseexit() SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex 1) void OnCollisionEnter2D(Collision2D col) if (col.gameObject.CompareTag( quot Player quot )) Houseexit() GameObject.Find( quot Wizard quot ).transform.position GameObject.Find( quot SpawnPos quot ).transform.position This code belongs to the scene quot Goblin House 1 quot and I'm trying to find the wizard and the spawn position both from level 1. |
0 | Unity 4 mecanim 'Quaternion to Matrix conversion failed, input quaternion is invalid' I'm trying to animate a stick figure in Unity, with placeholder animations. Character is built animated in Blender, exported to FBX. When imported to Unity, everything appears correct in the editor. All animations are imported, and i can preview them normally. I set up the "rig" section of the model import to use generic rigging. This creates the avatar which is used in mecanim. I set up a simple "walkForward" animation, and setup mecanim parameters to get it called when the player moved forward all that works. The animation is called at the right times. However, during play, as soon as any animation is started on the avatar, the model disappears, and a flood of error messages appear in the console, stating Quaternion to Matrix conversion failed because input Quaternion is invalid 1. IND00, 1. IND00, 1. IND00, 1. IND00 1 IND00 I'm not altering the animation with any scripts of my own, it's all mecanim. Is there a setting i'm missing? I'm using Unity 4.3.0.0f4, building exporting my mesh with Blender (latest). |
0 | Unity Texture2D raw data TextureFormat problem I am trying to load raw image data into a Texture2D in Unity using LoadRawTextureData but I can't get it to work correctly. First I receive an array of bytes from an unmanaged function that captures a window. I am pretty sure these bytes represent an image in BGRA32 format. int dataSize width height 4 byte imgData new byte dataSize bool success CaptureWindow(windowInfo, imgData, (uint)(dataSize)) Then I try to create a new Texture2D with this data Texture2D tex new Texture2D(width, height, TextureFormat.BGRA32, false, true) tex.LoadRawTextureData(imgData) tex.Apply() And finally I create a new plane and assign this texture to its material. GameObject plane GameObject.CreatePrimitive(PrimitiveType.Plane) plane.GetComponent lt MeshRenderer gt ().material.mainTexture tex This doesn't work (Notice how the color channels are mixed up) However, when I reverse the byte array before loading it into the texture as ARGB32, it does work Texture2D tex new Texture2D(width, height, TextureFormat.ARGB32, false, true) Array.Reverse(imgData) tex.LoadRawTextureData(imgData) tex.Apply() The problem with this solution is that Array.Reverse is too slow. Why doesn't loading it as BGRA32 work? Isn't BGRA32 just the reverse of ARGB32? FYI I am using Unity 5.1.2f1 on Windows and SystemInfo.SupportsTextureFormat returns true for both BGRA32 and ARGB32. |
0 | Unity Mirror Network Transform not working I am having an issue with Mirror's network transform component in unity. Players cannot see each other move, and in the inspector window only the host's player moves (this is not updated to the connected player though). In the inspector window you see a sphere moving and facing in the direction of the connected player (I did not program this so it must be Unity trying to tell me something) as per the picture below. Any help is much appreciated as there doesn't seem to be anybody that I can find online with a similar problem. Thank you! |
0 | Rotate GameObject on click I'm trying to get a card to flip when clicked but the flipping only works the first flip. While debugging, I can see that OnMouse is called every time I click. public class CardController MonoBehaviour bool isShowingFront true bool isFlipping false float speed 0.005F Quaternion flipRotation new Quaternion (0, 0, 0, 0) Use this for initialization void Start () Update is called once per frame void Update () if (transform.rotation.y ! flipRotation.y) transform.rotation Quaternion.Lerp (transform.rotation, flipRotation, Time.deltaTime speed) isFlipping true else isFlipping false void OnMouseUp () if (isShowingFront) flipRotation.y 180 else flipRotation.y 0 isShowingFront !isShowingFront Debug.Log ("I was clicked") |
0 | Technique to find a mesh intersecting with a primitive solid without using colliders? For what it's worth I'm using Unity3d, but I believe the problem is more general. There are hundreds if not thousands of meshes with hundreds of vertices each. There is one sphere that can be intersecting any of those meshes and is constantly moving. Are AABB colliders approximating the mesh's volume the best way to go about this? Or is there a more specific technique that can be used here? (A limitation I have is that my colliders need to be rotated, so they're each stored in a game object, so the number of game objects becomes absurdly large for my meshes(tens of thousands) which is slowing down my game.) I have a couple of properties unique to my situation I believe might allow me to ditch colliders I don't care about the meshes colliding with each other. Just the one sphere. I only need to know that the intersection exists, I don't care about the point of the intersection or any other metadata. Just a boolean of the intersection occuring and what mesh it happened with. I don't need to know the exact moment frame when the intersection occurs. If I can find out an intersection occurred within 100 200ms 20 30 frames of it happening it'll be fine. |
0 | Skewed 3d model when moving device around with Unity and Vuforia I am having trouble with the orientation of a 3d model that is larger (think queen sized bed) than the target image(a4 size bond paper). The model appears to be slanted in a way that looks totally unrealistic especially when moving the device around. Is there a way to keep the model horizontally aligned with the real world floor? I have already enabled Extended Tracking but the behavior is still present. I have also set the world center to Specific Target and set Device Camera focus mode to FOCUS MODE CONTINUOUSAUTO. Thank you. |
0 | Photon Unity Instantiation not working I use Unity and Photon for the multiplayer. I Instantiate my gameObjects using this method void LoadGameObject(PhotonPlayer player,bool isMaster) if (isMaster) GameObject baby PhotonNetwork.InstantiateSceneObject(babies 0 .name, babies 0 .transform.position, Quaternion.identity, 0,null) baby.SetActive(true) Debug.Log("playerpref created on " player.ID) else Nothing for the moment I call the method in "OnJoinedRoom()" and "OnPhotonPlayerConnected(PhotonPlayer other)", but when the second player join the room, he can't see the gameObjects because they aren't activated on his scene. Any Idea of the mistake ? |
0 | Why the spotlight is working only in scene view window but not in game view? What i did is disabled in the Hierarchy the Directional Light. The Spotlight is child of the character so it will move with it. Then in Window Lighting Settings In the Spotlight i just changed the range and rotation a bit. It's strange since it's showing the light in the scene view but not in the game view not even when running the game. And this is the Spotlight config |
0 | Only host can spawn object I am currently making a multiplayer game however only the host has the capability to spawn projectiles. Command void CmdSpawnEgg() if (cam null) return GameObject instance Instantiate(eggPrefab, transform.position (transform.forward offset), cam.rotation) NetworkServer.Spawn(instance) cam is the transform of the players camera and if its not the local player the camera is destroyed The projectile is also a registered spawn able prefab for the network manager |
0 | How to create a high score in Unity from a Time.deltatime float? When I play my game, it sets my score to 0 and does not change, no matter how high my float gets. using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class highscore MonoBehaviour public Text Highscore void Start () Highscore.text PlayerPrefs.GetFloat ("Highscore", 0).ToString() This is where the next page starts using UnityEngine using UnityEngine.UI public class Score MonoBehaviour public Text ScoreText public float playerScore 0 void Update () playerScore Time.deltaTime 10 ScoreText.text playerScore.ToString("0") private void OnCollisionEnter (Collision collisionInfo) if (collisionInfo.collider.tag "Obstacle") PlayerPrefs.SetFloat ("Highscore", playerScore) |
0 | Save slider value and load it? I'm trying to save a slider value and load it when I run again the game. but here is not working. yes, I can change the value and save it but not load it. public Slider Brightness public float bri,briv only briv value I saving it. Use this for initialization void Start () PlayerPrefs.GetFloat("briv") Brightness.value briv void Update() briv bri bri Brightness.value if (Input.GetKeyDown(KeyCode.S)) PlayerPrefs.SetFloat("briv",briv) Debug.Log ("save") end update |
0 | delaying enemy attacks I have an enemy attack script that when a raycast hits the player it deals damage to the player, however the enemy attacks at multiple times per second and I wish for the enemy to have to wait 1 second after it attacks the player before it can attack again. The script is here, the main focal point is the void update(). Any help is appreciated, let me know if I've missed out any needed details. ) public class DamagePlayer MonoBehaviour int attackDamage 10 SerializeField float agroRange SerializeField Transform castPoint Rigidbody2D rb2d bool isFacingLeft Start is called before the first frame update void Start() rb2d GetComponent lt Rigidbody2D gt () bool CanSeePlayer(float distance) bool val false float castDist distance if (isFacingLeft true) castDist distance Vector2 endPos castPoint.position Vector3.right castDist RaycastHit2D hit Physics2D.Linecast(castPoint.position, endPos, 1 lt lt LayerMask.NameToLayer( quot Action quot )) if (hit.collider ! null) if (hit.collider.gameObject.CompareTag( quot Player quot )) val true else val false Debug.DrawLine(castPoint.position, endPos, Color.red) else Debug.DrawLine(castPoint.position, endPos, Color.green) return val Update is called once per frame void Update() if (CanSeePlayer(agroRange)) PlayerHealth.currentHealth attackDamage Debug.Log( quot can see player quot ) else |
0 | Should I combine multiple tiles of terrain as one mesh in Unity3D? I have a tiled terrain, generated by multiple noise algorithms. Currently, each tile is it's own GameObject, that has a handler for an OnMouseOver event. The area that is loaded at a time consists of 9 chunks that each contain 4096 tiles. This totals to 36864 tiles that are loaded at a time. On top of this, there are actual objects on top of these tiles. Is there any considerable performance difference if I were to combine some of these tiles into a single GameObject and mesh? |
0 | How to design enemies pattern in non bullet hell shmups in Unity? I am making a top down shooter. Enemies will come in waves and attack in many different patterns (i.e. wave of 10 enemies flying in a elliptic curves, or a huge boss floating and shooting at you, etc.). I'm thinking of 2 solutions Design paths using an animation tool Hard code paths For the first solution, I think it will be faster to create the paths since I will be able to see them in the tool, but is it performant? There will be hundreds of flying patterns in my game. I've also heard of BulletML, but looks like it's more for bullet hell shmups, and there's no visual editor to design the patterns easily. Are there other solutions to design path patterns for non bullet hell shmups which I haven't considered? What are the pros cons of each solution? |
0 | Adding an extra Pass to the Unity Standard Shader I'm experimenting with adding some procedural textures to the unity standard shader. I'd like to add an extra pass (with vert and frag functions), but am unsure about where in the sequence this should go, and how to properly integrate it with the other passes (I want to keep all the standard shader lighting features etc.). To keep things simple, I'd like to start with adding an extra pass which simply paints the mesh one color. Where should this go (in Standard.shader)? Note I've tried adding a pass between passes 1 ("FORWARD"), and 2 ("FORWARD DELTA"). This works, and casts shadows, but does not recieve shadows. Thank you! |
0 | Mesh from MagicaVoxel cast a strange holed shadow I have a problem with any mesh I import from MagicaVoxel into Unity. As you can see from the screenshot below, the mesh on the left cast a shadow that has holes in it. That's a basic 7 voxel mesh exported as OBJ and dragged into Unity. The light is the standard directional light Unity automatically creates in an empty scene. The glitch occurs in scene editor, preview and exported builds, I tried on multiple PCs as well. The mesh on the right is a cube extruded on all faces created in Blender and exported as 3DS. As you can see from the wireframe, it is basically the same mesh, but its shadow looks good. Note that if I import the MagicaVoxel's OBJ in Blender first, and then I export in 3DS and into Unity, the shadow stays holed, so it's not a problem with the mesh format, but with something in the mesh itself. What can it be? Can I solve it somehow or try some others approaches? Thank you. |
0 | Unity2D Multiplayer Spawning player at user's end I am currently into a 2d mobile multiplayer project. Its going to be a 2 player game for now. So the host and the client are the only players. I am using Unity 5.4 and the default multiplayer platform by the way. I am able to spawn the character both on client and server. The syncing also works pretty well. But for the game to be user friendly, obviously I have to spawn the player on his end of the screen and the opponent on the other end. I am unable to achieve this on the client screen. In the client screen, the client starts from the upper end of the screen making it difficult to play with. So, my question. How would I go about spawning a player in his device on his end of the screen and the opponent on the other side? The only idea I came up with was switching the spawn points in the client version of the game. Is it possible accessing client's version of the game during runtime? And would it be the right way to go about it? If not please share an alternate solution. Thanks |
0 | Make a platform appear and disappear constantly I am building a platformer. In this game, I need one of my platforms to constantly activate and deactivate. Here is how I have tried to code this so far, but it causes Unity to freeze void Update() for (i 0 i lt 2 i ) platform.SetActive (false) if (i gt 1 ) i platform.SetActive (true) |
0 | Using GrabPass for 2D water reflection? I'm trying to achieve some neat 2d water reflection effect with Unity, something like this What I've managed to accomplish so far The problem is GrabPass captures the entire screen but I really want to control precisely what area of the screen will be captured. Is it feasible with GrabPass? (I'd rather not use a new camera for a rendertexture). Is that even the right approach? |
0 | How do I set up a dedicated server for my multiplayer Unity game? I've made a multiplayer game with Unity and Mirror networking, and it all works perfectly when just running it on my own computer. However, I am trying to host on a dedicated server so that I can put the project on my portfolio and not have to worry about whether players can log in and test play the game or not. I tried a AWS Free server and I see that the Tanks example from Mirror is working just fine (although laggy), but my own project doesn't. I think this has something to do with the RAM limit of the free server but I'm not sure. I can see the task manager going up to 95 memory usage. When I remove some particle effects and geometry and enemies, it works. I'm not sure if this is my code that is so cloggy or the server or both. In any case I would need a solution for this but I don't know what my options are. Would be great if anyone can point me in the right direction. Thanks! |
0 | Unity is reimporting everything! How do I stop that? I have a relatively large project (about 8GB) and it is constantly reimporting itself over and over, to the point that I spend 80 of my time waiting for Unity to Reimport everything Stop hanging. Even for the smallest of changes (ie. removal of a comment on one line in a script), or changing import settings on an asset can cause these long hangs and reimports. To make matters worse, this project is also synced over UnityCollabBETA, which throws manual selective import (auto refresh is forced on) out the window. I've also read up that other programs locking asset files (to read them) can also cause Unity to reimport everything as opposed to simply doing a selective import (only reimporting things that has been changed). I've tried creating blacklists for my auto backup programs, anti viruses and anything that would snoop around and or mess with the Unity Project folders. However, despite those programs not accessing anything, Unity still reimports the whole project every time I alt tab out. The only workaround I've found so far is to just kill Unity every time it does it and relaunch it as for some reason it processes the actual changed files first, then hangs itself by going through everything else. It is also worth noting that I O is maxed up by Unity (due to the sheer size of the project) and CPU GPU usage are relatively low (does not exceed 20 30 , assuming nothing else is running in the background). Note This has persisted through installs and computers. Question How do I stop Unity from reimporting everything without constantly killing Unity? |
0 | How can I convert 3D mesh to SDF? Previously, I found an useful article that explained how to convert 3d mesh to SDF easily. I want our artists to be able to easily convert from polygonal data to SDFs with little to no effort. http colourmath.com 2018 development signed distance fields in unity this article is what I want but unfortunately there wasn't simple Implemention. there is algorithm in this article foreach (pixel in texture) foreach (triangle in mesh) get pixel center as mesh bounds position get closest point on triangle calculate distance from pixel position to triangle keep the smallest distance perform a raycast along arbitrary vector against triangle if(raycast intersects triangle) increment an intersection counter if(number of intersections is even) pixel value is positive outside mesh else pixel value is negative inside mesh I like to Implement this article but I can't understand above algorithm and I don't know how can I convert 3D mesh to SDF data and then sotre this data to 3D RenderTexture? |
0 | What is the transformation order when using the Transform Class? I am currently using Unity 5.5 for the first time in a project and I've got some problems regarding transformations. I've got a background in more general 3D graphics meaning that I'm used to manually manage scene graphs and matrix transformation orders. My greatest problem when moving to Unity, and using their built in Transform Class, is that I can't find any information regarding the transformation order of rotation, localrotation, scaling, localscaling, position and localposition. I can't find any good information of this and It's driving me slightly mad. TL DR What's the transformation order of the Transform class? |
0 | Questions about texture compression So when I choose the texture in the Inspector window I see three tabs Default, Standalones amp Android. I can choose some variants of how to compress this texture, but My texture is a png (so it's RGBA). When I click the Default Format I can see stuff like Alpha 8, R 8, RGB 24 bit. So if I choose R8, for example, does that mean that my GBA channels will be thrown away? What is the Max Size? My texture is 600x375. If I choose 512 will it clip my texture to 512x375 or what? And why it is called Max Size if I am working with a single texture right now? If I choose Default Format to Automatic and does not do any override on any specific platform will Unity choose default texture compression formats for a specific platform using this table? |
0 | 2D Finding an algorithm to check pizza toppings positions Using unity 3D I am creating a 2D pizza game and I am stuck at finding an algorithm to solve this problem which is Detecting if the pizza is half and half taking into consideration that the user can put the toppings in all rotations shown in the picture and lot more possible distributions. I used Physics2D.OverlapAreaAll to get position of ingredients on the pizza and I tried getting the sumX and sumY of coordinates of all topping A and sumX and sumY of all topping B and adding A.sumX B.sumX and A.sumY B.sumY and if the 2 totals are between 0 and 1 then A and B are on opposite sides but the bad distribution of toppings in the second pic is also accepted by my algorithm. The toppings must be spread like in the 1st pic I need some easier way to detect the correct distribution of ingredients maybe using collisions or something. if (sumX gt ErrLvl amp amp sumX lt ErrLvl amp amp sumY gt ErrLvl amp amp sumY lt ErrLvl) Debug.Log( quot APPROVED HALF HALF PIZZA quot ) else Debug.Log( quot BAD HALF HALF PIZZA quot ) |
0 | How to blend textures with different size optimally? I am trying to create a 2D lighting map. For each light source I have an Color , with size less than whole map and a coordinate of center. There can be many light sources and they can intersect (2 or more, so I can't just sum it). I need to blend all light colors for every map pixel, not override. Is there a better approach other than to loop over every light for each map pixel, get colors and mix them? |
0 | How to handle forward backward movement in an oblique top down view I'm making a pseudo 2D top down game, where my assets are actually 3d but I use an orthographic projection to introduce more depth. I saw a picture of how the game "Enter the Gungeon" was actually made in unity 3d. When I tried doing something likes this I put the camera in orthographic view and after some adjusting I got it to look kind of like this. The problem is that movement in the z axis (away toward the viewpoint, or up and down on the screen) feels very slow because of the whole orthographic thing. You can notice this when moving a player for example. When I simply increased the speed of the player in the z axis it felt pretty normal, but I am wondering if that would introduce some unforeseen consequences? I couldn't find any guides, posts or videos about this. How should I solve this movement problem? |
0 | Unity 2d circle collider not stopping after collision with box collider 2d I'm using unity circle collider 2d and rigid body 2d but when it hits the box it doesn't stop there but instead just pass through and fall. Can someone help? Circle Collider and rigid body 2d setting Box Collider Settings Game output As you can see in game output my circle instead of stopping at collision it is getting passed by box. I want the circle to fall in square rather than free fall. |
0 | why does my objects only spawn once or really slowly? public GameObject fallingRockPrefab public Vector2 spawnsMinMax float randX float randY void Update() if (Time.time gt nextSpawnTime) float SpawningInBetween Mathf.Lerp(spawnsMinMax.y, spawnsMinMax.x, Difficulty.GetDifficultyPercent()) print(SpawningInBetween) nextSpawnTime Time.time SpawningInBetween randX Random.Range( 5.6f, 5.6f) randY 5.57f SpawnPosition new Vector2(randX, randY) Instantiate(fallingRockPrefab, SpawnPosition, Quaternion.identity) I set the quot spawnsMinMax quot over at the inspector in Unity as high as I can like (25 or 30 etc) but it still spawns once or like 1 or 2 per second. Even I set the number as low it can go, it still spawn in the same way. How do I fix this? |
0 | AddForce results in stuttering movement I'm currently developing a simple breakout arkanoid mobile game. Now, I noticed that my ball movement is noticably stuttering. I've read various approaches about how to make the ball move and decided to go for AddForce so I don't have to do any physics calculations myself. The only thing im currently doing is using AddForce on my ball's rigidbody2D and have it collide with the walls and blocks. There's nothing done manually in Update or FixedUpdate and there are no other scripts running while the ball is moving. The scene is pretty empty actually. Things I have tried so far without success Disable V Synch Increase the velocity iterations (I tried values 15 500) Set the RigidBody2D's interpolation mode to Interpolate Extrapolate Using different mass values and force values in AddForce Checking, whether it's just an optical illusion (it seems to run more smoothly in editor and other breakout arkanoid games don't have that problem on my Galaxy S7) RigidBody settings of the ball Body Type Dynamic Material Friction 0 Bounciness 1 Mass 0.025 Linear Drag 0 Angular Drag 0 Gravity Scale 0 Collision Detection Continous Sleeping Mode Start Awake Interpolate Interpolate The walls and blocks are simple BoxCollider2D components. And I'm calling AddForce(new Vector2(0f, GameConstants.DESIRED BALL SPEED)) on the ball's RigidBody2D. Edit public void OnPointerUp(PointerEventData eventData) if(! ballStarted) PaddleController.ShootStickingBalls() ballStarted true public void ShootStickingBalls() int stickyBallsAmount stickingBallsRigidBody2D.Count for (int i 0 i lt stickyBallsAmount i ) stickingBallsRigidBody2D i .AddForce(new Vector2(0f, GameConstants.DESIRED BALL SPEED)) stickingBallsRigidBody2D i .transform.SetParent( nonStickyBallsTransform) Sticky false |
0 | GameObject's scale gets 0 after being parented in editor 1) Before 2) After being parented. I found a pattern. When adding the child, if the parent's scale.z 0 the child scale.xyz becomes 0 on parenting. If the parent's scale.z ! 0 it works. Another experiment that I tried was, after successfully adding the child(without getting scaled down to 0) and then to make the parent's scale.z 0, the children's scales don't get affected at all. Why? |
0 | smooth loading of the heavy scene in unity3d I have a very very big huge scene to load, I can't load it at once. So what I know I have applied but it still loading takes some time I want to make it smooth. How it possible? What i have tried so far is I divided the scene into multiple scenes and loading it into async manner as my character controller move. I am moving my character controller and accordingly loading (its near)scenes by matching its position. How do i load smoothly a big scene? what will be the strategy? Is this right strategy which I am doing or there any else solution. |
0 | A shader that casts shadows, doesn't receive shadows and doesn't render any textures models at all? Bit of a strange one but I'm in the situation where i need a shader to essentially render nothing and cast a shadow! I found this though some googling but sadly that casts shadows onto itself which is undesirable. |
0 | System.Runtime.Serialization.SerializationException while trying to deserialize List I'm trying to serialize deserialize a class that holds inventory items. The code is attached below. First I call AddOne() void a few times, then I call SaveFile(), then I call LoadFile(). In LoadFile() the following error occurs ex "System.Runtime.Serialization.SerializationException End of Stream encountered before parsing was completed. r n at System.Runtime.Serialization.Formatters.Binary. BinaryParser.Run () 0x00288 in lt 1f0c1ef1ad524c38bbc5536809c46b48 0 r n at System.Runt... Does anybody see my mistake? Thank you for the help! using System using System.Collections using System.Collections.Generic using System.IO using System.Runtime.Serialization.Formatters.Binary using UnityEngine public enum Type undefined 0, Pistol 1, Magnum 2, Grenade 3, BlendGrenade 4, FireGrenade 5, PistolAmmo 6, MagnumAmmo 7, Rifle, RifleAmmo, System.Serializable public class Inventory MonoBehaviour public class InventoryItem public int Amount 0 public int Row 0 public int Col 0 public int Rotation 0 public Type ItemType Type.undefined public List lt InventoryItem gt Items public void Start() Items new List lt InventoryItem gt () public void AddOne() InventoryItem n new InventoryItem() this.Items.Add(n) public void SaveFile() string destination Application.persistentDataPath " save3.dat" if (File.Exists(destination)) File.Delete(destination) using (Stream stream File.Open(destination, FileMode.Create)) BinaryFormatter bin new BinaryFormatter() bin.Serialize(stream, this.Items) public void LoadFile() string destination Application.persistentDataPath " save3.dat" using (Stream stream File.Open(destination, FileMode.Open)) BinaryFormatter bin new BinaryFormatter() try this.Items (List lt InventoryItem gt )bin.Deserialize(stream) catch (Exception ex) Debug.Log(ex.ToString()) |
0 | How to change the intensity of a light I just want to change the intensity of a light. The script is already in the light object, but I can't turn it up or down to save my life, and wherever I look, no one has the answer. using System.Collections using System.Collections.Generic using UnityEngine public class Flashlight MonoBehaviour public bool flashOn void Update() if (flashOn) light.intensity 0 if (Input.GetKey("q")) flashOn false else light.intensity 1 if (Input.GetKey("q")) flashOn true |
0 | Spine, Dragonbones or Live2D for interactive 2D animation? I'm planning to make a game with some interactive 2D animation. For example, when the player holds mouse button, the character gradually pulls his bow, and releases it when the player releases mouse button. I think skeletal animation works better than frame by frame sprites for this purpose, right? I googled for a while and it seems there are several tools can do that, like Spine, Dragonbones and Live2D. But I have no idea what's the difference and which one I should choose. Could you share your advice experience on it? Also do they have API for Unity? I'm have a bit programming experience with Unity, but I know nothing about 2D animation, so please bear with me if this question makes no sense. |
0 | Changing the RotateAround center point dynamically Black circles are static Red player Blue line path I'm trying to achieve a constant movement of the red dot like on the image below. For now, I have something like void Update() target firstCircle here I need to perform some calculations this.transform.RotateAround(target.transform.position, Vector3.forward, speed Time.deltaTime) As you can see in the code, it rotates around the upper circle now. I need to switch the target variable to the secondCircle when the player comes back to it's initial position (or is near it). I came up with something like if(Mathf.Abs(Mathf.DeltaAngle(360f,this.transform.rotation.eulerAngles.z)) lt 5f) change target and it works but has two issues. First the epsilon value. If I set it to 5f the above if is true like 7 times (depending on the player's speed). Of course I could make a lock to run it only once per cycle, but there's a second problem. If the object is moving too fast, the if will be false each time, cause the speed step is always higher than the epsilon. How is this done in 'gravity' games like AngryBirds when the bullet changes it's attraction point? |
0 | GameObject.Find() finds objects in the old scene I'm trying to create a simple scene transition. On entering a collider, there is a black canvas that's slowly faded in over the duration of 3 seconds. Then, a new scene is loaded, and the scene slowly fades from black to invisible. Now, I've almost finished it. However, I'm running into a small problem I cannot seem to fix. The animation consists out of two text elements and one image. The hierarchy looks like this SceneLoader is an empty object, SceneFader is a canvas. Image is a black image stretched across the screen, and RegionName and RegionSubtext are two text elements that are filled as soon as the transition begins. The code I'm using to load the scene is this private IEnumerator loadSceneWithTransition(string sceneToLoad, Vector3 spawnCoordinates, string regionName, string regionSubtext) this.screenFade.SetTrigger(SceneLoader.AnimatorTrigger) GameObject.Find("SceneLoader SceneFader Image RegionName").GetComponent lt Text gt ().text regionName GameObject.Find("SceneLoader SceneFader Image RegionSubtext").GetComponent lt Text gt ().text regionSubtext yield return new WaitForSeconds(4f) SceneManager.LoadScene(sceneToLoad) GameObject.Find("SceneLoader SceneFader Image RegionName").GetComponent lt Text gt ().text regionName GameObject.Find("SceneLoader SceneFader Image RegionSubtext").GetComponent lt Text gt ().text regionSubtext GameObject.Find("Player").GetComponent lt PlayerMovementController gt ().spawnCharacterToLocation(spawnCoordinates) Now, this doesn't work as I'd expect it to. The first part runs perfectly fine The animation is started, the text is displayed and the scene changes. However, that's the part where everything breaks. As soon as the scene loads, there is no text. Also, the player position is not set to where it should be. I really do not know why, the only reason I could think of was that the script was called in the first scene, and therefore, the GameObject.Find() calls return the elements in that scene, not in the currently used one (actually, I'm fairly sure of that because GetInstanceID() returns the same for both calls). Now, the problem at this part is that I do not know how to make that work properly. One idea I had was to do try and fetch a new instance of the script with something like GameObject.Find("SceneLoader").GetComponent lt BaseSceneLoader gt () and work with that, but then I remembered I still need GameObject.Find() for this, which would probably yield the result of the old scene, so it's not helping at all. On top of that, I'm not even sure if that is the actual problem. I'm kinda out of ideas here. I also do not know what's the best practice in that situation, and I couldn't find anything meaningful on DDG either. Lastly, I've created a small video clip showing off the problem. I hope this helps in identifying the issue. https imgur.com a 1eS8rcG |
0 | Quixel asset to unity I downloaded asset from Quixel, I'm using Unity HDRP, the problem I am facing is how to properly create a mask map cause the asset from Quixel doesn't have metalness map where in HDRP mask map it requires channel R should be metalness map, and the base map requires RGB color and I've got diffuse map from the asset, to put diffuse map to the basemap slot the right way to do? I'm fairly new to the channel, so put it simple 1.How to pack channels for mask map if no metalness map in the asset, what to do with the empty channel 2.Is it right to put diffuse map to basemap slot? 3.What to do with the detail map in the maskmap , the same as to no metalness map provided in the asset. 4.Another question is heightmap, Unity provide pixsel mode and vertex mode, what is the consideration before choose the displacement mode, When I choose pixsel mode, the whole texture seems to be lowered down not the pixsel on the texture surface bumped or lowered down, it is the whole texture moved. Thanks for answering these! |
0 | custom mesh object orientation is not correct using I am making a custom mesh with the help of Traingulator script. At runtime, user can click and and generate a point then mesh creation start. Here is the way i am getting user input. void Update() RaycastHit hit Ray ray Camera.main.ScreenPointToRay(Input.mousePosition) if (Physics.Raycast(ray, out hit)) if (Input.GetMouseButtonDown(0)) GameObject sphere GameObject.CreatePrimitive(PrimitiveType.Sphere) sphere.transform.position hit.point sphere.transform.localScale new Vector3(0.2f, 0.2f, 0.2f) positions.Add(sphere.transform.position) positionsVector2.Add(new Vector2(sphere.transform.position.x, sphere.transform.position.z)) traingulatorTester.MeshMaker(positionsVector2.ToArray()) And here is the mesh maker function that calling tringulator public void MeshMaker(Vector2 vertices2D) Use the triangulator to get indices for creating triangles Triangulator tr new Triangulator(vertices2D) int indices tr.Triangulate() Create the Vector3 vertices Vector3 vertices new Vector3 vertices2D.Length for (int i 0 i lt vertices.Length i ) vertices i new Vector3(vertices2D i .x, vertices2D i .y, 0) Create the mesh Mesh msh new Mesh() msh.vertices vertices msh.triangles indices msh.RecalculateNormals() msh.RecalculateBounds() if (gameObject.GetComponent lt MeshRenderer gt () null) Set up game object with mesh gameObject.AddComponent(typeof(MeshRenderer)) filter gameObject.AddComponent(typeof(MeshFilter)) as MeshFilter filter.mesh msh Now the problem is the rotation of the custom mesh object is not correct look at this. Now I have manually set the rotation. |
0 | What are these yellow lines between toggles, and how do I turn them off in Unity? I don't understand what these faint yellow lines are and how to turn them off (see screen shot). I have created toggles from a prefab and to save time have been duplicating them and moving them. Unity chugs everytime I move a group of them, and I imagine it is because it is recalculating how to draw these lines. All of the toggles have lines between them. Send help! |
0 | Unity3D Rigidbody2D not colliding with BoxCollider2D In Unity3D (Version 5.3.1f1 Personal) I have a scene with a sprite with a Rigidbody2D and some sprites with a BoxCollider2D. The BoxColliders don't have the Is Trigger enabled and the RigidBody is not Kinematic, but they are not colliding. What am I doing wrong? |
0 | Destroy object copies? I want to know how to destroy object copies. public GameObject sparks void Update() void OnTriggerEnter(Collider bulletv) if (bulletv.gameObject.CompareTag("enemy")) Destroy(this.gameObject) Instantiate(sparks,transform.position,transform.rotation) destroy sparks copies after 2 seconds !!! |
0 | Trying to extract file icons and use as a sprite texture I'm trying to extract file icons from the files inside a folder (eg Program Files), and have them set as my Sprite's texture. I extracted the file icons, converted them to Bitmaps and then to byte array, and call the LoadImage(byte byte) function in my Sprite object. But when I test, the textures become the image belows. Any idea how to fix this? I just want to set my sprites texture as the extracted file icon, I'm creating something similar to a file explorer. this is the result that i get this is what I should get if I navigate to the notepad folder (eg "C Program Files(x86) Notepad ") this is my settings for the texture (supposedly, later being replaced with the extracted icons) Here's my code public UnityEngine.UI.Image targetImg public void Load(string directory) Icon icon System.Drawing.Icon.ExtractAssociatedIcon(directory) Bitmap bmp icon.ToBitmap() targetImg.sprite.texture.LoadImage(ImageToByte(bmp)) public static byte ImageToByte(Bitmap img) ImageConverter converter new ImageConverter() return (byte )converter.ConvertTo(img, typeof(byte )) |
0 | Show 3D elements on 2D background I'll make a navigation menu in my game and had the good idee to this the enemies to start games or go to the gun store. The problem is when I look in game mode, the enemy named ZomBear in hierarchy and gun are away. The ZomBear and the gun are 3D elements that I will show on a canvas named StartScreen in hierarchy. How Can I do that? (Click on image to see full size) Notes by the hierarchy Everything that begin whit Btn are button elements. StartScreen, PlayButtons and LevelButtons is a panel Gun and ZomBear are 3D elements form the Prefab folder. Here you have also a screen from aside |
0 | How to test for BoxCollider2D intersection in Unity? I have a Player object with a BoxCollider2D component and a Ladder object also with a BoxCollider2D component. Each object has a script, and in each script, I set up references to the box colliders in the normal way. public BoxCollider2D box collider void Start () box collider GetComponent lt BoxCollider2D gt () My player script is called "PlayerController", so that's the class defined in the script. In my Ladder's script I have the following void Update () GameObject player GameObject.Find("Player") PlayerController player controller player.GetComponent lt PlayerController gt () if (player controller.box collider.bounds.Intersects (box collider.bounds)) Debug.Log ("collision") else Debug.Log ("no collision") This script invariably returns "no collision" and I'm not sure why. Any ideas? |
0 | How to detect if a 2D object overlaps any other 2D objects I am programmatically placing 4 large dots on my 2D scene which already has some objects on it. If the new dot overlaps an existing object I want to destroy the existing object. All the objects have 2Dcolliders and all are on the same layer ( quot Action quot ). Since I only do this once during the initial setup of the game I don't want to use collision detection events, instead it would seem that Collider2D.OverlapCollider would be the way to do this but I can't get it to work. The following code is called from Start() after all the objects have been placed, and thinking it might be something to do with the colliders not being active until the first frames, I also called it from a mouse click with the same result (no overlaps). void EraseOverlapDots() GameObject largeDots GameObject.FindGameObjectsWithTag( quot LargeDot quot ) foreach(GameObject ldot in largeDots) Debug.Log( quot Object quot ldot.tag quot ( quot ldot.transform.position quot ) quot ) Collider2D collider ldot.gameObject.GetComponent lt Collider2D gt () ContactFilter2D contactFilter2D new ContactFilter2D() contactFilter2D.SetLayerMask(ldot.layer) contactFilter2D.useLayerMask true List lt Collider2D gt collisions new List lt Collider2D gt () int colCount collider.OverlapCollider(contactFilter2D, collisions) int i 0 foreach (Collider2D col2d in collisions) i Debug.Log( quot HIT quot i quot quot col2d.tag quot ( quot col2d.transform.position quot ) quot ) In an attempt to debug this I purposely put 4 small dots in exactly the same position as the large dots to ensure they overlap. When I run the game they are visibly exactly on top of each other but the result is always zero overlaps. |
0 | Cutout fragment shader pixels arent square It has been solved, link to the final shader Shader The problem (as portrayed by the image below) is that the pixels seem to be, for lack of a better word, cut off. I wish to either display a pixel, or not. My fragment function, it uses the red value of the vertex colors (displayed by the image blow) on the edge of the mesh which are assigned during mesh generation to determine the pixel cutout "weight" by multiplying it with the texture. fixed4 frag (v2f i) SV Target fixed4 tex tex2D( MainTex, i.uv) if (i.color.r tex.r gt 0.4f) discard return fixed4(tex.rgb clamp(i.color.r, 0.3f, 1.0f), 1.0f) |
0 | How do I stop gyroscope controlled camera from jittering when holding phone still? I have here a simplified version of my gyro controlled camera with a sensitivity modification (a side effect of increasing sensitivity is that the jitteriness is exacerbated). public class GyroControl MonoBehaviour private Transform rawGyroRotation Vector3 gyroAdjust SerializeField private float smoothing 0.1f void Start() Input.gyro.enabled true Application.targetFrameRate 60 rawGyroRotation new GameObject( quot GyroRaw quot ).transform rawGyroRotation.position transform.position rawGyroRotation.rotation transform.rotation private void Update() rawGyroRotation.rotation Input.gyro.attitude gyroAdjust rawGyroRotation.rotation.eulerAngles 2 increase rotation sensitivity transform.rotation Quaternion.Euler(gyroAdjust) transform.rotation Quaternion.Slerp(transform.rotation, rawGyroRotation.rotation, smoothing) When in motion, the jittering isn't noticeable. But when you hold the phone still, there's what I assume to be just analogue noise that causes jittering. I would really appreciate any help or advice on how to add a filter or something to reduce the jittering for this kind of controller. Thanks. |
0 | In Unity, how can I register a custom file type that is always opened with my game? I want my players to be able to create their own scenes as custom levels, save them as files (say custom1.gamelevel), and open them directly in my game program by double clicking the level file, rather than having to go through the steps of opening the game, browsing to the file in my menus, and then loading that scene level. I already have loading custom levels covered. I just need a way to associate this custom file type with my game which can open it. I am mainly interested in a Windows based solution. How can I do this? |
0 | Tilemap is sent to back disappears behind background when I go into play mode or save (video included) screencap of the problem here I'm sure this has a simple solution but I haven't found it answered yet. I have two tilemaps, one a BG and one a middle layer, and everything works when I paint on the middle layer. It shows up on top of the BG. But if I save the project or open play mode to test it, the middle layer disappears. Seems like it gets sent behind the BG tilemap but the order of the tilemaps hasn't changed. Also of note is that nothing changes even if I reorder the tilemaps, and the only way I can make the tilemap quot reappear quot is by ctrl z undoing my last action. At a loss, any takers? EDIT I just realized that my video capture didn't pick up my drop down menus, but I create a new tilemap at the bottom of the hierarchy, put some assets in it, then save the project (stuff disappears) and then undo (stuff reappears). |
0 | Two Points Rotating Around Circle? Currently I am working on a 2D game just like duet game, it is my first game (Unity 2D). When I press left key both points rotate fine. But when I press right, the points are not rotated. So my problem is why do both points rotated only in one direction Code public class TouchControll MonoBehaviour float movespeed 3 float angle 45 void Update() if (Input.GetKey(KeyCode.LeftArrow)) when i m press leftarrow both point should be rotate fine transform.Rotate(Vector3.forward Time.deltaTime Input.GetAxis("Horizontal") angle movespeed) Debug.Log("moveleft") if (Input.GetKey(KeyCode.RightArrow)) problem is here when i m press right arrow key both point are not rotated transform.Rotate(Vector3.forward Time.deltaTime Input.GetAxis("Vertical") angle movespeed) Debug.Log("moveright") Output create a empty gameobject first circle second circle |
0 | Raycasting on Z in 2D I'm making an isometric game in Unity. So far I have managed to render a diamond shaped board, with tiles that are aligned on the x and y axis (and the camera looks down the Z axis). I am spawning game objects for each tile with their own polygon collider and sprite renderer. I hope this is the correct way. They appear in front of each other naturally as you would expect them to in an isometric view. I want to make a raycast from the player and forward on the z axis, to hit the sprite right under him. As you can imagine, I run in to problems when I do that, I imagine it's because they are all on the same 0.0f on the Z axis. So my question is, does the raycast care about when a sprite is rendered in front of another, when it calculates what to hit, or is it just the physics engine handling this? And if so, how can I get around this? I guess I can translate the player coordinates to the board, but I just want to know how this works anyway. |
0 | Instantiate prefab as a type that inherits from MonoBehaviour I have a CeilingTile class. In this class, I have an InstantiateCeilingLamp() method, which instantiates from a CeilingLamp prefab. Here is the code protected void InstantiateCeilingLamp() Object ceilingLampPrefab AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) CeilingLamp ceilingLamp Instantiate(ceilingLampPrefab, this.transform.position, Quaternion.identity) as CeilingLamp if (ceilingLamp null) Debug.Log("Failed to instantiate the ceiling lamp.") return ceilingLamp.transform.SetParent(this.transform) prefabPath is a const string defined within the class. Stepping through my code using the debugger, I can see that ceilingLampPrefab is non null after executing AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) . However, Instantiate(...) as CeilingLamp returns null, because the instantiated prefab cannot be cast to the type CeilingLamp, which inherits from MonoBehaviour. How should I modify my code in order to instantiate a prefab as a type that inherits from MonoBehaviour? |
0 | The value of VSync on vSync Count in Unity In Unity, we can set the vSync value as "No sync" 0, "Every V Blank" (60 fps) 1 and "Every Second V Blank" (30 fps) 2. But in the Unity Quality Setting documentation , it's written the vSync count value must be either 0, 1, 2, 3, or 4. What is 3 and 4 ? You can set this vSync value on your code, the value must be either 0, 1, 2, 3, 4. But in Quality Setting in Unity, the option is only for No Sync, Every V Blank, and Every Second V Blank. So basically only for 0, 1, and 2. There's no option for 3,4. If we set the value on the code as 3 or 4, how should we set the value in Quality Setting Properties ? Because we need to choose a value other than No Sync for the vSync to work. How the vSync count in Properties and Code related if they accept different value ? |
0 | Unity Analytics I see custom events in funnels, but not in the Event Manager? I've just started using Unity Analytics, and I send two custom events level1Started and level2Started. After 1,5 days, the first results came in The funnels are working, so my custom events do reach Unity Analytics. But in Event Manager I can't see the mentioned events by themselves. 4 days already have passed, the funnel is updated every day, but the Event Manager is still empty. Or I'm looking at the wrong page? Then where can I see the raw number of events? Why? UPDATE For some reason, it took 12 days for them to show up in the Event Manager as well. Anyone knows why? UPDATE AGAIN Now it's gone again. Why? |
0 | The farther I move my character, the more its projectiles fire in the wrong direction I'm making a top down shooter, and the movement is working fine. However, I'm having trouble getting my Fire function to work correctly. When I run the game, it kind of fires in the right direction, but the more I move, the more off the shooting becomes. Anyone have any idea why? using System.Collections using System.Collections.Generic using UnityEngine public class PlayerMovement MonoBehaviour private float horizontalInput 0 private float verticalInput 0 public int movementSpeed 2 public int rotationSpeed 2 Rigidbody2D rb2d float coolDown 0 public Rigidbody2D bulletPrefab public float attackSpeed 0.5f public float bulletSpeed 500 public float yValue 1f Used to make it look like it's shot from the gun itself (offset) public float xValue 1f Same as above Start is called before the first frame update void Start() rb2d GetComponent lt Rigidbody2D gt () Update is called once per frame void FixedUpdate() MovePlayer() RotatePlayer() void Update() GetPlayerInput() Determines if the player can fire if (Time.time gt coolDown) if (Input.GetKeyDown(KeyCode.Space)) Fire() private void GetPlayerInput() horizontalInput Input.GetAxisRaw( quot Horizontal quot ) verticalInput Input.GetAxisRaw( quot Vertical quot ) public void MovePlayer() rb2d.velocity transform.right Mathf.Clamp01( verticalInput) movementSpeed private void RotatePlayer() float rotation horizontalInput rotationSpeed transform.Rotate(Vector3.forward rotation) private void Fire() Rigidbody2D bPrefab Instantiate(bulletPrefab, new Vector3(transform.position.x xValue, transform.position.y yValue, transform.position.z), transform.rotation) as Rigidbody2D bPrefab.GetComponent lt Rigidbody2D gt ().AddForce(transform.position bulletSpeed) coolDown Time.time attackSpeed |
0 | Learning to think like a programmer I'm pretty interested in game development and I've tried a couple of platforms and languages. Including libgdx and game maker studio, all without any real success. I'm currently using unity and it's the farthest I have ever gotten, but it just doesn't feel right. I follow tutorials and learn how to do certain things, but it just feels like I'm a parrot learning a new word I don't really understand what I'm doing just kind of memorizing stuff. I'm trying to become a good game developer, but I just don't know how to practice c in a way where I will gain actual understanding and not just memorize a bunch of syntax. Thanks in advance I really need help. |
0 | In Unity, does a reference delegate clear out when its parent GameObject is destroyed? If I have a GameObject with a component like some class SomeComponent MonoBehaviour System.Action DoStuff class SomeOtherComponentInAnotherGameObject public GameObject ObjectWithThatComponent void Start() ObjectWithThatComponent.GetComponent lt SomeComponent gt ().DoStuff SomeFunc Destroy(ObjectWithThatComponent) is there still a reference to SomeComponent somewhere? I'm getting some odd behaviour random crashing when deleting this stuff but I'm not sure if it's being caused by these delegates. |
0 | Ways to get around the limiting default terrain shaders in Unity I am trying to use the Toon Rim Light shader for Unity however there are a few problems when trying to use any custom shaders for a terrain in Unity. The most well known is of course, that all textures immediately become a blurry mess and ruins the look. The other issue is that all shading on the terrain ceases to be, and causes it to not cast shadows for both nature objects as well as characters. I have researched methods for circumventing this problem, however all sources for troubleshooting have been inadequate in providing enough details or steps in correcting the issue and I am left to turn here for a possible better breakdown of the processes and coding involved in achieving the effect that I desire. Thank you in advance, I appreciate any help. |
0 | Tweaking screen transitions not to fire every time in Unity I'm making a simple screen transition system for my game which consists of two states firing the right clips (one for the starting half od the transition animation, one for the ending one) and a condition between the end and start one which is set to true when user wants to change the level (so that the Start animation would fire in the previous animation and the End in the new one). This is cool and all but poses two problems firstly, the game starts with the End phase animation which looks a bit weird. Secondly, since the Restart button in the main game just reloads the level, it causes the End transition to fire every time too which looks weird and out of place. How would I go about tweaking the Animator so that the End phase only runs when I actually change the level as opposed to when starting the game or reloading the current scene? Maybe there's some way to pass some kind of a parameter when loading a new scene that I'm not aware of? This way, I could just pass a flag like shouldFireEndAnimation so that it does not fire when the game just starts or a level restarts? |
0 | Unity augmented reality app doesn't work on android I am pretty new to unity and augmented reality applications. I use unity 2019.4.4f1 and my project is very simple as you can see in the screenshot below I am using Wikitude plugin for image tracking and the image i am using as the marker is the Jack of Clubs card as you can see in the assets. The project works fine when i press play and use my laptop's webcam , but when i build the project for android (unity 2019 automatically uses Gradle to build the project) and install the .apk file in my android phone, all i see on my phone screen when i open the application is As you can see the phone camera doesn't work and it gets stuck in this screen. How should i fix it? Does it have to do something with Gradle? I haven't tried using unity version 2018 to build it using the quot Internal quot build option. Anyways that's just my own thought and i might be wrong, but the final question remains which is how this problem can be fixed? By the way i don't build the .apk file directly from the unity engine. I use the export option in unity to get a gradle project folder then i use that in Android Studio to build the final .apk file. The reason that i don't use unity to build .apk is that it gives errors and doesn't work for me so this is the solution i found for it. Update I debugged the application and it seems that the application needs camera permission to work, this is my debugging log 07 22 17 47 16.908 E Unity(32483) On Camera Error 07 22 17 47 16.908 E Unity(32483) Error Code 1000 07 22 17 47 16.908 E Unity(32483) Error Domain com.wikitude.camera.android 07 22 17 47 16.908 E Unity(32483) Error Message Permission denied. Make sure to have camera permissions before trying to access the camera. 07 22 17 47 16.908 E Unity(32483) 07 22 17 47 16.908 E Unity(32483) (Filename . Runtime Export Debug Debug.bindings.h Line 35) I'm pretty sure that it didn't ask for camera permission, how should i allow the permission if it's not asking? |
0 | My array loads in the wrong order I have a load all chapters script which loads up all the Chapter items in an array and instantiates the buttons in the Viewport so you can select which chapter you would like to play. The problem is the chapters load up in the wrong order, they load up as Chapter 4, Chapter 0, Chapter 1, Chapter 2, Chapter 3. Below is the code I am using. void Start() menuManager GetComponentInParent lt MainMenuManager gt () levelManager GetComponentInParent lt LevelManager gt () chapterArray Resources.LoadAll lt GameObject gt ("Chapters").OrderBy(go gt go.name).ToArray() txtStatus.text "" if (chapterArray null) txtStatus.text "Could not find Chapters" return else txtStatus.text "Loading..." FillChapterList() txtStatus.enabled false void FillChapterList() foreach (GameObject chapter in chapterArray) GameObject listChapter Instantiate(chapterListItemPrefab) listChapter.transform.SetParent(chapterListParent, false) ChapterListItem chapterListItem chapterListItemPrefab.GetComponent lt ChapterListItem gt () chapDetails chapter.GetComponentInChildren lt ChapterDetails gt () chapterListItem.Setup(chapDetails.chapterNumber,chapDetails.chapterName) This is not only happening with the Chapter Select, it has been happening with all the arrays I load up in this fashion. Below is the visual side of the problem where you can see it loads the last object First. I have been struggling with this for a while and I think its stopping me from progressing forward. Thank you for reading this and taking the time out of your day to help. |
0 | How to stop a host from the client script? I am developing a two player multiplayer game. Since its only two players, I don't want to keep my connection open if a player disconnects. Now this works well from the host side, through usage of StopHost(). If the player who hosts disconnects, it disconnects both the players from the game. But using StopHost() in the client(Player B) side does not remove the host player(Player A). In other words, the client is out of the game, but the host is still in the game. So, what I want is if one player(host or the client whoever it is) disconnects, I want both of them to be disconnected. So, how can I do it? Please help me with this. I have almost lost hope with UNET. Thanks EDIT My setup is like this, my LobbyManager comprises of UI elements like "TitlePanel", "MainPanel", etc. The Disconnect button is part of the title panel and gets enabled on press of Esc key. The button is linked to a script attached to the "TitlePanel". This script uses a MonoBehaviour which I changed to NetworkBehaviour in order to use Command . But it doesn't work as my "Title Panel" does not have a NetworkIdentity. Adding one creates even more problems So, I thought if there was a way to send mesages from client to server without NetworkBehaviour, then maybe I could send a flag there to the server. So is it possible? |
0 | Unity remove logo in splash screen Heavily related to this question, as of now, Unity's TOS has changed dramatically. And searching in the TOS, it looks like I'm allowed to remove the Unity logo in my exported game. Looking at Section 4.1, it still retains You will not remove, alter or obscure any copyright, trademark, service mark or other proprietary rights notices incorporated in or accompanying the Services. However looking at how "Services" is defined in the first paragraph of the TOS Unity Technologies ApS ( Unity , our or we ) provides game development and related software (the Software ), development related services (like Unity Analytics ( Developer Services )), and various Unity communities (like Unity Answers and and the Made with Unity Platform ( Communities )), provided through or in connection with our website, accessible at unity3d.com or unity.com (collectively, the Site ). Except to the extent you and Unity have executed a separate agreement, these terms and conditions exclusively govern your access to and use of the Software, Developer Services, Communities and Site (collectively, the Services ) It does not seem to include the exported game itself. And even if Section 4.1 says "accompanying the services", I assume it still wouldn't include the game as the game does not need to accompany them. Otherwise it would be illegal to remove the logo from the splash screen from a game made in Unity Pro since the TOS applies to all tiers of Unity. Furthermore, I haven't found anywhere that says you can't modify or hack into the produced executables (I even looked in here which contains another part of the TOS). Does this mean I can remove the logo from the splash screen no matter what Unity tier (personal, plus or pro) I'm using? (My aim is to actually move it to a dedicated credits section accessible from the title screen of the game rather than having it appear in the splash screen. Players of the game will still know that it's made in Unity.) |
0 | AR Foundation video player in Unity without Vuforia I am trying to follow this mini tutorial and I can detect an image and replace it with my 3D object. The object is an AR Session Origin tracked image prefab, but when I try to add a Video Player instead, nothing happens. I was using Unity 2019.2 and got an error when trying to put the video player on the object, then searched about it and Unity fixed that issue on 2019.3. I am now using 2019.3 and don't get the error anymore, but there is also nothing on the screen when the image is detected. |
0 | Monobehaviour script method does not appear as an option for UI button's On Click I have the following script, and when I try to use a UI button to call the CheckGuess method, it does not appear as an option using System using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class Guessthenumbergame MonoBehaviour public InputField input public Text infoText private int guessNumber private int userGuess Start is called before the first frame update void Start() guessNumber Random.Range(0, 100) Update is called once per frame public void CheckGuess() userGuess int.Parse(input.text) if (userGuess guessNumber) infoText.text "You guessed the number right" else if (userGuess gt guessNumber) infoText.text "Your number is higher" else if (userGuess lt guessNumber) infoText.text "Your number is lower" input.text "" |
0 | How to cache the main camera as a global variable? I want to create a utility class that will, among other things, return a cached reference to the main camera. Is the below code correct? My concern is that I'm doing it wrong and that FindGameObjectWithTag is being called each and every time the getter is referenced. using UnityEngine public static class Utils public static Camera MainCamera get Camera.main |
0 | Rotating a parent rectangle to align child with target My beautiful drawings will explain better than many words (or at least I hope) The structure The black rectangle is a GameObject (my weapon sprite). A and B are also GameObjects (children of black rectangle) StartShotPoint and ShotPoint used for the direction of my projectile. C is the first hypothetical target In this situation my sprite will be rotate of 0 degree. In this second image there is the question. I want to find the rotation of my sprite ( 10 degree in the example) knowing the Vector2 destination D and of course all the coordinates of the 3 GameObjects. The situation is simple as long as the player rotates the weapon, but in this case is the AI (after finding the player at the point D) must turn the weapon in the right direction. I know how to find the direction between one point and another, but between two decentralized points and a third one messed up my brain. I really don't know which "direction" to take. Thanks for your help. |
0 | Why do I need offset on my camera? So I've been away from Unity and game development in general for a bit, so I'm working through Unity's UFO Tutorial and had a question about the camera set up. I don't understand why you need the offset for it? It follows the Player object directly it seems, and they use a Vector3? But it's a 2D game, so why not just use a Vector2? I was experimenting with the code just to see if I could figure it out, so I removed the offset variable completely but then when I ran the game it just showed a blank space in the game view. Any body who can help me understand this? public class CompleteCameraController MonoBehaviour public GameObject player Public variable to store a reference to the player game object private Vector3 offset Private variable to store the offset distance between the player and camera Use this for initialization void Start () 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 LateUpdate is called after Update each frame void LateUpdate () Set the position of the camera's transform to be the same as the player's, but offset by the calculated offset distance. transform.position player.transform.position offset |
0 | Unity3D different object with the same mesh imported from Blender I would like to instantiate different objects (i.e. poker chips with different values) that actually share the same mesh imported from blender. To this end I have copied the assets and changed the texture but all the assets automatically switch to the last texture I choose as they are actually the same entity. What am i doing wrong? |
0 | Why isn't OnCollisionEnter2D working? I've made a hole. I have animals tagged as animals. When an animal walks into the hole, they disappear. I tried OnTriggerEnter2D() as well, and set the collider to isTrigger, but it still didn't work. I can get it to work without the tag part, but anything that bumps into each other sets each other to inactive. public class BlackHole MonoBehaviour void OnCollisionEnter2D(Collision2D other) if (other.gameObject.tag "animal") other.gameObject.SetActive(false) |
0 | Get MouseUp event outside of Sceneview scene window? So I have an editor script that uses a dragging operation which works quite nicely. Except, if you release the button while OUTSIDE the Scene Window, the event doesn't register. How do I detect mouseup outside of the scene window? private static void OnScene(SceneView sceneview) Event e Event.current if (e.type EventType.MouseDrag) do some drag stuff e.Use() if (e.type EventType.MouseUp amp amp e.button 1) is the Right Mouse button released? I suspect somehow it's due to my Event e being inside the OnScene making the mouse actions only existing in the context of the Scene Window perhaps? I have no idea, very new to Editor scripting... |
0 | In Unity3D, how can I improve image clarity? The same images that appear clearly in Adobe Flash appear blurry in Unity. My game uses quads, cubes and sprites. I've tried the game on Android, iPhone, Mac and PC, but the image appears poor quality on all of them. A sample screenshot What can I do about this? |
0 | Jump when the screen is tapped, rather than when the space key is pressed I am trying to make my character jump when the player taps the screen. At the moment it jumps when I press space bar, but how can I change the code to make him jump when the screen is tapped? This code works as the character then jumps up void Update() if (Input.GetKeyDown(KeyCode.Space)) rb.gravityScale 1 This code using touch does not work the character just stays where he is when I click the screen on my computer. public void Update() if (Input.touchCount gt 0) Touch touch Input.GetTouch(0) rb.gravityScale 1 |
0 | Can I add rigging bones to a model imported from Blender inside Unity? I created a model in Blender but recently I stumbled upon a video claiming that you can add rigging to a model in Unity. So instead of rigging in Blender, is it possible to do it in Unity? |
0 | Scaling a UI bar for progress in Unity I have created a progress bar inside Unity for one of my energy systems. The bar progression works fine. Its just a plane pivoted on one of the faces so scaling it in x axis makes it progress further as seen in the image below Now I am trying to implement a feature where when the bar stops progressing I would want to show a red bar indicating that it has stopped like in the image below To implement this I would need to know somehow that the bar has stopped scaling and not progressing any further so that I can put the red bar at the position where it stops scaling. But how do I know when the yellow progress bar stops progressing as its position stays the same throughout and its just scaling in the x direction. I hope my question makes sense. Please help me out if it does. Thanks ) |
0 | Get the tile in unity tile map I am trying to get the sprite of a tile in unity from where a raycast hits. Right now it only works in some cases, and always in positive x. This is my current code. Vector3Int LocalPos new Vector3Int((int)hit.point.x, (int)hit.point.y,0) Sprite spr tilemap.GetSprite(LocalPos) From what I can tell it gets the correct sprite. Edit I removed pointless code |
0 | Unity Custom aspect ratio in build I have made a game that was supposed to be for mobile but now I need to build it for PC. I want the aspect ratio to be 2 3 but as you can see on the image that doesn't exist. How do I add a custom aspect ratio for the build? |
0 | Peer to peer Multiplayer Game I built a casual game where the user answer the right word in random question. Now I want to make this game multiplayer (4 players) working on smartphones and tablets (Androird amp iOS) where all the players are clients but one of them is Host Client who receives the in game answers to check who won and answer back to the other three players (Clients) with the score. However, I'm confused about HLAPI, LLAPI, dedicate server, PUN, Standalone, Local, LAN... I'm a mess right now. What should I choose? having on mind I only send receive strings, and the game should work with and without Wi Fi connection. |
0 | Unity, NavMeshAgent SetDestination acts funny I had a scene set as the following picture. And a NavMesh baked as the following picture. But my "player" (The left bottom corner sphere) don't go where I want it want to go! Test vedio Source Codes public Camera cam public NavMeshAgent agent public GameObject particle Update is called once per frame private void Start() particle.GetComponent lt Renderer gt ().material.color Color.red void Update () if (Input.GetMouseButtonDown(0)) Ray ray cam.ScreenPointToRay(Input.mousePosition) RaycastHit hit if(Physics.Raycast(ray,out hit)) Vector3 v hit.point agent.SetDestination(v) Instantiate(particle,v,transform.rotation) Could somebody please help me out!? Much appreciated!!! PS. I found out through my "particle" that after first few hits, the "hit position" starts to "float"! That's why my "particle" became bigger! It doesn't "hit" the plane no more! It always hit at somewhere above the plane! That's why my "player" can NOT go to the destination! Could somebody teach me how to fix it please! Much appreciated! |
0 | Why the points List and the agents List are empty in the WaypointsAI script? I created a class for the points and agents using System.Collections using System.Collections.Generic using UnityEngine using System.Linq using System using UnityEngine.AI Serializable public class WaypointsClass public List lt Transform gt points new List lt Transform gt () public List lt NavMeshAgent gt agents new List lt NavMeshAgent gt () Then created a script that find waypoints and add them to the points list and agent s to the agents list using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.AI public class RedWaypoints MonoBehaviour public GameObject redWaypoints public NavMeshAgent redAgent private void Awake() redWaypoints GameObject.FindGameObjectsWithTag("Red Waypoint") WaypointsClass wpc new WaypointsClass() foreach (GameObject point in redWaypoints) wpc.points.Add(point.transform) wpc.agents.Add(redAgent) Start is called before the first frame update void Start() Update is called once per frame void Update() In the end the WaypointsAI script using System.Collections using System.Collections.Generic using UnityEngine public class WaypointsAI MonoBehaviour public WaypointsClass waypoints public float distanceToContinue private float currentDistanceToPoint private int lastPointIndex private int goalPointIndex void Start() Firstly check if the waypoints are set up correctly if (waypoints.points.Count lt 1) Debug.LogError("Set up the waypoints for this gameObject!") else Now set up the path lastPointIndex 0 Start from the index 0 waypoints.agents 0 .transform.position waypoints.points 0 .position if (waypoints.points.Count gt 1) goalPointIndex 1 Go to the 1 waypoint else goalPointIndex 0 void FixedUpdate() for (int i 0 i lt waypoints.agents.Count i ) Calculate the distance and check if it should move to the next waypoint. currentDistanceToPoint Vector3.Distance(waypoints.agents i .transform.position, waypoints.points goalPointIndex .position) if (currentDistanceToPoint lt distanceToContinue) Save the old index, totally useless in this implementation though lastPointIndex goalPointIndex Increase goal index to change the goal waypoint to the next, (Or maybe random one?) goalPointIndex if (goalPointIndex gt waypoints.points.Count) goalPointIndex 0 Now move towards the current waypoint, Change this to fit your code with navMesh anyway I think I did a lot for you anyway waypoints.agents i .transform.LookAt(waypoints.points goalPointIndex .position) waypoints.agents i .transform.Translate(Vector3.forward Time.deltaTime 10) The problem is that in the first line in the WaypointsAI script the points List is empty if (waypoints.points.Count lt 1) points is empty. How can I resolve it ? |
0 | Add 1 to a PlayerPref float if a day has passed in Unity 2D I'm making a daily rewards system in my Unity 2D game. For each real life day the user logs in (not necessarily consecutive) the player earns a Reward Point. Reward Points do two things Increase the rarity of what the player may obtain from Reward Chests. Increase the frequency that a player may open a Reward Chest. The frequency starts at 24 hours, and for each Reward Point, it is decreased by 24 hours. (The frequency a player earns a Reward Point is not increased, just the frequency that the player can open a chest.) I am asking how to check if a day has passed since the player last opened the game, and, if they have, add 1 to a PlayerPrefs float (this float contains the amount of Reward Points). I am familiar with Time, but I'm not sure how to accomplish my goal with it. . |
0 | Why is ScreenToWorldPoint always giving same coordinates with mouse position? Whenever I use ScreenToWorldPoint(Input.mousePosition) and display the output in console this always gives me the same coordinates. MyCode Vector3 screenToWorld void Update() screenToWorld Camera.main.ScreenToWorldPoint(Input.mousePosition) Debug.Log(screenToWorld) |
0 | How to know the size of object in Unity in world units? Suppose I have some external package with objects. Suppose I place some of these object to the scene. Now how to know actual size of object in world units? I found no any rulers or something in Unity. The I thought I can place primitive cube and compare it, but then I realized that I don't know the size of cube too. Is is possible to "measure" arbitrary object in Unity somehow? |
0 | How to manage collision of two player ? I'm developing a multi player car game. Suppose that car A hit car B both A and B have Rigidbody and collision functions attached. Because car A hit car B i want to take actions only to car A (add or remove point) but not to B. So i need to identify that car A is 'hit' (with guilty ) car B that has no 'guilty'. Can you suggest me how to do ? |
0 | How to block the player from moving left and right from two empty game objects? I made the game space shooter in that game my spaceship move left and right but its not stop in right and left corner. When its move to left its go out of the screen. how i stop block in the left and right screen edges. using UnityEngine using System.Collections public class PlayerMovement MonoBehaviour public float speedMove 3 public float bonusTime private Rigidbody rb private float limit 3 1 for right and 1 for left. private float direction 1 You can call it as speed private float speed 0.01f private bool toLeft false private bool toRight false public GameObject shield public GUIText bonustimeText private bool counting true private float counter private Weapon addWeapons public Sprite strongShip public Sprite normalSprite public Sprite shieldSprite private SpriteRenderer sRender private Weapon weaponScript void Start () counter bonusTime rb GetComponent lt Rigidbody gt () sRender GetComponent lt SpriteRenderer gt () addWeapons GetComponentsInChildren lt Weapon gt () foreach (Weapon addWeapon in addWeapons) addWeapon.enabled false weaponScript GetComponent lt Weapon gt () weaponScript.enabled true Update is called once per frame void Update () transform.position Vector3.MoveTowards (transform.position,new Vector3 (transform.position.x direction, transform.position.y, transform.position.z), speed) if (Input.GetMouseButtonDown (0)) direction 1 void OnCollisionEnter2D(Collision2D coll) if (coll.gameObject.tag "StrongMode") Destroy (coll.gameObject) counting true StrongMode() Invoke ("Downgrade", bonusTime) if (coll.gameObject.tag "ShieldMode") Destroy (coll.gameObject) counting true ShieldMode() Invoke("Downgrade", bonusTime) if (coll.gameObject.tag "Life") GUIHealth gui GameObject.Find ("GUI").GetComponent lt GUIHealth gt () gui.AddHealth() SendMessage("AddHp") SoundHelper.instanceSound.PickUpSound() Destroy(coll.gameObject) if (coll.gameObject.tag "Enemy") SendMessage("Dead") void Downgrade() SoundHelper.instanceSound.BonusDownSound () counting false bonustimeText.text "" counter bonusTime sRender.sprite normalSprite weaponScript.enabled true foreach (Weapon addWeapon in addWeapons) addWeapon.enabled false weaponScript.enabled true shield.SetActive (false) void StrongMode() SoundHelper.instanceSound.BonusUpSound () sRender.sprite strongShip foreach (Weapon addWeapon in addWeapons) addWeapon.enabled true weaponScript.enabled false void ShieldMode() SoundHelper.instanceSound.BonusUpSound () sRender.sprite shieldSprite shield.SetActive (true) void OnDestroy() bonustimeText.text "" |
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 |
0 | Using Unity and MonoBehavior for UI only? I've made a turn based game (think xcom) in Unity, and because I don't need real time, asynchronous elements, or physics calculations I decided to make a pure c Model (in the sense of Model, View, Controller) which everything is based on. I use Unity and a MonoBehavior based game loop to handle rendering, camera, UI and input, but stuff like a character attacking another and then calculating a counterattack, or player equipment and spells, are all pure c . Am I missing some capabilities of Unity that I should be looking at or is this a basically reasonable approach? |
0 | How to create 3D area mask? I have two cubes, one parent and one child. I want to use the parent's cube mesh as a mask for the child cube. I want to make visible only the part of the child cube that it is inside the parent cube. I can easily achieve this effect with 2D sprites using the Sprite Mask, but I can't find a way to do it for 3D areas or 3D objects. What I have What I want |
0 | Can I export animated models from Unity? Into what formats? I have an animated 3D model from the Unity Asset Store that I would like a new animator to touch up (the license allows this). But they need it in a format they can use (in Maya or... something else?). All I have been able to find so far is how to export from the Editor into Unity Package format scripts to export the mesh (only?) into OBJ format 1 Is it possible to export a textured and rigged model from Unity? If so, into what formats and how? 1 ObjExporter and ExportOBJ |
0 | Could a Peer To Peer network architecture be good for my fighting game I am looking forward to developing a 2D spaceship fighting, brawler game and I have so many ideas about it. I am going to make a single player component anyway, but the core of this game would certainly be its multiplayer. For this game, I was inspired by Brawlhalla and its dynamic play style. In my game, there has to be real time action features such as attack, dodge, getting hit, killed, so a reliable networking needs to exist. I have thought initially about a client server architecture, but a peer to peer connection would be in my opinion more easily for me to implement. I have read this article and it proves encouraging for me to go on with this simulation solution. Let me describe my concept A client initializes a room and using sockets, IP, port and the other players would after connect to him. Therefore, there is always a Master Client that handles the new connections and gives signal to other clients about a new existing player. Then, as the game is running, the byte data packets would stream each player's input, his position, his ship rotation, his ship status and so on, so that each of the other clients could run a perfect simulation of the initial client. In other words, this data packets would trigger all the actions on each client. As network protocol, I am thinking about TCP IP and should someone be willing explain to me in more practical terms the difference between this and UDP, I would be thankful. I have even computed how much data it would take to transmit over a second assuming a byte 256 array that holds all the data at one time multiplied by the number of calls per second (about 32 times) multiplied by the number of clients the data should be broadcasted to (3 4) results in about 32 kb s. It might be a dummy result, i might have left a lot of things out, but again, I am ready to learn. As a note, I do not intend to make at this moment a professional multiplayer system, but rather, I would like to learn more about this programming part of applications and I think this is a very good project idea to enhance my skills. Of course, I am opened to any advanced tips, solutions, materials and should I add anything else about my concept, please let me know. How is my theoretical model so far? |
0 | Measure the length of the platform in Unity I created a platform in Unity. It consists of an empty parent object and child objects. Child object have attached components Sprite renderer and Edge collider 2D. How could I get the length and height of such a platform? By the length and height in the case I mean the respective measures in x and y axis. |
0 | Character falls through the Platform Effector 2D in Unity. How can I fix it? Character falls through the Platform Effector 2D in Unity. How can I fix it? Here is the demonstration https imgur.com G5YkTxa. I tried changing the Edit Project Settings... Physics 2D Default Contact Offset from the current 0.01 value to the 0.1 value. The result is the same and here is the demonstration of it https imgur.com 3TAOsNY. Here are my settings for the platform Here are my settings for the character's RigidBody 2D Here is what character colliders look like when my character runs https imgur.com CTialU3. I basically run the recorded inside Unity animation of running and move my character with the help of the private void FixedUpdate() ... some code which computes the velocity vector depending on the input (the pressed buttons) characterRigidBody2D.velocity velocityVector I googled for a while now similar issues, but was not able to find a solution. I want to avoid the character falling down randomly during running. |
0 | Where should my 3D character's pivot anchor be? I created a 3d character with some animations a month ago and when testing the character in my game, I notice there are some weird interactions with the scenery that have me worried, particularly when climbing slopes and jumping over ledges. My character is a humanoid biped and his pivot point is his pelvis (it was the first bone I made for the armature in Blender). Should I have moved the pivot to the bottom of his feet? Does it matter? My character does NOT use "use root transform" in Unity He was animated "in place" in Blender and forces move him around (including jump trajectories) in Unity |