#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 628 of 1

raw fiber
#

its a code where when i click on a button a sound comes up but now i fixed the error. And i want to repeat the sound when i click i can only click once and when i click the sound doesent play anymore how to make it infinite

verbal dome
#

Does it play once?

raw fiber
#

i can click once and it play and when i click it again it doesnt play anymore

#

but i dont want a loop

#

hello can someone please help?

rich adder
raw fiber
#

no error

scarlet aspen
#

Where do I find the IDE set up for Unity?

raw fiber
#

this comes up

hexed terrace
#

!ide

eternal falconBOT
scarlet aspen
#

ty

rich adder
#

show your AudioSource settings

slender nymph
#

just because you are mad that i told you to learn the basics of c# does not mean you need to ping me justifying why you are asking a question every single time you do so.

raw fiber
#

@rich adder

rich adder
tacit vigil
#

i made an infinite loop on start, how can unity from executing?

frosty hound
#

You're going to have to kill the process in task manager.

tacit vigil
#

unfortunate, would've been nice for a kill option

frosty hound
naive pawn
#

i mean, isn't that the kill option

void notch
#

Haha, why not create a program to kill the executable? ๐Ÿ˜„

tacit vigil
#

*kill option that doesn't make me reopen the whole project ๐Ÿ™ƒ

raw fiber
rich adder
#

its infinite. The program doesnt know it needs to be killed since its stil " processing"

#

it will keep eating RAM until crash

raw fiber
#

@rich adder but if i click the button again after the one time it doesnt work

rich adder
verbal dome
rich adder
#

put a Debug.Log insde PlaySound

#

see if thats being called

tacit vigil
#

Follow up, is there any way to debug the infinite loop? considering it seems like i don't have access to the console while it's "processing"

raw fiber
#

when i put a debug log i get a error

#

but i think i did it wrong

#

im new

median hatch
rich adder
median hatch
#

Debug.Log

#

()

#

and put the rest inside brackets

#

dont you have intellisense

rich adder
#

not a property

median hatch
#

yes

#

i put the brackets underneath

#

typign at the speed of light

rich adder
#

why are you putting the add listener there

median hatch
#

has its consequences

rich adder
#

also why is it in start

verbal dome
rich adder
median hatch
rich adder
#

Put the log where I told you to put it
inside PlaySound

slender nymph
polar acorn
#

But it should be fairly clear what's infinite, look for while loops you added recently

raw fiber
#

guys can someone say now what the problem is that i can only play it once

rich adder
raw fiber
#

idk how

#

tut?

rich adder
#

i told you how

rich adder
#

again, we need to see if PlaySound is being called at all

hexed terrace
#

clicksound is probably null

polar acorn
rich adder
#

Put Debug.Log inside PlaySound function, to see how many times that method is being called

verbal dome
#

They said "i can click once and it play" but it's probably just the play on awake

verbal dome
#

And now you say a different thing

#

Like it's somehow obvious

raw fiber
#

yes omg i was so stupid

#

but i now put it in update

hexed terrace
#

...why

median hatch
#

good job

rich adder
#

instruction arent your thing

median hatch
#

takes time

raw fiber
#

ok but how can i do it now?

rich adder
#

you test if PlaySound is being called at all

#

put log inside of it before the if statement

#

idk its not that complicated of an instruction is it?

raw fiber
#

log? you mean debug.log?

rich adder
#

thats what I been saying yes..

polar acorn
#

No, he means Yule Log, the christmas delicacy and/or the actual fireplace log that it's based off of (apparently it's not just a cake! I learned something today)

verbal dome
#

๐Ÿชต

rich adder
#

Debug.Log("Hello, this is being called", gameObject)

#

untick collapse in Console window

raw fiber
hexed terrace
#

do both.. put 2 logs in..

rich adder
#

pay attention plz

median hatch
rich adder
#

google what?

#

"how to place a log before if statement" ?

median hatch
#

yes

raw fiber
#

where guys?

median hatch
#

you see what i mean

raw fiber
#

im so confused rn

rich adder
#

you just made it worse

#

somehow

raw fiber
#

im so sorry

median hatch
#

no worries man we all started the same way

slender nymph
#

this is why you were instructed to learn the basics

rich adder
raw fiber
#

bro boxfriend

rich adder
#

code runs from top to bottom

median hatch
#

just please learn the basics

raw fiber
#

please just say it to me

polar acorn
median hatch
#

Debug.Log Mann

raw fiber
#

just give me the line of code empty but in right order and everything

median hatch
#

einfach Debug.Log

rich adder
raw fiber
#

bro wo รผber if oder bei if

rich adder
#

english only server

polar acorn
#

If it gets this conversation over with, German is fine

median hatch
#

exactly

raw fiber
#

bro where above oder at if

rich adder
#

do you want me to hold your mouse for you too

median hatch
raw fiber
#

welche zeile

#

ahh omg i got it

median hatch
#

ich weiss nicht, ich kann sie nicht sehen

#

LETS GOOOOO

#

german >>>

raw fiber
#

what is supposed to come in side debug.log

rich adder
#

this in english only server, keep it so

median hatch
#

dude omfg

#

read what i said

raw fiber
#

i get cs0104

rich adder
median hatch
#

Debug.Log("played");

#

literally copy paste what i wrote

#

ctrl c ctrl v

rich adder
#

show what u wrote

#

after this go through the basics or you're gonna burn al your help cards here believe it

raw fiber
polar acorn
median hatch
polar acorn
#

I know the problems solved already I just needed to find a comically large picture of an arrow

rich adder
# raw fiber

Okay seems its grabbing the incorrect Debug class

polar acorn
#

took me a bit

rich adder
#

worth

raw fiber
#

what is the right debug class?

rich adder
raw fiber
#

i only get a green one

rich adder
#

you should remove the one that has Debug from System.Diagnostic

polar acorn
raw fiber
#

yes i have it

median hatch
#

DELETE IT

polar acorn
raw fiber
#

omg finaly no error

rich adder
#

yes things go smooth if you pay attention to instructions

raw fiber
#

same thing

rich adder
#

same thing what?

raw fiber
#

only playes once

rich adder
#

that isnt what the logs are for..

#

logs dont fix code..

#

they are used to Debug it

raw fiber
#

then say me what does

#

please

rich adder
raw fiber
#

i dot wanna script today anymore

rich adder
#

and just for good measure send what you wrote

raw fiber
#

this is a mobile game button

polar acorn
# raw fiber only playes once

The entire point of the debug log was as a tool for seeing what the code is doing. This is an information gathering step

raw fiber
#

nothing is showing up

polar acorn
#

Now you can see when the function is called

rich adder
polar acorn
raw fiber
#

only

polar acorn
#

Which is, itself, information

raw fiber
rich adder
#

assuming you put the log before the if

#

if you dont see other logs then the button is not working

polar acorn
# raw fiber

If you don't get the log you just put in, then you're never calling the function

rich adder
#

typically, either something is covering it OR you dont have an event system

polar acorn
#

So it's not running at all

median hatch
#

can you show your button inspector + code?

raw fiber
#

nothing running

rich adder
median hatch
#

he probably didnt add a listener to the button

frosty hound
#

@raw fiber Please make a thread, you're spamming this channel with your noise at this point.

