#💻┃code-beginner

1 messages · Page 502 of 1

marble hemlock
#

its also inconsistent, which makes me uncertain what the problem or cause is

#

uhhh
okay

#

ig we'll just

#

ill try another system

astral falcon
#

What system are you even using?

marble hemlock
#

currently its just set up to make the gameObject to setactive whenever canInteract becomes true, which becomes true if the raycast hits a layermask called "pickupLayer"

astral falcon
marble hemlock
#

it was working fine before, and the script was left unchanged because of that. but now i get random snapping of the camera whenever i hover over the pickupLayer

marble hemlock
#

the problem isnt that its not registering it, because it is. its that for some reason something is causing the camera to suddenly snap away.

#

ill just figure it out later ig

astral falcon
#

Does your player get pushed away by that collider for some reason?

marble hemlock
#

no

#

its inconsistent so im not sure whats causing it to be exact

astral falcon
marble hemlock
#

im going to turn off gravity then cuz its gonna fly through the floor

#

well its not causing any problems now, but the raycast isnt hitting anything

#

i shall try something else

astral falcon
#

You should check the physics collision matrix and place your items on another layer than your player

neon oar
#

how do i delete the wolken Script component

ivory bobcat
#

Try the remove component?

neon oar
#

omydays

#

im so sorryu

#

looooooool

solid marlin
#

Hey so I am still super early in learning, but I have two questions. Firstly, is unity learn going to be enough for basically anything? Or should I look up/use third party tutorials as well? Secondly, how will I know that "I am ready" to make something bigger? Obviously Ill start with smaller projects for practice and experience but I'd like to move onto something bigger when I have enough knowledge.

faint osprey
#

i want to create a system where when the player dies the scene instantly restarts however would the engine take longer restarting the scene than just resetting everything else

teal viper
teal viper
solid marlin
#

Fair point, I mostly meant anything as in Ill know my way around unity mostly.

#

I dont think my goals are THAT ambitious honestly so once I get over most of the basics I feel like I wont get stuck much

teal viper
faint osprey
solid marlin
#

How different is unity 6 from the current LTS version? Any major differences that I should consider while learning?

teal viper
teal viper
faint osprey
topaz thistle
#

!code

eternal falconBOT
topaz thistle
#

Is there anything in my code that could be preventing me from interacting with the game? I start the game and I can't interact with it at all:
https://hastebin.com/share/onexumusoy.csharp

deft grail
wintry quarry
topaz thistle
swift elbow
wintry quarry
#

and the appropriate raycasters/input module

deft grail
#

if i have a script on a prefab i can just Instantiate that?
or do i have to do GameObject?
im getting a "the object you want to instantiate is null" error

swift elbow
deft grail
#

or does this only work with rigidbodies and stuff?

swift elbow
deft grail
swift elbow
#

oh i see, but no i dont think this works with anything other than rb

deft grail
eternal needle
iron wing
swift elbow
eternal falconBOT
wintry quarry
deft grail
#

or maybe its that i didnt put it in a variable and change it on that, but directly on the instantiate instead

iron wing
iron wing
eternal needle
arctic ridge
#

I'm trying to make a camera control script to use with a joystick here: https://paste.ofcode.org/Z2S9aHRA9rihXqmcczWRfE, but when i use it it both snaps back to the default camera, and the camera clamps on the left and right as well as up and down. I assume the camera snaps back due to something with the multiplication and the joystick at position (0,0), and the clamping is due to soemthing with the Mathf.clamp method, but i'm not super familiar with it.

#

Also, mouse x and mouse y are bound to the correct axes in the input manager

rocky axle
#

Should I start with the unity beginner programmer or unity essentials? I’m about done with code academy’s intro to c#

iron wing
# swift elbow is your !ide setup?

I went through this for Visual studio Code and I'm fairly sure I went through all the steps. Even though I'm using VS Code is Visual Studio actually nessecary??

deft grail
ivory bobcat
cosmic dagger
minor pier
#

Hiya yall! Im a starting dev and im learning c# rn, but a lil problem i have is that im struggling with writing code.
I understand each piece of the code what it does but i struggle with just writing it into a proper script, does anyone have tips to make it easier?
(Its like knowing what the pieces in a pc do but that u have no idea how to put it together into a pc)
Idk if this is the correct chat for this but if it isn't please redirect me!

bold gale
#

I want to check if an object is in the camera view, and I've looked online and tried many solutions like OnVisible, and TestPlanesAABB with camera frustums but they dont work if the object is behind another object, or if you arent looking at the center transform of the object or in other words you are looking only at a small part of the object.
I'm going to do raycasts for the entire camera view with spacing in between them, but surely unity has an inbuilt function for this already, can anyone help point in the right direction?

teal viper
#

And testplanesaabb should work if you provide proper bounds

iron wing
#

I dont remember adding a second camera in the first place. why am I getting errors trying to remove it?

iron wing
# iron wing

weird. i think restarting unity fixed my issue unless it comes back

valid turtle
#
{
// LogicoScripto is another script I want to use a number from
    public LogicoScripto scoreText;
    public Text HighestScore;
// you can ignore this int for right now   
 public int PlayerScore;

    void UpdateScore()
    {
        GameObject.Find("playerScore").GetComponent<LogicoScripto>();
        if(playerScore )
    }


}

Im trying to code a highscore and I coded this so far. But when I want to use the "playerScore" from the other script it says as an error that "The Name "playerScore" does not exists in the current context."

What am I doing wrong. I thought I could maybe use find to grab the number from the other script.

ivory bobcat
#

But if the two objects are in the scene, you should consider referencing from the inspector instead: cs [SerializeField] private LogicoScripto logico; ...``````cs if(logico.playerScore > ...)

#

where you'd drag the other game object from the scene into the inspector field of the script that wants access to that object's component.

valid turtle
ivory bobcat
strong mica
#

sure

valid turtle
languid spire
#

because ToString is a method not a varaible

ivory bobcat
#

Methods should have ().

valid turtle
#

But how else would I get the Number from the other script?

#

I would like to use your first method

ivory bobcat
#

If you want to use find (not advise) you'd cache the component

valid turtle
#

how would I do that? 😦

ivory bobcat
#
    public int HighScoreValue;
    public Text HighestScore;

    void UpdateScore()
    {
        var logico = GameObject.Find("playerScore").GetComponent<LogicoScripto>();
        if(logico.playerScore > HighScoreValue)
        {
            HighestScore.text = logico.playerScore.ToString();
            HighScoreValue = logico.playerScore;
        }
    }```
languid spire
#

you missed the .text

modest dust
valid turtle
#

Dont want to end up in hell

modest dust
#

And here's the result

#

Take a normal C# course, the link is in the pinned messages in this channel

languid spire
#

well don't expect to be constantly spoonfed here

swift elbow
swift elbow
#

no ive been out for a long time, but its only because of persistence

#

would not recommend this method though

modest dust
#

I strongly advise to take a C# course

valid turtle
#

dont I just reproduce?

swift elbow
modest dust
swift elbow
modest dust
#

Those courses exist and are pinned here for a reason

#

You first learn how to place a single brick, then make a wall out of them

valid turtle
swift elbow
languid spire
swift elbow
#

but following along with courses will teach you problem solving as well

modest dust
#

Problem solving and syntax are two different things, but you still need both

dry geyser
#

can anyone help me with this script refusing to recognise AudioListener? it just keeps erroring that the refrence needs to be an instance of an object

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AudioSettingApplier : MonoBehaviour
{
    public AudioSource audioListener;

    private void Awake()
    {
        if (audioListener == null)
        {
            audioListener = GetComponent<AudioSource>(); // Automatically assigns AudioSource from the GameObject
            Debug.Log("assigned: " + audioListener);
        }
    }


    private void Update()
    {
        audioListener.volume = SettingsHandler.instance.Volume;
        Debug.Log(audioListener.volume*100);
    }
}
valid turtle
iron wind
modest dust
languid spire
swift elbow
#

For your case

valid turtle
#

Discouraging, but I guess I have to pull trough

languid spire
# dry geyser

then SettingsHandler.instance.Volume is your problem not the AudioSource

dry geyser
opal zealot
#

That's odd, I already have the InputSystem set up with the name but I cant connect it.

#

Following a video tutorial for the script in question: https://hastebin.com/share/xojunusoti.csharp
Said Video Tutorial is from here: https://www.youtube.com/watch?v=q-VfsQQlji0

Let's build a simple mechanism to move player around the scene. We are going to use the new Input system in unity. Let's learn how to receive inputs and read them. We will learn to create an action map, input actions and bindings to achieve our mechanism.

Please do support me on patreon.
Patreon - https://patreon.com/OpenWorldEra

Feel free to ...

▶ Play video
opal zealot
languid spire
#

`obvious error

