#💻┃code-beginner

1 messages · Page 168 of 1

rare basin
#

check the scale if you copied/paste them

#

or just make new buttons and tweak them

#

would be faster than debugging it

stuck palm
#

maybe this is why?

#

the green line is probably the size

#

yeah that fixed it

#

@swift crag ur system works well enough but when i decide to switch to using mouse, it highlights two at the same time

#

how could ufix this?

swift crag
#

It's a non-trivial problem. I haven't figured out the best way to handle it.

#

You could auto-select whatever your mouse cursor is over, but then that causes headaches for people using both the mouse and keyboard to navigate the UI

#

You can make the "hover" and "select" colors different, at least

#

I use these tints, for example

stuck palm
#

fair enough

#

unrelated, sometimes when i want to load a scene, it doesnt load the scene i want to go to and just loads the current scene instead. any idea how i could fix this?

swift crag
#

well, how are you picking which scene to go to?

#

and are you getting any warnings in the console?

stuck palm
#

it works fine the first time i go somewhere but the second time it breaks

#

i'll record video

swift crag
#

show me your code.

stuck palm
#

hold on

#

i need to test something

#

figured it out

#

i had a script that broke it because i didnt want to keep going between scenes

amber nimbus
#

can I somehow disable the influence of a parent GameObject? I dont want the child object to move with the parent object

swift crag
#

then don't parent it

#

you can unparent the child during Awake if you need this to be in a prefab

amber nimbus
#

yeah that sounds good

#

thanks

swift crag
#

that's what I do in my game -- I have a ragdoll that can't be parented

#

I make a new "root" object, parent the entity to the root, and then parent the ragdoll to the root

#

(the root is there to make it easy to destroy everything later, but I could also just keep a list of game objects that all need destroying)

stuck palm
#

@swift crag the issue still seems to be happening in my pause menu, its loading the wrong one for some reason. despite being set to "HubWorld", it loads "menuscreen" for somer easoon

#

the debug even says its going to hubworld

#

but it goes to the home screen and idk why 😭

swift crag
#

where is that being logged?

#

the code you sent doesn't have any log statements in it

#

so it's possible that something else is also trying to load a scene

stuck palm
# swift crag so it's possible that something else is also trying to load a scene
public class ExitToSceneButton : MonoBehaviour
{
    public string sceneToLoad;
    private FadeInAndOut fade;
    void Start()
    {
        fade = FindObjectOfType<FadeInAndOut>();
    }

    private void OnEnable()
    {
        FadeInAndOut.FadeInCompleted += LoadScene;
    }

    private void OnDisable()
    {
        FadeInAndOut.FadeInCompleted -= LoadScene;
    }

    public void Click()
    {
        print("loading to " + sceneToLoad);
        StartCoroutine(fade.FadeIn());
    }

    private void LoadScene()
    {
        SceneManager.LoadScene(sceneToLoad);
    }
}
#

my button code

swift crag
#

log it inside LoadScene instead

#

I'd also log when you subscribe to/unsubscribe from the FadeInCompleted event

#

notably, if you have two ExitToSceneButton components in the same scene, or two exist anywhere, both will try to load a scene

stuck palm
swift crag
#

since all they do is respond to FadeInCompleted

stuck palm
#

I didn't even realise

#

There are two buttons with this component on

swift crag
#

I have similar behavior in my own game, but all scene loading is done by a singleton GameController

stuck palm
#

That makes so much sense now

swift crag
#

You ask the controller to enter a scene, and it starts a fade effect

#

then when the fade is over, it loads the scenes

#

i need to make it log a warning if it's in the "loading" state and gets asked to load another scene

#

i think that happens if I mash the "start" button..

stuck palm
#

obviously not as good as a proper controller

swift crag
#

That's an option, yes. You can unsubscribe in both OnDisable and in LoadScene

stuck palm
#

but like i think that would avoid the issue

swift crag
#

unsubscribing excessively is fine

stuck palm
#

how can i delete a player input from the game? lets say if a player wants to leave or whatever

#

i have this player input manager thing

#

and i want the player input to get destroyed if it exits to main menu

buoyant knot
#

a script would need to do that

cinder void
#

my first week using Unity....I'm very confused as to why my GameObject can be detected using the OnPointerEnter / OnPointerExit....but my UI Buttons aren't....unless I place them at the edge of the screen, then they only show up in the debug info once I move my cursor on/off screen. I'm considering just changing all my Buttons to GameObjects at this point

buoyant knot
stuck palm
#

it says there are player join and leave messages though?

buoyant knot
#

gameobjects can only be detected via components on them

cinder void
#

Yeah I tried that method and it just didn't work for me, but then I am very new

buoyant knot
#

Unity’s UI system is kind of weird

cinder void
#

I wanted to be able to detect when I hover over buttons

swift crag
#

No. these are for UI objects.

#

You implement an interface and then add the method that interface calls for.

buoyant knot
#

let’s backtrack first

#

Gameobject contain components

cinder void
#

'//Attach this script to the GameObject you would like to have mouse hovering detected on' thats why I was confused I guess

amber nimbus
#

Alirght I tried unparenting a GameObject using transform.DetachChildren() the script is on the parent and it does not seem to work, the child stays a child anyone know why?

buoyant knot
#

components have logic/script associated with them

polar acorn
#

which are game objects

#

like everything else

buoyant knot
#

gameobjects cannot do ANYTHING without components

swift crag
#

ah, yes, I was being unclear there.

cinder void
swift crag
#

the two things we care about are...

  • UI objects: things like Image
  • Physics objects: things with physics colliders attached to them.
#

That is the distinction.

#

hence why we have GraphicRaycaster and PhysicsRaycaster

buoyant knot
#

i’m not sure that the two are mutually exclusive

swift crag
#

You could mash both together, yeah

buoyant knot
#

let’s not confuse the man

cinder void
#

So let's start with the basics....I put a UI Button into the project, then to make that detectable by cursor what script do I use???

buoyant knot
#

u have a gameobject that is a child of a child of a child… of a canvas. This gameobejct is tied to the UI. This gameobject can have components in it that work with UI

#

you also have a gameobject automatically put into scene called EventSystem. EventSystem takes in inputs, and manipulates UI elements. Such as causing mouse position to activate buttons

cinder void
#

got that

buoyant knot
#

EventSystem is automatically added when you add a canvas

high hearth
#

somebody help me?
the object not accompanies the character's hand

buoyant knot
#

Ok, now the gameobjects in the canvas use special UI only components, like button, rect transform, and grid layout group to do their thing

#

Button is the one responsible for making a button.

cinder void
#

yeah well I know how to make my game object a button, I've done that haha

#

but I wanted to add a UI Button into the game, which I can hover over and detect in the console

#

my debug only shows my cursor entering/exiting that button when the button is placed around the edge of my canvas

#

and I'm like what

#

so this was frustrating me and I built a new 'button' using a blank GameObject, and for some reason that could be detected anywhere when I gave it the script

buoyant knot
#

so for this, it sounds like you need to use OnPointerEnter

#

which needs to be on a class derived from Monobehaviour, implements IPointerEnterHandler, is on the gameobject, and has a function with the exact signature:

public void OnPointerEnter(PointerEventData eventData)

#

which is in the UI space

#

ie it has a rect transform

swift crag
#

(so, attach it to the same object as the Button component)

buoyant knot
cinder void
#

can I just send you a video of what I am experiencing because it probably isn't clear

buoyant knot
#

i can’t rn

