#💻┃code-beginner

1 messages · Page 340 of 1

swift crag
#

you aren't recomputing rndCoin in here, so this will spawn a ton of coins if rndCoin is equal to ten

rancid tinsel
#

seems thats what it was, I put the check in for the if, but forgot about the else if

gentle stratus
#

ive tinkered with it and now it doesnt immediately start hitting the player but it also never hits the player because it only detects the player's viewsphere which ive set to invisible tag and it only hits if the tag is player

rancid tinsel
#

weird that it was only spawning 2 though since rnd can go up to 3

#

but maybe i just got unlucky and didnt get to see it with rnd 3

gentle stratus
#

no but its parent does

teal viper
gentle stratus
#

so i cant make it only detect the player body?

#

or maybe i add a kinematic rb to the viewsphere?

teal viper
#

Every individual collider needs it's own rigidbody. Otherwise it would be part of a compound collider.

gentle stratus
#

ic

swift crag
#

I wasn't aware that the layer of the rigidbody would clobber the layer of the collider's object

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

fossil tree
#

a little question why when i Instantiate(prefab,new Vector2(i,4.4f),quaternion.RotateZ(190)); that rotate only at 86.198 ?

polar acorn
#

That will return a quaternion that represents an orientation of something rotated 190 degrees about the Z axis. There are infinitely many ways to express that with euler angles. It's possible that the X or Y values are also changed to achieve the same orientation. Try to change the object's rotation in the inspector to 0,0,190 and see if it is physically in a different orientation

fossil tree
#

the rotation of the prefab?

polar acorn
#

Pause the game, change the rotation, and see if it's actually at an incorrect angle

#

or if it's just being displayed as some value you aren't expecting

fossil tree
#

ok ty

gentle stratus
willow scroll
gentle stratus
#

well basically i have an enemy class that has an attacksphere where if the player is in that area itll trigger ontriggerstay and damage the player

#

but the player has a viewsphere called collider where if the enemy is in it itll change material and that collider keeps colliding with the attacksphere and then the playerbody doesnt show up

#

it checks for player but it encounters collider before the playerbody and collider doesnt have the player tag

willow scroll
wintry quarry
#

Why don't you just put the different colliders on different layers and use layer-based collision to filter things out?

ivory bobcat
#

Or have the specific colliders ignore each other?

gentle stratus
#

i tried doing both of these

#

set the spheres to the same level and removed the collisions between the level and itself

#

and went into the collider and excluded the layer it was on

willow scroll
gentle stratus
#

yeah

willow scroll
#

Well, you may do what PraetorBlue said or simply check for the collider being the collider you need in your enemy's logic

#

By either checking the Components or tags

willow scroll
#

You should make AttackSphere ignore Viewsphere, if I understand the issue correctly

gentle stratus
willow scroll
#

Oh, right, it has Collider layer

#

The Colliders do ignore each other

#

Does the 2nd image, called Collider, correspond to the Viewsphere you have mentioned?

gentle stratus
#

yeah

#

the player viewsphere is called collider

willow scroll
#

They should ignore each other, don't they?

gentle stratus
#

doesnt seem to be the case

willow scroll
#

And send the code, please

willow scroll
clear river
#

Hello.

gentle stratus
#

its the code of attacksphere which is in enemy if thats what you mean

clear river
#

I'm the latest newbie off the bus

willow scroll
gentle stratus
#

yes

clear river
#

I have 30+ years programming experience

#

But Unity is new

#

So I'm a rookie

#

And I have a key question

willow scroll
clear river
#

I get scripting, declaring variables in a .cs file and making connections and operations in code. And I get visual interfaces, adding elements and auto-building code with automatic methods etc. But I'm stuck on something weird

willow scroll
gentle stratus
#

okay

willow scroll
#

Then send a screenshot

clear river
#

Sorry cashiering at the same time x.x

languid spire
wintry quarry
#

Damn times are rough out there if a 30+ year programmer needs to be a cashier too 😦

clear river
#

Disregarding tbat

gaunt ice
#

slasher

gentle stratus
# willow scroll Then send a screenshot
private void OnTriggerEnter(Collider other) {
    Debug.Log(sphere.gameObject.name + " layer: " + sphere.gameObject.layer + "\n" + other.gameObject.name + " layer: " + other.gameObject.layer);
    if (other.CompareTag("Player")) {
        canHit = true;
    }
}```
clear river
#

You make variables in a .cs, attach it as a component, then link the data to other components in the visual inferface.

WTF?

#

How can you tell from the script what is attached to what?

wintry quarry
ivory bobcat
willow scroll
clear river
#

Ah. Gimme a second to consider that

willow scroll
gentle stratus
#

yeah idk why

ivory bobcat
#

You'll not have access to the hierarchy objects directly without proper referencing or Finding the objects in the scene and will mainly be working with callback methods.

willow scroll
willow scroll
polar acorn
gentle stratus
gentle stratus
willow scroll
#

So in Physics, not Physics 2D

willow scroll
# gentle stratus

I meant the collision matrix in Project Settings -> Physics -> Layer Collision Matrix

gentle stratus
#

oh

#

it is physics not physics 2d

willow scroll
gentle stratus
#

yeah

willow scroll
#

And the collision is disabled..

willow scroll
#

Why do they exclude layers?

#

On your SphereCollider

#

Exclude Layers: Collider

gentle stratus
#

i added that when fooling around im testing it again excluding no layers

ivory bobcat
clear river
#

So the BattleHandler.cs is a code module blueprint,

wintry quarry
# gentle stratus

These objects don't match your log. Your log says ViewSphere and AttackSphere are colliding

#

doesn't look like "Collider" is colliding

#

which is as expected

clear river
#

And the attached component is an instance of that blueprint
Correct?

clear river
#

Thanksm

wintry quarry
#

really the "class" inside the script is the blueprint for the component

#

public class BattleHandler

gentle stratus
ivory bobcat
gentle stratus
#

didnt seem to actually highlight

#

when i doubleclick it just goes to the attacksphere code

ivory bobcat
#

I'm assuming you've got other objects with attack spheres and view spheres besides those shown - or on both enemy and players without the correct layers.

ivory bobcat
gentle stratus
#

ok

clear river
#

In that case hardcoding a connection in the script is.. slightly less clean? Than connecting vis the interface?

gentle stratus
ivory bobcat
gentle stratus
#

yeah

clear river
#

But I'm never gonna have two battlehandler instances. Is there a better way to do this than a comonent connection?

rich adder
#

nvm thought yu were talking about web lol

ivory bobcat
# gentle stratus yeah

Meaning the rigid body was on the enemy that had a different layer (not collider) and not the part of the enemy with said collider and correct layer.

rugged gulch
#

Does anyone know how to fix this decal stretching issue? this is for bullet holes applied to corners:
and relevent code:

    {
        // Define an offset distance to move the decal into the wall
        float offsetDistance = 0.2f; // Adjust this value as needed

        // Calculate the position of the decal slightly deeper into the wall
        Vector3 spawnPos = hit.point - hit.normal * offsetDistance;

        // Instantiate the bullet hole object at the calculated position
        GameObject spawnedObject = Instantiate(bulletHolePrefab, spawnPos, Quaternion.identity);

        // Align the bullet hole with the hit normal (assuming your bullet hole prefab is facing in the positive Z direction)
        spawnedObject.transform.forward = hit.normal;

        // Optionally, you can parent the bullet hole to a container
        spawnedObject.transform.SetParent(bulletHoleContainer.transform);
    }```
