New answers tagged

0 votes

How to use Unity ECS without URP or HDRP?

URP or HDRP isn't necessary to run Unity ECS. However, to render an entity, you require the Entity Graphics package, which doesn't function on the Built-in Render Pipeline. In fact, an entity isn't ...
Muhammad Faizan Khan's user avatar
0 votes

is it possible to render world space canvas over other objects in unity?

I would solve this by using a "camera stack". Two cameras in the same position and with the same settings, except for their culling masks, clear flags and depth. First, make sure that the ...
Philipp's user avatar
  • 119k
0 votes

how can I distance camera according to player speed?

Use SmoothDamp, very similar to what you are currently doing with the Y axis. ...
Kevin's user avatar
  • 5,734
1 vote
Accepted

Why doesn't Coroutine work the way I want with if blocks?

Your array TotemKoruyanlar has only 2 elements, but your loop tries to access 7. This will cause an array index out of range exception and stop the coroutine from ...
Paul's user avatar
  • 131
2 votes
Accepted

Chain cutting swipe input skips over chains

You are currently experiencing a form of tunnelling. You are checking if touch coordinates move through the Collider's boundaries inwards (outside-inside) or ...
liggiorgio's user avatar
  • 4,716
0 votes
Accepted

How to make camera follow player on Y+ axis only

I'd do this in LateUpdate to ensure the camera moves after the player, as liggiorgio suggests. This avoids judder where we smoothly follow the player but then the ...
DMGregory's user avatar
  • 134k
0 votes

How to make camera follow player on Y+ axis only

If the camera and the player were independent GameObjects, a viable strategy would be: Update the player's position first. Update the camera's position last. The ...
liggiorgio's user avatar
  • 4,716
0 votes

How to make camera follow player on Y+ axis only

2d? You could do: ...
CheckerT's user avatar
0 votes

How to mouse click an object in scene view to select it from editor

Just because your request sounds like an issue I had early on, if you're trying to click on a particular piece, and you instead get a larger part (say, you're trying to select part of a wall, but it ...
Sean Duggan's user avatar
1 vote

How do I check if a GameObject is touching another GameObject in Unity?

ONLY FOR 2D: If you want to detect the mouse clicking on an object, you could use OnMouseDown and OnMouseUp. ...
CheckerT's user avatar
1 vote

How to mouse click an object in scene view to select it from editor

Also you could draw a completely transparent box in gizmos to make the object selectable as well: ...
Slava Cherkasov's user avatar
0 votes
Accepted

Image over everything Unity

As you can read in the documentation: Draw order of elements UI elements in the Canvas are drawn in the same order they appear in the Hierarchy. The first child is drawn first, the second child next, ...
Philipp's user avatar
  • 119k
3 votes
Accepted

How do I check if a GameObject is touching another GameObject in Unity?

In order for an object to be detectable by the collision detection system of the engine, it needs a collider component. There are both 2d and 3d colliders that come in different shapes. So you need to ...
Philipp's user avatar
  • 119k
1 vote

Why are all materials pink in my Unity URP project?

I followed all the steps above and only ran into trouble with upgrading materials. I'm using Unity 2022.3.18f1 and found the final step to upgrade materials is actually now: *select materials Edit>...
banjo_frette's user avatar
3 votes

I need multiple custom game objects to stick to a parent object

Say you have two GameObjects p and c. You can make c a child of ...
Kevin's user avatar
  • 5,734
0 votes

Splatoon like gun in Unity

You would use a textured plane mesh, not a quad. You could use a large plane mesh with a single large texture which you update parts of in CPU-side code (this can be done in Unity). Temporary decals ...
Engineer's user avatar
  • 29.5k
0 votes

Splatoon like gun in Unity

Fun fact, this technique is older than Splatoon, it is present in Super Mario sunshine. You will need an extra texture over the entire paintable battle field. Then on collision of a pain splat you can ...
ratchet freak's user avatar
0 votes

Add round edges to heptagon shaped image with fill in Unity