cinder void
#

I have a GameObject button that is detectable in the console
I have a UI Button that is detectable in the console, but only when placed at the edge of the canvas

#

so I am trying to figure out why it is only detectable when placed there

swift crag
#

Show us the inspector for this UI button.

#

Show every component on the object.

cinder void
swift crag
#

now show us the "Verb Button" script

#

!code

eternal falconBOT
earnest atlas
#

What should I use to make animation of 2d objects? Simple ones like rotation.

swift crag
#

Okay, this looks fine. It implements the right interfaces.

shrewd swift
#

what can cause a FindFirstObjectByType not work ?
i am loading a scene and trying to get a object that exists, but unity isnt finding it, i wonder why

swift crag
#

When you click on the button, does it visibly change color?

#

you can change the colors in the "Button" component. The defaults are a bit hard to see.

earnest atlas
#

What type are you searching? Why are u searching for a type?

swift crag
#

they're trying to find a unity object in the scene

cinder void
swift crag
#

(generally a MonoBehaviour)

shrewd swift
swift crag
#

t:eventsystem

#

punch that into the search box in the hierarchy window

cinder void
#

yeah

earnest atlas
#

Post the line u are using to search for it

swift crag
# cinder void yeah

Show me the hierarchy with the button object selected. Include all of the other children of the canvas -- let me show you an example...

shrewd swift
#

looks like the script is only awake after the find

swift crag
#

I have "Choice Entry(Clone)" selected

swift crag
earnest atlas
#

Post the entire function (if its not long) where you try to find it?

cinder void
swift crag
#

Yeah.

#

I'm wondering if another UI element is getting in the way.

earnest atlas
#

I still don't really understand what he is searching to need anybytype.

shrewd swift
earnest atlas
#

Yeah but whats the goal

shrewd swift
cinder void
#

it's been a complete mess, just been experimenting with everything

swift crag
#

You can check if this is the case by making a new empty canvas

cinder void
#

but now my mind is at 'why do the butons not light up like they used to'

earnest atlas
#

Is that a script?

swift crag
#

copy just the single button onto it and deactivate the original canvas

earnest atlas
#

You are searching for

cinder void
#

yeah I should do that Fen

swift crag
#

this will ensure you don't have any other UI elements in the way

shrewd swift
swift crag
#

Children draw in front of parents, and later siblings draw in front of earlier siblings.

shrewd swift
#

wait ik why it doesnt find it

swift crag
#

A common error is to have a huge Image element that's blocking all of your buttons

shrewd swift
#

the code is prob executed before the reload

cinder void
#

I'll try a blank one

earnest atlas
#

Maybe make a courutine that is delayed by 1s ?

#

To let the scene load

swift crag
shrewd swift
#

i need to do stuff to a objetc that is loaded, so I can only execute the code after the scene loaded

swift crag
#

LoadScene loads the scene at the end of the frame.

#

It doesn't interrupt your code

swift crag
earnest atlas
#

I fixed issues my scene loading issues like this, search happend before object got loaded.

little oak
#

the game object wont show up unless im click on it

shrewd swift
#

can i just make a load scene with params, then in my Menu read the params from SceneManager.sceneLoaded ?

earnest atlas
#

You can

shrewd swift
#

i need to look how the scene params work

earnest atlas
#

You can also use the same DontDeleteOnLoad object to store data

swift crag
#

This object is getting completely destroyed by the scene load

earnest atlas
#

Yeah

late bobcat
#

Guys i've a question, my game starts lagging when multiple collision occurs, how can i optmize collision?

shrewd swift
#

yes

swift crag
#

so it seems kind of pointless to do anything in it

faint osprey
#

Instantiate(enemyDiff1[0], (activeRooms[0].transform.position + dungeonSpawns[Random.Range(0, 9)].position)); why does this not like the addition of the the two transform.positions arent they both vector3's

swift crag
#

that's not the problem

swift crag
#

read the error.

faint osprey
#

it says cannot convert vector 3 to transform but when u hover over both they both say vector3

earnest atlas
#

Maybe remove transform?

swift crag
#

yes, they're both Vector3

#
FunctionThatWantsAnInt(1.0f + 3.0f);
polar acorn
dusty hull
#

is there any way to apply a physics material through code?

swift crag
charred spoke
dusty hull
rich adder
# dusty hull how?

Reference the Collider and apply it?
keep a reference to material as well

little oak
#

bru my messages drowned

earnest atlas
#

I think he has issues with whatever code he runs in the oncollision (trigger or enter)

cinder void
#

@swift crag I'm having a moment....I just copied the button onto a new canvas/scene and I can't see the button? I probably need sleep

late bobcat
#

like a lot. If you know vampire survivor you get the idea @charred spoke

polar acorn
swift crag
#

"Canvas" and "Scene" are two wildly different things, so we need to know which one it is..

cinder void
#

yeah I just realised I dont have a canvas LOL

swift crag
#

Create a new Canvas from the GameObject menu

#

Then you can attach a Button to it and try interacting with it.

charred spoke
late bobcat
#

@charred spoke so you kinda get the idea, don't mind sprites ahah

charred spoke
late bobcat
#

kk @charred spoke ty