raw fiber
hexed terrace
raw fiber
polar acorn
# raw fiber

Oh my fucking god it's still not before the if

#

I don't have a higher resolution arrow image to point to the instructions again

rich adder
#

oof

#

they are using a SpriteRenderer..

#

and no canvas

#

and no event system

#

this borked

raw fiber
#

can someone please give a tut

median hatch
#

please basics

rich adder
median hatch
raw fiber
median hatch
#

LMAO

raw fiber
#

bro on youtube there are only tuts for movement on mobile

hexed terrace
#

imbicile

frosty hound
#

@raw fiber If your next message isn't making a thread, you will be muted.

#

And if your persistence on not learning, and expecting people to solve all your issues continues, you will be muted.

raw fiber
#

@frosty hound buddy this was no question this was a thing

frosty hound
#

!mute 986696803208532078 1d You can return tomorrow.

eternal falconBOT
#

dynoSuccess snail_thunder was muted.

hidden fossil
#

is this a place to ask for help?

polar acorn
#

Sure, if it's related to beginner coding concepts in Unity

hidden fossil
#

ok i need help im getting this really werid bug

#

for some reason

polar acorn
hidden fossil
#

idk if has to do with coding or not

#

but its like when i click play and go to my game menu and click on level 1, the enemies in the inspector and waves just all disappear

#

but then when i exit play mode they just all go back

polar acorn
#

Well, everything should go back to normal when you exit play mode, any changes to anything during play mode get reverted

hidden fossil
#

no its not that

#

its like i put it there when im in exited play mode

#

but then when i play and click on level 1

#

they just all disappear

#

like i use the same script for level 2

#

and for some reason they are stilll there for level 2

#

but they just disappear in level 1

polar acorn
#

Well, first off, are you getting any errors in the console

hidden fossil
#

lemme check

#

nope no errors

#

like it shows this in the inspector when im not playing

#

but then when i play it just becomes this

hexed terrace
#

something is probably setting that list empty / creating a new one in code

hidden fossil
#

no

#

if i like play the game from level 1

#

its there

#

but when i play the game from the game menu and click on level 1

#

it just disappears

rich adder
#

they probably are two different instances?

hidden fossil
#

yea but

#

i did the same for level 2

#

and i played level 2 from the game menu

#

its there

#

but its just not there for level 1?

hexed terrace
#

something is telling it to do that, find out what has a reference to it

hidden fossil
#

in the scripts?

rich adder
#

yea

hexed terrace
#

!code

eternal falconBOT
cosmic dagger
#

Use a paste site to post your !code . . .

eternal falconBOT
hexed terrace
#

delete this and post properly

hidden fossil
#

can i just upload file?

hexed terrace
#

no

#

can you just do what's expected?

hidden fossil
#

yea

#

do i just paste it on there?

cosmic dagger
cosmic dagger
rich adder
#

you're supposed to SAVE IT then get the generated link

#

not send us the root of the website..

hidden fossil
queen adder
#

i cant get my object to move, using a rigidbody and it wont work correctly. It has a rigidbody attached and im using rb.addforce and its not showing any actual errors but the object wont move.

rich adder
queen adder
#
public Rigidbody rb;

void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
        rb.AddForce(transform.forward * 20f);
    }
rich adder
hidden fossil
#

is my problem fixed yet/

queen adder
cosmic dagger
queen adder
hexed terrace
hidden fossil
#

still happening

hexed terrace
#

so, not fixed

#

the code you shared doesn't show anything

cosmic dagger
hidden fossil
#

so uhh what now?

cosmic dagger
rich adder
hexed terrace
# hidden fossil so uhh what now?

record a video and show the issue happening. Make sure to include the hierarchy and inspector in the recording, do not crop anything out

queen adder
queen adder
#

but i also tried it w the default stuff just incase that was the issue

queen adder
rich adder
rich adder
verbal dome
#

Does the object have an animator?

queen adder
hidden fossil
rich adder
#

Kinematic ๐Ÿ˜‚

#

no shit its not moving

queen adder
rich adder
#

Kinematic = no physics

#

AddForce will not work

queen adder
#

OH

#

i uh

rich adder
#

something you should've probably mentioned when they asked " if you changed anything on RB" lol

hidden fossil
#

wait so

#

how do i do an mp4?

hexed terrace
queen adder
#

it was on network rigidbody so i didnt think to but in hindsight yeah

#

welp

#

learning curves

rich adder
#

forgot where

hexed terrace
#

or shareX to record straight to mp4

#

quicker /easier than setting up OBS

rich adder
#

ShareX is good too

queen adder
#

lmao just turned kinematic off and saw it go past at mach speeds awesome that fixed it

rich adder
queen adder
#

ohhh

rich adder
#

also probably not a good idea to do Multiplayer if you dont know the unity basics yet ๐Ÿ˜†

queen adder
#

see i didnt realise that and was just looking at my player prefab and doing the same stuff w the logic of "this is how i do it"

rich adder
#

yaa..its gonna get quite complex, quickly lol

#

start with a simpler thing, work your way up

hidden fossil
#

alright

queen adder
hexed terrace
# hidden fossil

Is something destroying the Levelmanager GameObject and instantiating it on scene load?

rich adder
# hidden fossil

LevelManager is a prefab, are you creating a new instance maybe and deleting old one?

hidden fossil
#

i did the same for level 2 and it works

rich adder
#

jinx!

rich adder
hexed terrace
hidden fossil
#

i used the same scripts and setup

hexed terrace
#

So.. it's a yes/ no question.. and if you're not sure, you need to check and confirm

rich adder
hexed terrace
#

A list won't become empty on its own, SOMETHING you've done/setup has to be interacting with the component or the game object

hidden fossil
#

so what would i need to double check?

rich adder
#

how you set that up

hidden fossil
#

like the script?

rich adder
#

sure whatever handles LevelManager prefab

hidden fossil
#

so like a picture?

eternal falconBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

hidden fossil
rich adder
#

also doesnt seem EnemySpawner is part of the original prefab

hidden fossil
#

oh the levelmanager script?

hexed terrace
#

we do not know if levelmanager class spawns itself.

hidden fossil
#

it spawns itself

#

just not the wave setting

#

but it spawns everything else

rich adder
hidden fossil
#

nah

#

i followed an online tutorial

#

and just modified the game by myself a little bit

rich adder
#

well whatever you touched broke it then ๐Ÿคทโ€โ™‚๏ธ

#

if you dont know your own setup its going to be difficult fixing

hidden fossil
#

so right now were looking for if the level 1 enemyspawner is loading?

rich adder
#

you would check if something might be finding / Spawning LevelManager and deleting the old one for some reason

rancid tinsel
#

right?

cosmic dagger
rancid tinsel
#

if we are talking singletons though I would assume that you have a spare level manager in Level 1 scene, but not in Level 2 scene @hidden fossil

cosmic dagger
#

Check which scenes have a level manager . . .

hidden fossil
#

ok

hidden fossil
rancid tinsel
#

!code

eternal falconBOT
hidden fossil
rancid tinsel
#

ok just to double check, because you are using a static instance so its quite likely

#

type LevelManager in here in all scenes to make 100% sure you dont have another one