Shader Solution Outline I don't think there's any built-in that would do this without writing your own shader-code. The chain of effects that you want to apply are: Start with an image where the ...
Tim C's user avatar
  • 410
0 votes

Add round edges to heptagon shaped image with fill in Unity

Ended up creating this shape with line renderer and used script from this video to help me animate it: https://www.youtube.com/watch?v=RMM3BAick4I&ab_channel=HamzaHerbou ...
Ivan's user avatar
  • 317
3 votes
Accepted

two colliders for same trigger are conflicting

If there's only one thing (the player) these triggers interact with, you can do something like this: ...
DMGregory's user avatar
  • 134k
2 votes

scale and rotate a cube automatic the cube is never scaling and rotating to the end. how to fix?

I'm not well-versed in Unity C# scripting, but I'm guessing your Scale() function starts a process that changes your scale over time. Thus, if you were to call this function each frame, it would start ...
Gyoo's user avatar
  • 176
0 votes

two colliders for same trigger are conflicting

You can add a polygon collider. That is a bit difficukt to set up, but it would nerge the two box colliders into one.
CheckerT's user avatar
0 votes

light difference between scenes on player model

Solved by adjusting Environment Reflections settings, changing Skybox to Custom
anderlaini's user avatar
1 vote

Unity LookAt says reference not set but it is

Single-click on the error message in the Unity Editor console, and the Editor will select the GameObject that the script is attached to in the Hierarchy panel. This way, you'll know what object has ...
Kevin's user avatar
  • 5,734
0 votes

Unity LookAt says reference not set but it is

Maybe it is not set in the prefab. I had the same issue where I have set a reference for a game object in the inspector and it did not work, all I had to do was to go into the prefab and assign the ...
CheckerT's user avatar
1 vote
Accepted

How to set up high-performance collisions for level geometry in Unity?

Whenever possible, add your colliders to prefabs so that you don't have to manually place them in the scene. For something curved like that railing, you can save yourself a lot of headache by finding ...
Kevin's user avatar
  • 5,734
0 votes
Accepted

Skybox doesn't get displayed on mobile Chrome in Unity WebGl

I ended up using Mobile skybox shader and it seams to work, only problem here is that it needs split textures for skybox.
Ivan's user avatar
  • 317
-2 votes

Skybox doesn't get displayed on mobile Chrome in Unity WebGl

Have you imported Chrome, Opera and Edge into your script?
lucutes's user avatar
1 vote

Animation Clip Won't Play Despite Transition Showing in Animator

Your animator doesn't have any transitions (other than the default Entry transition). A transition would be represented as a line between states (notice the line from "Entry" to "...
Kevin's user avatar
  • 5,734
0 votes

Click to move - get NavMesh layer

Documenting the SamplePosition solution from Fr0z3n's comment to give this Q&A thread some closure: I found the problem. I need to use NavMesh.SamplePosition() ...
LudoProf's user avatar
  • 194
2 votes
Accepted

Linerender material is distorted

Here's an attempt to reproduce your situation: Notice how the circles develop a kink as we move from the free end of the line toward one of the sharp corners? That happens because, by default, the ...
LudoProf's user avatar
  • 194
0 votes

How do I move both the child & parent game objects at the same time?

Fixed! Turns out my y constraint wasn't frozen on the rigidbody.
Saltii's user avatar
  • 1
1 vote

Adding a function call to a prefabbed button in Unity

If you instantiate the button you can get a reference to it, like GameObject _Button = Instantiate(_ButtonPrefab) and then you can call ...
CheckerT's user avatar
0 votes

Why are my angle calculations not working properly?

To convert degrees to radians, you need to multiply the angle in degrees by Mathf.PI / 180.0f. HAZ = (float)0.8 * Mathf.Tan((ha * Mathf.PI) / 180.0f);
Nick NaSvlishvili's user avatar
0 votes

Unity Game Architecture

