New answers tagged

4 votes
Accepted

How to clean up list entries when objects are destroyed in Unity?

The best way that I came up with is, according to the observer pattern, to notify all classes where the object was stored about its destruction and remove references to it from there. That's what I ...
Kevin's user avatar
  • 4,961
1 vote
Accepted

Best way to implement a carrying tray in VR using Unity

I have found a suitable solution using both Unity's built-in materials and a script that uses a trigger as a parent modifier. Both the tray's and mug's collider has a material attached that raises ...
Richard Muthwill's user avatar
2 votes

Best way to implement a carrying tray in VR using Unity

It sounds like you've already figured out the solution: I'm thinking of some kind of magnet-like system where if you drop an item onto the tray, it becomes stuck until you manually take it off. From ...
Tom Tsagkatos's user avatar
0 votes

Simulate Velocity For A Projectile Moving Along A Spline

I think when a projectile is thrown it should have a burst of speed at the start and begin to rise slower as it reaches its peak height. Then as it starts to fall it should gradually begin to fall ...
Kevin's user avatar
  • 4,961
-2 votes

Simulate Velocity For A Projectile Moving Along A Spline

Remove the spline and split speed into 2 components X,Y ie Vector2. Fix a horizontal velocity.X from the spline. Apply a negative rather large value to velocity.Y, and each step adjusted for delta ...
agone's user avatar
  • 323
0 votes

Getting a pixel of Sprite at the cursor position in Unity

This is a super old question, but I was struggling with this for a while, used the code from Savlon's answer and then found it wouldn't work if I moved or scaled the object at all. After hours of ...
Andrew's user avatar
  • 1
4 votes
Accepted

Detect if a key other than "this" key has been pressed

You can first check whether "any" key has been pressed, then check if the key you're listening to has not, to respond only to presses that were not that key. ...
LudoProf's user avatar
1 vote
Accepted

Converting number in name of gameobject into alpha keycode

If slot is a string then slot[11] is one character of this string and is of type ...
Olivier Jacot-Descombes's user avatar
3 votes

Game loop isn't performing well enough, so my frame rate is too low (Windows Form + GDI+)

I wonder, do you really need to render noise that is uniquely random down to the pixel? Or would it be okay if it just appears random? If you're alright with an approach that relies on staggered ...
Mentalist's user avatar
  • 153
1 vote
Accepted

What would be the best way to gradually increase the speed of a 2D arcade game with gravity physics in Unity?

this might not be consistent for different framerates - is that right? Time.timeScale is independent of framerate. Unity will continue to try to render at the same ...
Kevin's user avatar
  • 4,961
40 votes
Accepted

Game loop isn't performing well enough, so my frame rate is too low (Windows Form + GDI+)

TLDR: Get DirectBitmap from https://stackoverflow.com/a/34801225 and add ...
PTwr's user avatar
  • 516
17 votes

Game loop isn't performing well enough, so my frame rate is too low (Windows Form + GDI+)

When things bog down, check your inner loop. That's the code being run the most often, so even a small inefficiency there stacks up. Here we see: ...
DMGregory's user avatar
  • 132k
0 votes
Accepted

Flying AI shakes when chasing and avoiding obstacles simultaneously

If I'm understanding correctly, the issue is that you're oscillating back and forth between two states... State 1 is when you're out of collision range and it moves normally. State 2 is when it's ...
Basic's user avatar
  • 1,166
1 vote
Accepted

How can I instantiate a prefab in a canvas and have it positioned relative to its parent?

The correct solution is to use Instantiate as follows: ...
tatmanblue's user avatar
0 votes
Accepted

Euler Angle X is wrong after using Quaternion.LookRotation

If you want to enforce angular limits, keep it in terms of angles from the start. Don't count on an automatic conversion from quaternions to Euler angles to give you angles in a specific range, ...
DMGregory's user avatar
  • 132k
0 votes

Euler Angle X is wrong after using Quaternion.LookRotation

If you want to isolate the heading of a look direction then zero out the up and use the atan2 function directly. ...
ratchet freak's user avatar
3 votes

Fast way to calculate angular intervals and occlusion of circular objects in a 2D vision cone

Here are some optimization suggestions: 1. Filter unnecessary tests Objects located outside the field of view circle(distance>r1+r2) do not need to be detected. ...
Mangata's user avatar
  • 2,451
1 vote

Fast way to calculate angular intervals and occlusion of circular objects in a 2D vision cone

My first move would be to use a Raycast at regular intervals between the start & end angles. In other words: begin at the starting angle perform a raycast ...
Pikalek's user avatar
  • 11.5k

Top 50 recent answers are included