PlayerInputSystem playerInput;
...
playerInput = GetComponent<PlayerInput>();
opal zealot
#

Ahh

snow warren
#

hello

#

i have a big issue going on here

#

whenever i instantiate a new game object

#

it says on the end of the name of the gameobject gameObject(Clone)

#

how to remove the (Clone) from the end of the gameobject

languid spire
#

seyt the instantiated objects name property

snow warren
#

i am setting names like this

languid spire
#

and please type in full sentences before pressing enter

snow warren
#

GameObject Managed = new GameObject("Managed");

snow warren
languid spire
snow warren
languid spire
#

sure

GameObject newObject = Instantiate(prefab);
newObject.name = prefab.name;
snow warren
#

i hope it works

opal zealot
swift elbow
#

you dont have the component on your object

languid spire
#

so your GetComponent is not working. Is the component on the same game object?

astral falcon
languid spire
languid spire
# opal zealot Ah

it always boils down to the same problem, you are assuming something which is not the case

opal zealot
astral falcon
# opal zealot I need to watch the video again.

I advice you to read the docs about the types and methods you are using in the tutorial. Otherwise you will just follow someone telling you what to do and have a very narrow learning curve

languid spire
#

and this is why I hate video tutorials, they show but do not teach

opal zealot
#

Tea

astral falcon
#

I rather read several pages of a blog post tutorial then watching one tutorial again, that is not covering a specific topic just to remind

opal zealot
#

I did miss something.

languid spire
#

yes, you forgot to add the PlayerInput component to the gameobject

snow warren
#

hey when i do change the name and remove the clone keyword from the end
it creates another gameobject with clone written at its end

#

how to deal with that?

languid spire
#

show your code

opal zealot
#

My bad, its all fixed by now.

astral falcon
opal zealot
#

Thanks Smith

snow warren
#

so i dont know what to show with it

languid spire
#

just post the bit where you are making the gameobject

snow warren
#
if (!UAEFileRoot.Find("target").Find("Managed").Find(ids.ToString()))
{
    GameObject Entity = new GameObject(ids.ToString());
    Entity.AddComponent<TypeFieldCell>();

    ContactInfo Infos = new ContactInfo();
    Infos.Name = Entity.name;
    Infos.Type = identifiers[54];
    Entity.GetComponent<TypeFieldCell>().ConfigueHierarchyCell(Infos);

    var obj = GameObject.Instantiate(Entity, UAEFileRoot.Find("target").Find("Managed"));
    obj.name = Entity.name;
}

Transform GEntity = UAEFileRoot.Find("target").Find("Managed").Find(ids.ToString());```
astral falcon
#

so you are creating a new gameobject already with Entity line, then instantiate a gameobject again

#

new Gameobject will just be an empty gameobject in your hierarchy

#

also, for whoevers sake, get a better way to avoid all those Find() calls.

snow warren
languid spire
#

because you are creating them

snow warren
#

one with no clone written at the end and other with clone written at the end

snow warren
#

ok i fixed everything

languid spire
#

this

GameObject Entity = new GameObject(ids.ToString());

create an new object and this

var obj = GameObject.Instantiate(Entity, UAEFileRoot.Find("target").Find("Managed"));

makes a duplicate of it

snow warren
#

now the word clone is gone

#

but there are duplicates

snow warren
#

then what's the instantiate for?

languid spire
#

you dont need the instantiate, replace it with Entity.transform.SetParent

snow warren
#

thanks for the big info

#

let me fix my code

languid spire
snow warren
#

its not easy to rewrite 5k lines

languid spire
#

that block is though

snow warren
#

its not a function

languid spire
#

and, if you have a 5k line script you are definitely doing something (probably lots of somethings) very wrong indeed

snow warren
#

it used to work

#

i intended to make a hierarchy like suppose you open a folder and you want to see the contents of the folder in a hierarchy like you open folders and stuff like that
previously i wrote the code when on button click the contents were shown
but now i am working on making it a complete hierarchy so in simple words i am just modifying the previously existing code

#

take a look at this

#

this is also a hierarchy but i this case of gameobjects

#

inside scene

languid spire
#

ok, that should probably be less than 200 lines of code, not 5k

snow warren
languid spire
snow warren
#

i turned 18 a few months ago

languid spire
weak cedar
#

I have a script that derives from Button. How do I add my own code to Start() or Awake(), or is there an alternative?

weak cedar
languid spire
burnt vapor
#

new hides the original method, and if you were to cast or match the old button, then it uses that Start method instead

#

Button inherits from Selectable, which inherits from UIBehaviour. This method has a virtual Start method you can override

#

So override, don't new

languid spire
#

It is my understanding from the OP's question that that is exactly what he wants

burnt vapor
#

@weak cedar

#

You add your own code by overriding

#
public class Button : UnityEngine.UI.Button
{
    override void Start()
    {
        base.Start();
        // Your code here
    }
}
#

new should generally only be used if a method is not virtual, though in this case you should wonder why it's not virtual in the first place

weak cedar
#

I'm making a custom button with some tweening animations, and since the Button completely overrides the inspector, I can't drag and drop image references

#

so I need to pass references somehow

eternal needle
#

would your start method even be called by unity if you use new?

burnt vapor
#

Not sure. I have no idea how this would fix their issue, hence why I suggest against it. But, this is probably my lack of understanding what the point is

weak cedar
burnt vapor
weak cedar
#

wdym by hides?

burnt vapor
#

The issue is that if you were to call one of the base methods, you would not call the final new method in one of its derived types. Compared to override which overrides the method and does call it

#

So if Unity calls Start in a way where it does it from one of the base types, it will not call your new method

#

And perhaps it actually calls it from MonoBehaviour. I don't know what logic they use here

#

Regardless, if this happends, it would call the final method. In your case there are no overriding methods, and thus the base virtual Start method is called

#

But like I said, I don't know your issue well enough to see why new could possibly work better here. I haven't used Unity enough for that

fluid lagoon
#

how do i make dynamic rigid body not flip in unity 2d i want my charechter to not fall and flip

weak cedar
#

appearently start in the uibehaviour is protected

burnt vapor
#

Doesn't matter

#

Use the correct access modifier

weak cedar
burnt vapor
#

Notice with the first and second line, both call the final override method and not the new method

#

It's only when you directly use the class with the new method where it works

languid spire
burnt vapor
#

Like I said, I don't know what logic they use and what is called in the end

#

This is just an example of the issue with new and why you should override instead

weak cedar
#

I'm not going to use any of the base classes methods. In fact, just Start()

weak cedar
burnt vapor
#

You're not the one calling the methods though

queen adder
#
using System.Collections.Generic;
using UnityEngine;

public class MovementScript : MonoBehaviour
{
    static string deathTag = "DeathWay";
    public GameObject player;
    public float moveSpeed = 5f;
    public Vector3 teleportPosition;

    private Rigidbody rb;

    void Start()
    {
        player.tag = "Player";
        rb = player.GetComponent<Rigidbody>();
        if (rb == null)
        {
            rb = player.AddComponent<Rigidbody>();
        }
    }
    void Update()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(moveHorizontal, 0f, moveVertical);
        rb.velocity = movement * moveSpeed;
    }

    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("DeathTrap"))
        {
            player.transform.position = teleportPosition;
        }
    }
}
``` MissingComponentException: There is no 'CharacterController' attached to the "PlayerBase (1)" game object, but a script is trying to access it.
You probably need to add a CharacterController to the game object "PlayerBase (1)". Or your script needs to check if the component is attached before using it.
MovementScript.Update () (at Assets/Scenes/MovementScript.cs:14)
cosmic dagger
queen adder
#