rich adder
gentle stratus
#

think i see the issue now, the enemy object itself also has attack detection

#

cause i needed to link it with my animator

wintry quarry
gentle stratus
#

nvm even when i turned it off it still collides with collider

rugged gulch
rich adder
wintry quarry
rugged gulch
crystal chasm
#

It's one of the standard primitives in unity.

clear river
#

If BattleHandler.cs is attached to a GameObject as a Component, I get an instance of code I'll only ever use one time. Is there a betyer way?

crystal chasm
#

Right click, create 3D object, Quad.

rugged gulch
#

so you're saying that the decal projector can't handle corners?

ivory bobcat
ivory bobcat
rugged gulch
#

with the right rotation it seems more than possible but im unsure of the math behind calculating this

wintry quarry
#

and maybe take the average

rugged gulch
#

i'll have to look into this, thank you

fossil tree
#

why the hell this error pop in my console (that dont affect my game) ```NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at <4fa92967e90043cbb25cde5b275e9e4e>:0)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List1[T] inEdges, System.Collections.Generic.List1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <4fa92967e90043cbb25cde5b275e9e4e>:0)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at <4fa92967e90043cbb25cde5b275e9e4e>:0)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at <4fa92967e90043cbb25cde5b275e9e4e>:0)
UnityEditor.Graphs.Graph.WakeUp () (at <4fa92967e90043cbb25cde5b275e9e4e>:0)
UnityEditor.Graphs.Graph.OnEnable () (at <4fa92967e90043cbb25cde5b275e9e4e>:0)

rich adder
#

generally UnityEditor errors are not caused by you directly

clear river
#

Or, does the manager also attach to a GameObject?

wintry quarry
#

it attaches to a GameObject

ivory bobcat
clear river
#

Okay. Thanks.

#

Truth be told, I was handed someone else's code [In Unity?!] And was told: "this doesn't work. Fix it"

#

I've been doing my best for a few weeks now. Thanks for the backup

willow scroll
gentle stratus
#

nop

clear river
#

I'll return if/when I have more questions.

willow scroll
#

Which are supposed to collide

#

Not supposed, actually

#

And print the objects using the Debug.Log's 2nd parameter, Object context

gentle stratus
#

yeah i added this from delphat's suggestion

private void OnTriggerEnter(Collider other) {
    if (other.transform.parent.CompareTag("Enemy")) return;
    Debug.Log($"A collision occurred between {name} and {other.name}");
    Debug.Log($"Click this message to have {name} highlighted in the hierarchy", this);
    Debug.Log($"Click this message to have {other.name} highlighted in the hierarchy", other);
    if (other.CompareTag("Player")) {
        canHit = true;
    }
}```
stuck palm
#

how can i check what is setting a script active to false? i havent written any code and have no references to this code whatsoever and something is setting it to false and i have no diea why

rich adder
stuck palm
#

i'll send a video

stuck palm
#

after you come back

swift crag
stuck palm
#

from the frozen

swift crag
#

then use a debugger

#

alternatively, just log something in there

stuck palm
swift crag
#

show the stack trace

stuck palm
#

left one is from the outline script

#

and right one is from disableoutline on the character

swift crag
#

Is it a coroutine?

#

(DisableOutline, that is)

stuck palm
#

its just a standard method

swift crag
#

share the Character script.

stuck palm
swift crag
#

yes, I won't die

stuck palm
#

i'll paste it in a thingy one sec

stuck palm
#

i've tried to keep it as tidy as possible

swift crag
#

perhaps you are using Invoke

#

which can send a message after a delay

stuck palm
willow scroll
swift crag
#

ah, an animation event

#

i'm surprised there wasn't at least a hint as to where that came from

stuck palm
#

i thought the animator would show up in the stack trace at least

#

yeah

rich adder
#

doesn't it use reflection?

swift crag
#

indeed, but I'd still expect to see the code responsible for doing that reflection

#

maybe that's all native

rich adder
#

isn't it basically the same as GameObject.SendMessage ?

swift crag
#

messages are also reflection-based

prime cobalt
#

can you access a custom tilemap rule tile's properties from a raycast?

rich adder
prime cobalt
#

I tried that but it said it was invalid

ivory bobcat
rich adder
# prime cobalt

Should probably check what type of tile you're grabbing first

#

btw this has a generic version with <T>

prime cobalt
prime cobalt
ivory bobcat
prime cobalt
#

Oh I didn't know you had to specify the type with the <> it doesn't return an error anymore

#

Thanks!

stuck palm
#

can you change a variables access modifier at runtime?

slender nymph
#

no. why would you?

stuck palm
slender nymph
#

well just like how you cannot change the actual lines of code at runtime (because they've already been compiled into IL), you cannot change the access modifier for a variable or any other object

polar acorn
prime cobalt
#

Is there a way to change the color of a rule tile in runtime? I've currently got it like this with another script calling changecolor during runtime but it doesn't actually change anything until I exit playmode.


TileData myTileData;



public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData)
{
    base.GetTileData(position, tilemap, ref tileData);

    tileData.color = color;
    tileData.flags = TileFlags.LockColor;
    myTileData = tileData;
}

public override bool StartUp(Vector3Int position, ITilemap tilemap, GameObject instantiatedGameObject)
{
    color = Color.white;
    myTileData.color = color;
    myTileData.flags = TileFlags.LockColor;
    return base.StartUp(position, tilemap, instantiatedGameObject);
}

