Hot answers tagged

3

I found the answer online! I had to go to the editor preferences (Edit -> Preferences) and under External Tools, there's a section with checkboxes under "Generate .csproj files for:." All I had to do was check "Registry Packages," click Regenerate project files, and it worked! Thanks to everyone who tried to help, I hope this ...


2

It doesn't know. What it does is point the local z axis of the object (that's the blue arrow you see in the scene view when selecting its local transform gizmo) in the forward direction you pass to LookRotation, and the local y axis (green arrow) as close as possible to the upwards direction you pass, or world up if you didn't provide a second argument. By ...


2

The problem was that the animator controller had checked the "Apply root motion" option. After unchecking it everything went back to normal. It seems my idle animation was not correctly defined.


2

Assets in Unity (textures, materials, etc) are not garbage collected as readily as other types. Unity will clean up unused assets on scene loads, but to keep this cruft from piling up it's our responsibility to manage the assets we're creating, and Destroy() them when we're finished. We can't just destroy the texture at the end of your ...


2

I can think of a couple of ways to achieve that. You can either: Write some boilerplate code to check whether a Component is present multiple times or not at runtime (boring and error-prone). Or, you can play around with inheritance and interfaces (which is Vaillancourt's good proposed solution, plus an extra by me). The latter method grants in-editor and ...


2

There is the [RuntimeInitializeOnLoadMethod] attribute. Excerpting from the documentation: Allow a runtime class method to be initialized when a game is loaded at runtime without action from the user. Methods marked [RuntimeInitializeOnLoadMethod] are invoked after the game has been loaded. This is after the Awake method has been invoked. Note: The ...


1

You could use Input.GetAxisRaw instead of Input.GetAxis to get the unfiltered values. So with binary inputs like keyboard keys, you are always going to get -1, 0 or +1. You can then add your own smoothing logic on top of that for a maximum of control. Or you could go to Edit -> Project Settings -> Input Manager and configure the smoothing of your axis....


1

First I'm going to answer your actual question: You have configured your day to last 30 minutes. That means 1 hour is 30 / 24 = 1.25 minutes. That is why the hours appear to increase roughly every 2 minutes. Additionally, your GUI code uses Mathf.Round(), when you should be using Mathf.Floor(). For example, let's imagine we're using real time (60 minutes/...


1

It looks like your offset range is relatively large in relation to the float number format. Floats have about 23 bits for actual number data, the rest being for the exponent and sign. At extreme offset values around 100000, you'll only have about 4-5 bits worth of precision left for the fractional part between integer values. This can very easily cause ...


1

I later looked up an implementation of this algorithm so I could do it on another thread, I didn't even know it existed and it is actually fairly simple! My implementation still uses a Unity function Plane.GetSide(point) but it's thread safe. It just tells you if a point is on the positive side of a plane. foreach (plane in frustumPlanes) { ...


1

If you write the old input system, in code, then unity's code checker will automatically update it for you. If unity doesn't automatically then in the menus up top press Assets->Run API Updater. Hope this helps.


1

Basically thanks to DM Gregory's help, I have managed to fix it very simply. I already had a 'pivot' object as a parent to my Gun. This itself is child directly of players root. All I had to do was drag its local position forwards a little and it stopped the problem. In doing this I noticed dragging it upwards also looked a little better. Now it looks pretty ...


1

Check what layer the sprite is on. Make sure it's not on the same layer as the background. Otherwise it might occasionally draw behind the background instead of in front, making it look like it's blinking.


Only top voted, non community-wiki answers of a minimum length are eligible