rich adder
#

is there something that spawns LevelManager?

rancid tinsel
#

^ that too

#

but that one is harder to find

hidden fossil
rich adder
#

LevelManager is also missing the singleton cleanup so that might not be the one deleting the copy (if one existed)

rancid tinsel
hidden fossil
#

anything else?

rich adder
#

yeah when you access the Instance it will grab the new one

hidden fossil
#

so is that the problem?

rancid tinsel
#

if you want to read up on what this is in more detail ill get you a resource real quick

rich adder
rancid tinsel
#

so I think you're right

hidden fossil
#

the code u sent me is giving thousands of bugs

rich adder
rancid tinsel
#

oh wait

#

whoops

#

change Instance to main

hidden fossil
#

oh yea thats the problem

rancid tinsel
#

you usually want to name it Instance though from what I understand, seems to be standard practice

#

but its really semantics

hidden fossil
#

alright all fixed ima test it now

rich adder
#

outta nowhere unity uses Singleton for NGO Network manager

rancid tinsel
hidden fossil
#

nope still not working

rancid tinsel
hidden fossil
#

so like when i play level 1 from level 1 scene

rich adder
hidden fossil
#

it shows that the wave setting is all set and enemies are there

#

but when i play level 1 from the game menu

#

the wave setting and enemies just all disappear and spawns nothing

rancid tinsel
#

in practice i mean

hidden fossil
#

like the inspector is even empty for the wave setting

rancid tinsel
#

since you prob wouldnt couple a singleton to a non-single instance class

hidden fossil
#

but when i exit play mode and go to inspector it just all comes back

rancid tinsel
hidden fossil
#

no

rich adder
hidden fossil
#

i need a level manager in the menu scene?

rich adder
#

such a tiny amount in the grand scheme its a non-issue

rancid tinsel
#

like other scripts where you do LevelManager.main...

hidden fossil
graceful jasper
#

if i have a object with a dependency on a component in a child object, should i get the component in Awake() or Start()

rancid tinsel
# hidden fossil

i dont see anything that would cause the issue here. so what happens is that you load into the scene, and the level manager's references are gone?

#

could you show the inspector for it both in edit mode and play mode?

hidden fossil
#

from like the game menu scene play?

rancid tinsel
#

yeah so you said its there and then its gone

#

so show me before and after

hidden fossil
#

before i play level 1

rancid tinsel
#

and this is in the level 1 scene right?

hidden fossil
rancid tinsel
#

are you sure this is the same one? i dont see build manager in the first screen shot

slender nymph
#

are you spawning a prefab? because from the looks of it you have made changes to the one in the scene but not saved those changes to the prefab

hidden fossil
#

its below it

#

like everything else in levelmanager is there except for the wave settings when i play

rancid tinsel
#

oh were prob looking in the wrong place

#

show the EnemySpawner class

hidden fossil
#

script or inspector?

rancid tinsel
#

script pls

hidden fossil
#

!code

eternal falconBOT
hidden fossil
#

wait i got an idea on how to fix this

#

since it works on level 2 but not on level 1

#

can i just duplicate level 2 scene and delete level 1 scene?

#

and change it?

rancid tinsel
#

that should prob work

#

but i wouldnt delete the original scene

hidden fossil
#

should i try it?

rancid tinsel
#

just rename it to something else for the time being

#

you could

hidden fossil
#

ok

#

delete level 1?

rancid tinsel
#

no just rename it

#

you may still need it

hidden fossil
#

ok

#

yea, i did made level 3 by duplicating level 2 and it works

#

but level 1 still doesnt owrk

#

so im guessing delete level 1?

glacial forge
#

Im having some issue with the IDragHandler interface. if anyone could help me out

I have included event systems, I'm inheriting all 3 of the interfaces IBeginDragHandler, IDragHandler, IEndDragHandler

but yet all 3 of these functions dont log anything, so therefor I assume are never called

public void OnBeginDrag(PointerEventData eventData)
{
    Debug.Log("drag start");
    velocity = 0f; // Stop momentum
}

public void OnDrag(PointerEventData eventData)
{
    Debug.Log("draging");
    SelectedIndex -= eventData.delta.x * dragSensitivity; 
}

public void OnEndDrag(PointerEventData eventData)
{
    Debug.Log("drag end");
    velocity = -eventData.delta.x * dragSensitivity * 10f; 
}
hidden fossil
#

any rigid body used?

glacial forge
#

for some more context this is a script on an empty gameobject inside a panel. I got it to work for a second but then it stopped

glacial forge
hidden fossil
#

no

#

if u used rigidbody i think u would have to write velocity to linearvelocity

#

i think btw im not sure

glacial forge
#

yeah the issue is im not even getting the debug.log

#

the other code im fairly certain works, but is just never triggering

hidden fossil
#

so ur problem is it is not interfering?

#

like the code isnt working?

glacial forge
#

the functiuon is never called

#

debug.log never prints

hidden fossil
#

does the object have a collider?

sour fulcrum
#

there's a couple channels that could be the most appropriate spot for this question so apologies but regarding like displaying 2d tiles, That's generally down from top left to bottom right correct?

glacial forge
sour fulcrum
# glacial forge yes

feels weird doing it for the first time because in regards to setting position i gotta use positive x but negative y so it made me question reality aha

glacial forge
#

yeah its a standard cord system and you are starting at 0,0. the direction you chose to populate is up to you.

#

for example I populate my world like this:

Vector3Int[] vector3Ints = new Vector3Int[width * mapChunkSize];
for (int y = 0; y < mapChunkSize; y++)
    for (int x = -width / 2; x < width / 2; x++)
        vector3Ints[y*width+x + (width / 2)] = new Vector3Int(x, -y, 0);

world.ClearAllTiles();
world.SetTiles(vector3Ints, mapData.tileArr);

where world is a tileMap, and mapData.tileArr is just a 1d array of tiles
that makes 0,0 the top center and it populates downwards

waxen aurora
#

how can I change the object reference of this specific binding via code?

rich adder
#

its probably a struct in Playable Director

rich adder
#

thats probably it

#

to swap

waxen aurora
#

but with key does it mean the previous object or what

#

"The source object in the PlayableBinding"

rich adder
#

its the Key

#

so its used to find it

#

probably checks the extact ref / type

waxen aurora
#

mhhh

#

so what if its null?

#

I hoped to do something simple like this (code as screen so you can see the error)

covert raft
#
System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <191a1970a53948f9819ac1d2e4f5c72e>:0)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at <84f0d810adef4e6c8deab33e4ae93f7c>:0)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)  
#

what does this error message mean?

polar acorn
#

Something's trying to call MeleeAttack.OnMelee but it doesn't exist

#

Since it's an Invoke or a Coroutine with a string parameter, there is no stacktrace

#

Well, no useful stack trace

#

One of the main reasons not to use those

rich adder
wintry quarry
covert raft
#

okay so rn im using a triangle as a temporary trigger to deal damage but its very incosistent anyways to make it better?

#

but it works when i move the hitbox around more

idle charm
#

how do i make a day/night cycle for my game?

rich adder
deft igloo
#

Hello

#

So uh...

#

I have Heard is recommended to check some courses online to learn some programming

#

But how can i know if a course is good or not before buying it?