rich adder
# dusty hull how?
 [SerializedField] PhysicMaterial physMaterial; 
  [SerializedField] Collider theCollider;
        public void ChangeMaterial()
        {
            theCollider.sharedMaterial = physMaterial;
        }```
dusty hull
#

ok thanks will try

little oak
#

how can i make a gameobject visible if its overlapped by another gameobject?

little oak
#

it is on

rich adder
#

so start it off

little oak
#

wdym

languid spire
polar acorn
cinder void
#

@swift crag now it's just the blue screen. I see the button in the window but not in game mode

prime cobalt
#

How could I give a cone of light a hitbox that travels as far as the light itself? So like things know if there's a flashlight being shined on them or something.

polar acorn
little oak
#

how lol

rich adder
polar acorn
# little oak how lol

by changing the position of the object so that it is no longer in the current position but a different one

languid spire
little oak
#

put it infront

languid spire
#

so do that

little oak
#

doesnt work

swift crag
prime cobalt
#

can physics raycasts find everything within an entire cone instead of just a single point?

rich adder
#

you can create a cone shape from multiple rays

cinder void
polar acorn
swift crag
#

This is becoming more of a #📲┃ui-ux problem, so you should ask about further issues there. The channel also has some resources pinned

rich adder
polar acorn
# little oak yes

Then it's definitely blocking the object and you'll need to position it further from the camera

little oak
#

but im changing the z value

static bay
polar acorn
#

and not closer to it

static bay
#

Your background might be sorted higher.

little oak
#

dub

languid spire
little oak
#

i always put everything in the same order lol

#

i made it higher

swift crag
#

ui problem

polar acorn
little oak
#

wdym background was sorted higher

static bay
polar acorn
polar acorn
#

But I haven't done much 2D so it's entirely possible I'm wrong

static bay
#

Could be wrong.

swift crag
#

Position is used.

little oak
#

what are u guys yapping abt

swift crag
#

ah, yeah, but "Order in Layer" beats position

#

That's right.

static bay
# little oak wdym background was sorted higher

Sprite sorting is kind of a whole thing. Basically your background sprite was always on top because reasons. Changing the sort order of the cracks is telling Unity to always render the cracks ABOVE the background.

swift crag
#

The red sprite is physically behind the white sprite, and its "Order in Layer" is 1

little oak
#

interesting

polar acorn
little oak
#

counterintuitive init

swift crag
#

sorting layer also makes the red square appear in front of the white square

static bay
little oak
#

is there darkmode on unity docs

swift crag
slender nymph
little oak
#

lol that wasnt the first question i asked it was abt the topic

static bay
polar acorn
swift crag
#

That's also the opposite of what I expecting, haha

polar acorn
#

One of these days I should actually try to do something in 2D so I can understand how it all works

swift crag
#

I've only ever been interested in dealing with things that overlap

#

so I guess the misconception was just as good in that case

static bay
#

It would be absolutely mind numbing to sort anything in the transparency queue with a perspective camera.

late bobcat
#

guys, do you have any good updated tutorial on how to use unity profiler?

swift crag
#

yes: the documentation

#

consult the "Profiling in the Unity Editor" section of "Profiling your application" for info about using it in the editor

pastel dome
#

so how would one typically offset a camera in 3rd person so that it appears over the shoulder instead of direct center of the player

rocky canyon
#

back and to the left..

stuck palm
#

my player has been destroyed, but stuff in the playerscript is still running and idk why

pastel dome
#

@rocky canyon they usually use child object?

rocky canyon
rocky canyon
#

id use cinemachine

#

has a built in camera that has orbits

pastel dome
#

i like static lol u havent seen what ive been through xD

rocky canyon
#

if ur loookin down on the player the camera goes closer.. if ur lookin up at the player hte camera goes closer..

stuck palm
rocky canyon
# pastel dome <@317141358894645248> they usually use child object?

In this video, we’re going to look at how we can set up a third-person camera using the new Aiming Rig of Cinemachine 2.6, and how we can use Impulse Propagation and Blending to create additional gameplay functionality for our camera controller.

Download this project here!
https://on.unity.com/36nVNzt

Learn more about Cinemachine 2.6 here!
htt...

▶ Play video
buoyant knot
#

you want some amount of damping

pastel dome
#

i really hate cinamachine

#

might be for bad reasons but i think its bad

buoyant knot
#

That is truly not our problem

rocky canyon
#

check out that video, its really not hard.

#

but if want a player locked camera u can use a child yea

slender nymph
buoyant knot
#

we provided you a simple camera technique. If you just don’t like it, then you should figure out your own way.

pastel dome
#

not really complaining my boy just feel like the only person not using it

craggy oxide
#

how would I go about creating an "IsWalking" boolean that can detect all WASD inputs so that I can optimize my code

buoyant knot
#

I don’t use it because I am in 2D

rocky canyon
#

the main camera stays around just like it normally does.. (only with cinemachine you use the virtual camera) and the normal camera snaps to the virtual camera's position..

wintry quarry
rich adder
rocky canyon
#

the virtual camera is what controls all the cam movement

slender nymph
buoyant knot
#

but I also needed to make a whole big system for my camera to work. Probably about 1 month of coding on my camera, with all the little knick knacks.

wintry quarry
craggy oxide
rocky canyon
#

and YET i still used a cinemachine as the camera ;D

pastel dome
#

hehe thats cool

slender nymph
craggy oxide
#

why are you so rude for man

#

im new

pastel dome
#

i was looking at warframes camera and noticed the offset was pretty much a child

#

but ya warframes definitly pans in an out the further you go up down

slender nymph
rocky canyon
#

the farther up or down the camera the smaller orbits it uses

buoyant knot
quick ruin
#

im finding if a child is active to turn on movement, is this performance wise bad

fluid remnant
buoyant knot
late bobcat
slender nymph
pastel dome
#

i just wish cinemachince code wasnt so long or id go into it

buoyant knot
#

because you can use specific things/interactions to break/move these camera targets/barriers, to let the player effectively move the camera as a part of the game

pastel dome
#

lol cinamachince lite tm

buoyant knot
rocky canyon
rocky canyon
# pastel dome i just wish cinemachince code wasnt so long or id go into it

ur thinking of it the wrong way.. the cinemachine components just do what they do. (rarely do u need to get into that code to do anything)
u still declare a camera in ur own scripts (only u can declare it as a virtual cinemachine camera) and u then u can enable it, disable it, move it, parent it, or w/e

pastel dome
#

lol i like learning camera code though

#

i might change it and make it like a drone or hawk

#

anyway thanks for your help

rocky canyon
#

Let's learn how to make a solid third person controller with a moving camera!

Jason no longer offers the course mentioned in the video.

👕Get the new Brackeys Hoodie: https://lineofcode.io/

● Third person controller asset: https://assetstore.unity.com/packages/templates/systems/third-person-controller-126347?aid=1101lPGj

·····················...

▶ Play video
#

well its hard to find a third person camera tutorial that isnt cinemachine, but brackeys has one i guess!

buoyant knot
#

third person camera is hard because walls will get in your way

rocky canyon
#

yup

#

good luck with clipping

buoyant knot
#

we went through the entire N64 era without devs figuring out how to stop walls from obscuring your view

rich adder
#

cinemachine collider does ok job but can be improved

buoyant knot
#

learn from what came out in the end. don’t repeat their struggle and still shitty cameras

rocky canyon
#

ya, its hit or miss even with the cinemachine collider

#

u pretty much need to design ur level in a way that compliments what ur camera can do

buoyant knot
#

super mario 64 was amazing.
the camera was suck

#

it all averages out

rocky canyon
#

lol, back when the camera might as well been its own character

#

hitting all those yellow buttons just to get a decent angle to walk forward

cosmic dagger
rocky canyon
#

lol, this guy gets it 😄

#

when those buttons gave out on ur controller, it was a whole different level

charred spoke
craggy oxide
#

I understand the basics of Unity C# but i can't really put any of it to practical use, I don't know how to combine anything yet

#

What do I do

#

Any easy exercises that could teach me to connect stuff together?

polar acorn
#

Try things

#

You're not going to fast track this. You're just going to have to do

rocky canyon
#

yea, ^ what type of game do u wanna make.. start small.

slender nymph
#

the best advice anyone can give to someone who has already learned the basics is to just start making shit

craggy oxide
rocky canyon
#
Unity Learn

Welcome to the John Lemon’s Haunted Jaunt: 3D Beginner Project! In this project, you won’t just discover how to create a stealth game — each of the 10 tutorials also explains the principles behind every step. No previous experience is needed, which makes John Lemon’s Haunted Jaunt the perfect start to your journey with Unity.

craggy oxide
#

yeahhh judging by that thumbnail that is wayyy too advanced

rocky canyon
#

unity learn is still a good resource, for putting the stuff together

craggy oxide
#

i need something that is like, the bare minimum, even if its a tiny snippet of code, a very easy challenge

#

just something to help me connect the dots

#

i know what booleans are, i know what strings are, i know it all, but i cant seem to put them together in my head

craggy oxide
#

but what game??

polar acorn
rocky canyon
#

think small, basic clicker games maybe..

#

angry birds, flappy bird, temple run

polar acorn
#

You can try whatever you want. Just don't expect to finish something complicated

slender nymph
late bobcat
polar acorn
late bobcat
#

now i've tried reducing the fixed time update from 0.002 to 0.003

polar acorn
#

there's no reason these characters can't have box colliders

late bobcat
#

but then hitboxes aren't gonna be accurate no?

rocky canyon
#

^ or capsules

late bobcat
#

just asking

rocky canyon
#

how accurate do they need to be?

polar acorn
rocky canyon
#

do u have a finger damage modifier?

late bobcat
#

not yet eheheh

rocky canyon
#

usually 2 colliders are enough for anything

late bobcat
#

i'll put box colliders then

rocky canyon
#

a body and a head

late bobcat
#

perfect

#

i'll try it out and tell you how it goes

polar acorn
#

You'd only need that if they actually have different behaviors

late bobcat
#

different behaviors like?

#

animations etc?

polar acorn
rocky canyon
#

bad collider

#

good collider

late bobcat
#

but it shouldn't affect hitboxes

late bobcat
#

perfect

#

ty

lost kelp
#

hello, i'm trying to save data in a file for my game using application.persistentdata, but it keeps telling me that there is no authorisation, how do i fix this

rich adder
swift crag
late bobcat
#

and another thing. Is there a way to make it so i don't have to use 2 different colliders for one object if i want it both to collide and trigger? Right now my enemy object has two collider. One is set to is trigger and the other is not, so that the hitboxes have some sort of physics collision. Question is, is there a way to use just one to use less resources?

#

while achieving the same result

slender nymph
#

it depends. what is the trigger collider used for?

rich adder
late bobcat
#

enemy colliding with the player and dealing dmg @slender nymph

#

@rich adder i wanted to optimize the game a bit, and putting 1 less collider for each enemy would've improved a bit maybe

slender nymph
#

and why does that need a separate collider? why can that not just be the non-trigger collider

late bobcat
#

because then enemy overlaps with player

#

they can sit on top of eachothers

#

not good looking

rich adder
polar acorn
#

Just put them on a layer that is set to not collide with itself

slender nymph
#

non-trigger colliders do not overlap unless they are being moved without physics

late bobcat
#

@polar acorn ye enemy cannot collide between themselves if that's what you're saying

#

so if i put on capsule collider 2d on the enemy object and set it to trigger it won't overlap with my player object?

#

@slender nymph

slender nymph
#

what do you think "non" means in "non-trigger"

late bobcat
#

but i'm talking about "is trigger" colliders

slender nymph
#

and i asked you why you need one in the first place

late bobcat
#

to detect collision between enemy and player object

slender nymph
timid hinge
#

hi did anyone know why this is not installing?

slender nymph
#

this is a code channel

timid hinge
#

its downloading for 10 hours

late bobcat
#

@slender nymph you're probably right

#

sorry but i'm kinda new to unity

charred spoke
timid hinge
#

i restart unity and install the lattest version of unity

late bobcat
#

so i just use oncollisionenter @slender nymph ?

timid hinge
slender nymph
late bobcat
#

ye that's right

#

ty @slender nymph

charred spoke
#

Also @late bobcat you can get away with the simplest collider a circle

#

For this type of game

late bobcat
#

Using capsule rn

#

still good no?

charred spoke
#

Try and see

late bobcat
#

okok

#

love you guys

charred spoke
#

Computation wise it would be capsule -> box -> circle

late bobcat
#

where circle takes less resources i guess

charred spoke
#

Yes

late bobcat
#

aight

charred spoke
#

Cant get simplier that a circle

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

late bobcat
#

games looks supersmooth atm and i can still optimize stuff @slender nymph @charred spoke 😄

cobalt creek
#
StartCoroutine(sayHi("hi", response=>
{                   
        Debug.Log(response);
}));

public IEnumerator sayHi(string greeting, System.Action<string> callback)
{
    Debug.Log(greeting);
    callback("hello");
    yield return null;
}

Is there easier method than this to pass and return value for coroutine, or how i can improve it?

final plinth
#

i'm using cine machine and moving my mouse down make the camera goes up how do i fix this.

literally no code behind it

slender nymph
wintry quarry
swift crag
#

it's just a minimal example

#

This is reasonable, although the syntax is ugly in that StartCoroutine line, yes.

slender nymph
swift crag
#

You can create the anonymous function ahead of time

late burrow
#

random range 0,3 will have equal same chance for 0 1 and 2 right

swift crag
#

You can also pass in a method instead of an anonymous function

#
StartCoroutine(sayHi(MyMethod));
late burrow
#

it had weird way of calculating

#

so i always need add 1 to random range

shell sorrel
#

how it acts depends on if its float or int

polar acorn
shell sorrel
#

but its even chance of 0, 1 and 2 for a Range(0, 3)

#

its exclusive of the upper range, but inclusive of the lower

late burrow
#

because when im splitting it in half it starts getting confusing

#

as i still need add 1 for calculation

cobalt creek
#

thank all who responded, i will debug.

shell sorrel
#

now Random.value is better for a lot of things though

swift crag
late burrow
#

if (Random.Range(0, shells[0] + shells[1] + 1) < shells[0])

#

weighted chance

shell sorrel
#

that will not give you a reliable weighted chance

late burrow
#

i have only 2 values defining weighted chance

dusk minnow
#

the cube moves left to right continously and when i jump it sometimes glitches in the wall and gets stuck

#

anyone knows why? setting vel to move it

swift crag
#

show your code

#

we can't guess what you wrote

dusk minnow
#

mb, one moment

swift crag
#

have you checked if OnCollisionEnter is ever called?

#

you've got several debug.log statements commented out

dusk minnow
#

Oh yeah theyre for test, yes the direction gets changen, OnCollisionEnter is called as usual

swift crag
#

okay, so then this part:

the cube moves left to right continously

is not a problem?

#

It sounded to me like you were saying the cube never changed direction

dusk minnow
#

nope

#

wait i send a ss

#

stuck

swift crag
#

if you ever get stuck in the wall or against the wall, OnCollisionEnter won't get called repeatedly

#

check what your direction is when you're stuck

dusk minnow
#

one sec

#

-1 is left +1 is right for understanding

#

check if player doesnt move then change direction?

swift crag
#

Yeah, so you're against the wall, but you're also moving towards it

dusk minnow
#

velocity is somehow 13?

#

so running in da wall

swift crag
#

I noticed that you switch directions even if the collision was from below. What if you're hitting the white blocks?

dusk minnow
#

had the issue, if its below it doesnt change

#

the parts have different tags/layers

terse osprey
#

can somebody help with this error?

rocky canyon
#
using Unity.Mathematics;``` both of these using statements have a `Random`
#