public void ChangeColor()
{
    myTileData.color = color;
    myTileData.flags = TileFlags.LockColor;
}```
#

I should clarify that the color variable changes but it just doesn't actually affect the sprite

slender nymph
#

try removing the lockcolor flag before assigning the color

stuck palm
prime cobalt
cursive hinge
#

is someone kind enough to show me how would jumping look like in a fps controller script? I'm currently using Move and it looks like teleporting

if (Input.GetKey(jumpKey))
            {
                Debug.Log("Jumping");
                if (isGrounded)
                {
                    controller.Move(Vector3.up * Mathf.Sqrt(jumpHeight * 2f * gravity));
                    isJumping = true;
                }
            }
lofty star
#

How do you create adaptive joystick on touch screen?

polar acorn
#

If you're posting in #💻┃code-beginner you should basically pretend literally any C# code containing the word "unsafe" just does not exist

hallow sun
#

i personally just use AddForce as an impulse

polar acorn
hallow sun
#

oh didnt notice that part

cursive hinge
#

Jumping is killing me 😭

polar acorn
#

.Move is an amount to move this frame. If you want to jump you will need to track velocity over several frames, and use that velocity to call .Move

#

You'd increase the Y velocity by some amount, and then decrease that every frame until you're back on the ground

ember tangle
#
for(int index = 0; index < unitCount; index++)
{
    //add unit to list as prefab
    units.Add(Instantiate(prefab) as GameObject);

    // lock origin to Formation position
    units[index].transform.SetParent(gameObject.transform);

    //reset position to equal formation position;
    units[index].transform.position = gameObject.transform.position;

    //set desired position
    units[index].transform.position = new Vector3(0 + 5 * index, 0, 0); // ???
}

When I use the new Vector 3 to set a new position for the 'Unit' game object, 0 is not based on the position of the parent game object. I thought that by setting the parent I'm changing what 0 is for the child?

wintry quarry
eternal needle
prime cobalt
#

Is there any reason that this wouldn't be changing a rule tile's color in runtime? I can't find anything helpful online.

sand gate
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

wintry quarry
#

TileData is a struct. Changing your tile data struct won't affect wherever you copied it from.

sand gate
#

!docs

eternal falconBOT
wintry quarry
#

Structs are value types

prime cobalt
#

I checked the unity learn for rule tiles and the rule tile documentation neither was helpful

prime cobalt
#

Because it works when it's in the editor

polar acorn
polar acorn
wintry quarry
#

or this.color = whatever;

prime cobalt
wintry quarry
prime cobalt
#

Ok I'll try that

ember tangle
wintry quarry
ember tangle
#

alright ty

wintry quarry
#

so local position wouldn't mattter

polar acorn
final totem
#

How do I use quality modes in ui like high low is there API for that?

lime pasture
#
CustomAnimation customAnim;
void Start()
    {
        customAnim = GetComponent<CustomAnimation>();
        
    }
 void StopGrapple()
    {
        customAnim.whenKeyPressed(true);
    }

why do i get the error "NullReferenceException: Object reference not set to an instance of an object" when stop grapple is played?

polar acorn
#

Does this object have a CustomAnimation component on it?

lime pasture
wintry quarry
polar acorn
#

because there isn't one

wintry quarry
lime pasture
#

so I find the parent and then do get component?

wintry quarry
#

Maybe you want GetComponentInParent?

polar acorn
#

Or just make the field public and drag it in

lime pasture
prime cobalt
wintry quarry
#

Why are you reading color

prime cobalt
#

color is just a public variable that I created it isn't connected to anything

wintry quarry
#

Pretty sure what you want is someting like this:

public void ChangeColor(Vector3Int tilePos) {
  this.color = myITilemap.GetColor(tilePos);
}```
wintry quarry
prime cobalt
#

It's derived from RuleTile

wintry quarry
#

Then you maybe want:

public void ChangeColor(Vector3Int tilePos) {
  base.color = this.color;
}```
#

You shouldn't mask field names from the base class ideally

#

Oh I see TileBase doesn't have a color

prime cobalt
#

it says that color isn't in the base class

#

yeah

wintry quarry
#

well I guess I don't understand how you're using this color variable then

prime cobalt
#

like I said the color variable is just a public one I created and named color

#

The other scripts change the color variable then call ChangeColor

#

The tutorial I followed that was explaining rule tiles showed that you could make a public color variable, then set the tiledata to that color in gettiledata. So I've been trying to work off of that.

swift crag
#

why is that a thing? i do not know!

#

let me find where that is..

prime cobalt
#

I tried unlocking it but it didn't work

#

It says there's no locks

swift crag
#

I have always just used tilemap.SetColor(theCell, theColor);

swift crag
#

let me check something..

#

yeah, so the problem is that it just copies the data from your Tile asset. Changing the asset after setting the tile doesn't do anything.

#

I just tried doing that in a 2D project. Existing tiles didn't change.

#

New uses of the tile do use the new color, of course.

prime cobalt
#

Oh I see. That's too bad. Guess I'll have to find another solution.

swift crag
#

If the tilemap is small, iterate over the entire tilemap and just set colors as needed

#

If it's large, I'd make a hash set of Vector3Int that you populate with the positions of the tiles you want to change

winged valve
#

I have some problems with UI image in unity can someone help me with it?

deft grail
winged valve
#

My UI image suddenly turns into script idk how to fix it

deft grail
winged valve
# deft grail what does that even mean? show a video maybe or try explaining better?

https://www.youtube.com/watch?v=yxzg8jswZ8A&list=PLgOEwFbvGm5o8hayFB6skAfa8Z-mw4dPV&index=7

[7:26] when I try to duplicate my image UI it suddenly turns into a script which does not happen here

In this episode we'll create a health system. We will add health to our player, create a health bar, make a deadly saw trap that can damage the player and health collectibles to restore your health.

➤ Download the heart sprites: https://drive.google.com/drive/folders/1audm9sjm-JiGRu4PtckMoI8a_nudnzHg?usp=sharing
➤ Starting Project: https://gith...

▶ Play video
deft grail
#

what does that mean

winged valve
# deft grail what does that mean

If i create any type of UI Slider and press play it turns invisible and all children "Images" become "Scripts". This happends even if i dont use it for anything.

winged valve
#

It suddenly turns into acript then gets invisible

#

And I always get this error code

deft grail
#

restart unity

#

something is definitely broken by looking at this icon

winged valve
#

I'll try it thanks

#

I got this error after re-opens the unity

#
Error loading the file 'VirtualArtifacts/Primary/13bd0b2b84cd782408ba37c684c50988'. File is either empty or corrupted, please verify the file contents.
ember tangle
hushed hinge
#

like similar to when Mario collect giant coins

frosty hound
#

Is this code running? Verify that first.

hushed hinge
#

should I Debug?

frosty hound
#

That would be one way to verify it

#

And before you show some random code with a "like this?" Comment, please actually test it.

hushed hinge
ivory bobcat
hushed hinge
ivory bobcat
#

Where did you put the debug?

#

Is the function being called?

hushed hinge
#

I tried the first and the second one but doesn't call the Debug

hushed hinge
#

it still doesn't trigger the debug

#

nothing triggers the debug

slender nymph
#

then that method is not being called

polar acorn
hushed hinge
#

oh

#

why isn't the function running?

slender nymph
#

where are you calling it from

hushed hinge
#

https://gdl.space/voseqiyolu.cs well it supposed to function when the Muon gameobject get touched and triggers and the UI Image changes to the face of the rescued muon

slender nymph
#

okay but where are you calling it from

hushed hinge
#

SetMuonRescued method should be called from the script or component that handles the player's interaction with the Muon GameObjects

slender nymph
#

okay so make sure that code is running

hushed hinge
#

but how?

polar acorn
ivory bobcat
polar acorn
#

Do that, again, but here

#

log the thing you're checking for and see if it's actually true

hushed hinge
polar acorn
ivory bobcat
hushed hinge
ivory bobcat
polar acorn
slender nymph
#

there's also another huge logic issue here. you specifically check if the object you clicked on has the tag Muon then you pass it to your SetMuonRescued method which checks for different tags. so even once you get the code actually running, your logic is going to prevent it from working the way you expect it to

hushed hinge
polar acorn
ivory bobcat
#

OnMouseDown only occurs when the mouse button is down/clicked whilst over the target

#

Maybe you're wanting on trigger enter

#

Though this would imply that you're using Rigidbody physics

polar acorn
#

Before we continue, I really, really want to know why you thought OnMouseDown was called when the player walked into it

final totem
#

should i use

sbyte[] sbyteArray = ArrayPool<sbyte>.Shared.Rent(5);

or normal arrays?

hushed hinge
ivory bobcat
polar acorn
final totem
hushed hinge
polar acorn
paper peak
#

Im getting a "Type or namespace TextMeshProUGUI could not be found error but it was working moments ago in this script

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

public class Dialogue : MonoBehaviour
{
    [SerializeField]
    private TextMeshProUGUI textComponent;
#

Any idea what couldve caused this

polar acorn
ivory bobcat
slender nymph
paper peak
#

I only see the error in the unity console

#

And because of this i cant set the reference in the serializefield

slender nymph
#

well that sounds like you either need to save your code again or your need to get your !IDE configured or both

eternal falconBOT
ivory bobcat
hushed hinge
# polar acorn So, either you thought it was a Unity function that Unity would call, or you tho...

I am trying to call SetMuonRescued

public void SetMuonRescued(GameObject muonGameObject)
    {
        string muonTag = muonGameObject.tag;

        Image muonImage = null;

        switch (muonTag)
        {
            case "Muon1":

                if (!muon1Rescued)
                {
                    muon1Rescued = true;
                    muonImage = muon1Image;
                    muonGameObject.GetComponent<Collider2D>().enabled = false;
                }
                break;
            case "Muon2":
                if (!muon2Rescued)
                {
                    muon2Rescued = true;
                    muonImage = muon2Image;
                    muonGameObject.GetComponent<Collider2D>().enabled = false;
                }
                break;
            case "Muon3":
                if (!muon3Rescued)
                {
                    muon3Rescued = true;
                    muonImage = muon3Image;
                    muonGameObject.GetComponent<Collider2D>().enabled = false;
                }
                break;
        }

        if (muonImage != null)
        {
            muonImage.sprite = rescuedSprite;
        }
    }
polar acorn
hushed hinge
paper peak
#

Im using Visual studio and it seems to be updated already

polar acorn
polar acorn
#

So where are you calling SetMuonRescued

paper peak
#
public class OuumaNPC : MonoBehaviour
{
    [SerializeField]
    private MovementScript movementScript;
```Is this the right way to reference a script?
polar acorn
hushed hinge
#