frosty hound
#

Read reviews? ๐Ÿ™†

polar acorn
#

Don't pay for online courses. All that info is likely available for free

frosty hound
#

But in this day, you don't need to buy courses. Everything you need to learn is free.

deft igloo
#

Mostly asking because i would like to have a base to start with

#

I know everything is available in the internet but there is so much that idk what to do or try first

frosty hound
#

You're overthinking it. There are pinned resources in this channel you can start with.

deft igloo
#

Okay i can check that out

#

Also i see the page is mainly in English but are these explanations also available in any other language?

frosty hound
#

No idea

covert raft
#

idk why but i gotta move my cursor to register the hit and idk why that is

wintry quarry
covert raft
wintry quarry
#

and show your code

covert raft
#
using UnityEngine.InputSystem;
using System.Collections.Generic;

public class PlayerCombat : MonoBehaviour
{
    public GameObject Melee;          
    public float atkDuration = 0.5f;  
    public float damage = 10f;       

    private bool isAttacking = false;
    private float atkTimer = 0f;
    private InputAction meleeAction;
    private HashSet<Collider2D> hitEnemies = new HashSet<Collider2D>(); 

    private void Awake()
    {
        meleeAction = GetComponent<PlayerInput>().actions["Melee"];
        if (Melee == null) Debug.LogError("โš ๏ธ Melee GameObject is not assigned!");
        Melee.SetActive(false); 
    }

    private void OnEnable() => meleeAction.performed += _ => StartAttack();
    private void OnDisable() => meleeAction.performed -= _ => StartAttack();

    private void Update()
    {
        if (isAttacking) HandleAttack();
    }

    private void StartAttack()
    {
        if (!isAttacking)
        {
            Melee.SetActive(true); 
            isAttacking = true;
            atkTimer = 0f;
            hitEnemies.Clear(); 
        }
    }

    private void HandleAttack()
    {
        atkTimer += Time.deltaTime;
        if (atkTimer >= atkDuration)
        {
            isAttacking = false;
            Melee.SetActive(false); 
        }
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        
        if (isAttacking && other.CompareTag("Enemy") && !hitEnemies.Contains(other))
        {
            Enemy enemy = other.GetComponent<Enemy>();
            if (enemy != null)
            {
                enemy.TakeDamage(damage);  
                hitEnemies.Add(other);     
            }
        }
    }
}
#

thats the hitdetection and attack code

wintry quarry
#

just use a direct physics query

covert raft
#

and how do i do that im like very new to this

wintry quarry
#

e..g Physics2D.OverlapXXX or Physics2D.XXXCast

covert raft
wintry quarry
covert raft
#

ill look into it tomorrow too tired rn

pine crater
#

I'm attempting to transform a mesh which is in the shape of a toothbrush but I think it still has the original mesh of the square I placed the sprite onto, because when I get the length and width of the sprite, they are equal. How can I fix this?

small dagger
#

Why does my input map keep getting lost? Kind of a minor thing because I just need to re-apply it, but for some reason, th Input map here just keeps going "missing" and I have to re-add it

wintry quarry
small dagger
wintry quarry
wintry quarry
#

What did you assign it to?

small dagger
# wintry quarry missing means it was destroyed

these are the only two scripts making any use of input, when I re-add it and play the game, everything is fine, it seems like if I keep the editor open for a while (like working on something else) it for some reason removes it?

pine crater
# wintry quarry > it still has the original mesh of the square Huh? What square? What are we tal...

Well when I made the PNG I imported it into my Sprites folder. I made a square in the workspace and then put the sprite onto the little black bar in the inspector (sorry I'm new to unity I don't know the words for some things), so I have the toothbrush PNG in the game. I want to be able to click on the screen and the toothbrush moves to where I clicked, I got it working but it always landed in the middle of the toothbrush which isn't what I wanted, so I said okay all I have to do is get the length of the toothbrush, halve it, turn it into a vector, and take it away from my mouse position. This is not working. The length of the toothbrush seems to not correct and when I tried to incorporate a width, it is the same as the length

wintry quarry
pine crater
#

I can post my code here if you want

small dagger
wintry quarry
# pine crater Well when I made the PNG I imported it into my Sprites folder. I made a square i...

I made a square in the workspace and then put the sprite onto the little black bar in the inspector
What's a workspace? What black bar in the inspector? The inspector of what?

I got it working but it always landed in the middle of the toothbrush which isn't what I wanted, so I said okay all I have to do is get the length of the toothbrush, halve it, turn it into a vector, and take it away from my mouse position. This is not working. The length of the toothbrush seems to not correct and when I tried to incorporate a width, it is the same as the length
Sounds like you actually want to just change the pivot of the sprite, which you can do from the sprite editor. Access the sprite editor by selecting your image file and selcting sprite editor at the top

wintry quarry
#

which actions asset did you assign it to?

small dagger
wintry quarry
#

And where is that? is it in any special folder or anything

small dagger
#

Just in an Input folder under the generic Assets folder Unity starts with

#

I wonder if maybe I just accidentally assigned it to the player in the map instead of the player prefab, who knows, if it happens again I will come back and worry about it...

pine crater
#

I'm a blender veteran that's why I'm getting confused over meshes and stuff I don't get how unity does things

#

I could technically divide them by 4 and it would look alright but it's for my coursework I have to explain my code as I go along and I can't really say "it looked okay"

wintry quarry
#

but I don't understand why you're doing all this bounds stuff

pine crater
wintry quarry
# pine crater

Ok so like I said above:

Sounds like you actually want to just change the pivot of the sprite, which you can do from the sprite editor. Access the sprite editor by selecting your image file and selecting sprite editor at the top

pine crater
#

I want it to be offset by its length

wintry quarry
#

changing the pivot would be the easiest way

pine crater
#

Idk what that means

wintry quarry
#

I gave specific instructions on how to change the pivot.

The pivot is where the actual position of the object is

#

such that when you do transform.position = somePosition the pivot of the sprite will go exactly to somePosition

wintry quarry
eternal falconBOT
pine crater
#

I'm tryna find it rn

wintry quarry
#

The sprite is definitely not "still a square"

#

the bounds of the SpriteRenderer will be based on the sprite import settings

#

specifically the boundaries of the sprite as represented in the sprite editor, and whether your mesh mode is set to Tight or Full Rect

pine crater
#

I can't find the sprite editor

#

I've got my image selected

wintry quarry
#

should be a button in the inspector

#

like this

#