ur script doesn't know which one to use.. the error tells u how to fix it..
decide which one u want to use and call it
UnityEngine.Random.Range(1,101);

#

or you can set the entire script to use a certain one..

using UnityEngine;
using Random = UnityEngine.Random;```
#

oooor, just get rid of the mathmatics namespace.. unless ur using it

swift crag
#

your IDE might have imported Unity.Mathematics at some point

terse osprey
#

thankyou for the help this fixed it

rocky canyon
#

like, whats even good in that namespace?

late bobcat
#

what am i doing wrong 🤔

shell sorrel
rocky canyon
#

ur using the Class Animator

#

and not an instance of that class

shell sorrel
#

so use GetComponent to get one

late bobcat
#

oh i see

#

ty

rocky canyon
#

Animator myAnimator;
myAnimator.SetBool...

shell sorrel
#

or use lowercase animator looks like you already got a field for one

swift crag
rocky canyon
#

ohh true true

potent echo
#

Hey guys, So it seems I've run into a bit of a problem: I'm writing a script to detect figure out whether a gameObject is colliding with something from a certain direction (the ground and walls, namely). However, the ground and walls are on the same layermask due to them being part of a tilemap. This apparently causes a bunch of problems with raycasting, as the cast doesn't know the difference between a wall and the ground.

Is it possible to detect the ground seperately from the wall (maybe using a Physics cast instead of Collider2D cast now that I think about it)?

cosmic dagger
potent echo
cinder lynx
#

Hello! I need help. I was following "Learn Unity Beginner/Intermediate 2023 - Code Monkey" and than I encounter an error. Basically I selected the wrong prefab and then when I trade it and put everything the right way it only interacts with the main prefab. Video: 2:48:30. Can anyone help me please? I already checked and I'm applaying the scripts on the prefab page(the right way).

north kiln
#

Post the error and the video

cosmic dagger
rocky canyon
#

culd use seperate box 2d colliders and put them along the walls

#

and have an additional check on that when that edge-case happens

potent echo
#

But it works nontheless

rocky canyon
#

can u get the centerpoint of the tile when u hit? i could think of another way, where u do some math to get the angle between the center point of the tile and the player.. if that angle is > than 45* or w/e (which would be the where the tile's corner meets) u could know whether u hit the top of it or the side of it

cinder lynx
# north kiln Post the error and the video

💬 This was a ton of work to make so I really hope it helps you in your game dev journey! Hit the Like button!
🌍 Course Website with Downloadable Assets, FAQ, Related Videos https://cmonkey.co/freecourse
❤ Follow-up FREE Complete Multiplayer Course https://www.youtube.com/watch?v=7glCsF9fv3s
🎮 Play the game on Steam! https://cmonkey.co/kitchencha...

▶ Play video
rocky canyon
potent echo
# rocky canyon

can u get the centerpoint of the tile when u hit?

Unfortunately not, since my tilemap's collider is just one big piece (due to a compositecollider without which there'd be other collision issues)

potent echo
# rocky canyon

I'm guessing that means this wouldn't exactly work due to the tilemap's origin position

rocky canyon
#

ya, i woudlnt know of a way to do it w/o having the exact center point of the tile, and the tile needing to be perfectly square

#

theres other methods tho

cinder lynx
north kiln
cinder lynx
#

no. it's the fact that I can only interact with one counter

#

nvm

north kiln
#

That's not an error, unless you're referring to a logic error. You'll have to post your !code so someone can help you look into it

eternal falconBOT
cinder lynx
#

I just solve it!

#

Thanks anyway

polar acorn
#

🦆

buoyant knot
#

i ask because one of those tiles looks not correct

paper seal
#

hello guys! I'm doing like a spider man game first person game and i wanted to implement front flips. I used chatgpt but it was really buggy and it woudn't work properly. With this code, when I press "Q", my player does a front flip as expected but when its in about 180 degrees angle, it starts flickering a lot and sometimes when the flip is over im facing the wrong direction... can someone help me please? https://paste.ofcode.org/36BScLxvi5zJfaQgzafGYXU

potent echo
rich adder
eternal needle
barren vapor
rocky canyon
#

chatgpt is good at lookin for syntax mistakes and stuff (but ur IDE can do that)..
the only thing i think chatgpt is decent at is refactoring.. or helping u refactor

shell sorrel
#

maybe i am just used to the tools i already got, but dont find it great for that either

paper seal
rich adder
polar acorn
#

ChatGPT is a text generator. Use it to generate text. It doesn't know code, so it doesn't really help with code. Sometimes people talk about code so it can sometimes accidentally say something useful, but only if that thing was said often enough that the LLM thinks that's what people talk like.

paper seal
grizzled pagoda
cosmic dagger
# potent echo How would you implement that?

Sorry, AFK. I saw someone use OnCollisionEnter and GetContact to use the Contact.point with WorldToCell to get the cell position

Once you have the cell position, you can get the tile with GetTile or use CellToWorld to get the tile position . . .

eternal needle
dense root
#

How I debug.log this method?

#
cImage.changeImage();

Debug.Log(cImage.changeImage());
stuck palm
#

I have an issue where when a DDOL object is initialised in the scene, and then i go back to that scene, a copy of that DDOL is made and i dont want 2 of them

#

how can i avoid this issue?

polar acorn
polar acorn
grizzled pagoda
polar acorn
polar acorn
cosmic dagger
stuck palm
polar acorn
cosmic dagger
polar acorn
#

This is known as the Singleton pattern

grizzled pagoda
stuck palm
cosmic dagger
grizzled pagoda
dense root
#

So I'm trying to play sound however it does not appear to want to play... ideas?

public void changeImage()
{
    Debug.Log("changeImage()" + "readInput.currentWord: " + readInput.currentWord);
    if (readInput.currentWord == "manzana")
    {
        oldImage.sprite = apple;
        audioSource.PlayOneShot(appleSpaClip);
    }
#

AudioSource is assigned too

#

Volume appears to be set correctly

polar acorn
grizzled pagoda
#

should i implement the delay somewhere else? before i call the coroutine in the first place?

polar acorn
grizzled pagoda
#

oh yeah

#

just a boolean should be fine

open apex
#

why do I not have the "Credits" choice?

swift crag
#

Show the inspector for this Credits object.

stuck palm
open apex
tender breach
shell sorrel
# open apex

you dragged in the wrong object, or it does not have the script on it

open apex
#

I made it public

cosmic dagger
# open apex

Does the GameObject you dragged into the slot have the script attached to it?

open apex
#

fixed

#

pro programmer 😎

cosmic dagger
#

@open apex Also, make sure the method is public or it will not display . . .

stuck palm
cosmic dagger
stuck palm
cosmic dagger
stuck palm
tender breach
eternal needle
cosmic dagger
stuck palm
cosmic dagger
shell sorrel
eternal needle
#

Your brackets are all messed up so it's really tough to see where a statement begins and ends

cosmic dagger
tender breach
stuck palm
#

thats it really

#

like gamemanager.instance or whatever

shell sorrel
grizzled pagoda
#

https://gdl.space/kibimapizi.cpp can anyone help me with this? i need to delay my coroutine so that it doesnt go straight to the 3rd wave/index. How would i do that

cosmic dagger
cosmic dagger
stuck palm
shell sorrel
polar acorn
frosty hound
# tender breach How do I format?

I'm replying to this so I have an official final caution. If you post unformatted code again in the future, you will be muted. If you continue, you will be kicked.

You have been told over three times by now.

shell sorrel
polar acorn
#

Oh, hang on I see it, it was mobile searching

swift crag
#

(unless a component already exists in the scene, of course)

polar acorn
#

I'll let someone on a computer handle this

stuck palm
#

right

shell sorrel
#

or you can just put it in a scene manually and it will find the existing instance

swift crag
#
    void Initialize()
    {
        LoadData();

        foreach (var mode in DefaultGameModes.Instance.gameModes)
            mode.CreateConfig();

        // make the menu load itself
        var x = MainMenu.Instance;

        gameSessionsStat.Increment();

        State = GameState.MainMenu;

        Application.quitting -= OnQuit;
        Application.quitting += OnQuit;

        DontDestroyOnLoad(gameObject);
    }
stuck palm
swift crag
#

I don't understand your question.

#

SomeSingleton.instance <-- after you evaluate this, the instance is guaranteed to exist

stuck palm
#

okay

#

does that spawn just the class or the prefab?

swift crag
#

It does exactly whatever the instance property does

#

You can just read it!

shell sorrel
#

it creates a gameobject then adds the class to it

stuck palm
#

i see

swift crag
#

(or are you talking about my code?)

shell sorrel
#

read the code

stuck palm
#

idk if that works for my instance though

#

i mean like

#

my use case

swift crag
#

well, what's your use case...?

stuck palm
shell sorrel
#

its simply a way to get a reference where ever you need it, and create it if it does not exist

swift crag
#

If you need to instantiate an entire prefab, then you need a completely different singleton implementation.

stuck palm
#

😭

swift crag
#

Read the dang code.

#

It does exactly what it says it does. No more, no less.

#

You can't just pray that it magically does what you intended

polar acorn
stuck palm
#

okay im gonna look up prefab singleton then

shell sorrel
swift crag
#

now, fortunately, it's also really easy to make a singleton that instantiates a prefab

#
using UnityEngine;

public abstract class SingletonPrefab<T> : MonoBehaviour where T : SingletonPrefab<T>
{
    private static T _instance;

    public static bool Safe => _instance != null;
    public static T Instance 
    {
        get
        {
            if (_instance == null)
            {
                _instance = Instantiate(Resources.Load<T>("SingletonPrefab/" + typeof(T).Name));
            }

            return _instance;
        }
    }
}
#

you can probably ignore the Safe property

dense root
#

So I'm trying to map two different words ("りんご” and "manzana") to the same currentJapWord and currentSpaWord... any thoughts on how to do that? Like how do I assign two different words with the same meaning to the same current word?

private void Awake()
{
    foreach (Word word in allWords)
    {
        mappings[word.English] = word;
        mappings[word.Spanish] = word;
        mappings[word.Japanese] = word;
    }

    // Find the InputField dynamically during runtime     

    if (japInputField != null && spaInputField != null)
    {
        // Set the focus back to the input fields
        japInputField.Select();
        japInputField.ActivateInputField();

        spaInputField.Select();
        spaInputField.ActivateInputField();

        // Set currentWord for both languages
        //currentJapWord = GetRandomWord().Japanese;
        //currentSpaWord = GetRandomWord().Spanish;

        currentJapWord = "りんご";
        currentSpaWord = "manzana";
swift crag
#

I use that to test if an instance currently exists. It's relevant when the game is shutting down

#

i don't want to instantiate things while the game is shutting down

stuck palm
stuck palm
#

do i need to explicitly mark a folder as a resources folder or

shell sorrel
#

also dont over use resources, everything you put in the folder gets included in your game even if never used

shell sorrel
stuck palm
swift crag
swift crag
grizzled pagoda
swift crag
#

then your code is wrong

#

i'll need to see it

stuck palm
swift crag
#

I do not have a MainMenu prefab in any scene in my game

#

that was the entire motivation for this SingletonPrefab class - I didn't want to have a menu prefab in every scene, and I didn't want to have to worry about making sure I always started the game from a scene with a menu prefab that'd get DDOL'd or something

#

When the game starts, the prefabs are instantiated

swift crag
#

it works really nicely

swift crag
#

nothing else "starts itself"

stuck palm
#

i already have a gameManager prefab open in the scene, that could be t he problem ig

#

i see, the game manager isnt getting reinstantiated when i reference it again from the first time

polar acorn
tender breach
#

Ok

round umbra
#

https://gdl.space/wugohoguge.cs
hello im having a small issue

i have a
float currentHighScore
float reactiontime

if (reactionTime < currentHighScore)
o want the highScore to update

when you first play the game currentHighScore = 0f;

but reactionTime can never be < currentHighScore

i would be wierd if i set it currentHighScore to 100f; couse then the highscore wil be 100 at the start
is there an other way than this aprouch?

rocky canyon
#

ur first reaction wouldn't compare to the highscore,

#

it would just log the reactionTime as the new highscore, then ud compare

grizzled pagoda
polar acorn
#

Meaning it won't block the coroutine from starting until it's already done

grizzled pagoda
#

oh

polar acorn
#

You want to set your book before the timer and then un set it after

grizzled pagoda
#

yeah

#

i got it it works now

#

@polar acorn thanks a lot! man idk how i missed that thanks a bunch

round umbra
tender breach
tender breach
#

I tried removing dropset++ and Spawn = True, but I kept getting the problem.

polar acorn
#

How about instead you just log those values in start and see what they are

tender breach
#

Okay

#

That didn't work

frosty hound
#

Logging isn't a fix, it's to help you understand the issue.

polar acorn
tender breach
#

Oh, I just moved dropset++ to another place in start.

polar acorn
tender breach
#

I didn't know what you meant.

polar acorn
#

If you don't know what debug log is you need to stop everything and do the beginner tutorials linked in the pins.

polar acorn
#

Debug log should literally have been the first line of code you ever wrote

late yew
#

I'm trying to make a twin-stick shooter where the player follows the cursor, but when they sprint I don't want them to look at the cursor, and instead at the direction of travel. This is the code I have, but it's not working, even while running the character continues to look at the cursor. Any idea why?

void RotatePlayer()
{
    if (isRunning == false)
    {
        transform.LookAt(new Vector3(cursorToWorldPoint.x, transform.position.y, cursorToWorldPoint.z));
    }
    else if (isRunning == true)
    {
        transform.LookAt(new Vector3(xForce, transform.position.y, zForce));
    }
}```
#