Ultimately, I find that giving classes meaningful names, and using "as many namespaces" as necessary to make sense of it all, is what keeps things sane. The harder a class is to name, the &...
Gerry Schmitz's user avatar
-1 votes

Kinematic "dive bomb" motion toward a moving target

Based on the image, the rubble is moving in the x direction, and the asteroid in x,y. Using 3 DoubleAnimations (StoryBoard) and a common target point (CompositeTransform.TranslateX and Y for asteroid; ...
Gerry Schmitz's user avatar
2 votes

Automated playtesting in a 2D platformer

Automated testing of full levels is a difficult topic. As you've noticed, replaying inputs is tricky. Even if you get the timing right and switch to a deterministic physics engine, a small change in ...
Kevin's user avatar
  • 5,734
-1 votes

Performance issues with high-resolution maps in 2D strategy games

(Beware of premature optimizing). My "current" map is only 6000x6000, but I have had no issues (UWP). I used a ScrollViewer to zoom and scroll the map. The map is also "parsed" to ...
Gerry Schmitz's user avatar
-1 votes

How can I securely store Gmail SMTP credentials in a Unity project to comply with security guidelines?

Consider "Isolated Storage". Using isolated storage enables partially trusted applications to store data in a manner that is controlled by the computer's security policy. https://learn....
Gerry Schmitz's user avatar
0 votes

Different Spacing of all Children Grid Layout Group

Create the prefab with a few possible positions of the triangle. Then each cell will contain this prefab. Then set the triangle to the random (or defined) space inside the prefab. For example each ...
Bogdan's user avatar
  • 133
0 votes

Different Spacing of all Children Grid Layout Group

The "simplest" way is to populate a Canvas; so you don't have to worry about "rows and columns". Starting from the "origin" (0,0), you "chunk" your way from top ...
Gerry Schmitz's user avatar
1 vote

Type or namespace name 'Collider' could not be found

You need to add using UnityEngine; to the very beginning of the script because unity does not know what a collider is. As the error suggests: are you missing a ...
CheckerT's user avatar
1 vote

Type or namespace name 'Collider' could not be found

This is the compiler saying "I don't know what this Collider name is referring to". Collider is a class in the ...
DMGregory's user avatar
  • 134k
1 vote
Accepted

In Unity, the character's spine position reference changed after I put something into its hand

In the Scene view, click the "Toggle Tool Handle Position" dropdown, and select "Pivot".
Kevin's user avatar
  • 5,734
0 votes

How to correctly add animation for a rotating object with Script?

When one of the animation states of an Animator changes a certain property of an object, then the Animator thinks that it "owns" that property. It will reset it to the default value each ...
Philipp's user avatar
  • 119k
3 votes

How can I securely store Gmail SMTP credentials in a Unity project to comply with security guidelines?

Since your goal is to send feedback to yourself, there are others ways instead of storing or even giving the credentials to the asset. As Almo pointed out, giving your credentials to a random asset is ...
Zibelas's user avatar
  • 4,291
0 votes

How to correctly add animation for a rotating object with Script?

To solve it, I used parent object to have such structure: I am rotating Body and Head via script, and create animation for an BodyAnimRotator, I have added reference to a BodyAnimRotator and Animator....
Jabka's user avatar
  • 1
1 vote
Accepted

Compiling Unity to WebGL gives a Node ESM module error

I fixed it by removing "type": "module" from my home directory's package.json. I'm guessing it had something ...
kalilamodow's user avatar
24 votes
Accepted

Avoiding string literals to reduce memory allocations

A string literal in C# will be compiled to string literals in IL. Then the IL is compiled to machine (or to C++ and then to machine code if you are using IL2CPP). On machine code the strings constants ...
Theraot's user avatar
  • 26.7k
5 votes

Avoiding string literals to reduce memory allocations

There is a trick with strings called "interning" Which stores the string in a global pool and lets you get the same string object for the same string contents. C# is defined to automatically ...
ratchet freak's user avatar

Top 50 recent answers are included