Questions tagged [unity]

Unity is a cross-platform game creation system that focuses on easy art pipeline process. It consists of a game engine and an integrated development environment. The game engine's scripting is built on Mono.

Filter by
Sorted by
Tagged with
0 votes
1 answer
6 views

Destroy and instantiate player prefab

I am new to game development. I am trying to change the player prefab every X seconds. For that, I am destroying the previously spawned prefab and instantiating a new prefab. But I don't know how to ...
2 votes
0 answers
14 views

Add opacity control to SoftLight blending shader

Just a heads up: I have very little experience with shader languages so please excuse if this is a trivial question. I got a SoftLight shader from this blog (Archived here). It blends the given sprite ...
  • 131
0 votes
0 answers
23 views

problem lane switching in endless runner game

I'm working on an endless runner game like subway surfers but can´t get the code for switching between lanes right. Can anyone help please? Code so far: ...
  • 1
0 votes
0 answers
44 views

Why does my AI rotate on the y axis?

I have a simple sensing script to sense when my player is close to the enemy but when my player gets close to the enemy, it turns -90° on the y axis. Here is my script: ...
15 votes
2 answers
2k views

Development pattern for interactive in-game tutorials

Interactive in-game tutorials often interrupt game flow and override standard behavior in a way that can be difficult to implement cleanly. For example, imagine we have an action game and we want a ...
  • 4,170
0 votes
1 answer
71 views

Most efficient method to render hundreds of thousands to millions of stationary particles

I am making an app to visualize data, I am new to Unity but have an extensive background with Blender. I have written my script to read in data and plot those points. In this example its ~528k points. ...
  • 101
1 vote
0 answers
22 views

Getting leaves' stem to stick out of the branch with Unity's tree creator

I am using unity's tree creator to create... well you can guess. However the leaves' stem doesn't exactly stick out of the branch... I've tried to play with parameters like ...
0 votes
0 answers
14 views

Making changes to tree prefab does not update the terrain trees

I am using this package as my terrain trees. I have added Oak_Tree as a prefab for tree on the terrain editor (On tree brush). When I make changes to Oak_tree prefab (by opening it from a .prefab file ...
  • 101
0 votes
2 answers
37 views

Unable to access an instanced health system

I am having an issue with a health system I am making for my game. I have been at it for 3 days now and have not made much progress. For reference, I am following this tutorial by code monkey: Code ...
0 votes
1 answer
46 views

A*Pathfinding generating wrong path

I'm building a maze game where there's an enemy ready to pursuit the player if the player gets in his range, I'm using A*Pathfinding algorithm to do so, and I build the maze in a procedural way, where ...
0 votes
1 answer
22 views

Unity's Animation Rigging Override on Rig with Optimize game objects enabled

I’m working on a top down third person shooter game and was trying to add recoil animations that we can easily tweak through code for all of the different guns available. I wanted to do this through ...
7 votes
1 answer
5k views

Enemy is losing 2 health instead of 1

I am trying to componentize all of my scripts and I would like the enemy to lose 1 health (enemy max health is 3) every time the player collides with the enemy. Right now the enemy is losing 2 health ...
1 vote
0 answers
37 views

Can I match a Unity camera to a real world camera for an overlay by slecting screen space points on a known object?

I asked this same question on stackoverflow, and someone suggested that this was a better place to ask. I have a real world object (table, basically a rectangle), and a 3D model of the same object ...
0 votes
1 answer
16 views

Assigning references to Prefabs placed in each Scene

I am currently working on a small 2D game which has a few different scenes, which are each a different level. I want to use my object prefabs from one scene in the others, but these do not include ...
0 votes
0 answers
32 views

Importing an animated Blender tree into Unity

I've been trying to import a tree blowing in the wind (using Blender's Sapling Tree Gen) into Unity to play the animation. However, I can't get it to play The steps ...
0 votes
0 answers
11 views

How to deal with mutiple gameobject;s animator?

I have 10 or more GameObjects, and in the Animator window. Each of them has difference animator controller and avatars,but same parameters and state (walk die attack) and transitions. I need to edit ...
0 votes
1 answer
20 views