(although that's a pretty outdated screenshot it should be similar)

pine crater
#

Oh yes I see it

#

Okay Pivot is on centre right now so I change it to wherever I want my mouse to land?

#

Where I want it to land when I click my mouse*

wintry quarry
#

change it to the part of the brush you want to overlap with the mouse cursor

#

yeah

pine crater
#

Okay thank you brother

wintry quarry
#

also remember to take out the bounds calculation offset stuff from the code

pine crater
#

Of course ๐Ÿ‘

jolly moat
#

I'm in Unity, what's the best way to reinstaniate a UI slider after a scene reload? I have a Manager object that I drag the sliders onto for my script's public variables and they work on the first play. But If I trigger a Scene reload, the sliders won't reinstantiate for my Manager object's script. I have this in the Awake() method of my Manager's script: healthSlider = GameObject.FindWithTag("HealthSlider")?.GetComponent<Slider>();

#

Can I not do this with UI elements like I would a regular gameObject?

wintry quarry
#

your problem is that Awake only runs once per object

#

So it's not going to run again when you load a new scene

#

basically it's odd for this "manager" to have references to other objects in the scene when it's apparently a DDOL object

#

and those other things are not

#

that's a design that isn't going to work

#

Some options are:

  • Make the manager not DDOL.
  • Make the UI stuff also DDOL
  • Make the UI elements register themselves with the manager when they are created (in their OnEnable)
  • Switch the dependency - make the UI elements listen to an event to update themselves instead of the manager referencing them and updating them
unkempt hound
wintry quarry
unkempt hound
#

Ah!

#

So I'm guessing I should switch to Visual Studio for C++

pine crater
unkempt hound
#

I just use extensions

jolly moat
wintry quarry
#

but I don't know the specific details here

#

so it's hard to say

#

the first is also a strong contender

#

The first is definitely the easiest, but it depends on what else this "manager" does and why it needs to be DDOL in the first place

unkempt hound
#

Getting VS rn

#

Finna ditch VS Code altogther

jolly moat
# wintry quarry so it's hard to say

I suspect I made too many managers. I started off with just 1 scene "Gameplay". I made a StatsManager as a singleton instance to handle player's current and max health, magic (sliders). Then I made a "Title" scene and a GameManager to handle when Game Over is reached and scene transfers. I thought maybe the GameManager should take over all managerial responsibilities. Thoughts?

#

The only reason to DDOL any managers was initially to reset the current values of the health and magic sliders. Then GameManager seemed like it also needed DDOL to handle scene transfers

wintry quarry
#

the observer pattern is something to look into

jolly moat
#

who is the broadcaster of the event the UI should be subscribing to?

wintry quarry
#

whatever manages the data that's changing

#

i.e.:

something happens in the game (player gets hit?) -> the new player HP is set on the data manager. -> Data manager fires an event -> The UI receives the event broadcast and updates itself

cedar prairie
#

why does my velocity.magnitude go this low?

slender nymph
#

that's basically 0

cedar prairie
#

this is when the player is litreally isnt moving

wintry quarry
#

Turns out it's moving just really slowly

#

but yeah that's basically 0

cedar prairie
#

can i floor it?

wintry quarry
#

if you want

cedar prairie
#

whats the thing for that again haha

wintry quarry
#

if (rb.velocity.magnitude < someThreshold) rb.velocity = Vector3.zero;

jolly moat
slender nymph
# cedar prairie can i floor it?

not really necessary to floor it, that is literally 0.0000002 meters per second so after a few minutes it may have moved a barely noticable amount

cedar prairie
#

dont worry i gott it i just needed to look at it like it was floored so i can fuck about with it easier

#

bless you all

#

its cause the way i was doing code would take a second to deactivate cause it wasnt technically 0 so ill just floor it

#

easy peasy

slender nymph
#

ah, sounds like you may have been doing float equality when you should pretty much never do that. there's the Mathf.Approximately method to handle comparing floats, it checks if the difference between them is less than Mathf.Epsilon

slate roost
#

hey I realized a really noob mistake I made in a script a long time ago and its giving me a headache now
if (velocity.y < 0)

I'm using this as a check to see if my player is moving in the downward direction, but its inconsisten because... floating point values
I.E. the float is sometimes 0... and sometimes 0.0000000000003

whats a better, consistent way to check this?

slender nymph
#

tbf neither of those numbers is less than 0

#

if you want to know if your object is actually moving downward then you need to check if its velocity is below a lower threshold, because just because it is less than 0 does not mean it is low enough to actually be moving

slate roost
#

er, yea, you're right that was a poor example

well the problem more specifically, is this
float directionY = Mathf.Sign(velocity.y);
this is returning -1 and 1 alternating rapidly, because when velocity.y should be 0, it sometimes is very slightly negative instead, so it makes directionY -1 when it should be 1

slender nymph
#

right so read my previous message

slate roost
#

so something like this?
float directionY = velocity.y < -0.0001f? -1:1;

surreal minnow
#

I am writing a shader to create a texture. I have seen people make the camera output the texture on the screen. So the screen renders the texture in its resolution. Does anyone know how to do this?

#

I think by putting a render texture as the cameras Output Texture but it just says "Display 1 No cameras rendering" so hm

teal viper
#

I don't know if a screen space canvas counts or not. Probably not.

#

So you'll need 2 cameras

surreal minnow
#

Ah nvm. I did it wrong. But Graphics.Blit() does not work in URP anyways

hidden fossil
#

guys i just have like a quick question about visual code studios

#

how do you implement that IDE where like for example if you type in the keyword f it gives you the option float and a bunch of other options?

slender nymph
#

!ide

eternal falconBOT
hidden fossil
#

which one do i download

#

oh nvm

#

how do i enable this?

slender nymph
#

why? did you bother following the actual instructions for configuring vs code? or did you just go and search "IDE" in the extensions?

hidden fossil
#

i went on one and it said u could just install one from the visual studio

slender nymph
#

huh?

hidden fossil
#

oh wait nvm i forgot enable it in the unity

eternal needle
#

maybe take more than 2 seconds to actually read the page..

#

you arent even using visual studio

slender nymph
teal viper
hidden fossil
#

ok i should prob uninstall jetbrain rider

teal viper
#

Rider is also an ide.

hidden fossil
#

yea i put that as my preference but for some reason its n ot opening any scripts

#

and im trying to open the app but its not opening

#

guess it prob has a malware

#

yea idk why i put it as my external tools and its not opening any scripts the app isnt even opening when i double click onit

teal viper
hidden fossil
#

it said finish installing

#

but now it doesnt work?

#

its 1.4 gigabytes and the app says 1.4 gigabytes

#

ok im uninstalling it it is taking up too much storage and its not working

teal viper
#

Why would you even go for Rider if you're a beginner?

cosmic gorge
#

!code

eternal falconBOT
cosmic gorge
#
void FixedUpdate()
    {
        playerInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        rb.velocity = playerInput.normalized * moveSpeed;

        if (Input.GetAxisRaw("Horizontal") < 0)
        {
            rb.transform.localScale = new Vector3(1, 1, 1);
        }
        else if (Input.GetAxisRaw("Horizontal") > 0)
        {
            rb.transform.localScale = new Vector3(-1, 1, 1);
        }

        if(Input.GetAxisRaw("Horizontal", "Vertical") > 0)
        {
            dust.Play();
        }
        else if()
        {
            dust.Pause();
        }
    }
}

#

how do i make it to where if my player is not moving, my dust particles dont show up, and when he is moving, they do show up?? i'll post more reference rn

eternal needle
cosmic gorge
eternal needle
#

and your other else if() isnt valid c#, i recommend going over c# basics really so you arent struggling with both c# and unity at the same time

cosmic gorge
eternal needle
#

the errors are just standard c#. there are pins in the channel for intro to c#
for your immediate problem, you could probably just compare the vector to Vector2.zero. if its the zero vector, pause the dust. else play the dust

#