yeah

polar acorn
#

So, where did you try to call OnMouseDown

ivory bobcat
# paper peak Im using Visual studio and it seems to be updated already

You'll want to go through the installation guides again. You won't need to uninstall/reinstall but rather just run the installer. It'll allow you to modify your current installation. Most often, folks miss the workloads step (3) that has it's image shown below step 5 https://learn.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/getting-started-with-visual-studio-tools-for-unity?pivots=windows#install-visual-studio-and-unity

hushed hinge
polar acorn
ivory bobcat
polar acorn
ivory bobcat
#

This function will not be called unless you click on the Muno in the scene, which isn't what you're wanting to do.

ivory bobcat
#

They ought to really follow a tutorial instead of walking into this blindly

polar acorn
paper peak
hushed hinge
polar acorn
polar acorn
#

Since you didn't know Unity would call it, that would mean that you tried to call it

#

so where

#

did you

#

try

#

either you thought "This is a Unity function" and it ran when something happened. Or you thought "This is not a Unity function" which would mean you intended to call it manually

ivory bobcat
polar acorn
#

So either:

  1. Where and when did you try calling it
  2. Did you assume code is magic and it would just psychically know you wanted that function called at that point
ivory bobcat
polar acorn
#

Code means things. It can be understood. You have to stop assuming it's brain-scanning wizardry that can read your intentions as you type the Sacred Keystrokes™️ into the machine and that only The Ancient Ones can communicate with the Machine

#

For example, when I ask you "What do you think this line does" and your answer is "I don't remember it was a while since I wrote it" that's telling that you don't think code can be understood unless you were there when it was written. It's literally just words. It conveys meaning exactly as precise and discernable as my text on your screen right now.

#

Glyphs that translate into tangible thought. It does not matter whether the font is serif of monospace it's still language

ivory bobcat
# ivory bobcat Check your external tools in the Unity Editor and make sure it's correct (yours ...

You may need to regenerate your project and restart the Unity Editor if all of the above have been completed but still doesn't work (Intellisense). @paper peak
It's absolutely necessary to acquire help from this Discord server though as these are syntactical mistakes that really ought to be immediately addressed by Intellisense - you'll know it's incorrect the moment you try to type it (it would not even be an available option) or better yet, be given the appropriate correct suggestion.

paper peak
#

I restarted both Visual studio and unity, visual studio seems to be working better with c# so it seems to have fixed itself but now im getting this warning

rich adder
#

you closed project with compile error?

polar acorn
# paper peak Should i be worried about this warning?

If you currently have compile errors, it can't be sure the editor scripts aren't to blame. Safe mode would disable all editor scripts so you can get in and fix them. You can hit ignore to go in, but your project won't run until you fix the errors

hushed hinge
#

I was busy doing something, is this better?

public MuonUIController muonUIController;

    private void OnCollisionEnter2D(Collision2D collision)
    {
        string muonTag = collision.gameObject.tag;

        // Check if the collision is with a Muon GameObject
        if (muonTag == "Muon1" || muonTag == "Muon2" || muonTag == "Muon3")
        {
            // Call the SetMuonRescued method on the MuonUIController
            muonUIController.SetMuonRescued(collision.gameObject);
        }
    }