this is being called in update

#

It's actually only facing the x value of the cursor, as soon as it passes where it sits on the screen, the model does a complete 180

dense root
#

Any ideas why I cannot tab into my next inputfield? I even have interactable set to true

shell sorrel
#

think tab might want nav for moving down so could setup the rest of the references under navigation

open apex
#

Is there any reason why this wouldn't work?

shell sorrel
#

use * not +

amber spruce
#

how do i draw this area with gizmos like with the offset

Physics2D.BoxCast(m_Coll.bounds.center, m_Coll.bounds.size, 0f, Vector2.down, .01f, jumpableGround);
open apex
rich adder
#

Only multiply

shell sorrel
rich adder
#

Sorry wrong reply @shell sorrel lol

shell sorrel
# open apex

who also got rotate as a field, how are you setting it, quaterions are not what you think they are, the x y z and w components are not angles like you think

dense root
#

Odd, even the visualizer is showing that it should be able to tab between thw two, am I missing something in code?

open apex
rocky canyon
#

this was the best way i seen quaternions explained

shell sorrel
silver sun
#

i am trying to call an OpenAI API like:

  -d '{
    "model": "gpt-4-vision-preview",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What’s in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
            }
          }
        ]
      }
    ],
  }'

here's my 8 hour progress:

https://pastebin.com/Fs8MpWwu (just the relevant parts)

