Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 107276

2D refers to two dimensional space where coordinates are represented with X and Y values.

2 votes

Why does the script stop working after respawning?

Interestingly, if the player dies before reaching any checkpoint, the MoveTowardsPlayer scripts still works after respawning. It only stops working after any of the checkpoints are reached. Presumab …
Kevin's user avatar
  • 6,946
1 vote
Accepted

How can I set up a 2D circular boundary in Unity?

Your if-else block for constraining the position of the stick looks like this: if (currentPoint.y >= 2.7f){currentPoint.y = 2.7f;} if (currentPoint.x >= 2.5f){currentPoint.x = 2.5f;} if (currentPoint. …
Kevin's user avatar
  • 6,946
1 vote
Accepted

Sprites not being destroyed when interacted with

In your OnCollisionEnter2D() function, you have this line of code: enemy.Hurt(); You don't set the value of enemy anywhere in that function. It's likely that enemy is always pointed at the same enemy …
Kevin's user avatar
  • 6,946
0 votes

Spawning prefab on touch after previous spawn(s) had been destroyed

Here's your problem: if (numberOfCans >= 3) { canSpawn = false; } You never set canSpawn to true after this. Maybe what you wanted is canSpawn = (numberOfCans >= 3). This will update canSpawn eac …
Kevin's user avatar
  • 6,946
1 vote
Accepted

Need help with rotating sword around player (Unity 2D)

Here's a very simple example: public class SwordPointer : MonoBehaviour { [SerializeField] private float distance = 1; [SerializeField] private Transform sword; private void Update() { …
Kevin's user avatar
  • 6,946
1 vote

unable to see sprite in scene Getting error as floating point precision limitation

This happens when the GameObject is very far away from the world center. Check its transform in the Inspector. The x, y, or z coordinate is probably greater than 100,000 units. You should never positi …
Kevin's user avatar
  • 6,946
0 votes

Scrolling the map in a 2D a tiled game

That looks like how I'd do it. If possible, use an array or array-like data structure that lets you add and remove elements. Pseudo-code: //O(1) or O(n) depending on data structure public void ScrollR …
Kevin's user avatar
  • 6,946
6 votes

Creating a new camera in 2D mode sets it as default, despite not being the main camera

Unity uses the depth property to determine the order that cameras are drawn in. If two cameras have the same depth, there's no guarantee which camera will be drawn first. Unity will render any camera …
Kevin's user avatar
  • 6,946
0 votes

How can I make a camera follow an instantiated object at runtime?

Camera is the name of a built-in component in Unity. You should not name your component Camera, and you should refer to your component by its type. public class FollowCamera : MonoBehaviour { publ …
Kevin's user avatar
  • 6,946
2 votes
Accepted

Canvas not scaling to screen size

It looks to me like your code is placing things in a grid that you've built in world space. The canvas scaler component doesn't help if your grid is in world space. Instead of manually creating a grid …
Kevin's user avatar
  • 6,946
-1 votes

Gradual strafe rotation with focus on mouse (circle-strafe)

EDIT: D'oh! You've apparently already tried this in your commented-out code that I ignored. Hmm, re-thinking. You probably want to Lerp or Slerp: var targetRotation = Quaternion.Euler(0f, 0f, v_lookAn …
Kevin's user avatar
  • 6,946
0 votes
Accepted

UNITY: How to LOAD save file from main menu

When your code doesn't work, the first thing you should try is usually adding some logging: public void LoadDataFromFile() { Debug.Log("Loading data from file..."); BinaryForma …
Kevin's user avatar
  • 6,946
0 votes

How to build a system for ammunition being fired out of cannons when player characters and c...

Whenever you want to be able to do similar things with different objects, you should create a reusable component. As an analogy, think about how you typically add physics to a GameObject. Whether that …
Kevin's user avatar
  • 6,946
2 votes
Accepted

What's the Unity way of implementing data driven UI

I generally prefer ScriptableObjects for storing data that: You want to be editable with a GUI in the Unity Editor (as they can be edited in the Inspector much like the components on a GameObject) Is …
Kevin's user avatar
  • 6,946
1 vote

2D drag and drop dynamic rigid body spinning out of control in Unity

You should do this with a joint instead of with forces. (Edit: These steps are for 3D gameplay because I didn't read the question carefully enough. Oops!) Create a Rigidbody (let's call it the "Hand" …
Kevin's user avatar
  • 6,946

15 30 50 per page