Fair enough 😄

wintry quarry
real geyser
#

i have this code here

#

and it gets scriptable object

#

but its not becoming one?

slender nymph
#

you cannot create an instance of an abstract class. you can only create instances of a concrete implementation

#

you also don't have a CreateAssetMenu attribute on that anyway so even if it weren't abstract, you can only create an instance of it in code

real geyser
#

in here i did override which is not instancing?

slender nymph
#

okay so then create an instance of that object using the Create menu

real geyser
#

ah

#

damn

#

mb

forest widget
#

Hey Guys i have an weird problem i am doing the unity beginner program and i just cant watch any of the videos because they wont load even tho i have a good and stable connection to my Wifi.
Has anyone a Tip for me how to fix it?

slender nymph
#

that's not a code question. that is not really even unity related as it's an issue with your own internet connection. if you cannot watch videos due to poor internet, then find text based courses

frozen plaza
#

how can I fire an event on EditorGUILayout.Toggle?

forest widget
frozen plaza
cosmic quail
hexed terrace
frozen plaza
languid spire
frozen plaza
#

pretty new to C#.. this means with get/set?

languid spire
vivid ginkgo
#

i have a main folder with many subfolders. these subfolders contain many images. i want to change the filter mode of all these images to Point no filter. How do i achieve this, can i automate this? I dont want to go each folder, ctr a and change it to point no filter, when there are about a thousand folders to get through.

vivid ginkgo
#

If anyone could help me, i would appreciate it a lot. thank you all

languid spire
past stone
#

Hello I have a Serializeable and I am having an issue where I cannot drag my Text or Image component to the list i am not sure why this is happening how do I make it work?

[System.Serializable]
  public class UpgradeUI
  {
    public Image icon;
    public Text name;
    public Text description;
  }
slender nymph
#

your Text component is probably actually a TMP_Text, as for the Image component, make sure your variable is the right type of Image. UnityEngine.UI.Image is not the same as the UIElements.Image type (you want the former)

past stone
#

i made sure that i am dragging a legacy text/image component and it says type mismatch or just not allowing me to do it

slender nymph
#

then are you perhaps trying to drag scene objects into a prefab or other asset?

past stone
#

yes

slender nymph
#

also consider switching from the legacy text to text mesh pro, it's better is nearly every way (unless of course you like your blurry text)

past stone
#

i see, so how do i correctly connect the text component to my script? I wanted to display the text from my script to the UI

slender nymph
fervent abyss
#

how can i await a method thats not async? or wait until this method is executed?

past stone
#

got it thanks

slender nymph
polar acorn
slender nymph
#

whatever is supposed to use that returnValue variable should be executed in the result callback. because this is clearly an API request which means that callback isn't executed here, it is executed whenever that API request completes

polar acorn
#

If you want something to happen after returnValue is true, instead of having this script return a value to something, just have the ExecuteCloudScript call that function instead of setting returnValue

faint osprey
#

is it possible for a raycast to be blocked by a trigger collider

languid spire
faint osprey
languid spire
#

no

faint osprey
#

oh oof mine was dont know when that happened or if its a unity 6 thing

wintry quarry
faint osprey
#

cool that fixed my issue

#
    {
        SceneManager.LoadScene("Tutorial" + player.currentScene.ToString(), LoadSceneMode.Additive);
        player.playerStart = GameObject.Find("PlayerStart" + player.currentScene.ToString());
    }```

is there a function to wait for unity to finish loading a scene or do i need to put this in a coroutine
astral falcon
faint osprey
#
    {
        Debug.Log("Loaded");
        player.playerStart = GameObject.Find("PlayerStart" + player.currentScene.ToString());
    }```
it doesnt call at all not even when i start the game
languid spire
lofty sequoia
#

is there a special process to using FormerlySerializedAs?
When I use it I add the header, save, rename, save, remove header, save, and it STILL loses all inspector references

faint osprey
languid spire
#

yes

faint osprey
#

thats giving me errors

astral falcon
languid spire
faint osprey
#

all i can see is putting it in onEnable but thats still giving me the error

astral falcon
keen dew
languid spire
#

method signature!

faint osprey
#

i had my params in my loadNextScene not OnSceneLoaded

languid spire
#

you need to pay more attention to what you are doing!

fading barn
#

Can animation controller be used for same purpose as state machine or behaviour trees?

slender nymph
#

the animator is a state machine so it can be used for that yes, behavior trees would likely be difficult in it but you can use unity's Behavior package for that

trail heart
#

I'd look out for performance though
Animator has an overhead cost since it's designed to blend many layers of properties when animating them

fading barn
#

Why do some features come in unity seperately as packages be installed instead of just being preinstalled?

languid spire
slender nymph
fading barn
#

Ok i get it.

languid spire
frozen plaza
#

no, every time..

languid spire
#

nah

frozen plaza
#

oh nvm.. the != value didn't work properly

forest widget
#

`using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MovementPlayer1 : MonoBehaviour
{
private float movingspeed = 10;
private float diry;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    if (name == "Player1")
    {
    diry = Input.GetAxisRaw("Vertical") * movingspeed;
    }
    if (name ="Player2" && Input.anyKey) //<-- Right here
    {
        if (Input.GetKey(KeyCode.I))
        {
            diry = movingspeed;
        }
        if (Input.GetKey(KeyCode.K))
        {
            diry = -movingspeed;
        }
    }
    else if (!Input.anyKey)
    {
        diry = 0f;
    }
    
}

}`
I searched online for half an hour and i cant find out why unity doesnt like that i use a && in the if condition...

cosmic quail
forest widget
rustic maple
#

"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:set_destination (UnityEngine.Vector3), how can i fix this error? because my game wont start either, this is the script ive been using: https://gdl.space/mamivalena.cpp

cosmic quail
wintry quarry
rustic maple
#

yeah i did, but at first the blue "ground" was there, and later it dissapeared

cosmic quail
rustic maple
#

i just re bake it a second ago and nothing happened

crystal fiber
#

So i want to get the Axis of the Mouse X (and y) without the value going to a negative value, but the Horizontal and Vertical ranges change from 0 to +1 or -1. i want to get the axis of the mouse at only a positive value whenever you move ur mouse, is there soemthing that might do that?

crystal fiber
#

Wait

lofty sequoia
wintry quarry
#

or do you want [-1, 1] to become [0, 1] ?
Or something else?

#

FYI if you're still interested in this or haven't figured it out on your own, that asset is now free.

tender stag
#

thanks for letting me know

#

i'll check it out

rustic maple
slender nymph
#

do you have gizmos enabled and the navmesh surface object selected in the hierarchy?

slender nymph
#

well those screenshots aren't very helpful at all. if at this point you've determined that your navmesh is not baking, then the issue is likely whatever settings you have for the navmesh surface. share the relevant setup details in #🤖┃ai-navigation

rustic maple
#

alr sorry for that

sand goblet
#