here's my error:

HTTP/1.1 400 Bad Request
line 58 on PasteBin.

don't bother explaining, i know i'm not sending the parameters correctly, but that's the issue...

i've done this before:

`"model": "gpt-3.5-turbo",
  "messages": [
   {
    "role": "system",
    "content": "You are a helpful assistant."
   }
  ]
 }```
**
but not:**

```py
"model": "gpt-4-vision-preview",
  "messages": [
   {
    "role": "user",
    "content": [
     {
      "type": "text",
      "text": "What’s in this image?"
     },
     {
      "type": "image_url",
      "image_url": {
       "url": "blahblhah"
      }```
i switched the channel because i think a "general" programmer would of known how to fix it by now...
rich adder
shell sorrel
#

or AngleAxis or many others you can see for certain purposes

#

you can find them all as static methods on Quaternion

rocky canyon
open apex
rocky canyon
#

this was helpful to me when i read it

shell sorrel
rocky canyon
#

ya, only those still plugged into the matrix can visualize quaternions

shell sorrel
rocky canyon
#

im a euler man myself..

#

even tho im told to use quaternions 😄

shell sorrel
#

most of what i do is do some vector math to get a direction then LookRotation that

rocky canyon
#
        if (Input.GetMouseButton(1))
        {
            rotateCurrentPos = Input.mousePosition;
            Vector3 difference = rotateStartPos - rotateCurrentPos;
            rotateStartPos = rotateCurrentPos;
            newRotation *= Quaternion.Euler(Vector3.up * (-difference.x / dragRotationSpeed));
        }```
ya, i pretty much use` Quaternion.Euler `like its going outta style
open apex
#

I am just trying to rotate z to a 180 😔

timber tide
#

Imagine getting gimbal locked

#

cant be me

frosty hound
shell sorrel
#

transform.rotation = Quaterion.AngleAxis(180, Vector3.forward)

open apex
#

I did the * you told me,
But it does 180 times 0 which make it still 0

rocky canyon
open apex
#

The problem is, I don't know why. I don't understand what I am reading sometimes

shell sorrel
silver sun
rocky canyon
#

if you've commited a crosspost.. then yes, probably delete 1 of em

frosty hound
#

It was already removed, and you reposted it in #💻┃code-beginner. So knowing the rules is questionable.

#

Just pick one channel and stick with it. It's up to you if it's beginner or general.

amber spruce
#

hey so i could use some help with something so basically my player is colliding with the ground fine as you can see with the image thats my code for the boxcast and for some reason it will randomly say it isnt colliding with it and wont let me jump any idea what im doing wrong here

public bool IsGrounded()
{
    return Physics2D.BoxCast(m_Coll.bounds.center, m_Coll.bounds.size, 0f, Vector2.down, .01f, jumpableGround);
}
silver sun
rocky canyon
#

i was just answering what i'd do.. u asked

amber spruce
rocky canyon
#

hmm, is it a certain area of the level?

silver sun
#

okay, noted. but my bad i intended to reply to Osteel

rocky canyon
#

or just generally anywhere

amber spruce
#

i beilive its something to do with that part but im also not entirly sure

rocky canyon
#

the 0.1f in ur boxcast may be too small for all scenarios (on flat ground yea,, but maybe in other situations its not big enough?)

amber spruce
#

yes but when im back on flat ground that should be fixed no?

#

like i cant jump anywhere after this happens

rocky canyon
#

other than that its ur basic groundcheck 101:

  • is the playerobject and ground set up with the correct layers
  • is the layermask including these layers
  • check the size and position of the boxcast
  • check the distance
  • etc
rocky canyon
#

sounds more like maybe an error.. if u get a null error or somthing in the code, that code will just stop working

#

do u have any errors in teh console when it happens?

amber spruce
#

nope no errors or even warnings

rocky canyon
#

do u call the bool in the code? (like in all the right places?)

#

maybe the code bypasses it for some reason

amber spruce
#

i tried in update setting a public variable to it so i could see and after the glitch happens its just always false

rocky canyon
#

but im talkin about teh bool .. unless u use the bool, (the physics boxcast wont run) and then ur groundcheck will never be true anymore.. unless its called. maybe the code for that bit is broken

#

best to send the code anyway, in a pastebin site or something so we have some context

#

these types of errors usually aren't just the singular ground check thats wrong, its usually a multi-piece problem

amber spruce
rocky canyon
#

im gonna go ahead and guess it has something to do with u having 2 bools for grounded. and trying to manage both of them.. as well as the coroutine that has to wait half a second to set m_Grounded back to false

#

im still looking thru it.. not seeing it right off the bat.

amber spruce
#

it was happening before i added that

#

and the half second wait was because before it would instantly set it to false letting you double jump because you technically where still touching the ground

rocky canyon
#

i think its ur .1f like i said originally..

#

heres my test using the bool raycast return like you have with a .1f (never gets grounded b/c the player is too thicc)

#

and heres my test using the bool raycast return like you have with a .75f (works as intended)

amber spruce
#

yeah so that seems to fix it

rocky canyon
#
    private void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        coll = GetComponent<BoxCollider2D>();
    }

    private void Update()
    {
        isGrounded = IsGrounded(); // updating every frame (so we dont miss any ground detections)

        float horizontalInput = Input.GetAxis("Horizontal");
        Vector2 move = new Vector2(horizontalInput,0f);
        rb.velocity = new Vector2(move.x * speed,rb.velocity.y);

        if(isGrounded && Input.GetKeyDown(KeyCode.Space))
        {
            Jump();
        }
    }

    private bool IsGrounded()
    {
        float raycastLength = 0.75f;
        RaycastHit2D hit = Physics2D.Raycast(coll.bounds.center,Vector2.down,raycastLength,groundLayer);
        TestGround = hit.collider != null;
        return TestGround; //used a TestGround boolean that I exposed in the editor
    }

    private void Jump()
    {
        rb.velocity = new Vector2(rb.velocity.x,jumpForce);
    }``` just used your code and stripped out all the animations and extra noise so i could focus on the groundcheck
