All Questions
128
questions
2
votes
1
answer
53
views
Why is object array null later in the script even after confirming its not null after initialization
The title. there are no mentions of the spriterenderers or array anywhere else in the program
SpriteRenderer[,] Renderer = new SpriteRenderer[8,8];
void Awake()
{
if (D)
{
...
1
vote
2
answers
49
views
Why is null Unity Object equal to null in specialized class but not equal to null in generic class?
Attach TestMono to an empty GameObject, leave the serialized field uov empty and play. The result is not what I expected.
using System;
using UnityEngine;
using Object = UnityEngine.Object;
namespace ...
0
votes
0
answers
69
views
Unity setactive() not working because of object name
So I have a sort of item system in my game and it opens a savefile to see what items the player has at the time, when it loads it enables and disables objects based on the savefile information. Which ...
-1
votes
0
answers
35
views
Trouble with pickup physics in unity c# script
I am a beginner in unity scripting and I am having troubles with making a code on how to pick up an object.
I have ran through 4-5 YouTube tutorials and still cannot manage to pick up objects. When I ...
0
votes
0
answers
91
views
Unity avoid hardcoding values?
In a click handler, I'm saving a reference to a ScriptableObject like so:
actionSO=itemScriptableObject.actions.action1;
I have several different actions attached to this gameObject:
...
1
vote
1
answer
226
views
Unity "null" == Check Failing?
https://i.sstatic.net/jyYpi.gif
So I've been doing Unity C# programming for about 6 years now, and I only JUST found out about C# null v.s. Unity "null" (that's what you get when Unity is ...
0
votes
0
answers
481
views
'Find' is not allowed to be called from a MonoBehaviour constructor, call it in awake or start instead (but I did)
I'm getting the following error:
"UnityException: Find is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from ...
1
vote
0
answers
178
views
Can't add an object from scene to a Visual Scripting node in Unity
I can't add an object from scene to a Visual Scripting node in Unity. While I am dragging a object from a samplescene section to a scipt graph on a GameObject node it shows an unavailable symbol and I ...
-4
votes
1
answer
300
views
Object Reference Not Set To Instance Of Object When Using InputField Script
I just started learning how to do basic things in Unity. I am trying to learn how to use a text field box. I have followed several tutorials and copied everything but I always end up running into one ...
-1
votes
3
answers
122
views
Can't use static objects in a Switch statement in Unity
I have Unity 2021 so it uses C# version > 7 I believe.
Somehow I can not use static objects in Switch/Case statement.
private Position getStartingPosition(Direction direction) {
switch (...
-2
votes
1
answer
219
views
Create a Random position nearby for my object 3D
I am trying to do a random position nearby the initial position. I have been searching and working on many hours of doing this.
I wasn't be able to do this. I manage to use the script from unity https:...
-2
votes
2
answers
295
views
C# Unity while key pressed if condition true or false
So I'm new to C# I somewhat know Python I couldn't understand how functions work I tried doing something like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
...
0
votes
1
answer
60
views
Console should log a message when game object reaches reaches a certain point, why it is not doing it? [duplicate]
I am learning Unity with c#. I wrote some lines of code, so that an object moves forward while its z coordinate is less than 4, and when the z coordinate is actually 4, it prints a message to the ...
0
votes
1
answer
321
views
Unity findgameobjectswithtag still finds destroyed items
In my unity program i have two function who runs in an Update() function. In one of the functions, if a conditition is met an object will be destroyed. The problem occurs when because the other ...
0
votes
3
answers
310
views
Quaternion loop not synced with time in Unity C#
I've been having trouble with Quaternion lerps. I'm simply looking to rotate my character 90 degrees based on their current rotation. The script below executes that almost perfectly, except for the ...