Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

New answers tagged

0 votes

Changing the target of a button that takes a gameobject as a parameter

Have a variable on the context menu or a selection manager that stores what object was right-clicked. Set that variable when you run the code that shows the context menu. When searching, don't call ...
user avatar
  • 113k
1 vote

UI quality drops when changing canvas resolution in Unity

The lower quality you're observing is due to texture sampling artifacts. The sprite's texture stores what colour each pixel should be when the sprite is displayed at exactly its original size. When ...
user avatar
  • 113k
2 votes
Accepted

Possible to have Composite Collider 2D detect colliders in grandchildren?

Is it possible to have a Composite Collider (or some other collider aggregator) pick up the colliders for not only child nodes but also grandchildren nodes? Yes, the CompositeCollider2D component ...
user avatar
  • 76
2 votes

Unity 2d Sprite Swap Help

If I understand your problem correctly, you are trying to reskin your character with different visuals. In that case, using the Sprite Library Asset is a good choice because it will allow you to ...
user avatar
  • 76
1 vote

Rotate an object relative to the player to face another object

The relative distance between the shield and the player is a fixed length instead of a fixed offset. Record this fixed length and calculate the position according to the rotation. ...
user avatar
  • 721
0 votes

Tilemaps not showing up on Android build

I found your post a bit late but this might help some others. I was in the same situation, working fine on Simulator but not on device. Turns-out it was a silly Z position problem due to the different ...
user avatar
1 vote

Implement the snake movement in unity

I found a solution that uses backtracking. It records the snake route every frame, and the bodies trace the route back to find their property position. ...
user avatar
  • 11
2 votes

How do I convert 2d character rigging animation to frame by frame sprite animation?

There are no built-in tools to do that I'm afraid. I've made this simple tool to do this kind of export automatically. Hope you'll find it helpful!
user avatar
  • 76
0 votes

Unity3d - How to freeze a Animation in the Editor

This workflow isn't well supported in Unity even in the most recent versions (as of 2022) as the other answers say but there are some tools on the Unity Asset Store that may be-able to help you. For ...
user avatar
0 votes

Sprite with transparency: Create box collider (ignoring transparent area)

I would recommend using photoshop PSB importer package. You design your sprites in photoshop/illustrator, position them properly there, and when imported into unity, the resulting sprites will be ...
user avatar
  • 514
2 votes
Accepted

How do I detect if a player is touching the empty screen in Unity?

The quick way for rapid prototyping would be to simply have an object that can react on clicks as well on your background. Just because the user thinks the background is empty does not mean you can't ...
user avatar
  • 2,305
1 vote

If I have a number of nested GameObjects tagged with a particular phrase, how can I select the tagged GameObject one level above the bottommost child?

Instead of a tag, I'd use a marker component, something like this: ...
user avatar
  • 113k
2 votes
Accepted

Unity tilemap WorldToCell returns floored world position

PointerEcentData.position is a screen position rather than a world position. See EventSystems.PointerEventData-position : The position value is window-based. This ...
user avatar
  • 721
0 votes

How to make a Class of Clans style tilemap projection in Unity?

Try increasing the the aniso level in texture settings. Also check your graphics quality settings as it might have Anisotropic texture disabled.
user avatar
0 votes

How to set the UVs of a procedurally generated road mesh?

For the u coordinate - set it to be 0 for every vertex on the left boundary and 1 for every vertex on the right boundary. For the v coordinate - measure the distance along the boundary. So start with ...
user avatar
0 votes

How to remove Black screen and to properly play a portrait video in Unity

Actually I found a quick fix for this problem. I adjusted the left and right values of the raw image to some negative value
user avatar
1 vote

Listening for a Custom Trigger in a Preset (that will be instantiated in the scene)

I have a Preset that is listening for a Custom Event sent from the GameObject known as Magnet. You can find the parameter description when creating a new node. This GameObject parameter is the target ...
user avatar
  • 721
1 vote
Accepted

How to get selected value in a dropdown

This is really simple, all you need is to access the .value field of the dropdown. This gives you the index that is selected (starting at 0). So for a dropdown with ...
user avatar
  • 2,305
0 votes
Accepted

Why do my image sprites only change after closing the run, instead of when I start the game?

It looks to me like you want something more like this: ...
user avatar
  • 113k
0 votes

Unity HDRP Emissions - When setting over 1 nit, blue becomes progressively more purple

In the sky and fog volume object, add an exposure override if it doesn't already exist. In the exposure override, set sane min and max limits and mode to automatic histogram. Hope this helps anyone ...
user avatar
1 vote
Accepted

"There is no Camera attached to the Game Object" error

I had moved my Visual Scripting code from Embedded (in the GameObject) to Graph. By making it a separate Graph file, I had hoped that multiple GameObjects could use the same code. But when I moved the ...
user avatar
  • 115
1 vote

"There is no Camera attached to the Game Object" error

I suspect that it is the Camera which got untagged: for automatic code (Camera camera = camera.main; OR here visual scripting), it needs to be tagged. In the editor, select the camera, scroll down the ...
user avatar
1 vote
Accepted

How do i make my game object goes to that specific direction after it bounces off a collision and not behave erratically?

It sounds like you just want to bend the velocity to aim at a specific position, not add a force. So, don't add a force, just set the velocity. ...
user avatar
  • 113k
0 votes

"There is no Camera attached to the Game Object" error

Reason: Your script is trying to get the camera component from a Game object but is unable to find it. Solution: Inspect that the correct game object is assigned from which you want to access the ...
user avatar
0 votes