paper peak
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class OuumaNPC : MonoBehaviour
{
    [SerializeField]
    private MovementScript movementScript;
```Last line seems to be giving the error, is this the right way to reference a script?
paper peak
#

Type or namespace MovementScript could not be found

polar acorn
paper peak
#

Its a script im trying to reference, it is stored in the same folder this script is in

paper peak
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    [SerializeField]
    private Animator animator;

    public bool canMove = true;
    private float horizontal;
    [SerializeField]
    private float maxSpeed = 4f;
    private float currentSpeed = 0f;
    [SerializeField]
    private float jumpPower = 12f;
    [SerializeField]
    private float timeToZero = .15f;
    float deaccelerationRate;
    private bool isFacingRight = true;
```Everything below is just methods
ivory bobcat
paper peak
#

I dont get it, this is the script

#

Do they need to have the same name to be referenced?

polar acorn
paper peak
#

Ohh i see where youre getting at

#

I dint know they needed to have the same name

ivory bobcat
polar acorn
paper peak
#

Yeah it works now

#

I got too used to lua

ivory bobcat
#

I'm assuming there isn't such a thing which either implies your ide isn't configured or these were code before your configuration.

paper peak
#

So i got confused on how it works here

#

Also the other error about TextMeshProUGUI got fixed, seems like you were right and IDE wasnt properly configured

#

Thanks for the help

hushed hinge
hushed hinge
# hushed hinge since I am using the collider2D which triggers.. ```cs private void OnTriggerEnt...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MuonInteraction : MonoBehaviour
{
    public MuonUIController muonUIController;

    private void OnTriggerEnter2D(Collider2D other)
    {
        string muonTag = other.gameObject.tag;
        Debug.Log("Trigger entered with tag: " + muonTag);

        // Check if the trigger is with a Muon GameObject
        if (muonTag == "Muon1" || muonTag == "Muon2" || muonTag == "Muon3")
        {
            Debug.Log("Muon rescued: " + muonTag);
            // Call the SetMuonRescued method on the MuonUIController
            muonUIController.SetMuonRescued(other.gameObject);
        }
    }
}

well it seems functional but the UI Image still doesn't change

ivory bobcat
#

Good job debugging thus far. So the script stated that player hit this object.

polar acorn
hushed hinge
#

which are the three gameobjects on

polar acorn
#

You can see that

#

This object never collides with anything tagged Muon1, Muon2, or Muon3

ivory bobcat
hushed hinge
polar acorn
hushed hinge
polar acorn
ivory bobcat
polar acorn
ivory bobcat
hushed hinge
paper rover
#

Hey! For some reason my shaderGraph effects arent rendering in the game, but it is in the scene. Is there anything I should be looking for to fix this??

ivory bobcat
polar acorn
ivory bobcat
hushed hinge
ivory bobcat
polar acorn
#

you're logging the tag of the thing that this object collides with

polar acorn
#

Again: not magic

#

it does exactly what you tell it to do

hushed hinge
hushed hinge
spare mountain
#

any errors?

polar acorn
ivory bobcat
#

Maybe show your current SetMuonRescue code

delicate venture
#

not really a code question but when i build and run my project some sprites dont export with the project (at least thats what it looks like)
ik i can check the folders path when exporting and see if its correct but i dont know how to get to there

spare mountain
hushed hinge
# ivory bobcat Maybe show your current SetMuonRescue code
public void SetMuonRescued(GameObject muonGameObject)
    {
        string muonTag = muonGameObject.tag;

        Image muonImage = null;

        switch (muonTag)
        {
            case "Muon1":

                if (!muon1Rescued)
                {
                    muon1Rescued = true;
                    muonImage = muon1Image;
                    muonGameObject.GetComponent<Collider2D>().enabled = false;
                }
                break;
            case "Muon2":
                if (!muon2Rescued)
                {
                    muon2Rescued = true;
                    muonImage = muon2Image;
                    muonGameObject.GetComponent<Collider2D>().enabled = false;
                }
                break;
            case "Muon3":
                if (!muon3Rescued)
                {
                    muon3Rescued = true;
                    muonImage = muon3Image;
                    muonGameObject.GetComponent<Collider2D>().enabled = false;
                }
                break;
        }

        if (muonImage != null)
        {
            muonImage.sprite = rescuedSprite;
        }
    }
spare mountain
#

probably better to use a code pasting site for code this big

polar acorn
polar acorn
hushed hinge
polar acorn
hushed hinge
polar acorn
hushed hinge
polar acorn
#

try that

polar acorn
# hushed hinge

Instead of just logging text, why not log the thing you check in the if statement right after

plain owl
#

Hello! I think I have a simple question - I'm trying to do a raycast from an object to an area in front of the object (to see if there's any colliders there) so I tried using this.transform.forward (the object's transform direction)
but when I rotate the object the raycast remains fixed in one spot (doesn't change depending on where the object is facing)
is there a different vector I should be using to get the forward direction?

polar acorn
# hushed hinge

Instead of just logging text, why not log the thing you check in the if statement right after

hushed hinge
#
private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("OnTriggerEnter2D");

        if (collision.CompareTag("Player") || CompareTag("Player 2") && !isRescued)
        {
            Debug.Log("muon collision");
            isRescued = true;
            animator.SetTrigger("Rescued");
            animator.SetBool("isRescued", true);
            popSound.Play();

            // Start a coroutine to handle the happy animation and disappearance
            StartCoroutine(HappyAnimationAndDisappear());
        }
    }

it do debug OnTriggerEnter2D but not muon collision

polar acorn
teal viper
#

Dejavu

#

But really instead of logging text, you should log the thing.

radiant stump
#

Hi i have a question with a simple mechanic i am trying to develop, it is a system where you are using a shopping cart and i need the shopping cart to lag behind the player's movements. I got the rotation working but the movement is tricky since the cart is parented to the player. I have the cart working where it will move to the player's position with the lag, but in only one direction

spare mountain
hushed hinge
spare mountain
#

I might unparent it to prevent other issues too but if you can get it to work while parented go for it

spare mountain
radiant stump
spare mountain
radiant stump
#

oh, mb

polar acorn
# hushed hinge

Instead of just logging text, why not log the thing you check in the if statement right after

polar acorn
hushed hinge
spare mountain
#

😭

polar acorn
spare mountain
#

if your goal is to figure out why something isn't working
figure out what is happening that isn't what you expect
and then make it what you expect

hushed hinge
#

"why not log the thing you check in the if statement right after" like what am i supposed to write there?

spare mountain
polar acorn
hushed hinge
spare mountain
#

that's certainly a start

polar acorn
#

Instead of just waiting for someone to write it for you

spare mountain
#

🤯

hushed hinge
spare mountain
polar acorn
frosty hound
#

@hushed hinge Make another thread please, stop taking over these channels.

polar acorn
#

I'm not spending another fucking 11 hours explaining debug logs this time I'm gonna go play Hades

spare mountain
hushed hinge
#

muon animation

sharp mango
#

I can't get the character to dash, for some reason velocity is being changed but i see no movement

#

(dashes with c key)

wintry quarry
sharp mango
#

ah fuck you're right 💀

daring dragon
#

Idk for sure if this is the right channel but does anyone know why this distortion is happening

#

Ping if respond ples

cursive hinge
#

how can i disable the 60 fps cap in editor?

slender nymph
#

there's a checkbox for vsync in the aspect ratio selector for the game view. also not a code question

rancid tinsel
#

my circlecollider2D and polygoncollider2D are not detecting collisions, any idea what the issue might be?

#

the object with the polygoncollider2D is a prefab that gets instantiated at runtime, just fyi incase that matters

slender nymph
rancid tinsel
slender nymph
#

then show the other rigidbody2d involved in the collision

rancid tinsel
#

there is no other rigidbody2D

slender nymph
#

then you did not do what it says on there already

rancid tinsel
#

I don't see anything about rigidbodies there

#

I'm confused

slender nymph
#

a kinematic Rigidbody2D will only produce an OnCollisionEnter2D message when it comes into contact with a non-kinematic Rigidbody2D

rancid tinsel
#

but in general you only need 1 rigidbody right?

#

for collisions

slender nymph
#

look at the collision matrix and find out

queen adder
#

its stuck on building gradle project

slender nymph
queen adder
#

im on pc

slender nymph
#

okay but you are building for a mobile device, yes?

queen adder
#

nope im building for vr

slender nymph
#

pc vr or a mobile device

silk jackal
#

How to ignore clicks?

slender nymph
#

ignore them in what capacity?

silk jackal
#

¯_(ツ)_/¯

slender nymph
#

that's not very descriptive. but the obvious answer is to just . . . not do anything in response to those button clicks

storm pine
# silk jackal not allow player to press mouse buttons

If you just want to block the mouse input at some point you can play with the Event System. Check this video,it is a bit old but very clarifying: https://youtu.be/EVZiv7DLU6E?si=w9j1KmS_tzBOFzZx

Its kind of annoying how clicks on UI elements interact with the game world right? And the documentation is kind of sketchy on how to fix this.

Here are three sure fire ways to block clicks on UI elements. I recommend watching the whole video, and choosing the one that suits your project best.


Feel free to ask questions in the comments...

▶ Play video
sand gate
#

is the "beginner scripting" course on unitylearn a good starting point to learn scripting?

static cedar
#

Hi peps, how do you download a package from github?

slender nymph
#

that one is not set up to be a proper package that you can import using the package manager. you just need to download and import the unitypackage file from the releases

static cedar
#

Ah that makes more sense.

fossil tree
#

hello why this line dont work ??? ``` target = GameObject.FindGameObjectsWithTag("player").transform;

target is ``    public Transform target;``
cursive hinge
willow scroll
#

Read the error message

fossil tree
willow scroll
fossil tree
#

omg ty

#

at 1 letter xd

willow scroll
#

Right, that's why read the error messages. It should explain you everything.

willow scroll
#

Do you jump and then simply "fly"?

#

Without gravity being applied?

cursive hinge
#

when i press jump, i get lifted then gravity sets me back on the ground, i dont know how to implement a smooth jump so when i jumo while walking, i jump into that direction

willow scroll
teal viper
willow scroll
#

The gravity is already applied in Update method when the character is not grounded

// Apply gravity
if (!isGrounded)
{
    isJumping = true;
    moveDirection.y += Physics.gravity.y * Time.deltaTime;
}
cursive hinge
willow scroll
#
// Update
moveDirection.y += Physics.gravity.y * Time.deltaTime;

// UpdateMovement
moveDirection.y -= gravity * Time.deltaTime;
cursive hinge
#

sorry im a begginer 😭

willow scroll
#

I'm not blaming you, it was a simple question

topaz mortar
#

I still make em

willow scroll
topaz mortar
#

they're the hardest to find as well, since your code is doing what it's supposed to

cursive hinge
willow scroll
willow scroll
#

Also enabling moving while still being in a jump is up to you

cursive hinge
willow scroll
cursive hinge
#

well i cant jump as isGrounded is set to true because of gravity but if i set isGrounded to always true in UpdateMovement i can sometime jump, sometimes it doesnt seem to work

#

i dont have any record app but if you want i could stream you the results

teal viper
willow scroll
willow scroll
willow scroll
#

I would say, the gravity should be applied regardless of the isGrounded boolean

// Apply gravity
if (!isGrounded)
{
    isJumping = true;
    moveDirection.y += Physics.gravity.y * Time.deltaTime;
}
cursive hinge
willow scroll
willow scroll
#

I see your character jumping perfectly, am I missing something?

willow scroll
cursive hinge
fossil tree
#

wth my particle dont spawn :( void OnTriggerEnter2D () { Instantiate(explosionEffect, transform.position, transform.rotation); Destroy(gameObject); }

willow scroll
fossil tree
cursive hinge
willow scroll
tender walrus
#

Anyone knows a way to visualize Physics.CheckBox(position, halfExtents, Rotation) I'm using it in code and want to check if the behaviour is correct

tender walrus
#

thx guys

willow scroll
cursive hinge
#

i dont understand the message about isGround

willow scroll
#

There is a probability of you simply not seeing it

fossil tree
#

its a official unity asset

willow scroll
cursive hinge
muted cradle
#

why are wheel collider so shit and how can I make the steering better?

fossil tree
willow scroll
willow scroll
#

You're spawning either an invisible one or the one flying away

bronze zenith
#

is there a way to connect my backround to my camera

#

(2d)

fossil tree
willow scroll
bronze zenith
# bronze zenith (2d)

like yk so that i dont have to extend the backround cause when i do that it stretches the image and it looks bad

cursive hinge
fossil tree
#

i use the gameobject explosion from prefab of the particle asset pack from unity

tender walrus
bronze zenith
willow scroll
tender walrus
#

guess I will have to make it in gizmo

bronze zenith
fossil tree
willow scroll
# tender walrus guess I will have to make it in gizmo

What do you mean by "making it in Gizmos"?
Gizmos.DrawCube, which is, obviously, used in Gizmos, doesn't allow to change the rotation of the cube drawn directly, but you may want to change the rotation of the entire Gizmos by assigning its matrix.

cursive hinge
willow scroll
#

If it's not, you should, somehow, make is visible

tender walrus
#

and I meant using gizmo.drawline to make an oriented cube lol

willow scroll
cursive hinge
# willow scroll How do you set your `isGrounded`?
// Check if the player is grounded
        isGrounded = controller.isGrounded;

        // Jumping
        if (Input.GetKeyDown(jumpKey) && isGrounded)
        {
            //moveDirection.y = jumpForce;
            moveDirection.y += Mathf.Sqrt(jumpHeight * 22f * gravity);
            Debug.Log("Jumping move:" + moveDirection.y + " gravity:" + gravity + " jumpHeight:" + jumpHeight + " jumpSpeed:" + jumpSpeed + " isGrounded:" + isGrounded + " jumpForce:" + jumpForce + " Time.deltaTime:" + Time.deltaTime);
        }

        // Apply gravity
        if (!isGrounded)
        {
            isJumping = true;
        }

        moveDirection.y += Physics.gravity.y * Time.deltaTime;

        // Apply vertical movement
        controller.Move(moveDirection * Time.deltaTime);

i don't understand why the jump is inconsistent

willow scroll
willow scroll
willow scroll
#

Check the materials used

fossil tree
willow scroll
#

Well, something's wrong with the materials

fossil tree
#

this is my material

willow scroll
# fossil tree

If you play the particles in the edit mode, is it the same as in the game?

willow scroll
ivory bobcat
fossil tree
#

ty

#

and now that looping (i disable looping option) notlikethis

#

oh i see

#

its fine now

magic panther
#

I have a weird issue: I have a crate and a metal crate. I'd like them to be the exact same in every way (obviously different models, ignore that), except have the metal crate's checkObstacle function have a few lines changed. I have no idea how I could do that. Anything I try results in errors. Can someone tell me how to do that?

Crate Script -> https://hatebin.com/allknucvqv
Metal Crate Script -> https://hatebin.com/neqhpqkrum

storm pine
magic panther
#

lemme test that

#

this error appears

storm pine
#

Have you deleted the variables form MetalCrate and yous change private to protected on Crate?

magic panther
#

I got that wrong. One sec

storm pine
#

On MetalCrate you shouldn't have any variable, just the ones that you will use that are not in the parent

magic panther
#

It works just how I needed it. Thanks a lot, I'll keep the protected trick in mind

#

||Unrelated to previous question||

This code is weirdly nested and looks ugly. I have no idea what I could do with it to keep the same functionality but reduce the ugliness. Or is this exactly how it should be written?

#

got rid of that unnecessary metalCrate variable

willow scroll
#

One cannot even see it fully

#

Send just the code you want to be refactored using a site

green ether
#

!code

eternal falconBOT
magic panther
#

I think that's obvious

willow scroll
#

Send the code

green ether
#

you can send exactly this triple nested if in proper format

magic panther
#

I was lazy, my bad

storm pine
magic panther
#

didn't think about refactoring just yet honestly

willow scroll
# magic panther I was lazy, my bad

Ask your question properly, without laziness, if you expect people to spend their time answering it, especially if you expect an actual helpful answer, not "yeah, go see some stuff to write code".

storm pine
green ether
#
if (!encounteredWall || !hitInfo.collider.TryGetComponent(out Wall wall)) {
        lastMoveDir = checkDir;
        currentMoveStep = moveSteps;
        return false;
    }
#

cant you do something like this before?

#

to early return

magic panther
#

early return?

magic panther
frank zodiac
#

how do i use the new input system?

willow scroll
green ether
# magic panther this instead of the whole if chain, right?
virtual public bool checkObstacle(Vector3 checkDir, float castSize) {
    bool encounteredWall = Physics.BoxCast(transform.position + new Vector3(0f, crateSize / 2, 0f), Vector3.one * (castSize / 3f), checkDir, out RaycastHit hitInfo, Quaternion.identity, castSize);

    if (!encounteredWall || !hitInfo.collider.TryGetComponent(out Wall wall)) {
        lastMoveDir = checkDir;
        currentMoveStep = moveSteps;
        return false;
    }

    if (wall is Crate crate) {
        if (crate is MetalCrate) { return true; } 
        else { return crate.checkObstacle(checkDir, castSize); }
    } 
    else { return true; }
}

I guess it not too much better

frank zodiac
willow scroll
frank zodiac
#

what do you mean by subscribe?

willow scroll
magic panther
#

now this happens

willow scroll
green ether
#

yeah i didnt change any namings

magic panther
#

when you push 2 or more only the last one moves

#

but so does the player

green ether
#

did I do a mistake?

#

I dont think I changed the logic but im not 100%

magic panther
willow scroll
#

And I don't see any logic changed either

green ether
#

Ah wait

#

I think i see it

#

In my one this line


        else { return crate.checkObstacle(checkDir, castSize); }
willow scroll
#

That's how it's supposed to be

green ether
#

it just returns

#

it doesnt set the


            lastMoveDir = checkDir;

            currentMoveStep = moveSteps;
#

like it did before

willow scroll
#

I see, right

green ether
#

my mistake

magic panther
#

np, which bit do I change?

green ether
#

It only is wrong if that check returns false

#

But then you need another nested if again and we're back at where we started

storm pine
magic panther
#

I think at least for now I'll keep it as it is. There might be more variants of variants I add and this can devolve into another kind of mess. Thanks for the help anyways

willow scroll
storm pine
willow scroll
# magic panther I think at least for now I'll keep it as it is. There might be more variants of ...

I would do it this way

public virtual bool CheckObstacle(Vector3 checkDir, float castSize) 
{
    bool encounteredWall = Physics.BoxCast(
        transform.position + crateSize / 2f * Vector3.up, 
        castSize / 3f * Vector3.one, checkDir, 
        out RaycastHit hitInfo,  Quaternion.identity, castSize);

    if (!encounteredWall || !hitInfo.collider.TryGetComponent(out Wall wall))
    {
        UpdateDirection();
        return false;
    }

    if (wall is Crate crate)
    {
        if (crate is MetalCrate)
            return true;
        
        bool hasObstacle = crate.checkObstacle(checkDir, castSize);
        
        if (!hasObstacle)
            UpdateDirection();

        return hasObstacle;
    }

    return true;

    void UpdateDirection()
    {
        lastMoveDir = checkDir;
        currentMoveStep = moveSteps;
    }
}
magic panther
#

what is UpdateDirection

willow scroll
magic panther
#

updatedirection here is really just moveObject, but I guess that's not really telligible from my end

willow scroll
#

This code shouldn't change your logic and is more readable, as for me

willow scroll
#

MetalCrate is derived from Crate, so it's impossible for the Crate check to fail if the wall has the MetalCrate type

case Crate crate:
    crate.checkObstacle(checkDir, castSize);
    break;
strong token
willow scroll
#

I see, yeah, haven't mentioned the name of the method

#

It should make an infinite recursion

#

Not sure why they're doing it though

#

@magic panther

magic panther
#

yes?

willow scroll
#

If the wall is a Crate, but not a MetalCrate

static cedar
#

Wondering if object is serializable? I'm going to use custom editor for this.

languid spire
magic panther
#

if somehow there were infinitely many crates in a row, they'd infinitely check for a wall in front of the ininite row of crates

#

I could put a theoretical limit of 100 crates being moved at once

#

If this somehow happens I messed up really bad

static cedar
fossil tree
#

hello i have a question how can i make a loop for a limited time like "i want repeat that for 2 second"

languid spire
distant hill
#

What are the general way people handle Characters like Player and Enemy in a RPG?

  1. ScriptableObjects
  2. Prefabs
  3. Using a Dictionary that holds all the info?
baseStats = new Dictionary<string, float>
    {
        {"Health", 100},
        {"MaxHealth", 100},
        {"Armor", 50},
    };
  1. Something else entirely?
languid spire
distant hill
fossil tree
#

like that ? float timer = 0f;
do { timer += Time.deltaTime; } while (timer <= 2f);
{
//my code
}

static cedar
#

I'm thinking, isn't that synchronous?

fossil tree
languid spire
#

between the { and } like any other scope

fossil tree
#

before the timer += Time.deltaTime; or after

static cedar
languid spire
#

@fossil tree If you do not understand the code I have written then !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

languid spire
#

well now is your chance to learn how to

fossil tree
#

its code beginner channel so i dont really see the problem

#

im in gamejam

#

dont really have the time

static cedar
#

I never done game jam before ngl. UnityChanThink

languid spire
fossil tree
#

ok ty

cosmic dagger
# distant hill What are the general way people handle Characters like Player and Enemy in a RPG...

there are many different ways. what you have is one of them. you can define all of the stats in a separate class/struct, individual fields as part of the Player class, or as SOs (to avoid misspellings) with a dictionary

your actual player or characters can be prefabs to easily customize them. some people use a Stat class to hold and manipulate the value of the stat, or a Resource class for stats that can replenish . . .

potent anvil
#

hey so i made a game following brackeys game tutorial but now i want to add a highscore to it but i cant seem to program it correctly i need it to save when the player quits the game and display the same score again when it is rebooted

#

the high score resets after playing the game again

#

i want it to stop right as the player collides

languid spire
fossil tree
#

a second question because the thing i want make before dont work how can i make a object a parent of a other object programaticaly

languid spire
fossil tree
#

ty

#

a kid follow his parent right ?

#

like if the parent move my kid too?

distant hill
fossil tree
#

xddd

languid spire
#

@fossil tree Sorry, but why are you doing a game jam if you do not know these absolute basics?

fossil tree
#

i make jam for learning yk

cosmic dagger
fossil tree
#

its true sry

languid spire
potent anvil
#

how do i reference a script in another script to use its funtion

distant hill
fossil tree
#

i not start learning its not my first game

fossil tree
#

without gamejam its hard for me to find game idea and put deadline

thorny hamlet
#

i reset my window and now i got this error how to fix guy

languid spire
rich adder
thorny hamlet
cosmic dagger
honest haven
#
    {
        if (GameManager.instance.battleActive && !loadBattle)
        {
            StartCoroutine(LoadSplash());
        }
    }

    private IEnumerator LoadSplash()
    {
        loadBattle = true;
        Debug.Log("Calling LoadSplash");
        yield return new WaitForSeconds(1);
        effectInstance = Instantiate(battleSplash);
        Debug.Log("calling after instantiate");
    }``` my coroutine does not hit the effectInstance. before i look else where in the code. do you think its the update becuase im setting loadBattle to true
rich adder
#

or does object get disabled at some point?

cosmic dagger
languid spire
#

@distant hill The OP has already stated 'He is doing the jam to learn' but also 'I'm doing a jam so I don't have time to learn'. Do you not see the dichotomy in this?

cosmic dagger
strong wren
#
    public GameObject Coin;
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Coin.SetActive(false);
        SS.Score++;
        SS.Health.value++;
        
    }```
#

so im not getting an error but the Score and health isnt going up

honest haven
rich adder
strong wren
#

i tried changing the score whilst im in a game and well ofc it works but it doesnt work whne im colliding with the GameObject

strong wren
languid spire
rich adder
honest haven
strong wren
cosmic dagger
languid spire
rich adder
strong wren
rich adder
#

also where is ScoreSystem SS;

#

assigned

#

so far thats a null reference

strong wren
strong wren
rich adder
rich adder
cosmic dagger
languid spire
strong wren
rich adder
#

ok

honest haven
rich adder
strong wren
cosmic dagger
honest haven
rich adder
#

if you want yield to ignore timescale you want WaitForSecondRealtime

strong wren
rich adder
languid spire
cosmic dagger
rich adder
honest haven
strong wren
cosmic dagger
rich adder
strong wren
rich adder
languid spire
# strong wren

that is not filling the declaration you showed in your code

real rock
# rich adder

I'm realising I should probably adapt my timer code to account for this

rich adder
#

given so far you have not assigned it, your console is also in a different tab, makes me think you didn't check for NullRef at all @strong wren

cosmic dagger
strong wren
languid spire
rich adder
cosmic dagger
#

Always check the console for errors . . .

rich adder
#

if its private and you haven't assigned it else where in code, its null

potent anvil
#

ok so i did it but now how do i reset the highscore

cosmic dagger
#

And make sure they're visible to the console . . .

potent anvil
#

so the player can reset the highscore

cosmic dagger
strong wren
potent anvil
#

just make the value 0?

rich adder
#

use the assignment operator

cosmic dagger
#

That's game dev . . .

rich adder
#

we even have emoji for it

cosmic dagger
#

If I move my hand and I want to reset it, I'll move it back to a previous or a default position. The same applies to anything you want to reset . . .

strong wren
potent anvil
#

yea my brain was not working

strong wren
#

oh nvm

rich adder
strong wren
#

nvm

#

i fixed it

rich adder
#

it should be either done in the inspector or code with assigment operator

strong wren
#

ye i just realized i have to Attach smth to the SS and in my case its the Canvas since its the GameObject with the code

#

fixed it

#

thanks guys

rich adder
rich adder
static cedar
fossil tree
tranquil scarab
#

https://gdl.space/ayujumowac.cs Hey i have a question about this bit of code. the thing i am trying to create is a simple script for handling downforce of a car controller. when i use this bit of code the car at high speeds begins to wobble and bug a lot. how can i fix this? oh and im using wheel colliders btw

strong token
tranquil scarab
meager osprey
#

Hello, do you know how to configure the NetworkRoomManager? Can i get some explication thx

twilit jolt
#

Hey everyone, quick question
i'm doing a small game for a jam, and i have a shopping cart, that can get items put into it
the items are non kinematic rigidbodies with box colliders on them

my issue is, i'm trying to get every item in the players cart, and my quick and dirty solution was just doing an overlapbox on the cart, and then looping over the stuff to check for items
but for some reason the overlapbox returns an empty array every time (the green wirebox shows the area and the position of the overlapbox, it should by all accounts get every items collider, yet it does not)

i used overlaps a bunch of times before, and never had this happen, so i don't know what could be causing it

rich adder
twilit jolt
#

i printed out the array right after getting it, and log shows an empty array (second picture i attached)

rich adder
#

the array object is there, its not gonna show it like [amountofitems] you're logging the whole array object, so its just []

#

try logging the Length property

#

itemsInCart.Length

ivory bobcat
#

Maybe show your implementation

twilit jolt
rich adder
#

I think the only time you can see contents is via breakpoints /debugger, stepping through code

#

but at least its sorted now UnityChanThumbsUp

#

if you don't do it often no need to worrry, if you do this caluculation often consider using the non-alloc version

strong wren
#
  public Slider Health;
  void Update()
 {
     Health.value -= 1 * Time.deltaTime;
 }```