you dont need to read the Input.GetAxisRaw("Horizontal") everytime as well. its already stored in playerInput

cosmic gorge
eternal needle
#

Vector2.zero is just (0, 0). you'd be comparing the input to (0, 0)

cosmic gorge
eternal needle
#

theres nothing specific to if its actually moving or not, since it could be moving against a wall

frigid sequoia
#

Is this statement ok, or I am doing some forbidden math stuff? lol

eternal needle
frigid sequoia
#

I want to do a loop on a list to get the lowest value on it, so the default min is... infinite

#

But health works on int, Math.Infinite is float

eternal needle
#

there is a min and max value const
you don't need to do anything float related if you want an int

#

int.MaxValue

frigid sequoia
#

So what's the difference?

eternal needle
#

the difference is you want an int. so just grab the int instead of doing it through a float

celest flax
#

I'm having an issue. When loading a scene, I'm trying to move the player to a specific point, but there is something in the project that moves the player back to where it was before. I've been scouring all relevant scripts but am unable to find what causes it. Does anyone know anything that might help me locate the problem?

teal viper
charred spoke
#

Bet that the character controller is responsible for that

topaz mortar
#

I'm using this to play sound effects (sword slash for example), but (obviously) it keep creating new gameobjects that are never removed, what's the proper way to handle this?