#

ya, that was my first guess and gut reaction, and thats what it ended up being on my end

amber spruce
#

i also just realised the gizmos is 0.1 and the actual boxcast is 0.01

#

so it may not have been colliding lol thanks for the help

rocky canyon
#

yea .01 is extra tiny

amber spruce
#

yeah didnt think about that i thought it was .1 lol

rocky canyon
#

another thing is, learn about Gizmo's

#

u can draw them using code.. and it'll really help out trying to visualize these things..

#
    private void OnDrawGizmos()
    {
        // Draw a raycast line to visualize ground detection
        Gizmos.color = Color.green;
        float raycastLength = 0.75f;
        Vector2 raycastOrigin = coll.bounds.center;
        Vector2 raycastDirection = Vector2.down;

        Gizmos.DrawLine(raycastOrigin,raycastOrigin + raycastDirection * raycastLength);
    }``` ^ that example
amber spruce
#

yeah i was drawing them already lol

rocky canyon
#

oh okay 👍 just trying to give ya some things to help

#

sounds like ur pretty good tho

amber spruce
#

yeah thanks any way

rocky canyon
#

np, 🍀

white yew
rocky canyon
#

true true

north kiln
#

Did you read the paragraph that tells you what that error means?

#

Great, so you have some gradle errors. Ask about them in #📱┃mobile

grizzled pagoda
#

what does this all mean?

rich adder
#

You're trying to build but have some UnityEditor classes that you cannot export

#

put scripts in editor folder or wrap in #if editor

rocky canyon
#

^ MenuScript is gonna have to be modified

sour fulcrum
#
        public bool DetectChanges<T>(T firstValue, T secondValue)
        {
            return (firstValue.Equals(secondValue));
        }

can i get a vibe check on this, would this work as intended for objects like monobehaviours, so's etc.?

teal viper
sour fulcrum
#

Oh it's a validation thing i'm gonna have some optional debug logging in here in theory

teal viper
#

Okay. I don't really get the question then. It would work the same as if you're doing an Equals directly.

rocky canyon
polar acorn
sour fulcrum
#

Sorry, new to generics and wasn't sure if me passing in stuff like monobehaviour, scriptableobject etc. generically would make it fail an object comparison like this

rocky canyon
#

ahh, Type == Type?

sour fulcrum
#

nah i want object instance

rocky canyon
#

Object == Object ? im just curious what its for

polar acorn
teal viper
#

Equals can be overriden though, so the behavior might vary depending on the object.

sour fulcrum
polar acorn
rocky canyon
#

ooo.. and if u modify something in one object the comparison is supposed to fail??

polar acorn
teal viper
#

Reference types check reference equality. So even if the contents are the same, 2 objects would never be equal

rocky canyon
#

as far as i know ur just comparing two objects, if its the same object

sour fulcrum
rocky canyon
#

b/c its different *entities? (identifier, GUID?

polar acorn
# sour fulcrum oh?

For reference types, == and .Equals check if they're literally the same instance

teal viper
polar acorn
#

Also, if they are the same instance, if you change a variable on one of them, that variable would be changed on both variables pointing to that same instance

#

If I have a cat, and I tell you about my cat, and then I put an adorable little bowtie on him, the cat that we're both thinking of now has a bowtie

sour fulcrum
#

yeah yeah forsure

#

i think were on the same page here

rocky canyon
#

ya, okay yea thats what i thought i read. lol

teal viper
#

To put it simply, your method doesn't really detect any changes.

#

Unless you're planning to use it for value type mainly.

sour fulcrum
#

The name of the function might be a little misleading,

I don't want to detect if something has changed. I want to check if setting x to y would be changing it

teal viper
#

Well, then no. It would always return false if x and y are different instances.

#

Even if it doesn't change anything.

sour fulcrum
#

yeee but if x and y are the same instance it'll like detect that correctly right

rocky canyon
#

i doubt it

#

i mean if ur asking if its the same instance with different data /values

polar acorn
sour fulcrum
#

which is the purpose of this function

teal viper
rocky canyon
#

ya, if its the same instance how is anything supposed to be different?

eternal needle
#

what is the actual purpose of the function?

polar acorn
rocky canyon
sour fulcrum
#

one moment

#

eg. i want to use it like

        public void DebugDetectChanges<T>(List<T> firstList, List<T> secondList)
        {
            string debugString = "Detecting Changes" + "\n";

            if (firstList.Count != secondList.Count)
                debugString += "List Count's Differ, Changes Confirmed!";

            if (firstList.Count >= secondList.Count)
            {
                foreach (T item in firstList)
                {
                    debugString += "Detection Check #" + firstList.IndexOf(item) + " - (" + DetectChange(item, secondList.IndexOf(item)) + ")" + "\n";
                }
            }
        }

        public bool DetectChange<T>(T firstValue, T secondValue)
        {
            return (!firstValue.Equals(secondValue));
        }
cosmic dagger
teal viper
#

If the user have created a new instance of a type and tries to assign it somewhere. Is that what you want to check?

polar acorn
sour fulcrum
cosmic dagger
sour fulcrum
#

( might be misusing generics, i'm new to them)

teal viper
sour fulcrum
#

return (!(firstValue == secondValue));

rocky canyon
#

generics confuse me. so its an extra layer of complicated when i watch them get debugged by others lol

cosmic dagger
sour fulcrum
#

ah

north kiln
#

That's not true though

rocky canyon
#

ya, thats why i originally asked at the begining, do u mean Type==Type

#

ohh.. nvm lol

teal viper
#

I think you just need a constraint how random pointer initially.

north kiln
#

The problem is a lack of constraints

sour fulcrum
#

I have two lists of values and i want to have a easy way to check if there are differences in the two lists

the two lists will always be the same type but i want to do this check with multiple types if you know what i mean

cosmic dagger
#

If one is a reference type and the other is a value type, a null assignment will be an issue . . .

#

They need a type as a common denominator . . .

north kiln
#

They are the same type, both T

#

You won't be able to use ==, but you can use Equals, and should add IEquatable<T> as the constraint

cosmic dagger
#

IEquatable will use its—the type—default Equals method. So it disregards the type mismatch, doesn't it?

north kiln
#

DetectChange(item, secondList.IndexOf(item)) this is nonsense however

sour fulcrum
#

Howso?

north kiln
#

why are you comparing an item to an index

#

it's nonsense

sour fulcrum
#

oh very true

#

thank you

north kiln
#

it should also not compile

violet spear
#

hey

near wadi
#

howdy

gaunt ice
#

There may be differences if the two lists count are the same (assume they are not same instance)

violet spear
near wadi
violet spear
#

ok thats fine

polar acorn
#

We'll move into here because it is a bit more of a code thing anyway. Send a screenshot of the object that has your script on it

violet spear
#

so when i start a new project and then i add canvas then add script through canvas on add component then typ to say hello

polar acorn
violet spear
#

i got it sorry for the inconvience guys i didnt know you had to drag the script over and attach it to canvas or main camera

unique furnace
#

Coding is an ass that is full of farts.

polar acorn
near wadi
#

Coding is a class that's full of art

unique furnace
#

I started watching an instructional video at 11am today and have been stuck trying to get this message to appear until this very moment

#

I have read 6 miles of forums and had no one help me change a setting that properly linked unity to VisualStudio

polar acorn
#

!ide

eternal falconBOT
polar acorn
#

We literally have a bot command explaining how to do that

unique furnace
#

I have learned this now. Thanks

young smelt
#

Paste of code isn't working, any alternatives?

near wadi
#

!code

eternal falconBOT
young smelt
#

To be honest I kinda got lost in the tutorials but here
https://hastebin.com/share/azusepehic.csharp
Basically the terrains are creating fine but I am not seeing shit in the game view I only see them in the inspector. And once I move past the observable distance, it does actually hide the ones outside said distance. After looking at it for a while, I noticed the mesh filter is not getting applied and stays empty which is weird because I do in fact do that in the UpdateTerrainChunk right after checking for if the mesh data has been gotten. Pls tell me if u want to see other parts of my code

near wadi
eternal falconBOT
#

:teacher: Unity Learn ↗

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

stone elk
#

how can i change my textmeshpro outline colour through script?

young smelt
#

Yh I can't reply it

near wadi
#

your message and link came through fine to me

quaint terrace
#

I have a scriptableObject. And every Time i call it it has to be initialized. Whats the point of ScriptableObjects if they have to be built everytime i call them?

teal viper
#

They don't. What exactly are you doing? Share code.

quaint terrace
#
    {
    //print("Looting something "+index);
    ItemDatabase itemDatabase = ScriptableObject.CreateInstance<ItemDatabase>();
    Item newItem = itemDatabase.GetItem(index);
    print("Index: "+index);
    print("NewItem: "+newItem.Name);
    foundItem = items.Find(item => item.Name == newItem.Name);```
#

and unless i put Awake{initinializeItems();} inside itemDatabase, i cant access any of the items.

teal viper
#

Doesn't seem like a correct way to use SOs.

#

The whole point of SOs is that you can reference an instance of it as an asset.

#

Here you're just creating a new instance every time.

quaint terrace
#

but when i public ItemDatabase itemdatabase; unity yells at me and says instance of object is not found.

timber tide
#

damn it unity

teal viper
quaint terrace
#

scriptableObjects cant be assigned in the inspector, it has to be a monobehaviour

timber tide
#

they can be assigned like any other object script

#

just not as a component

eternal needle
#

assigning it in the inspector is like the first thing you see online when learning SO

teal viper
#

Ofc they can. That's the whole point of them😅

quaint terrace
#

well then i am missing something, because i cant assign a script unless it is a component

charred spoke
#

You are mixing things up. You cant put a SO on a gameobject you can put it in the field of a component that is already on a gameObject

quaint terrace
#

i am not allowed to put any scripts into a field unless it is attached to a gameObject.

charred spoke
#

Yes you are

#

Wait