Vertical components not working with NavMeshAgent .move or .velocity?

This is a weird one. I'm using a 2d adaptation of the NavMesh (found here: https://github.com/h8man/NavMeshPlus) to get obstacle avoidance for my AI in my 2d game. I also want to use it for my player ...
1 vote
1 answer
51 views

Computations in GPU Unity

I've made a fluid simulation using particles in Unity, but now it is painfully slow because all computations are done using the CPU. In order to make it faster, I need to do computations on the GPU, ...
  • 149
0 votes
2 answers
32 views

Initializing Monobehaviour in Unity

I have three scritps and one plain C# class. EnemyMonobehaviour, EnemyAttackMonobehaviour and UnitState plain class. In enemyMono I have Initialize function that initializes unitState. ...
2 votes
3 answers
81 views

How can the player jump on top of the enemy, damage the enemy and the player does not get damaged?

Currently, when the player jumps on top of an enemy, the player and the enemy take damage. I'm trying to figure out a way that only the enemy gets damaged when the player jumps on top of the enemy and ...
0 votes
0 answers
24 views

How to make a moving platform with Unity Tilemap?

I am trying to make a 2D level of a game and want to know how to move a specific tile left and right. All the level is designed on a single Tilemap. I want to move one platform left and right. How ...
  • 23
1 vote
1 answer
59 views

Map arrays of game objects to values of an enum in Unity inspector

I want to have a serialized field with an array of game objects for each item in a global enum, like this: public enum MyEnum { Item1, Item2, Item3 } ...
  • 65
0 votes
0 answers
17 views

Box Collider on terrain trees activate far from the actual collider