audioSource.PlayOneShot(audioClip);```
#

Do I just have a GO in my scene to which I always add AudioSource components? Then destroy/remove the component when the sound is done?
Or do I just delete the GO every time?

#

Or should I be creating this GO & component just once and then only call PlayOneShot when a sound needs to be played?

cosmic dagger
astral falcon
# topaz mortar Do I just have a GO in my scene to which I always add AudioSource components? Th...

I used to have a soundmanager that spawns audisources, if needed and removes them when done. But only, if a certain amount of clips playing at the same time was hit. So imagine one source for weapons for example. And you play from there, but if its playing and you want to add another sound, spawn one temporary audiosource. Depends on your setup. If you know, you got two weapon sounds always, then keep 2 audiosource components alive and add a third for rare cases that gets removed or pooled

topaz mortar
charred spoke
topaz mortar
# charred spoke So bad that it should be removed from the internet

Let's learn how to play Sounds and create a simple Sound Manager class to handle playing any Sound we want in 2D and 3D.

GameAssets class video
https://www.youtube.com/watch?v=7GcEW6uwO8E

If you have any questions post them in the comments and I'll do my best to answer them.

See you next time!

Grab the game bundle at https://unitycodemonkey...

โ–ถ Play video
#

6 years old though

#

and maybe he goes on to fix the issues, didn't watch the rest lol

astral falcon
#

Why would you share it tho ๐Ÿ˜„ if its bad ๐Ÿ˜†

charred spoke
#

Jesus I did not expect code monkey to produce such garbage

astral falcon
#

I just scrubbed through, looks like he is fixing it at some point later

charred spoke
#

I recommend this guy I have yet to see a bad tut from him https://youtu.be/BgpqoRFCNOs?si=9fhybHVMyd1W7pee

Take control of the sounds in your game by pooling your Audio Sources! Reduce the number of real voices required to play a multitude of audio clips, manage their lifecycle, and enhance performance. Learn how to streamline your audio management and make your game sound fantastic with efficient audio source pooling!

Check the repository for impro...

โ–ถ Play video
astral falcon
#

Nah he does not ๐Ÿ˜„ keeps on creating gameobjects for every sound

topaz mortar
charred spoke
#

The amount of garbage tutorials out there is staggering

cosmic dagger
topaz mortar
#

If I ever need more complex sounds I have the video Uri linked ๐Ÿ™‚

#

for now this works fine

astral falcon
scenic charm
#

gm guys. I know nothing about coding or developing a mobile game but I want to learn. can anyone suggest me a guide? I just want to be able to create mobile games?

astral falcon
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

topaz mortar
# scenic charm gm guys. I know nothing about coding or developing a mobile game but I want to l...

๐Ÿ”ด Get bonus content by supporting Game Makerโ€™s Toolkit - https://gamemakerstoolkit.com/support/ ๐Ÿ”ด

Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then gi...

โ–ถ Play video
astral falcon
topaz mortar
#

It explains more how to learn instead of going in depth on unity

astral falcon
#

It was more of a general advice than specific to the content of that video ๐Ÿ™‚ If you hop on an older video or documentation and dont know how to handle deprecated stuff, you can easily get frustrated, so watchout for the timestamp on tutorials ๐Ÿ™‚

sour fulcrum
#

Doesn't help that Unity provides this evil built in function

    public static void PlayClipAtPoint(AudioClip clip, Vector3 position, [UnityEngine.Internal.DefaultValue("1.0F")] float volume)
    {
        GameObject gameObject = new GameObject("One shot audio");
        gameObject.transform.position = position;
        AudioSource audioSource = (AudioSource)gameObject.AddComponent(typeof(AudioSource));
        audioSource.clip = clip;
        audioSource.spatialBlend = 1f;
        audioSource.volume = volume;
        audioSource.Play();
        Object.Destroy(gameObject, clip.length * ((Time.timeScale < 0.01f) ? 0.01f : Time.timeScale));
    }
astral falcon
sour fulcrum
#

yeah but the creating and destruction for a single clip is awful

teal viper
#

If you have some spare frame time budget, why not

astral falcon
#

you cant handle it another way than having a gameobject at that point wher eyou want your sound to happen. Of course would make sense to be able to pass in a already existing gameobject too, but if not, that method makes sense

sour fulcrum
sour fulcrum
scenic charm
teal viper
rugged beacon
#

i just looking more into scriptable object, is singleton outdated by this now ?

eternal needle
eternal needle
astral falcon
potent nymph
#

I don't know which channel is most appropriate for this question, but I'm wondering why the size of my webGL build is so large, even after compressing most of the user assets (textures, sounds, etc)

#

this is an uncompressed build, but even the brotli build is 16 mb. Many people online have gotten their game down to 5mb or less

polar dust
#

Also a singleton is a design pattern related to C# in general, whereas a SO is just a thing Unity created. It's not really possible for unity to make something in C# become obsolete

teal viper
potent nymph
#

Oh, I see

bitter spruce
#

I have this weird bug, i have like a particle.Play() in my script. But it only plays when i click something in the hierarchy it dosent mae sense, does anyone know a fix?

teal viper
polar dust
#

A singleton just gives you a static reference to an class instance, making it convenient to access a game object from anywhere. Good use case might be for a player character if you want an enemy script to reference the player.

SO is like a configuration, so if 5 classes share the same SO, they'll all be reading the same values

bitter spruce
#

i have a debug.log in the part where the particle.play() is

#

its running

#

somehow only when i click on the hierarchy then it starts playing. Like i have to interact first then the particle really plays

rough lynx
polar dust
#

I have love hate for them

rough lynx
#

Lmao

polar dust
#

They're very helpful and I use them often

teal viper
bitter spruce
#

The debuglog is in the same if statement as the particle.play. But somehow only my log runs.

BUT when i interact with the hierarchy, my particle then stats playing (displaying)

rough lynx
#

Maybe your particle isn't play on awake? I vaguely remember that being a tickbox

#

Haven't used the particle system in a while

polar dust
#

Especially for classes that don't need to be MonoBehavior

rough lynx
#

I'm addicted to polymorphism and static classes just don't provide that

teal viper
polar dust
rough lynx
#

Yeh

bitter spruce
polar dust
bitter spruce
#

this problem dosent make sense to me

polar dust
#

I have just woken up so apologies ๐Ÿ˜‚

rough lynx
#

Oh right

#

Lol all good

rough lynx
teal viper
#

And active

bitter spruce
#

yes my scene and game is side by side

teal viper
bitter spruce
#

ill try find another way around it

#

thank you for your help

teal viper
bitter spruce
#

i cant send you the gameplay too because its for a company

bitter spruce
#

thank you man

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

cloud walrus
polar acorn
cloud walrus
#

but somehow it keeps bugging

polar acorn
cloud walrus
#

I'll show you the code

robust harness
quasi cradle
#

heya guys, im a bit lost. hoping somone can help me without being too much of a nag

trying my hand at unity again after a many year hiadus (for context im a developer in mainly powershell and python so not a beginner there)
basically a complete beginner here but trying to 'just do some stuff' approach with some road blocks.

im trying to setup a third person aim camera for a basic scene at the moment, seen cinemachine used so trying to implement that but im struggling with probably a simply step.

i cant figure out how to setup a script for attaching camera movement and player movement to the player, the guides ive found are using depreciated cinemachine and aren't helpful.
Basically i want to create a variable to see x/y of mouse and transpose that onto player and camera rotation. Not sure if theres a doco or something i could be looking into as a few solutions iv'e found don't seem to work

frosty hound
#

Cinemachine went through a bit of an overhaul with 3.0, so old tutorials will be slightly outdated when it comes to getting/modify properties on a virtual camera. The update was to make it easier to get those values by using the standard GetComponent to access them.

steady flame
astral falcon
steady flame
#

So all buttons dont work, i resume the game if i press escape again but i dont want that, the console doesnt say anything

#

except some other warnings which doesnt have anything to do with the menu

rocky canyon
#

search for functions that would be related to a pause menu in the IDE... Pause().. UnPause() or w/e

#

then u'll know the script MyPauseMenu.cs or w/e then u can search in the Hiearchy to find what gameobject that is attached to..

steady flame
#

thanks

rocky canyon
#

sounds like it may be pausing by setting timescale to 0.. then ur updates will freeze and u wont be able to detect any other kind of input

steady flame
#

oh ok i search for that now

rocky canyon
#

if u followed along with the script ur logic should be pretty similar to theirs i guess ^

steady flame
#

I copied the script

#

still doesnt work

rocky canyon
#

so u should see this in ur hierarchy?

steady flame
#

yes

#

whoops

rocky canyon
#

so whas the issue. u want the buttons to work while paused?

steady flame
#

yes

#

but the cursor everytime i click disappears

rocky canyon
#

find ur EventSytem in ur project

steady flame
#

yes

#

got it

rocky canyon
#

aye.. soo ur using the oldschool input system? not the new one

steady flame
#

there is a new one

rocky canyon
#

there is

#

but unless u want to go on a learning spree i'd stick w/ what u got

steady flame
#

okay

#

so how do I fix my issue?

rocky canyon
#

im reading..

steady flame
#

oh ok

rocky canyon
#

its one of those threads where its like:
well, it could be this..
or it could be this..
or perhaps its this..

steady flame
#

hm okey

steady flame
rocky canyon
#

say ur controller locks the cursor (hides it or w/e)

#

and ur pause menu tries to also change it.

#

could be conflicting

steady flame
#

oh i think it hides it maybe let me look it up

rocky canyon
#

๐Ÿ‘

#

i just recently moved all my cursor logic into its own script

#

so both my controlller and my menu systems ask it to change it

#

instead of changing it itself

steady flame
rocky canyon
steady flame
#

okey

rocky canyon
# steady flame

ya, mine was like that too.. once i wanted to "make the cursor visible" with the pause menu

#

they'd try to fight each other

steady flame
#

and the fps movement script wins i assume?

rocky canyon
#

it might be that ur cursor is still locked to the center

#

when u hit esc.. the mouse breaks out of the window.. (but this isnt the same as being focused)

#

if u click back into the window and u hadn't unlocked it.. it snaps right back to the center

steady flame
#

it isnt i can move it around until i press lmb

rocky canyon
#

(if its centered it makes it hard to click anything else)

coarse magnet
#
public class healingitem : MonoBehaviour
{
    public GameObject detonate;
    private void Update()
    {
        Debug.Log("just work you fucking moron");
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag.Equals("player"))
        {
            Destroy(detonate);
        }
    }
}
#

my object doesn't disappear when it collides with the player

#

oh

#

i forgot the debug message

steady flame
#

before I made the pause menu with the tutorial i could press escape and the game paused and the cursor was visable forgot to say that

rocky canyon
steady flame
#

wdym?

rocky canyon
#

ur moving around the editor at that point.. not around the game view..

steady flame
#

oh ok

rocky canyon
#

unless u Unlock it.. via code.. when u click back into the game window it'll get Locked again

steady flame
#

oh ok i understand

rocky canyon
#

i think ur character or something else is grabbing it and locking it

#

not giving it a chance to be able to navigate around ur buttons

#

u see all my Debugs in the corner?

#

thats how i helped build out my system..

#

its nice to know what ur mousePosition actually is..

steady flame
#

doesnt work

rocky canyon
#

u can debug.log it in an update() or something... when ur cursor gets grabbed and locked it'll spit out 0,0

steady flame
#

oh ok

rocky canyon
#

well thats not how u do it anyway lol

steady flame
#

how?

rocky canyon
steady flame
#

still doesnt work

#

is there a difference when i let unity build the project?

#

and then try

rocky canyon
#
    if (Input.GetKeyDown(KeyCode.Escape)) // When Escape is pressed
    {
        if (Cursor.lockState == CursorLockMode.Locked)
        {
            // Unlock the cursor and make it visible
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible = true;
        }
        else
        {
            // Lock the cursor and hide it
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = false;
        }
    }```
#

this would: when u press esc... if the cursor lockstate is locked we unlock it
if the cursor lockstate isn't locked we lock it

steady flame
#

do I put it in the fps movement script or the pause menu script?

rocky canyon
#

so like a toggle

#

anywhere u want in any update loop

steady flame
#

that sounds logical

rocky canyon
#

but probably need to keep it simple.. if u put it in ur controller..

#

dont accidently add something else to the main menu..

steady flame
rocky canyon
#

and vice versa.. the best thing imo is to have a gamemanager controllnig this type of thing

#

that way when anything wants to lock or unlock it has to go thru the game manager

#

that way it isnt taking over control itself. and maybe breaking other things

#

ur IDE doesn't seem to be configured either.. btw..

#

!ide

eternal falconBOT
rocky canyon
steady flame
#

okey so the fps movement?

rocky canyon
gray orbit
#

Hello, I think I am missing something fundamental here but:

I have created a test folder in unity that lives at Assets/Scripts/Tests and have a bunch of public classes I want to access defined in Assets/Scripts. I'm having trouble getting my test script to reference those classes as they are not defined in the context while I'm running my script. Can someone help explain to me what is going on with the scope and context here when I run tests through Unity TestRunner?