How do I detect if a player is touching the empty screen in Unity?

Just set a boolean clickedMe in OnMouseDown if this object was the one clicked on. If you get to ...
user avatar
  • 113k
0 votes

how to have player stay on a rotating platform?

On contact with the platform's trigger collide, store a reference to the platform and your position relative to the platform's coordinate system. The next time you move, transform that local position ...
user avatar
  • 113k
2 votes
Accepted

How do I fix missing anti-aliasing in the Unity scene view and game?

The Unity editor doesn't perform anti-aliasing directly any more, unfortunately. You're expected to add it as a Post Processing effect via the Post Processing stack (see https://docs.unity3d.com/...
user avatar
  • 36
1 vote

Is it possible to move Overlay Canvas away from (0,0,0) in the Scene View?

Turns out it's not possible. I just created a workaround using the magical Layers menu in Unity (I had no idea such a thing exists): ...
user avatar
  • 2,502
1 vote

How can I deal with tilemap position in the editor?

You can use this gizmo. It looks like this. More info in this tweet. Basically, what it does is draw the axes' cordinates of a selected Grid or Tilemap component. When zoomed in enough it draws the ...
user avatar
  • 11
1 vote
Accepted

bind mixamo bone to unity

In order to implement a Mixamo animation in Unity, you can use the auto-rigging from Unity, if you don't know how to skin animation to the mesh. You'll have to follow the next steps. Mixamo Download ...
user avatar
  • 26
0 votes

Unity asking to enter Safe Mode?

Your best bet is to make a new project open it in unity. Close unity and copy the asset folder over to the new project and then reopen unity and let it process each asset again. Then resetup your ...
user avatar
1 vote

Is it possible to move Overlay Canvas away from (0,0,0) in the Scene View?

No. It’s locked to the camera as that’s the function of screen space overlay. Create a child rectransform and use that rather as you can change its position.
user avatar
0 votes

Unity - Apply different Near/Far clip plane value for different layer

You can use Camera.layerCullDistances (https://docs.unity3d.com/ScriptReference/Camera-layerCullDistances.html) to control per layer farclip plane
user avatar
  • 1
1 vote
Accepted

Cloud based fog of war

Thanks to Mangata for finding this tutorial. It was exactly what I was looking for. Using a small hexagonal tile I made in blender, I followed the tutorial to create the shader in ShaderGraph. In game,...
user avatar
3 votes
Accepted

Random value is chosen 2-3 times, then after that it's always 1

The problem is these two lines: int ggg = Random.Range(1, numberOfChildrenInLevel); numberOfChildrenInLevel = ggg; Each time you run your function, the range that ...
user avatar
  • 2,305
1 vote

How to create a 2d array in Unity using Visual Scripting?

You can do this by making your own class. ...
user avatar
  • 113k
1 vote

How can I rotate the game stage?

Did you consider to leave the scene as it is and simply rotate the camera by 90°?
user avatar
  • 111k
1 vote
Accepted

Pathfinding over network and local avoidance

Unfortunately syncing between games is an extremely complicated problem. There is no simple solution. There are literally entire books on this subject. The usual solution is to have the server sync ...
user avatar
0 votes

Passing a string as argument to Unity Job System

Original code does not copy data from a string to a native array of bytes. First we need to copy String data to byte[], and then pass it back to a job, like this : <...
user avatar
0 votes

How do I check for nulls when called an event from another script?

The same way you check for nulls for literally anything else. ...
user avatar
  • 113k
0 votes

Preventing other animations from resetting when a new animation starts playing

Separating the scripts/controllers for all animations finally resolved the bugs. It seems that the animations interfere with each-other when they're manipulated using a shared script/controller.
user avatar
0 votes

How do I check for nulls when called an event from another script?

Create a class where you store all the boss references. Let's call it BossSpawnManager Then cache it in your script and use it ...
user avatar
0 votes

Best practices for mirroring actions of a humanoid rig?

Counter-Strike is the only game I can think of that made an effort to support holding weapons left handed; they went for the simplest solution and simply mirrored the right-handed models. This ...
user avatar
  • 3,405
1 vote
Accepted

How to detect long press on object using Unity EnhancedTouch?

A couple of notes: Unless you specifically want to check that the user keeps their finger on the desired object at all times, I would probably only check at the beginning of the touch, as well as the ...
user avatar
  • 586
5 votes

Why use Animator.StringToHash?

This has to do with the speed of looking up data. When you want to assign a new value to a parameter on an animator, Unity has to find where that parameter sits in memory, to be able to put the new ...
user avatar
  • 113k
0 votes
Accepted

Unity mobile joystick input doesn't react to touch

You have no input modules attached to your Event System. That means you have the central router for directing events to game objects, but you're missing the parts that actually receive input events ...
user avatar
  • 113k
0 votes

Sticking the Rigidbody2D player to a moving platform without parenting & transform fiddling

I attached this script to the player and it worked for me
user avatar
0 votes
Accepted

Centralized Event System with arbitrary number of parameters of arbitrary types

I'd say you're correct to have concerns about the code you've shown. Passing arguments through an params object[] will cause a memory allocation for the array, as ...
user avatar
  • 113k
1 vote

Configurable Joint rotation doesn't seem to respect mass difference

Well, turns out the answer was pretty simple: Colliders Colliders are present by default on the Cube primitive, but I'd been deleting them because I don't need/want collision detection. Since I'm ...
user avatar
1 vote

Applying upgrades to pickups that do different things

Here's a strategy you could try: ...
user avatar
  • 113k

Top 50 recent answers are included