hey does anyone know why my code isnt working? im not getting an error, i want the slider to slowly go down every second but it wont is there any reason behind that?
ivory bobcat
#

What happens instead?

strong wren
ivory bobcat
#

Maybe log the health value after

#

You might be referencing the wrong slider

strong wren
#

not possible since i only have 1 slider

fossil tree
#

hi again why when i randomRange my number (event number) i got everytime 1 IEnumerator Event() { while (true) { yield return new WaitForSeconds(timeForEvent); if (timeForEvent >= 2) { timeForEvent = timeForEvent - 0.4f; } int eventNumber = Random.Range(1,2); Debug.Log(eventNumber); if (eventNumber == 1) { missiles = missile; } if (eventNumber == 2) { missiles = missile_suivant; } StartCoroutine(missile_event()); } }

ivory bobcat
strong wren
#

no, no value is going down

ivory bobcat
fossil tree
rich adder
fossil tree
#

oh i see ty

fossil tree
#

i have not see ty

ivory bobcat
strong wren
willow scroll
ivory bobcat
strong wren
#

i dont have a debug.log

ivory bobcat
#

I'm assuming it becomes zero immediately

strong wren
#

no nothing is happending

strong wren
ivory bobcat
#

Maybe the script isn't on the object in the scene if you aren't getting any logs

strong wren
ivory bobcat
#

I can't help you if you're unwilling to debug. Good luck.

strong wren
#

well in this case

ivory bobcat
#

Add a debug log and see if it prints anything

clear river
#

Hello again.

fossil tree
#

another question why i cant drag and drop my balloons gameobject in my transform public variable on my prefab (the target variable)

strong wren
#

i can try to make it so if the value of Health Goes down then i get a log but again no value is really going down so that wont really do much

honest haven
#

hi i have this battle starter and i want to pass the game objects to another scene, is the only way to do it use DDOL? i just want to pass them to my battle manager, but i only want to use my battle manager on the battle scene

ivory bobcat
swift crag
#

A static List<WhateverThoseThingsAre> would be sufficient, as long as you only need to pass one list of levels at a time.

honest haven
swift crag
#

playerprefs would be inappropriate: you can't shove an entire unity object in there and then read it back