New answers tagged unity
2
votes
Unity New Input System - What Is The Correct Way To Check If Any Button From An Action Map Was Pressed?
Here is an example how you can check for any InputAction being triggered in any or specific InputActionMap:
...
2
votes
Emulating 3d trajectory in top-down 2d game?
I created this version which uses a target position and t (time 0-1).
I would loop this function in an update function if (t < 1) t would increase by ...
0
votes
Accepted
How to save and instantiate game data containing lists of polymorphic types
Option 1: ScriptableObject
The simplest way to do this is if Behaviour and Entity inherit from ...
0
votes
"Button is not an attribute class" error when integrating Steam achievements
When you put a word in square brackets before a type, variable, or method declaration, that's called an Attribute.
Attributes are special classes that annotate the declaration with metadata and can be ...
0
votes
Rotate Object Smoothly When Dragging
It seems strange you are updating prev mouse position if you use some other function to get mouse deltas.
I also strongly suspect you are tripping over different spaces, as the mouse deltas are most ...
1
vote
Accepted
Unity New Input System - What Is The Correct Way To Check If Any Button From An Action Map Was Pressed?
You could use a setup like this :
And then check with:
...
0
votes
URP Decal Projector - Decal Disappears Depending On Viewing Angle
by default decal method was set to automatic, which sometime it will be set to screen space, your problem could be the same as me, which could be fix by changing the decal method to dbuffer instead of ...
0
votes
Why are the transform game objects moving away from the snail when they are swapping their direction?
It looks like you meant to use localPosition (the offset of the child object relative to its parent) rather than position (the ...
0
votes
What is the general technique of optimizing a game's lag by updating thousands of mesh vertices using DOTS parallelism?
I was an idiot for trying to create game objects for metaball edge magnet points. After all, it was only their Vector3 position information I needed to move the vertices of the slimes accordingly. ...
0
votes
Accepted
How can I solve this error and this warning when destroying instantiated prefabs?
I solved this problem more than a month ago but forgot to post an answer. So, here's the answer:
Basically, instead of constantly instantiating enemies, I put a number of them above both triggers and ...
0
votes
Unity & Google Play Game Services - error: Leaderboard not found
Choose Proguard for Minify > Release and Copy the content into Assets/Plugins/Android/proguard-user.txt
...
1
vote
Units in Unity?
If you make your units \$mm\$ instead of \$m\$, then you need to inject a factor of \$\frac {1000 mm} {1 m}\$ into any quantity that normally has an \$m\$ in its SI units.
e.g. I want to apply a force ...
0
votes
Character controller that can handle sloped terrain and boxy ledge traversal
I recently came across this video about stair traversal in videogames, and I liked the way the solution looked. I think the main way it differs from your most recent attempt is that it only snaps ...
0
votes
Change of computing power/ time needed when imported Mesh triangle number changes
This depends on some specifics.
If the triangle mesh is using a convex collider, then only polygons on the convex hull contribute to the collision detection cost, while interior/co-planar triangles ...
0
votes
Accepted
ForwardAdd pass gets weird results when a point light is on in Unity
The funny thing is that I get rid of ambient in the ForwardAdd pass and then it's working as I imagine.
Quite confused...
1
vote
Can I rotate the velocity of a rigid body?
I got it working using DMGregory's suggestion.
This line is the ticket, just adjust the "20".
...
0
votes
Accepted
Rotate UVs in shader and contains result into quad with repeat edge pixels
Maybe someone will need it?
...
0
votes
Unity's Camera.ScreenToWorldPoint is apparently "missing", what could be the cause?
My best guess is, that one of the other imports is providing as well a camera and you are using that one instead of the one from UnityEngine. What would support ...
0
votes
How do I properly use Entities and ECS in a current project that uses MonoBehavior?
I was able to optimize it using ECS and jobs:
...
0
votes
How do I optimize computations for multiple game objects(>1000)?
I was able to optimize it using ECS and jobs:
...
0
votes
How do I optimize computations for multiple game objects(>1000)?
It would help to optimise the loop, and inside the loop. Some standard rules for this:
Dont use .Count in the loop statement (is it slow), cache the .Count to a variable first, e.g.
...
1
vote
Accepted
How to delete a face of a Primitive Cube
I found a link that helped me to solve this using normals. To solve this, first you calculate the normals of each point of the triangle that the Raycast hitted:
...
0
votes
Limit FPS in Scene view Unity
All in all there are only two solutions to limit FPS for scene view:
Re-check vsync in game view every time unity starts || exit game mode (unity bug). By some reason it affects scene view as well
...
1
vote
Instantiate prefab behind moving player
We can use the transform.forward property, and reverse it to put the object behind the player.
...
0
votes
Accepted
How to rotate NavMeshAgent toward its movement direction?
You can avoid the trig and angles by using the LookRotation helper method in a slightly different way:
...
0
votes
How to rotate NavMeshAgent toward its movement direction?
I've solved it with help of ChatGpt. Here's the code
...
0
votes
"ArgumentNullException: Value cannot be null" for AudioSource.PlayOneShot
If your sound effects are defined but the code still won't run, its possible that the game object the script is attached to has no audio source component. You can add that under the inspector manually ...
0
votes
Isolating a mesh so it doesn't interact with Raycasts in Unity
is not an option for you
is also too expensive (in addition to be not desireable)
relates to ECS
My advise would be to continue the raycast behind the object hit, tagging it as such, then going after ...
0
votes
How to use Camera.cullingMask to selectively render certain objects?
Go to Edit > Project Settings > Tags and Layers > Layers and create a layer called something like "Invisible".
Select the object you don't want the camera to draw. Set its layer to ...
0
votes
Accepted
The bottom of the player capsule collider is going into the ground box collider
I can't believe it took me 2 days to figure out what was the
problem. solution is way too simple. All I had to do was to set the
ray emitter object red sphere a bit higher so when the character
hits ...
0
votes
Recreating The Lighting In Paper Mario: TTYD In Unity
Some basic tips:
Reduce the intensity of the directional light a bit. If the scene gets too dark, increase the ambient light level.
Try using Linear color instead of Gamma color
Use flat shading ...
3
votes
Making contributions to a Unity project without having Unity editor installed
You said your data is strings. Since you haven't explained the nature of the data, I'll describe an example scenario: let's say you can talk to random NPCs in a town, and each time you talk to an NPC, ...
5
votes
Why does Unity have no official gameplay framework?
1. There's no one-size fits all system.
For example, you use MVC for your backend. Other teams might use MVP or MVVM or HMVC or MVA...
Unity attempts to be as flexible as possible. In some cases this ...
5
votes
How are character controllers built upon complex gameplay systems?
It sounds to me like you are trying to accomplish the impossible. There are limitations to how flexible and reusable you can make a system. Remember that a system with infinite flexibility will also ...
2
votes
Accepted
Character walks too fast when browser's hardware acceleration is turned off
I found the solution.
Quoting this discussion thread: "Inputs are provided by the player on a frame-by-frame basis. They never need to be scaled based on framerate, since you don’t want the same ...
0
votes
How can I do something after an audio has finished
Many posts indicate issues with using WaitForSeconds as well as WaitWhile(AudioSource.isPlaying) giving incorrect values if the clip is paused, game loses focus, or if the pitch of the audio is ...
1
vote
Gaps between terrain chunks generated with marching cubes
I fixed this problem.
There were 16x16 vertices per mesh and new chunk coordinates were calculated as:
...
0
votes
How to make a moving GameObject push a CharacterController smoothly?
Generally the best way to handle a character on any sort of moving platform is to make the character object a child of whatever it is standing on.
That way, movements of the platform will perfectly ...
0
votes
Interacting with UI with a locked cursor?
To riff off of @nicholas-zhang's answer, replacing the StandaloneInputModule component on EventSystem with this new component seemed to do the trick:
...
0
votes
Accepted
How to Constantly Apply a Force to a Rigidbody Within a Coroutine?
Keep setting the velocity every physics tick until the one second has elapsed.
...
1
vote
Accepted
Reading JSON nested objects with JsonUtility
As @Evorlor mentioned in comments, you should using Newtonsoft Json (also known as Json.Net)
https://docs.unity3d.com/Packages/com.unity.nuget.newton[email protected]/manual/index.html
It's the go-to ...
Top 50 recent answers are included
Related Tags
unity × 16070c# × 5531
2d × 1092
physics × 660
shaders × 660
animation × 649
collision-detection × 514
android × 471
rotation × 454
camera × 447
gui × 427
3d × 389
movement × 335
sprites × 325
unityscript × 297
textures × 294
rigidbody × 245
lighting × 237
raycasting × 236
mathematics × 231
input × 228
blender × 227
rendering × 219
gameobject × 202
transformation × 190