Hello, what would people consider a comprehensive Unity course for someone already knowing C#? In the search I found people discourage paid courses, but not sure what else would be recommended?
LIke, sure, I can look up 50 different YouTube tutorials (though I've heard mixed opinions on those too), but is there something nice and comprehensive by a single person/string of videos? I tend to prefer that than different teaching styles etc

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

sand goblet
#

Neat, thanks

nova wagon
#

Hey i have a Problem where i try to set a Variable of a Script (added to an Object) via the inspector. In my code the corresponding lines are
[SerializeField] private InputField FieldA;
[SerializeField] private Text FieldB;

but i cant drag and drop or choose the corresponding Inputfield / Text Object. any1 know what i am doing wrong?

slender nymph
#

your components are probably the text mesh pro ones not the legacy ones, so your variable types need to match. TMP_InputField and TMP_Text

nova wagon
#

so
[SerializeField] private TMP_InputField FieldA;
[SerializeField] private TMP_Text FieldB; ?

slender nymph
#

if my guess about the actual components was right, then yes

nova wagon
#

do i need extra using directives now ?

rich adder
#

using TMPro

slender nymph
#

yes, your !IDE should have suggested or autofilled them when you used that. assuming it is configured

eternal falconBOT
nova wagon
#

❤️ Legends thank you

twin bolt
#

How do i use .parent to check for the closest parent?

steep rose
#

You would loop though all the parents around you

#

And find the distance between each one of them to you

earnest yoke
#

Anyone mind helping me so solve these errors?

deft grail
patent imp
#
        {
            Debug.Log("Key 1 is pressed");
            transform.GetChild(0).GetComponent<Image>().enabled = false;
        }
        if (isSelected == null)
        {
            Debug.LogError("isSelected Image is not assigned in the Inspector!");
        }
        else
        {
            Debug.Log("isSelected Image assigned successfully.");
        }``` It saying "NullReferenceException: Object reference not set to an instance of an object
Slots.Update () (at Assets/Scripts/Slots.cs:33)" but i have the image in the slot can some help ChatGPT is being useless. im not sure what info is usefull so please ask if you need more
deft grail
patent imp
#

transform.GetChild(0).GetComponent<TextMeshProUGUI>().enabled = false;

#

it was all working intell i wanted that select thing

#

its all from a tutoral but that other part im adding

deft grail
patent imp
#

oh wow it was that simple. I had the image as the first one

wintry quarry
deft grail
#

which is possible even if its a prefab since its on 1 game object

patent imp
#

I have 9 slots and they are under inventory which is under a canvas. If i make it a componet will they all change at once?

wintry quarry
patent imp
#
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;

public class Slots : MonoBehaviour
{
    private InventoryController inventory;
    public int i;
    public TextMeshProUGUI amountText;
    public Image isSelected;
    public int amount;

    // Start is called before the first frame update
    void Start()
    {
        inventory = FindObjectOfType<InventoryController>();
    }

    // Update is called once per frame
    void Update()
    {
        amountText.text = amount.ToString();

        //Turns off text if nothings there
        if (amount >= 1)
        {
            transform.GetChild(0).GetComponent<TextMeshProUGUI>().enabled = true; //The 1(it starts from 0) is the first child under slot (1), amount. It then gets a component which is TextMeshProUGUI. It then enables it(the checkmark)
        }
        else
        {
            transform.GetChild(0).GetComponent<TextMeshProUGUI>().enabled = false;
        }

        if (transform.childCount == 3)//This is the amount of child under the slot if add more gui change this number
        {
            inventory.isFull[i] = false;
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            Debug.Log("Key 1 is pressed");
                isSelected.enabled = false;
        }
    }

    public void DropItem()
    {
        if (amount > 1) //If its stacked
        {
            amount -= 1;
            transform.GetComponentInChildren<Spawn>().SpawnDroppedItem(); //I think that last part is calling the function in spawn script
        }
        else if (amount == 1)
        {
            amount -= 1;
            GameObject.Destroy(transform.GetComponentInChildren<Spawn>().gameObject);
            transform.GetComponentInChildren<Spawn>().SpawnDroppedItem();
        }
    }
}
#

sorry i forget you can see everything i can. the slots have a counter if the items in it and the number turns off if there not an item in it

#

im just confused on how it knows which of the 9 to turn off.

#

Nevermind every thing

#

i just figured it out

polar acorn
#

It knows which one to turn off because that's the one you've told it to turn off

patent imp
#

ya the thing im trying to add is throwing me off my i think i got it now

tawdry quest
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

steep rose
#

All AI knows is related topics from the internet, so if those topics are wrong, it will be inheritly wrong. thats why we do not suggest AI for coding since its also better to use your brain which is supposed to be able to constructive think and critical think to solve an issue.

#

and its better to actually understand what you are doing rather than mindlessly doing it

cosmic dagger
#

you learn more by reading through those 50 topics to get the answer. it's the journey (along the way), not the result . . .

#

then you have an understanding of the problem and how to solve it, instead of just the code for the solution . . .

#

that's a big difference . . .

eternal needle
#

At this point, we might need some message to link about this conversation considering it gets suggested to beginners so often.

#

Though I dont really understand what they were suggesting, since one message says to learn properly and the next says to use AI instead of google.

tawdry quest
#

dont use it if you have no knowledege

#

thats the base of it

tawdry quest
#

cuz the AI even explains it to you

tawdry quest
sand goblet
#

(Assuming the AI explains correctly and doesn't invent things from thin air)

tawdry quest
#

And the lowend free version is garbolium, i should mention that

#

so if your trial GPT4 prompts runs out, you should stop using it or pay for the full version

tawdry quest
#

using it multiple times a week, so far none of the specialised gpts have hallucinated

steep rose
#

why use a tool thats wrong? and has proven to be wrong

tawdry quest
sand goblet
#

I mean, it can be a neat tool. Just whenever I used it, it usually eventually spits out something wrong and when I try to correct itself on it it either
a) claims it corrected but spits out the same code or
b) gives completely different code that has some new issue

tawdry quest
#

if were talking GPT 3.5 yes that was really bad, but since GPT 4 and the specialised GPTs it has gotten a lot better

steep rose
#

K whatever you say then, im not gonna argue an arbitrary point just to be correct 🤷‍♂️

tawdry quest
#

since that likes to do that, especially the claims it corrected but spits out the same code

sand goblet
#

I think even waht I tried of 4 did that a bunch. Maybe less with Unity, idk. It wasn't great at Rust

polar acorn
#

Why pay for the plaigarism machine

tawdry quest
#

or just the general ChatGPT prompt that isnt trained on a language

polar acorn
#

you could probably pay an actual tutor instead

steep rose
#

or use critical thinking and documentation

tawdry quest
#

what do i need a tutor for, i know how to code, its just a faster google

steep rose
#

if you have to rely on GPT as a tool then you're not learning much

sand goblet
#

Well there's a difference between knowing when it spits out stupid stuff and just using it as a google-like
And not knowing when it tells you made up stuff

tawdry quest
#

it gives me the correct thing i need and even an example and how to implement it and if i need more info it can link me to relevant posts

#

no need to waste 20 min on google going trough forums or stackoverflow

polar acorn
#

How much are you paying versus how long does it take you to google something?

tawdry quest
#

you just just not should want it to provide code for you, like "program me a loop that does this and then that and returns something else"

ripe shard
#

why don't you just write it yourself, thats much quicker 😮

tawdry quest
tawdry quest
#

idk if yall cant read

glad merlin
#

I just joined what’s going on

ripe shard
#

trolloing

tawdry quest
#

you use it to get specific help or like functions, not to get entire code and it works wonderfully

steep rose
# tawdry quest this

thats a contradiction to what you said after

AI especially Chatgpt 4s specialised coding Chats are very good at coding, if you can give it specific tasks and ask for specific help
Its way faster then googling and searching trough 50 topics 

tawdry quest
#

no ?
if you can give it specific tasks and ask for specific help
Its way faster then googling and searching trough 50 topics

#

not for generic coding stuff

glad merlin
polar acorn
#

Literally what are you googling for that you can't like, immediately find?

sand goblet
#

What are you googling that requires searching through that many topics

tawdry quest
#

there is so many stuff in C# and Unity thats not directly explained and you have like 40 different threads with a different answer, unless you are a complete beginner

#

saying the same thing to chatgpt gives you a summary and the most liked implementation

steep rose
#

the documentation explains them very well

sand goblet
#

If there's that much conflicting info, I dunno why the AI would know the silver bullet, but eh

tawdry quest
#

its like an optimized search engine

sand goblet
#

I'm going to doubt the "has all of them" part

tawdry quest
#

its litterally a web scraper

#

it has all of em

#

if it doesnt, it can scrape more sites for you

steep rose
#

did you know the internet also has all of them

tawdry quest
#

yes if you like to search

#

i rather code and get shit done

sand goblet
#

How do I know if it does or does not have all of them and thus need or don't need to tell it to scrape more

tawdry quest
polar acorn
#

So, if you are willing to pay money and download a chatbot, you can get type your message into a different page than google and get the same information at roughly the same rate

#

Totally worthwhile

tawdry quest
#

download a chatbot ?

#

its a website

sand goblet
#

Well, it working and explaining it well doesn't necessarily mean it's the best way

tawdry quest
#

its litterally a prompt like on google, but instead of searching you get an immediate answer

steep rose
polar acorn
#

Okay, so it is just google

#

google you pay for

tawdry quest
steep rose
tawdry quest
#

if it works and doesnt steal you 50 fps it does the job

sand goblet
#

well you said the AI has all and can show the best option

tawdry quest
#

code to get stuff done, dont code to code pretty & optimized

tawdry quest
steep rose
tawdry quest
#

what

steep rose
#

you make optimized code and working code

polar acorn
#

I don't really know what you're getting at on this one either

#

I can't really vouch for how good the paid chatbots are because seriously who the hell spends money on the plaigarism machine, but I think you're vastly overestimating how long it takes to google basically anything programming related

tawdry quest
#

im a programmer since im 12, im now 25, i have googled so many programming stuff and i hell i do be searching around 5-25 different websites till i find a good answer sometimes on more niche questions, while chatgpt just goes: "I got you: answer"

#

Thats a huge value for 20$ a month in saved time

polar acorn
#

there's like twelve websites on the entire internet

#

Any problem you'll search for will take you to either the documentation or StackOverflow

tawdry quest
polar acorn
#

It's seriously not hard to find anything. Data has been collected into these monolithic Websites of Alexandria

tawdry quest
#

im using this since GPT 4 (April), there are still so many random blogs and sometimes 12 different stackoverflow & 20 different reddit posts about one thing, prolly even more then 8 years ago

#

and then the next thing is so niche you only find a random ass article from 2015

polar acorn
#

Okay but why would you click on any of those

tawdry quest
#

to get an answer to my question, honestly this is useless, i tried to proove the point, but im talking against a wall with you guys

polar acorn
#

I feel like I've given a pretty solid response - googling is not hard and saving half a second is not worth $20

eternal needle
#

you dont even save half a second. This is just not knowing how to google. This is why at the start i said we should have some message or something we can link to for others to read about why you shouldnt suggest it to beginners. The ones using AI always like to just say "its never made up things that seems truthful to me!". Well either it has, or you're asking it to make for loops.

tawdry quest
#

This is just not knowing how to google. yep sure buddy 👍

polar acorn
#

You've said you find googling too difficult

#

That's why you pay $20 for a chatbot to google for you

tawdry quest
#

bye

eternal needle
# tawdry quest This is just not knowing how to google. yep sure buddy 👍

My point is more for the beginners that see this conversation and want to justify their use of AI.
But everytime someone advocates for AI its always the exact same conversation everytime. "It works for me why wont you guys listen". Yea ive went through the whole AI phase too. when I needed it for something else, i figured i might as well try out the coding side of it. It was horrible, yes even on gpt4. Sure you could ask it to make a for loop for you, and itll do it. But as soon as you want something above what a first year programmer can do, you're stuck on this cycle of "well if i just adjust my prompt maybe itll understand me this time!".

#

And anyways, you claim you're talking to a wall while repeating the same points we've seen dozens of times and clearly show you dont know how to google by your own points. I havent seen you actually address a point other than saying "chatgpt can do it without going through 50 links"

tawdry quest
#

I havent seen you actually address a point other than saying "chatgpt can do it without going through 50 links
cuz thats my main point ? It can answer your questions about programming and functions or implementations, without you needing to search for ages;
but it cant really code for you, litterally the first thing i said about it at the beginning... oh boy notlikethis

polar acorn
eternal needle
tawdry quest
#

"Most of the time you don't even have to click on anything" Thats not even remotly how it works

#

or youre searching for really simple stuff

#

but more complicated stuff you will have to go trough 2-3 posts minimum, extracting all the info, while chatgpt already has all that info can can just give it to you

#

thats what its useful for

#

and since gpt free has a worse database and cant do webscraping, its basically useless in general

polar acorn
steep rose
#

its a built in function of google

#

and the descriptions of sites also tells you a lot

tawdry quest
eternal needle
steep rose
rich adder
#

remind me of those late night infomercials , they make everything seem/look so difficult and inconvenient .

tawdry quest
#

i tried it last year and it barly ever popped up

steep rose
tawdry quest
eternal needle
opaque fox
#

anyone know how to tint an object a certain color when mousing over it rather than changing its color entirely?

i have an object that's disabled by default over the tile that activates when you mouse over it, but the highlight flickers rapidly

polar acorn
tawdry quest
#

i did the opposite

#

so why we even arguing

opaque fox
#

the problem is the object on/off rapidly

#

(this also means this isn't a tint i know)

eternal needle
eternal falconBOT
eternal needle
#

but if theres an object on top, then your mouse probably isnt over the same object anymore

polar acorn
#

and so on

tawdry quest
#

yeah the whole discussion was completly my bad

#

But yeah you @eternal needle @polar acorn @steep rose convinced me to give googling another chance even if gpt works for me, maybe its not worth it throwing money at them for faster results.

#

Thanks guys

tender stag
#

why is it not visible?

#

is it cause its static?

#

well it cant be cause of that

tender stag
opaque fox
opaque fox
#

thats why it’s flickering

polar acorn
tender stag
polar acorn
tender stag
#

i need them static

polar acorn
#

then you can't set them in the inspector

tender stag
#

brudda

polar acorn
#

They are mutually exclusive

#

Why do they need to be static?

tender stag
#

what about this

#

wait

#

remove the first static

#

nvm it still wont work

tender stag
polar acorn
tender stag
#

thats how long the line will be

#

with the .Instance

rich adder
#

use new input system with events ?

tender stag
#

i dont like the new input system

#

cant get into it

#

and dont have time to get into it

rich adder
#

oh alr , just makes what you're doing easier

tender stag
#

i know it does

#

but i just dont have the time to learn it

#

i tried it before

#

wasted over 2 months

rich adder
#

2 months? tbh it took me a few days, there are not just 1 way to use thats why

polar acorn
tender stag
#

true

polar acorn
#

I can't post the dismissive message because of the bot but it really is all that can be said

queen adder
#

making coroutines worse catlaugh

rocky canyon
#

heck ya

queen adder
#

I hope they totally remove obsolete methods and members on unity6

#

Random.RandomRange sux

tender stag
#

why cant you pass in multiple variables through an event?

#

like in a button

#

it can only be 1

rocky canyon
#

i was trying to make it read better..

#

but no luck

queen adder
rocky canyon
#

it actually reads better the way it is originally lol

teal viper
rocky canyon
#

using the Mono then .Run(Coroutine)

rocky canyon
#

just b/c it cant be done via the inspector doesn't mean it cant.

queen adder
rocky canyon
#

if it helps you go for it

queen adder
#

can just fix it later with a single magic regex lol

#

having me explain how my brain works just wasted back the time saved by doing this weird stunt tho lol

rocky canyon
#

thought there mighta been something there.. that i could add to my utils class

#

alas.. dont think so for me lol

tender stag
#

but i meant like visually

#

through the editor

rocky canyon
#

StartCoroutine(Rebound()); ftw

hollow slate
#

y'all trying to make a coroutine act like a method...?

queen adder
rocky canyon
#

not i.. Laptop might be

#

i was just goofin lol

rocky canyon
#

would be dope

queen adder
#

actually maybe I'll try looking at coroutine class lol

teal viper
queen adder
rocky canyon
#

ya, but its cooler

queen adder
#

the first one could be possible at least

rocky canyon
#

why not the second? you could use ur own Coroutine class.

#

wrap it in a namespace

#

nvm that would refactor back to what the original is

opaque fox
#

tried adding a while (true) loop to the OnMouseOver() method but that proved to be really bad

#

guess i could separate this code and add it to the object on the tile prefab, unless there's an easier way to do a tint effect?

polar acorn
iron wing
#

when I add my animation triggers they just play forever by deafult when i start the game. how do i stop that from happening?? I disabled "Loop Time" by clicking on the animation but it didnt do anything

opaque fox
rich adder
polar acorn
iron wing
polar acorn
#

don't

rich adder
iron wing
opaque fox
#

This isn't seeming to work either. The cube on this Tile3D object has the script attached, and I also made it so the Rendering mode is Transparent. OnMouseEnter isn't activating at all now.

polar acorn
rich adder
#

also GetComponent<GameObject>() is redundant as you can just get the gameobject with the property gameObject VS is trying to hint you at that

opaque fox
rich adder
#

if its a mesh, switch the material or use the color parameter on the material's shader

polar acorn
#

You can just change the color of the material or whatever other kind of renderer it's using

opaque fox
#

ah

opaque fox
#

i see now tho

rich adder
#

one is the prediction / intellicode in VS, the warning comes from Unity message / library

#

both are not exactly talking to eachother

opaque fox
#

Okay so I made sure the game object isn't disabled by default, but the OnMouseEnter code still isn't executing

#

it has a box collider and everything

#

unless it needs a box collider bigger than it

rich adder
#

bigger than it?

#

OnMouseEnter just cares about colliders

opaque fox
#

wrong word

#

i meant uhhhh actually yeah i do need a collider

rich adder
#

also put logs to always test if a function is running

opaque fox
#

okay the script isn't even activating

#

okay i found it, had another SetActive(false) somewhere

#

The parent object in the prefab was setting it inactive

rich adder
#

btw you should consider using a Raycast instead or even just the Event System with the Ipointer interfaces

#

you can have a bit more control on the hits / debugging information about hit objects

vivid slate
#

!bug

eternal falconBOT
#

🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.

📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!

💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.

For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting

vivid slate
#

i need help with some code i’m getting an error code and have no idea how to fix it

#

!code

eternal falconBOT
vivid slate
#

//cs

frosty hound
#

Try again

#

And if you're going to drop code for that long, use a bin site.

tawny edge
#

How do i learn coding?

I was in the middle of doing a unity course, then decided to make a small project, i then went to the first tutorial that looked decent but i feel overwhelmed.
the tutorial doesn't seem bad but i'm unsure how do i learn code.
Should i understand every line here?
Should i just copy paste code even if i don't 100% understand how it works to focus on finishing my project?
What is the best aproach to learn?

ttorial is this by the way:https://youtu.be/f473C43s8nE

FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial

In this video I'm going to show you how to code full first person rigidbody movement. You can use this character controller as final movement for your game or build things like dashing, wallrunning or sliding on top of it.

If this tutorial has helped you in any way, I would really appreciate...

▶ Play video
outer wigeon
#

Ive never seen this yet - is this just a unity bug? 'Unity self'

ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
UnityEditor.SerializedObject.FindProperty (System.String propertyPath) (at <9920ff0c944845d7b9f9a61ef1478edc>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindPropertyRelative (UnityEngine.UIElements.IBindable field, UnityEditor.SerializedProperty parentProperty) (at <8c3449848bd845499081ddbe4a09b367>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <8c3449848bd845499081ddbe4a09b367>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <8c3449848bd845499081ddbe4a09b367>:0)
UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation+BindingRequest.Bind (UnityEngine.UIElements.VisualElement element) (at <8c3449848bd845499081ddbe4a09b367>:0)
UnityEngine.UIElements.VisualTreeBindingsUpdater.Update () (at <7c69dfc1e63a4ea388c73014d3c7ce20>:0)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <7c69dfc1e63a4ea388c73014d3c7ce20>:0)
UnityEngine.UIElements.Panel.UpdateBindings () (at <7c69dfc1e63a4ea388c73014d3c7ce20>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <7c69dfc1e63a4ea388c73014d3c7ce20>:0)
UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <7c69dfc1e63a4ea388c73014d3c7ce20>:0)
UnityEditor.RetainedMode.UpdateSchedulers () (at <8c3449848bd845499081ddbe4a09b367>:0)
#

It's solved on relaunching the project but I'm not exactly sure what I did to trigger it in the first place

vivid slate
eternal needle
eternal needle
rich adder
eternal needle
vivid slate
vivid slate
pure crest
#

Hi all! I've been working on a basic first person game, and I wanted to use ray casts to shoot out to deal with a player interacting with the object they're looking at, and I have some basic code online using Debug.DrawLine that should just project a ray from the player's view to where they're looking but for some reason no matter how I program it, the ray always starts at the camera (Like its supposed too) but it will only point towards the ground no matter where the player moves. Im pretty stumped here as I've tried a bunch of different methods of fixing it

rich adder
eternal falconBOT
rich adder
#

also for rays yes you should use DrawRay, or even better Physics Debugger

pure crest
#

i've spent at least 5 hours trying to figure it out and it was literally just that, ive been going insane

#

thank you so much

#

i dont know how in all my searching I didnt realize I was just using the wrong debug 😭

rich adder
#

much easier to use physics debugger these days , hardly need to draw physics queries anymore

#

makes code repetitive, if you change raycast you gotta remember to match the debug n vice versa

pure crest
#

I was mostly using the draw debugging to make sure I was understanding rays correctly before I attempted to implement it

#

I didnt wanna implement the system unless I knew exactly how it was acting visually

pure crest
#

thanks!

steep rose
#

But yes do what navarone said, I didn't know that existed 😂

#

Unless it is a unity 6 thing, then I definitely wouldnt have known

rich adder
#

I just linked 6 docs cause 2022 is being weird lol

steep rose
#

Ah okay good to know, I guess I'm just living under a bunch of nested if statements 😄

rich adder
#

its lowkey a good feature to have especially for visualizing Spherecasts n such

hallow sun
#

wtf i think unity is struggling with simple division

#

check the variable named A, it is just for debugging and is simply the values of velocity x/y

#

not only does it ignore that i try to make it negative, but the division itself is way off

meager gust
#

computers don't struggle with basic division

#

you should probably verify the math in a debug.log rather than the inspector

hallow sun
#

you are right, debug log shows the correct result

wintry quarry
polar acorn
# hallow sun
Debug.Log($"-({vectorVel.x} / {vectorVel.y}) = {a}");

Right after the line

bold gale
# teal viper OnVisible should work imho. Unless you're using occlusion culling.

yeah, specifically im disabling a renderer until a player first looks away from the collider, then ill change the collider layer to include the player and then enable the renderer, but ive got it working and if anyone else is interested in raycasting the entire camera this is what i came up with

// in FixedUpate()
Vector3[] frustumCorners = new Vector3[4];
camera.CalculateFrustumCorners(new Rect(0, 0, 1, 1), camera.farClipPlane, Camera.MonoOrStereoscopicEye.Mono, frustumCorners);

Vector3 topLeft = frustumCorners[1];
Vector3 topRight = frustumCorners[2];
Vector3 bottomLeft = frustumCorners[0];
Vector3 bottomRight = frustumCorners[3];

Vector3 vertical = bottomLeft - topLeft;
Vector3 horizontal = topRight - topLeft;

int vAmount = 4;
int hAmount = 8;

for (int i = 0; i < vAmount; i++)
{
    for (int j = 0; j < hAmount; j++)
    {
        Vector3 point = topLeft + (((vertical) / vAmount ) * i) + (((horizontal) / hAmount ) * j);
        point = camera.transform.TransformVector(point);
        // Debug.DrawRay(camera.transform.position, point, Color.blue);

        if (Physics.Raycast(camera.transform.position, point, out RaycastHit hit))
        {
            if (hit.collider.gameObject.TryGetComponent(out ICameraSenseable senseable))
            {
                senseable._CameraViewFixedUpdate();
            }
        }
    }
}
teal viper
#

Still not sure what's the point of that. It's like checking against the frustum planes(+ maybe one raycast), just a lot less accurate.

#

And probably less performant.

queen adder
# bold gale yeah, specifically im disabling a renderer until a player first looks away from ...

It is pointless to create occlusion culling by yourself. The engine has it's own ways and it should get updated by them in order to make system stable. This is because they are the ones who can implement a system that is optimized very well since they can implement to the core of the engine. Even tho Unity 5 have Occlusion Culling, it is not enough for large worlds due to floating point errors and Unity provide no support for floating point while Unreal does. In Unity 6, they just updated the Occlusion Culling and told users that is a game changing shit but the same technology (GPU based OC) was always been there in Unreal...
So still, if you want a large open world, you COULD use Unity 6 or switch to Unreal for really better performance.

queen adder
graceful lintel
#

is it possible for some Start() to be called first before other object's Awake()?

#

Or did I do something horribly wrong...

teal viper
graceful lintel
waxen adder
#

Let's say I have a prefab. It's an empty gameobject with a model as a child. I would like to change specifically the material of the child to be a certain color. How would I do this?

#

To answer my own question: GetComponentsInChildren

Also, it would be wise to not have the same component in the hierarchy of the prefab

slender sinew
waxen adder
slender sinew
#

if you are dealing with child objects, usually it's good to make a new script to put on the parent so that you can assign references there

#

relying on GetComponentInChildren / Parent is not usually ideal

waxen adder
#

Oh, yeah that would also be a very good idea lol

#

Actually didn't think of that

real rock
#

Is doing Vector3.Dot(Vector3.up, myDirection) an effective way of finding the upward component of a vector or do I need to do actual trig? (Vector3.up could be the up of any vector, so .y doesn’t apply)

eternal needle
real rock
#

So I’m trying to do some vehicle physics stuff (don’t want to use wheel colliders) and having the right force be pushed back up from the ground is proving tough, so if I wanted to isolate just the force acting downwards after it’s acted through the suspension is it doable with .Dot or will I need to do trig?

#

(I may also just be entirely over thinking this and I can just have my suspension calculation handle gravity too idk)

eternal needle
#

If you want only the up/downwards force just take the y component of the vecror

#

I'm not really sure what you mean in the first message saying .y doesnt apply

real rock
#

Rather up/down according to a normal?

#

Wait I think I’m overthinking this anyway

eternal needle
clever idol
#

In a rigidbody you can add a mass, mabye you can try that too? Im no expert btw

real rock
#

I think I have it now though

wheat brook
#

Hello so I was creating a game where I need to throw food at my pan and then take the pan to the counter

  • After throwing the food it goes inside pan
  • but as soon as in move with the pan the food falls down
  • I want to make it move with pan and fall when I rotate it 90 degrees
languid spire
#

so parent the food to the pan and then unparent it when you rotate

wheat brook
#

The food is instantiating don’t want it to parent as soon as it instantiates ( drops )

#

Should I use enumeration or something

languid spire
#

so you parent it when the food hits the pan

wheat brook
#

Will try it basically the game is mining food ⛏️ so while mining it instantiates the food and it drops in the pan- excavator

pastel vector
#

Sorry couldnt find any other channel for this. Haven worked wih 3d i unity before and cant seem to find a way for a parent not to include its children when calculating its bounds. This is quite annoying since I want to rotate a object from a custom pivot and I thought just adding a parent could be done to controll the pivot (as you do in any other 3d package) and with 2d
Seems lite there is something really basic I missed

languid spire
pastel vector
#

With childeren:

#

Without

#

@languid spire as you can see the pivot changed when adding a child

keen dew
#

Change this to Pivot

pastel vector
keen dew
#

No, only the editor

pastel vector
#

Ok its maybe just an editor problem then? When roating the parent it will have a pivot at it position in world space?

wintry quarry
pastel vector
#

but yes you are right

wintry quarry
pastel vector
lapis frigate
#

I have these 3 variables (The bloodSacrificeChance and the 2 below it,) and when I set them up in the start method and then debug them they equal to what they should but when I use them in a diffrent method in thescript they just change to 0 for some reason and the isBloodUsed changes to false

#

the variables 3 at the top

#

for example when I debug them in this method they are equal to 0

polar acorn
#

Show full !code

eternal falconBOT
polar acorn
polar acorn
# lapis frigate https://gdl.space/ukofifesep.cs

Okay, so, you're calling it on the instance in the enemiesLibrary. I'm assuming that's set in the inspector, since it's serialized. Can you show me the inspector for the EnemiesLibrary component?

polar acorn
# lapis frigate

Okay, so, the knight unit is the one with problem, right? Double click on that box in this inspector, show the object that comes up

stoic tendon
#
using System.Collections.Generic;
using UnityEngine;

public class verschijnfuse : MonoBehaviour
{
    public fuseskript fuse;

    void Start()
    {
        // Controleer of dit object de tag "fuse" heeft
        if (gameObject.CompareTag("fuse"))
        {
            gameObject.SetActive(false);
        }
    }

    // Update is called once per frame
public void place()
{
    Debug.Log("Activating fuse object.");
    gameObject.SetActive(true);
}
}```

why isn't my gameObject appearing?
stoic tendon
polar acorn
# lapis frigate

So, it's a prefab. The prefab itself never enters the scene, so it's Start() function is never called

stoic tendon
#

it like placing something

polar acorn
polar acorn
# lapis frigate

Your EnemiesLibrary should reference the instances in the scene, rather than the prefabs. That way they'll have run their Start methods and whatnot

stoic tendon
polar acorn
polar acorn
# stoic tendon

Okay, and what is ObjectInteraction? When does this call that function?

stoic tendon
#

when i hover the object and click 'e'

lapis frigate
polar acorn
#

I found it, it's in SetupBattle

#

You're spawning a clone of enemyUnit, but then you're changing the prefab's currentHP and whatnot

stoic tendon
#

i added a debug thingy and when i click e it shows the messages but it does not let the object appear.

polar acorn
polar acorn
stoic tendon
#

no but do you know the solution of my problem

polar acorn
stoic tendon
#

yup

polar acorn
#

Then this object is being enabled

stoic tendon
#

but i can't see it

polar acorn
#

Show the inspector of the object with your verschijnfuse script on it after the log prints

lapis frigate
polar acorn
# lapis frigate umm tbh I'm still not that sure how exactly do I use that

Instantiate makes a copy of something and puts it in the scene. You're making a copy of your prefab and putting it in the scene. That copy then runs Start and sets its variables. enemyUnit is still the prefab that was not put in the scene and therefore has not set any of its variables in Start. Instead of using enemyUnit, you should use the thing that Instantiate created

stoic tendon
#

it stays like this

polar acorn
#

after the log

languid spire
stoic tendon
polar acorn
# stoic tendon

No, the object you're trying to activate, the one with the verschijnfuse script on it

languid spire
lapis frigate
#

isn't that what instaniate is created

polar acorn
#

How would you reference it if you don't actually keep a reference to it?

lapis frigate
#

I mean cuz its already in the scene

languid spire
#

but not in your code

stoic tendon
#

this objects dissapears when clicking on play. and it does not appears

polar acorn
polar acorn
lapis frigate
#

ok so after I stored the instantiate in a variable what do I do?

polar acorn
polar acorn
stoic tendon
stoic tendon
lapis frigate
polar acorn
lapis frigate
#

im sorry if it sounds dumb im just still not that great at coding

polar acorn
stoic tendon
lapis frigate
#

I mean I have one but I dont refrence it anywhere

polar acorn
#

The one you got from your enemy library

polar acorn
stoic tendon
polar acorn
#

It's working fine

lapis frigate
#

so I should replace every place I write enemyUnit in the battlesystem script with the nameof the new variable?

polar acorn
lapis frigate
#

aight

stoic tendon
polar acorn
stoic tendon
#

Yes, the object is activated, but the fuse doesn't appear. It just stays dissappeared

#

That isn't working

polar acorn
stoic tendon
#

the parent is a whole object.

polar acorn
#

Also, this looks pretty visible to me

stoic tendon
#

the right fuse has to appear

polar acorn
#

The one you have selected is the one outlined in orange

#

That's the object you're activating, and it's active

stoic tendon
polar acorn
lapis frigate
#

aight I did it and it accualy works now tnx @polar acorn

polar acorn
lapis frigate
#

actually *

amber nimbus
#

Hello, I was just wondering whether I should use Rigidbody for character movement. It would be a pretty basic movement, crouching and maybe mantling/hopping over objects. I cant decide if I should use Translate or Rigidbody. I am not really keen on the Character Controller component, as I think it would be easier for me to work with my code when implementing new stuff later on.

polar acorn
#

Your code's been referring to the Fuse1 object

stoic tendon
polar acorn
polar acorn
stoic tendon
#

so i need to make 2 skripts for this action?

polar acorn
#

Or have your script toggle a different object instead of itself

stoic tendon
#

Well i seperated them by using the tag 'fuse' so this object doesn't dissapear when you click on play

polar acorn
stoic tendon
#

    void Start()
    {
       
        if (gameObject.CompareTag("fuse"))
        {
            gameObject.SetActive(false);
        }
    }
polar acorn
#

if you want it to enable or disable a different object, you should use that

stoic tendon
polar acorn
#

You don't need two scripts

#

Just have this one reference a different GameObject and toggle that one

stoic tendon
#

how?

#

Sorry im just a noob with this lol

polar acorn
#

By calling SetActive on that object instead of this one

stoic tendon
#

Verdwijnfuse.SetActive(false);

#

this?

polar acorn
#

Sure, if Verdwijnfuse is a reference to the GameObject you want to toggle

stoic tendon
#

Assets\scripts\verschijnfuse.cs(21,5): error CS0103: The name 'Verdwijnfuse' does not exist in the current context

#

Im getting this error.

polar acorn
stoic tendon
#

the object i want to appear/dissappear

polar acorn
stoic tendon
#
using System.Collections.Generic;
using UnityEngine;

public class verschijnfuse : MonoBehaviour
{
    public fuseskript fuse;

    void Start()
    {
        {
            Verdwijnfuse.SetActive(false);
        }
    }

public void place()
{
    Debug.Log("Activating fuse object.");
    Verdwijnfuse.SetActive(true);
}
}```
polar acorn
#

You have not made a variable of that name

stoic tendon
#

UnassignedReferenceException: The variable Verdwijnfuse of verschijnfuse has not been assigned.
You probably need to assign the Verdwijnfuse variable of the verschijnfuse script in the inspector.
verschijnfuse.place () (at Assets/scripts/verschijnfuse.cs:20)
UnityEngine.Events.InvokableCall.Invoke () (at <0b78209fd00d4f419f30dd210cbab239>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <0b78209fd00d4f419f30dd210cbab239>:0)
ObjectInteraction.OnInteract () (at Assets/scripts/ObjectInteraction.cs:25)
CameraLookDetector.Update () (at Assets/scripts/CameraLookDetector.cs:40)

now im getting this error

#

the object has a name

polar acorn
#

This one you've got pictured is fine, so it's not this one

stoic tendon
#

it says the main camera when I dubble click the error,.

polar acorn
#

Does that object have a Verschijnfuse script on it?

stoic tendon
#

no

polar acorn
#

So, you're going to have to find whatever object has that script on it, but doesn't have the variable Verdwijnfuse assigned

snow warren
#

hello

#

i have 2 cameras in a scene
and i adjusted the rect of one camera to fit it in the other camera point of view
is it possible for the camera rect to rescale itself automatically with the changing size of the display just like UI elements?

stoic tendon
#

So i need to remove the skripts from this object? The one i use the skript to interact with?

polar acorn
snow warren
stoic tendon
patent imp
#

!Learn

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

hollow slate
#

You can adjust the FOV and what axis the FOV is acted on.

snow warren
#

but the rect

#

the rect of the camera in the display

hollow slate
#

oh. Is it using Unity UI?

#

anchoring with this should force an element to always fill the entire canvas.

snow warren
hollow slate
#

If you're just talking about a normal rectangle as an object, then yeah, some simple math should do the trick.

#

Check the distance from the camera

#

then calculate the FOV on X and Y

#

then use sin and cos accordingly to find the X and Y -scaling of the object.

snow warren
#

talking about this

hollow slate
#

aha.

snow warren
#

its a rect

#

not a rect transform

#

i never found a way to rescale rects

#

neither have i worked with plain Unity UI made with rects

hollow slate
#

well, to what purpose do you want to rescale the Viewport Rect?

#

I've never really had to do that in any of my projects, so I'm curious.

#

there might be a better solution for whatever you want to do.

steep rose
#

i could be wrong

#

since i have never used it

snow warren
#

it does it randomly

hollow slate
#

just Camera.rect.*

snow warren
steep rose
snow warren
#

how to calculate?

#

let me see

hollow slate
#

randomly?
You can adjust the height and width respectively

steep rose
snow warren
#

if i place a UI element and copied its rect to match the rect of the camera then would it work?

hollow slate
hollow slate
#

I have no idea what you want to do right now.

snow warren
snow warren
hollow slate
#

what in the world.

steep rose
#

also is that unity?

#

i dont know what im looking at

snow warren
hollow slate
#

Looks like Unity to me if we look at all the parameters. Everything else is INSANITY though.

snow warren
#

i hooked some c++ libraries at runtime to achieve the result

#

not really hooking but just some C++ calls inside C#

steep rose
#

thats on the border of not being unity 😆

steep rose
snow warren
#

in terms of user control

steep rose
#

seems like it

hollow slate
#

why'd you control it to make it look like... this.

steep rose
#

prob preference

snow warren
#

i have a goal and i dont think promotion is supported

hollow slate
#

I'm an open-minded individual but this... this is too far.

snow warren
#

so i prefer not to disclose what it is

#

aside from that

#

can you guys pls tell me how can i rescale the rect of the camera based on the changing size of the display