The trees are prefabs but are placed as terrain trees. There is a space ship that explodes when hits the tree. The moment I got the screenshot is the moment that the ship collides with terrain (the ...
  • 101
1 vote
2 answers
76 views

How do I ensure that an enemy has a maximum of 3 attackers on him?

I'm coding the combat system for my RTS game, and every time a unit spawns I iterate over all enemies and then attack the closest one. This is achieved using the below block of code: ...
0 votes
1 answer
40 views

How to move camera by "grabbing" ground and moving mouse

I want to grab my terrain and move the camera with my mouse, this was fairly simple to do using speed: Code (CSharp): ...
  • 349
0 votes
2 answers
80 views

How to get the name of a function added as a listener to a Button's onClick event?

If my button uses AddListener to subscribe a function to listen for clicks: mybutton.onClick.AddListener(getNameFunction); Is there a way to get the name of that ...
0 votes
0 answers
26 views

Predict whether projectile is coming at a teammate

Related to this question How to project a Vector3 onto the xz plane? ...
0 votes
1 answer
36 views

How do I know currently active TMP_InputField in unity

I have a list of TMP_InputFields on my canvas like OTP boxes. I made it in such a way that the cursor automatically moves to the next box once the user types something in the current box. I am ...
1 vote
1 answer
277 views

How to project a Vector3 onto the xz plane?

I have this code that tries to check whether a lobbed grenade will head toward a teammate: ...
0 votes
2 answers
38 views

Copying transforms from one object to another

I am working on a virtual production app, and I need to be able to copy the transforms of one GameObject and all of its children to another. I asked previously here how to animate a character moving ...
0 votes
2 answers
36 views

OnTriggerEnter2D and OnTriggerExit2D are firing each frame of a collision and OnTriggerStay2D never fires

So I'm basically making pong and lethal league combined, the paddles start with no collision until a certain key is pressed then the collider is enabled. OnTriggerEnter2D stops the ball, ...
  • 1
0 votes
1 answer
60 views

Switching a velocity from one rigid body to another in unity

I have a set up where the ground and the player move with physics and a stationary camera. I want the ground to move faster when the player is getting further away making it look that the player is ...
  • 123
0 votes
0 answers
15 views

SoftLight blending of images with Unity Shader Graph Scene Color Node

I am trying to emulate Photoshops "SoftLight" blending with a custom shader made in shadergraph. I would like to add that shader to an image or sprite, so it gets blended with the effect ...
  • 131
1 vote
0 answers
18 views

How can I create text underlayed with sprites in Unity UI?

I have some UI text in a canvas that I'd like to be able to render with sprites behind some of the characters. This is effect I'd like to achieve: I've been able to use Text Mesh Pro UI text objects ...
  • 111
0 votes
2 answers
77 views

How to detect enemies at a larger radius without expanding range where enemies can detect the player?

I had tried to enlarge the player's collider's radius so that it can detect enemies in a wider range and attack them by shooting. However, it seems like the large collider is also affecting the ...
0 votes
0 answers
30 views

Keeping background image fixed along Y axis of cinemachine camera

I have a background that I'd like to remain in the same position relative to the camera along the y-axis, but scroll in parallax along the x-axis. The x-axis parallax part I was able to implement just ...
  • 99
1 vote
2 answers
42 views

Player transform has not been assigned when player enters trigger collider?

I wrote some code so when the player falls off a platform and collides with a trigger collider called Respawn Trigger, the player's transform position is set to an empty gameObject called Respawn ...
0 votes
1 answer
34 views

Calculating normals for a simplified terrain mesh

I am trying to simplify a mesh I am generating from a heightmap by creating larger triangles for areas of equal elevation, like this: This however gives me issues with my normals: I am calculating ...
0 votes
1 answer
21 views

Getting exceptions in Unity3d with EasyRoads3D, when attempting to create roads

After importing EasyRoads3D version 3.2.2f2 into Unity 2021.3.20f1, and trying to create a simple road, I get a lot of exceptions: ...
0 votes
1 answer
36 views

Trying to have damage flashing for a short time every time player takes damage

The code below has the player flashing when touching a hazard but continues flashing indefinitely. If I stand on the spike for a few seconds, the flashing speeds up faster than I want. ...
1 vote
3 answers
64 views

How can I fully or partially colorize a SpriteRenderer and make its "color" value match the end result at 100% opacity?

I have a GameObject that looks like this: When I change the "color" value in the GameObject's SpriteRenderer to be (255, 0, 0, 255), the GameObject ends up looking like this: But I want it ...
0 votes
0 answers
20 views

"Build Disabled For Android" shown when using command line for build

I use my build server to build my game on GitHub merges. One of the errors I face is: ...
  • 2,524
1 vote
2 answers
169 views

OnTriggerExit Coroutine won't stop?

i use StopCoroutine to stop "AttackPlayer", but their keep exculte the TakeDamage() function, even i stop it. how to totally stop the IEnumerator , use bool to turn the whileloop on and off?...
0 votes
2 answers
57 views

Add delay between taking repeated damage from a hazard

I have a 2D platformer and when the player collides with a tile that is on the Hazard layer, the player takes 1 damage. However, I would like for there to be a 2 second delay until the next time the ...
0 votes
0 answers
38 views

Disable animations for specific bones in Unity

I'm working on a virtual production app in Unity, and I wanted to apply a walking animation (from Mixamo) to the character when it moves. When the character isn't moving, an idle animation is played. ...
1 vote
0 answers
35 views

Authentication errors when using build server

This is my build command: ...
  • 2,524
0 votes
0 answers
30 views

Why cube is getting stuck?

The cube sometimes, not always, randomly gets stuck at the edge of new platform. I do not understand why, the platforms are at normal level. And it does not happen all the time. The platform is not ...
2 votes
1 answer
61 views

Consistently moving a GameObject from Point A to Point B using Unity Visual Scripting

I built a subGraph in Unity Visual Scripting to move a GameObject ("returnThisGameObject") from its current location (Point A) to its originalPosition (Point B). The code run dozen of times ...
  • 351
0 votes
0 answers
26 views

How to prevent an object from moving beyond colliders? [duplicate]

I have an enemy object, and it needs to move around an arena. I also have four Wall gameObjects surrounding this arena, and both the enemy and walls have colliders (not set to isTrigger). This is how ...
0 votes
1 answer
85 views

How to fix the warning "Only textures with width / height being multiple of 4 can be compressed to ETC2 format"?

This question is about Unity texture compression. I have an image that has the dimensions as follows: width = 724, and height = 1044. The original size is 348 Kbytes. This means that both the width ...

1
2 3 4 5
315