rocky canyon
steady flame
#

doesnt work

rocky canyon
#

can u !code share ur movement script and ur pause script..

eternal falconBOT
rocky canyon
#

you're not gonna sort it out by changing one thng w/o changing the other thing

#

they'll need to work together

steady flame
eternal falconBOT
rocky canyon
#

or both of em use some other script to toggle and manage the cursor as i said earlier

steady flame
eternal falconBOT
rocky canyon
steady flame
#

oh ok

rocky canyon
#

thats y it keeps responding to u

#

just paste in ur script.. hit the save button and it'll generate a new url u can copy and paste here.

#

keeeps the channel clean

steady flame
#

ok ok

#

should I also send you the other scripts I use?

rocky canyon
#

aight give me a second i have an idea that might work.. (using a Manager type script that both the pause menu and the controller can reference)

#

when they need to unlock or lock the cursor they tell it to do it instead..

steady flame
#

okey sounds good

rocky canyon
#

โ˜• break tho

steady flame
#

sure

#

I still need to grab breakfast

rocky canyon
#

too much head flexing

#

brain starting to hurt already cant remember which project i just fkcd up

#

ill start a thread and ping u when i return cool/

steady flame
#

yeapo sure

rocky canyon
#

aight im back

rocky canyon
# rocky canyon aight im back

and.. mines still broken for some reason mines getting instantly locked and hidden ๐Ÿ˜… and i can't find it in my own code..
-# standby

limber flower
#

Destroy(gameObject); is not working, but its rotating fine

wintry quarry
#

Which means you didn't set up the scene properly for OnTriggerEnter

limber flower
wintry quarry
#

It means certain conditions need to exist in the scene for that to run, and those conditions are not present

limber flower
#

im doing the beginner tutorial and ive re read all the steps to check if i missed anyhting

wintry quarry
#

You must have missed something

#

Feel free to show how your objects are set up if you want a second set of eyes

grand snow
#

inb4 is trigger is false

limber flower
#

let me know if i need to send a more zoomed in screenshot to see better

wintry quarry
limber flower
#

how do i fix that

#

oh nvm

#

thgank you

wintry quarry
#

Check the box to... Yeah

limber flower
#

appreciate it

steady flame
rocky canyon
#

yea hangon.. im making a package out of it

#

its easier to just show u the entire example and let u work out the issues in ur own system

steady flame
#

ok

#

can we maybe go in a call later so its easier to communicate

#

if it still doesnt work

potent nymph
rocky canyon
#

plus im at work right now ๐Ÿ˜ˆ

rocky canyon
rocky canyon
# rocky canyon ๐Ÿ“Ž ๐Ÿ‘‡

check that package out.. ^ should have everything set-up for you to look around and see how its all working together... key point is:

  • anything that wants to mess w/ the cursors (hide it, unlock it, lock it, etc) is done by calling the MasterMouse singleton...
    that way theres only 1 script in charge of it.. you don't want multiple scripts fighting telling it to do something, let's say there's one script trying to lock it.. but then theres another script (that maybe you don't know about) thats going right behind it trying to unlock it... it gets really confusing really quickly if u have it happening in multiple places

and please note.. that i didn't mess with the time in my example.. its just dealing w/ the cursor..

#

i had to create a new scene.. b/c i did break my old scene (still trying to fix it)..
its b/c i have that same issue as well.. i got multiple things all trying to control the cursor ๐Ÿ˜ญ

#

can't remember exactly where tho lol

strong wren
#

Are you aiming for instant game platforms or do you have some other pressure to get super small build sizes?

rocky canyon
# steady flame if it still doesnt work

and something else you may want to know is use the EventSystem component to your advantage
if you expand it in the inspector in Playmode.. it'll give you lots of information...

in this example you can see.. (when i click into the game and its "unpaused" the numbers don't change) thats b/c its locked.. when i press the Tab key.. or w/e is set up to pause and unpause you can notice that all of a sudden the values start changing quickly.. (thats when we're not locked) and the cursor is actively moving around the UI/scene

#

and Debug.Log()s if ur not using those while ur learning, then ur doing it wrong ๐Ÿ˜›
you want to give urself as much information as possible when learning... and you need to get ur IDE configured correctly b4 someone else calls you out on it.. alot of people wont even help you until you do..

you snitched on yourself here: #๐Ÿ’ปโ”ƒcode-beginner message b/c that code should be underlined in red since its not correct..

rocky canyon
#

and the last tip i can give you b4 i gotta get back to work..


Consider using an alternative key that you don't use very often to test your pause system.. example, I chose 'Tab' in my test scene that I sent you.```
verbal dome
#

Show a video of the issue and also your joint settings

rocky canyon
#
   void Start()
    {
        head_up = false;
        jump_trigger = false;
        use_trigger = false;
        jump_has_ended = true;
        head_2_target_lerp_val = 0F;
        head_2_target_lerp_min = 0.15F;
        head_2_target_lerp_max = 0.65F;

        // from here
        Cursor.lockState = CursorLockMode.Locked; //Mauszeiger im Fenster einsperren
        Cursor.visible = false; //Mauszeiger unsichtbar
            if (Input.GetKeyDown(KeyCode.Escape)) // When Escape is pressed
        {
            if (Cursor.lockState == CursorLockMode.Locked)
            {
            // Unlock the cursor and make it visible
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible = true;
            }
            else
            {
            // Lock the cursor and hide it
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = false;
            }
            // to here
    }``` @steady flame  and this is odd.. in ur character controller..
you have this logic in the Start() method.. Start() only runs for 1 frame.... theres no way that it's gonna detect ur Input there anyway... But this logic can be removed from teh character controller anyway..

you can instead have a reference to ur controller in the PauseSystem script.. and when it gets paused you can set a bool in the controller called `canMove` or something 

like `characterController.canMove = false;` while its paused and
`.canMove = true;` once u unpause.. and then the character controller can just do its movement if the bool is true..
#

if the legs are whats causing the issue.. start w/ that

#

if its not enough you'll be asked to provide more ๐Ÿ‘

#

best of luck Finn, eugen.. ๐Ÿ€ work calls ๐Ÿ‘‹

#

lots of active ragdoll projects around lately

verbal dome
#

You probably want to adjust the axis of the leg joints

#

The setup looks weird though

#

Why is everything free

#

Is that a leg joint?

vital shadow
#

hey guys....so im thinking of making an npc which is ai based....meaning it learns from its actions by using machine learning and ai algorithms...i cant think of a way to start making it....can someone help me??

inner bane
verbal dome
#

Well normally you'd at least lock the positions instead of just using limits for the position

#

Did you follow a tutorial?

#

I knew it was AI code, didn't want to assume just yet

inner bane
#

lol

#

so I just lock the positions? the X axis or all?

verbal dome
#

That's not the main issue

inner bane
#

oh mb

verbal dome
#

The joint axis direction is

#

Adjust the Axis so that it rotates around the correct axis

#

Currently it is 1, 0, 0, which seems to be wrong

inner bane
#

thanks a lot!

tribal wave
#

can someone explain to me in very simple terms what instantiating is? i looked around and i didnt understand any of the explanations