#💻┃code-beginner

1 messages · Page 594 of 1

frigid sequoia
#

In like "you are just not using the right Raycast", I mean, thanks for telling me, but don't act as if I am supposed to know that that is a thing that even exists lol

floral thorn
#

I can assure you there are much more efficient ways to learn "the right way" than having some man child cuss at you in a beginner coding forum. It's just weird and sorta tasteless to offer help to someone (by being here) and then act like that.

Raycast (and most other similar things inside unity) use the physics engine to query a point from A to B, and pass along information of that "hit" to, well, whatever you want. I saw you mention mouse click. Raycast and world origin is what 99% of people would say

#

Sure, you might not need the directional information, throw it away

#

but you didn't seem to grasp overlap, so I offered an alternative to get you moving fast instead of getting abuse hurled at you

north kiln
#

Raycasts in 2D physics are on the 2D plane, and although you can pass an arbitrary vector and 0 distance to the API, it's the kind of thing you generally should avoid as it's if you have to justify something silly (a zero-length direction, or an arbitrary direction with 0 distance) when using an API you're probably using it improperly and may walk yourself into an edge case

frigid sequoia
#

Like would a caveman search what toothpaste is? No, cause they don't know that's a thing

north kiln
#

if a caveman had google and tooth pain they would soon find out

frigid sequoia
#

"Thingy to stop teeth pain". Sure they would find something accurate

floral thorn
north kiln
#

sure

floral thorn
#

Big fan

#

Did you develop tools for gobbys gold

north kiln
#

No, I joined to work on Enter the Chronosphere

floral thorn
#

Do you find that working as a tools designer is more rewarding and lucrative than a generalist or lead programmer?

north kiln
#

I'd rather not randomly have an interview in a coding channel; but I'm currently doing generalist/lead work. I just have a tools specialty because I like them

floral thorn
#

See ya!

sturdy wren
#

what does this even mean?

toxic yacht
# sturdy wren what does this even mean?

The first error is suggesting you're missing build tools needed to use il2cpp. Click on it, and see what the details are. That probably has tools you're missing and need to install.

sturdy wren
toxic yacht
inland canopy
#

!collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

wooden nacelle
#

Can someone tell me in a tetris like game. how do i make the blocks occupy multiple cells in the grid. currently what i have is tht the block only occupies one cell that corresponds to the centre of the block.

timber tide
#

Make a block object that contains a list of indicies that it occupies at once

proper yacht
little meteor
little meteor
wooden nacelle
timber tide
#

You really don't need to know about any of that. All you need to know is if the index below the blocks are empty or not (Though if the block below it is part of the same block we should consider it empty because it's actively moving)

little meteor
little meteor
wooden nacelle
#

i feel so dumb rn

rugged beacon
#

hi i got a goofy question
whats you guys optimal way to shuffle a list or hashset with seeded unityengine.random function

hexed terrace
#

this is a code channel my good man, and that is not a code question. Delete and ask in #🖼️┃2d-tools

timber tide
#

Ah, yeah I'm not too sure of the question here. If you need help with how the blocks move throughout the grid, those are the questions that should be asked here.

cosmic dagger
rugged beacon
burnt vapor
#

Not sure if doing this on a hashtable is as good on performance or if you maybe want to move to a list or array first. I don't think it matters.

rugged beacon
#

yea i understand this one, guess this will have to suffice

void dawn
#

im having some trouble , i explain it in the video

cosmic dagger
rocky canyon
#

I'm trying to use interfaces to define things in my game...
like for instance any interactable.. (right now im working on Points of Interest).. soo I want to start by just getting data from it when I click..

right now im getting errors i'll have to work thru.. but i wanna know am I doing this right?

#

just wanting to know if im assigning these correctly.. i do not think i am

#

nothing visible in inspector as well.. (thats what im trying to figure out right now lol).. and im a bit foggy this morning 😭

timber tide
#

What is supposed to be seralized here

rocky canyon
#

i was thinking I could asign the things lke Name Description Interaction Hint via the Inspector..

#

is that the problem? I need to serialize them? I thought public was good nuff lol

timber tide
#

C# getters are just methods

rocky canyon
#

OHH!

#

omg.. im an idiot

timber tide
#

you need a field

[SerializeField] private string name;
public string Name => name;```
rocky canyon
#

today may not be a good day for coding

#
   [SerializeField] string poiName = "POI Name";
    [SerializeField] string description = "A detailed description of the POI.";
    [SerializeField] string interactionHint = "Click to focus on this POI.";

    public string Name => poiName;
    public string Description => description;
    public string InteractionHint => interactionHint;```
#

it was that simple 🫠

#

im just feeling my way around interfaces.. i've used them for basic things like Interact() method.. but decided to try to make a modular system for once..

#

anything clickable basically

timber tide
#

Could also do:

[field: SerializeField] public string Name { get; private set; }```
#

super sekret backing field serialization

rocky canyon
cosmic dagger
rocky canyon
cosmic dagger
#

Yep, what Mao just posted above (I missed it) . . .

rocky canyon
#

like 86in this guy

#
public class POI : MonoBehaviour, IDescriptive, ICameraTarget
{
    [field: SerializeField] public string Name { get; private set; }
    [field: SerializeField] public string Description { get; private set; }
    [field: SerializeField] public string InteractionHint { get; private set; }

    public bool CanInteract() => true;

    public void Interact()
    {
        Dbug.Log($"{Name} Interacted with!");
        CameraController.Instance.FocusOnPOI(this);
    }

    public Transform GetFocusPoint() => transform;
    public float GetOptimalZoom() => 30f;
}``` i do *like* that alot better..
#

atleast from first glance

cosmic dagger
timber tide
cosmic dagger
#

CanInteract should be a property here . . .

rocky canyon
#

im a sponge..

#

taking it all in lmao

timber tide
#

Like, interfaces can run into the diamond problem but it's resolved differently (basically it just accumulates all implementations, but you'll never implement duplicate methods)

cosmic dagger
#

The same applies (using a property) to GetFocusPoint and GetOptimalZoom since you're returning the transform . . .

#

You can just remove the Get part of the name . . .

void dawn
#

So I have two main problems

1 I made a script to the bullet follow the cross hair and for the bullet come out of the tip of the gun , but for some reason the bullet always comes out of the same place and doesn't follow the tip of the gun

Also I also I'm trying to assign an UI text for the ammo counter but the script I made for the weapon systems won't allow the text UI into the automatic ammo counter.

Sorry if this sounds confusing I'm new to this

swift crag
#

for the second point: you're probably mixing up the legacy text, UnityEngine.UI.Text, with a TextMeshPro type, TMPro.TMP_Text

verbal dome
swift crag
#

TMP_Text can contain both TextMeshPro (for non-UI text) and TextMeshProUGUI (for UI text)

verbal dome
#

It makes it clear that some calculations happen when they are called

rocky canyon
#

@timber tide @cosmic dagger thanks guys.. i think i'm on the right track again (for now) 🧡

cosmic dagger
#

If there were calcs, then I agree that using a method would be fine . . .

#

It won't break or ruin anything, for sure, but mixing properties and methods when they all return a fixed value can be misleading . . .

swift crag
#

I use properties even when there's some math going on

cosmic dagger
swift crag
#

I can always switch to something that caches the computation later if necessary

#

I prefer to use methods only for things that require input or that change the state of the object

timber tide
#

problem with properties I like to keep them in the header space, but they start feeling like methods if I start doing logic in them and then i start having identity issues for where they should be

swift crag
#

a property is...a property of the object!

#

they look and feel like fields

cosmic dagger
dreamy dune
#

!code

eternal falconBOT
dreamy dune
cosmic dagger
swift crag
#

a property describes a property of the object. it does whatever is necessary to compute this value

#

of course, a property's get accessor should have no side-effects

rocky canyon
#

i've just started using them.. or atleast trying to..

cosmic dagger
#

bold, italicize, and asterisk "should" . . .

rocky canyon
#

4 + years of hobbyist stuff and im just now comfortable enough to try to use them

swift crag
#

they're trivial to write

#

especially as expression-bodied members

#
public float Coolness => baseCoolness + GetCoolnessBonus();
timber tide
#

I like just sticking to methods if it's nothing something that I can inline like that

#

it's more descriptive too when it comes to things like resources. Like sometimes I prefer doing a HealHealth(int value) and DamageHealth(int value) instead of a general Health property

cosmic dagger
swift crag
#

in that case, I would have a get accessor to retrieve the current health, as well as a set accessor that unconditionally sets health to an exact value

#

then I'd have methods covering other ways of changing health

cosmic dagger
#

Yep, exactly that . . .

last radish
#

Hey, im trying to create a backrooms-esque first person shooter game, where 2 people play against each other in a constantly changin backrooms map, in the sense that there is a constantly sized 100x100 square, but the walls inside constantly change when you arent looking at them. Does anyone have any good tutorials or tips on how to do the wall changing thing? it can't exactly be random as i dont ever want the players to get stuck or be unable to find the other one. I realize that this is similiar to procedural dungeon generation, but i havent found many tutorials that relate to this

swift crag
#

One thing that comes to mind is to guarantee that there will be at least one connection between every, say, 10x10 grid square

#

so this would be a valid square, for example

#

you could then freely swap them out without any consideration at all for the neighboring cells

last radish
#

Wouldnt pathfinding work better? where the shortest distance between the two players HAS to be in some range?

swift crag
#

You could definitely do that.

last radish
swift crag
#

You just need to be able to ask "do these two cells connect?"

#

then you can run Djikstra's on a candidate layout and see if a path exists (and is short enough)

cosmic dagger
#

Regardless of being hallways or boxes, you have to connect from one to the other . . .

swift crag
#

but the base idea should still work

cosmic dagger
#

You can create a variation of hallways and boxes that fit into this 100x100 space and mix them up . . .

swift crag
#

you'd construct a graph based on whether each, say, 2x2 square is reachable from its neighbors

#

"Backrooms" maps tend to be decently grid-aligned anyway

last radish
#

Would maybe a random maze generator with pathfinding work?

#

thats mostly just hallways and ive seen a few good ones online

swift crag
#

The tricky part would be updating parts of the maze during gameplay

#

I guess you can just reset part of the map to the "unfilled" state and then rerun the generator

#

as long as the generator you're using can handle that

#

You know what --

#

this would be a great place to use the "wave function collapse" method

last radish
#

Couldn't you just destroy all walls that arent currently being looked at, and then regenerate a maze around those not destroyed walls?

swift crag
#

Yeah, you just need to work out how to do that

#

"draw the rest of the owl" :p

last radish
#

And it wouldnt be constant, but like every 2 seconds, and if this was too complex, i could just make the lights go out every 5 seconds, and just make a random map

#

that completely removes the complication and is just procedural generation

swift crag
#

As long as you can restart the generator with a partially generated map, it's trivial

last radish
#

what things would you recommend me to look at?

#

the wave function collapse method?

swift crag
#

There are several different things that get called "wave function collapse" -- this implements several techniques!

#

The "OvelapWFC" mode takes an example layout and learns patterns from it

#

"SimpledTiledWFC" requires explicit rules to be defined

#

I've used this for a game before. It was a little awkward to pick up

last radish
#

thank you so much for the help, ill look into that

swift crag
#

I had trouble with it producing empty maps 90% of the time

#

I believe that was because my tile rules were too restrictive

#

I've also implemented the "tiled" technique on my own before (using Entities, and doing the work in a Burst-compiled Job)

#

super speedy

willow shoal
#

hi how to restart time in timer script? i need line of code ```cs
public float TimeLeft;
public bool TimerOn = false;
public TMP_Text TimerTxt;
void Start()
{
TimerOn = true;
}
void Update()
{
if (TimerOn)
{
if (TimeLeft > 0)
{
TimeLeft -= Time.deltaTime;
updateTimer(TimeLeft);
}
else
{
Debug.Log("Time is UP!");
TimeLeft = 0;
TimerOn = false;
}
}
}
void updateTimer(float currentTime)
{
currentTime += 1;

    float minutes = Mathf.FloorToInt(currentTime / 60);
    float seconds = Mathf.FloorToInt(currentTime % 60);

    TimerTxt.text = string.Format("{0:00}:{1:00}", minutes, seconds);
}

}

swift crag
willow shoal
#

i just need button restart

#

for this

swift crag
#

So you could nuke most of the map, do a random walk to draw a single valid path between the players, and then run the generator

last radish
#

That seems perfect for what i need to do

swift crag
#

I'm not sure how easy it would be to do that with the package I linked, though

#

The algorithm isn't actually that hard to implement

#

(especially for the "tiled" variant, where you don't try to learn valid patterns from an example map)

#

Each grid cell starts out with every possibility -- every tile in every possible rotation

#

When you place a tile, you update the possibilities for its neighbors

#

you intersect the existing possibilities with those allowed by the placed tile

#

so if a tile used to accept {A, B, C, D, F}, and the newly placed neighobr only allows for {B, C, E, F}, the tile can now only be {B, C, F}

#

you "collapse" the most-constrained tile until you run out of tiles to collapse

#

(you can also use probabilities instead of a binary "yes/no")

#

so a straight road usually has straight roads as neighbors, but sometimes has a corner

#

and you can leave very small chances for empty tiles to prevent impossible configurations

void dawn
#

Hey I think something is locked in a position even after I set it to follow the camera , is there a check box I can see if something is locked or not ?

polar acorn
cosmic dagger
ashen violet
#

Hello, I am trying to create a main menu for my game.
For some reason my buttons are not clickable.

I have done the following:

  • created an event system in my scene
  • My buttons are inside a canvas object, the canvas does have a raycaster
  • All butons are interactable, have Raycast Target On
  • The TextMeshPro component objects dont have RayCast Target On
rich adder
frosty hound
#

Put the mouse over the button and look at the EventSystem, it will tell you which object it thinks the mouse is over

rich adder
#

(new Input system only if you click on something)

void dawn
ashen violet
#

I only get this no matter where I click

polar acorn
void dawn
polar acorn
rich adder
void dawn
rich adder
#

cant see shit from this ss

polar acorn
eternal falconBOT
ashen violet
#

uhh I am in play mode

rich adder
ashen violet
#

it keeps saying "Null"

rich adder
#

dam..new input system makes this extra annoying to debug

#

can you show your canvas settings ?

ashen violet
#

I hate it :)))

rich adder
#

the old input system module would tell you what mouse was currently hovering

swift crag
#

Yeah, it doesn't give you much info in the preview area for some reason

#

Time to do it manually!

ashen violet
rich adder
#

someone got too lazy to implement it 😄

swift crag
#

check out EventSystem.RaycastAll

rich adder
#

yeah you might have to manually inspect it

#

raycaster is there yea, I have a feeling something is covering your raycast

swift crag
#

You'll need a PointerEventData to invoke that

#

You can construct it by hand or reuse one from another event

#

I wonder how hard it'd be to add that extra data to the preview area

ashen violet
#

could it be the background Panel?

rich adder
#

maybe

swift crag
#

The Panel will be behind every other object

void dawn
rich adder
#

also true, first = last in UI

swift crag
#

I suspect you have a very large Image or TextMeshProUGUI component that's getting in the way

#

Look at the size of the rectangle as you select each object

rich adder
#

have you check the rect transforms of each text

#

also you can just disable the raycast on TMP under Extras

#

I usually do this as precaution incase my layout decides to poop on some device

swift crag
#

Indeed. No reason to make that a raycast target

#

I try to proactively disable that on anything that isn't going to be clicked on.

rich adder
# void dawn

you literally send a screenshot from the proper link site 👏
a++

ashen violet
rich adder
cosmic dagger
# void dawn

You're suppose to send the link, not a pic from the link . . .

swift crag
#

There is nothing to hit on an empty game object

rich adder
#

rect transform that contains other rect transforms

cosmic dagger
#

I believe they mean the parent RectTransform . . .

rich adder
#

yea ^^

swift crag
#

CanvasGroups attached to parents can affect whether or not you block raycasts

#

but the parents themselves don't get hit

cosmic dagger
#

CanvasGroups are awesome . . .

rich adder
#

oh? been a while since i touched UI. could've sworn the bounds of the rect would extend the child but probably mistaken with something else..nvm my memory is bonkd

swift crag
#

It just defines a region of space (which children can use to position and size themselves)

rich adder
#

Oh okay.. Maybe I put one of those canvasgroups thingys and didnt realize

#

as soon as unity makes World canvas fully polished on UIToolkit it will soon be bye bye UGUI

ashen violet
#

so I asked Mr. ChatGPT to write a script that tells me what I click

#

Very helpful 👏

rich adder
#

I'm scared to see what it wrote lol

#

but i wanna see anyway

rich adder
ashen violet
#

I was trying to be scarcastic

#

idk what the issue is

#

lmao

rich adder
#

so there is no result on the button ?

ashen violet
#

none

rich adder
#

thats not right, can you show inspector for your button then

ashen violet
#

also has an onclick event below

rich adder
frosty hound
#

You need something to click on

wanton epoch
#

Im not sure if this would be in the code place or artist place but ill try code. I have been trying for a bit now to add a collider to my terrain in my 2d platformer like my player. But it doesn't seem to want to function. Any suggestions to this issue would be appreciated. Ive tried to do a terrain collider but when i move around in the game, my player falls through the ground still.

rich adder
#

isnt that the source of the raycast target

#

the Image defines the area to click on

rich adder
wanton epoch
rich adder
#

Tilemap Collider *

wanton epoch
#

🤦‍♂️

#

ive genuinely dumb

#

thanks a ton

rich adder
#

noworries

ashen violet
wanton epoch
#

ill make sure my eyes work properly next time

rich adder
#

is the raycast all still not printing the name ?

void dawn
#

this is the entire thing

polar acorn
void dawn
#

all of my weapons code is in there

ashen violet
rich adder
#

ah right.. forgot thats a thing, only be set throug code though no?

polar acorn
# void dawn https://paste.ofcode.org/3azsGviFBg8sMLeq58ZtjCJ

Add this line:

Debug.DrawRay(gunTip.position, shootDirection * bulletSpeed, Color.Red, 200f);

The line after you set the bullet's velocity. If you check back to the scene view after firing a bullet, you should see a line where it started, pointing in the direction it's supposed to go. Does that align with what you expect to be happening?

polar acorn
void dawn
ashen violet
#

Unity is cursed

void dawn
#

sorry im new

rich adder
swift crag
#

It also doesn't work unless the texture used by the sprite allows for read/write access

rich adder
#

it always does

swift crag
#

Turn every single object off in the canvas. Add a Button object. Can you click on it?

ashen violet
swift crag
#

minimize the number of variables

rich adder
#

Agree you should try slowly adding 1 by 1 and see whats happening

polar acorn
#

Okay random shot in the dark:

Does this button, or any if its parent objects, have the IgnoreRaycast layer?

ashen violet
#

if I disable a parent all children are disabled as well right?

rich adder
#

ye

ashen violet
#

ok so apparently MainMenu may have something to do with it (plus the disabled image part which I fixed already)

#

the MainMenu is supposed to be the parent of the buttons

late badger
#

Do you have a panel on the mainmenu that covers the screen?

ashen violet
swift crag
#

If you parented the buttons to the canvas and placed them before "MainMenu" in the hierarchy, then anything attached to MainMenu (or any of its children) would be able to block raycasts from hitting the buttons

late badger
#

Yeah I got a hunch its the panel thats blocking the buttons

ashen violet
#

now I moved the buttons outside the MainMenu

#

and they get detected

swift crag
#

notably, "MainMenu" is now also deactivated

ashen violet
#

activated it, still get detected

swift crag
#

I see no reason for the buttons to stop working when parented to "MainMenu".

#

unless the MainMenu object has a Cavnas Group that turns off raycasting

vernal wadi
#

custom scripts vs built in components

ashen violet
#

removed it

#

done now it works

#

im stupid

#

very stupid

#

ty very much

swift crag
#

hm, that also shouldn't have, by itself, broken anything

#

unless the canvas lacked a graphic raycaster, I guess? I'm not too sure how that works

polar acorn
ashen violet
swift crag
#

right, but that shouldn't cause any problems on its own

#

you should be able to raycast into that nested canvas

#

(I haven't actually used nested canvases much yet -- I probably should...)

ashen violet
#

ignore what I said earlier, apparently the buttons still dont work inside menu

swift crag
#

I have a main menu that has many totally independent screens, but they're currently all crammed into one giga-canvas

grand snow
#

I think a nested canvas may need a graphic raycaster too?

swift crag
#

I'd expect so

ashen violet
#

so I moved the event system inside the canvas

#

and now the buttons work inside the menu

swift crag
#

...what

#

the EventSystem component can live anywhere in the scene

#

I need you to show me the inspector for the MainMenu object.

ashen violet
swift crag
#

so you've removed the Canvas from this object?

ashen violet
#

yes

#

it was pointless, I added it accidentally

swift crag
#

now show me the hierarchy

ashen violet
#

ok now it works with the event system outside the Canvas

#

but it didnt work before

swift crag
#

neither EventSystem nor Debugger need to be in there

ashen violet
#

My brain is rotting

void dawn
#

here how it looks like after the changes

polar acorn
#

did you check where it ended up

void dawn
ashen violet
#

now my listeners dont seem to be working, im supposed to be sent to another scene when I click on PlayController

polar acorn
void dawn
polar acorn
#

Fire the bullet, switch back to Scene View, and look for that red line

lethal bolt
#

Idk what this method is called, so i couldnt find it onlline, how does one achive no errors?

swift crag
#

YDiference is a parameter of the CheckHeight method

#

There is no reason for that name to be valid anywhere else in your program

rich adder
#

what is CheckHeight supposed to do and why aren't you using the parameter you expect in it

#

if its a result , consider setting it as that value instead of void

lethal bolt
rich adder
#

you have given it no float

cosmic dagger
swift crag
#

parameters don't cause variables to appear for whoever called the method

#

CheckHeight wants a float. It then reassigns it (which does nothing) and exits

rich adder
#

perhaps explain what you're trying to do with this method exacly, what are you comparing to

#

you could always return the float difference or bool result?

polar acorn
lethal bolt
#

Alr..

swift crag
#

if you don't understand why your existing code is very wrong, then I'd suggest using !learn to figure out how to write C#

eternal falconBOT
#

:teacher: Unity Learn ↗

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

void dawn
#

im trying to assign a bullet hole texture so i can know if the bullets are hitting walls or not , but it wont allow me to put it , please help

timber tide
#

Texture asset != gameobject

rich adder
#

just use decal projector

magic panther
#

How can I make a serialized/public field only appear if a certain other serialized/public field is of specific value? Like, I have a bool isBot which changes some mechanics of an object, but some of them are not read even once depending on whether or not that bool is true or not. It's an inspector thing, but would make stuff much more readable.

void dawn
wintry quarry
verbal dome
#

You can also use NaughtyAttributes or put your bot settings in a struct/class variable

west radish
#

What's so naughty about them?

opal laurel
#

Hello, I need help with code.

polar acorn
rich adder
#

most of the stuff there is pretty much stuff unity has built in like MinMax slider

west radish
rich adder
#

yeah they are good, but tbh its a lot to add if you only need 1 or two just build it yourself to minimize dependencies

west radish
#

Well it beats needing something like Odin, especially one for [button]

rich adder
#

maybe I just enjoy editor scripting a bit more so I try to always build my own lol

rich adder
west radish
#

I think for the majority of cases, that's all you really need

#

Especially for very general purpose things you'd want to get the inspector to do

rich adder
#

yeah great for designers too

#

I'm in the UIToolkit rabbithole for custom editor windows, enjoyable tbh

humble marsh
rich adder
# humble marsh same here nav. I love UITookit for its easy to use visual interface. I love codi...

yeah UITookit just felt more natural for editor tooling, I'm guessing this was them then thinking "why not also put this as ingame UI" ? maybe idk lol
layouting and css styling options help out a ton though.
I havent fully used the uxml yet though (I hav kinda disgust from xaml styles)
you can do everything in c# so its nice making premade components for styling . I'll change this once I work with some layout artist

humble marsh
#

i havent like coded the umxl (css stylesheet with selectors right?), as its a large learn curve, but i use it for grouping related elements, or elements that need to be affected by the same thing, like the same thing as a prefab and variants

rich adder
#

my first one was a basic dynamic scroll list lol

humble marsh
#

ohhhh yeah, i love the prebuild lists, but some of them need to be editable after the fact, like for example you cant edit the input fields in the uitookit (i mean the editor window, had to use code)

rich adder
cosmic dagger
rich adder
swift crag
#

that all feels a bit confusing to me right now

errant copper
#

Hello I’m new to unity, I downloaded a 3D Character from the unity asset store and I wanted to ask if I can use it to animate in blender?
Or use a the character and apply Mixamo animations on it?
If it’s possible can anyone please help me with what to do?

timber tide
#

Start googling some tutorials, and if you have any specific problems then ask in #🏃┃animation

swift crag
#

did you also add the birdIsAlive condition?

lone sable
#

Is it possible to generate a navmesh via code that includes bidirectional offmesh links?

The NavMeshSurface has an option for "GenerateLinks" which doesn't appear to be public, nor does it seem to have an option to include Bi-Directional.

timber tide
#

Would be silly if you couldn't buttttt if you can't I can assure you that A* project does

lone sable
#

Would be a pretty big update I'd have to do to swap to it sadly. Project is already fairly far along.

frigid totem
#

I have a DOTS RigidTransform with local values as an offset how would I go about converting that to the world positions based on a provided world position?

tidal thorn
#

Hey, sorry if this is completely a "I know nothing, help me" question, but does anyone know any good tutorials for creating a camera system? Right click on an object, it acts as you 'taking a picture', maybe displays a line of text for a second, then activates something else? Similar to the game Amenti if anyone's familiar? I'm trying to learn my way through making this game, and I can't seem to find a good tutorial for this kinda thing

swift crag
#

You'll want to read about RenderTextures

wintry quarry
swift crag
#

You can tell a Camera to render into a RenderTexture, rather than to the screen

tidal thorn
#

As someone who knows nothing about either of those, what's a good place to start? Just googling "unity rendertextures" and going from there?

swift crag
#

You can start by creating a RenderTexture asset, plugging it into a material, and then assigning it to a Camera

tidal thorn
#

I'll check them out, thank you!

swift crag
#

You can disable a camera and then call the Render method on it to make it draw once

tidal thorn
#

Wait that would be really helpful

frigid sequoia
#

Do .Bounds work for 2D colliders or better use overlapingPoint?

swift crag
#

i'm not sure what you're asking about here

#

Collider2D does, indeed, have a bounds property

#

you can then check if this bounding box overlaps another bounds object

#

(and this does work properly in 2D, as long as the two bounding boxes are on the same plane)

frigid sequoia
#

I am asking if I want to check if a point is inside a 2D collide, would be better to use .Bounds or overlappingPoint

#

Since they... Kinda seem the same for this?

swift crag
#

you mean OverlapPoint?

#

oh hey, I didn't know that existed. neat.

#

You would want to use that.

#

The bounding box is very frequently not equivalent to the space taken up by the collider

#

that's only the case for a non-rotated box shape

frigid sequoia
#

Oh, so overlapPoint is for the bounding box only or how?

swift crag
#

No. OverlapPoint tells you if a point is inside the collider.

#

The bounds property gives you an axis-aligned bounding box that encloses the collider

#

This almost always covers more space than the actual collider

#

I imagine that OverlapPoint starts by checking if the point is inside the bounding box

#

and, if it is, it then does more complex math to decide if it's actually inside the collider

swift crag
#

imagine a circle shape: you can enclose it in a square. that's the bounding box

#

there are points in that box that aren't inside the circle

slender nymph
#

also if you want to detect arbitrary objects, checking the bounds would definitely not be the way to go or else you would need to reference all of the possible objects and check the point for each of them, if you just want to know what your cursor is over (which i'm assuming this is still about that) then the overlap point is the better option

swift crag
#

that'd be Physics2D.OverlapPoint

#

I just discovered that Collider2D.OverlapPoint also exists

#

But yes -- if you are querying for colliders at a point, you want to use Physics2D.OverlapPoint

#

Otherwise, you'd need to walk through every possibly-relevant collider and ask each one if there's an overlap

slender nymph
#

right, and Physics2D.OverlapPoint is what i suggested to them last night

swift crag
#

I couldn't quite tell which one was being talked about

#

the question appeared to be about testing a single 2D collider

slender nymph
#

yeah 2d physics has some neat quality of life stuff built in. you can directly cast a collider (if it has a rigidbody on it), you can to a single axis of velocity, and these other overlaps/casts

frigid sequoia
#

Ah, so if I want to check if a point is, for example, inside like a star shaped collider, I should check for overlapPoint right?

#

Cause Bounds would not be accurate

#

Kk

swift crag
frigid sequoia
#

I am dragging a 2D object inside a 2D collider area, in way that if I move the cursor outside the area it just stays as close to the cursor as possible within the area

#

Does that make sense?

swift crag
frigid sequoia
#

Oh, so the closestPoint must also be for 2D?

#

Oka

#

I was using 3D until now cause I didn't know how to do it in other way

slender nymph
#

wait, were you still using 3d colliders even after the discussion last night where i informed you that was entirely unnecessary for 2d and how to detect colliders using the Physics2D class?

frigid sequoia
#

No, I just did not change it yet, since I went to sleep

#

I was also coding some other stuff too in the meantime

lucid prairie
#

Hi all - I am having trouble with player movement; it seems to be slippery? I have code like below which works to keep the player in bounds if I move him slowly. If I press hard on the directional keys though he can gian enough momentum to go out of bounds which then means he can't move at all. Would anyone mind pointing me to relevant docs or letting me know why this is happening? Thank you so much!

void Update()
{
horizontalInput = Input.GetAxis("Horizontal");
if (transform.position.x > leftXRange && transform.position.x < rightXRange ) {
transform.Translate(Vector3.right * Time.deltaTime * turnSpeed * horizontalInput);
}
}

swift crag
#

i wouldn't expecting "pressing hard" to do anything

#

keyboard input is binary

#

unless you have one of those weird pressure-sensitive keyboards

rich adder
frigid sequoia
#

Ok, I am gonna fix what I am doing first and I was just seraching for a LookAt equivalent for 2D; and I found u kinda have to caculate the rotation manually? Is that right?

swift crag
#

you can assign to Transform.right or Transform.up

frigid sequoia
#

I found this, while for 3D would just be LookAt("point you want to look at")

#

I found it kinda weird

rich adder
#

simple enough
var dir = b-a
transform.right = dir

polar acorn
#

You can assign transform.up or transform.right to a direction and it'll point in that direction

spice wing
#

So I'm new to Unity and especially to using coroutines, and I'm tryna make a slowmo powerup. For now I just want it to initially drop to timescale=0 really quickly as a first step, and it just doesnt work.
The console outputs "Dropping time scale" only once and then nothing happens.
The ActivatePowerUp() function is called from another script when I pick up the powerup, and its called exactly once, so the problem's not there

I just feel like there's a really stupid mistake here somewhere but I just dont see it😭

And don't ask why my base timeScale is 1.15 lol

covert lichen
#

Hi Everyone - About three months ago, searching through addons for helping in game creation... I decided to take a challenge and write Unity code from scratch through a Udemy coarse on C#. A few months later I'm happy that I did, because I know every line of code and what it does which makes me feel more in control of my destiny. I'm a noob and I'm hooked on development now. Was scared to delve in, but now... I can't wait to learn how to write a new Class.

prisma jolt
#

i have a for loop inside an IEnumerator with a few WaitForSeconds in it. How would I quickly stop everything inside the coroutine and start it again from the start?

slender nymph
#

StopCoroutine exists

spice wing
covert lichen
#

With all that said... Most of the courses I've been training in was written using Unity 2018... I decided to code in Unity 6 against all advise, but to hell with it... I went for it anyhow and my code works after asking CoPilot for some help. Don't care what anyonw says negative about AI anymore... dang Artificial Intelligence is freakin awesome.

prisma jolt
covert lichen
#

One thing though... FindObjectsOfType was completely changed in Unity 6 to FindObjectsByType with some added stuff... but... I got through it

north kiln
#

God I wish it didn't throw

slender nymph
#

yeah that's silly, it should just do nothing if null is passed. or at most log a warning

spice wing
north kiln
jovial sable
#

is there any links to completely start unity c# as a beginner?

spice wing
slender nymph
eternal falconBOT
#

:teacher: Unity Learn ↗

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

covert lichen
#

Your public void ActivateThePowerUp() - What is calling this? Is it only being called once? I don't see the rest of your code and classes. Does something need to be in an void Update() which calls every frame

west radish
spice wing
#

It was the point, that the message is only logged once

west radish
#

It's possible the shrink the width of the console

prisma jolt
slender nymph
#

show what you tried

spice wing
west radish
#

I suppose so

covert lichen
#

Take your dropDuration from 0.2f and set it to 1.0f and just see what happens. Does it do anything? Sometimes I will adjust the values as a way to debug.

#

Time issues

spice wing
prisma jolt
slender nymph
#

and what exactly is not working?

#

also !code

eternal falconBOT
covert lichen
#

Look at your math you have timeElapsed set to 0 being divided by 0.2f... is 0

spice wing
north kiln
covert lichen
#

Set your timeElapsed to 0.05f and go from < to <= and just see what happens

spice wing
#

And the reason I did it is because its a powerup, its supposed to disappear when you pick it up

#

lol

prisma jolt
covert lichen
#

Ah that would do it

slender nymph
prisma jolt
#

i figured it out

#

thanks

covert lichen
spice wing
covert lichen
#

I've spent time pulling my hair out looking at my code... only to relized... I forget to attach the script to the game object.

spice wing
#

I was getting so frustrated

covert lichen
#

It's fun though finding the solution.

wintry quarry
spice wing
#

Now I know its probably better to disable the renderer or smth rather than destroying the object, unless I'm certain I want it destroyed

wintry quarry
spice wing
swift crag
#

each MonoBehaviour has a list of coroutines it's handling

#

hence why you have to call StartCoroutine on a specific MonoBehaviour

frigid sequoia
#

I want to get a reference to this script that I downloaded to enable and dissable it, but apparently it doesn't show? How can I get access to it?

wintry quarry
frigid sequoia
#

Like.... it's not in the collection of namespaces?

#

I am guessing I have to do a "using Something" but not sure what

wintry quarry
#

Why don't you go look in the code

#

that you downloaded

#

and see

frigid sequoia
#

That's exactly what I am asking, what I am looking for there?

#

I am not familiarized with that stuff

humble marsh
#

ScriptableObject is not showing up as a ScriptableObject in the inspector/editor/other scripts (name of script is ItemInventory)

#

ive been coding for years, and this just, just stumps me

slender nymph
#

It needs to be the first or only type defined in the file

humble marsh
#

the UiBuilder has it this way, so i thought the code would be correct

#

but thank you so much

slender nymph
#

Also the create asset menu attribute is on the wrong type

humble marsh
#

ah gotcha, thank you

humble marsh
slender nymph
#

MonoScript is literally the type of asset for the actual script file. you can create the SO instance from the Create menu

humble marsh
#

.... its legit an asset, that i havent thought to make.

#

thank you for educating me.

frigid sequoia
#

Could I make something like... use a CompositeCollider as a mask layer for a sprite?

#

I want to make the area defined by it to have like sorta of a tint

#

Do I have to do that manually?

lucid prairie
# rich adder You're probably just confusing it with GetAxis having smoothing vs GetAxisRaw th...

thanks for the suggestion - I tried switching it up but I am still having the same problem. If I have a range for player movement as -4 to 4, I would expect that a player can move only within that range. However, for some reason the player can get to -4.04, (not this value consistently, sometimes it's like -4.1), and then at that point they are no longer able to move. Anyone had similar problems??

wintry quarry
#

You are moving the player AFTER the check

teal viper
# frigid sequoia Do I have to do that manually?

Colliders have nothing to do with rendering by default, so you would need to implement it manually. For example, generate a mesh out of the collider and draw it with a mask shader(would need to implement it too).

frigid sequoia
#

So what would be the best way to have a mesh for both a 2D collider and a sprite mask?

#

I could make one different mesh for each, but seems like a massively hassle to scale properly from outside unity

teal viper
frigid sequoia
#

How would I generate a mesh from that?

lucid prairie
slender nymph
frigid sequoia
slender nymph
#

yes, this is a code channel that should have been implied

frigid sequoia
#

Seems that making a script to calculate those shapes for each and work and then trasnlate it to a mask would be even more complex than making it manually

ivory bobcat
#

If it wasn't intended to be a code question or wanting a code solution, maybe it ought to have been placed elsewhere? UnityChanHuh

frigid sequoia
#

Where do I ask how to get a very specific and editable shape for both a collider and a mask?

ivory bobcat
bold solstice
#

hi my pause menu is not working i need help

slender nymph
#

!ask

eternal falconBOT
slender nymph
#

pay particular attention to the last points (including the fine print)

bold solstice
#

i honestly just need to know if this code is broken or not its like 2 lines

#

Set Cursor.lockState to CursorLockMode.None;
Cursor.visible = true;

slender nymph
#

well that first line isn't even valid c#

bold solstice
#

ok

#

cool

#

thanks ig

slender nymph
#

there are beginner c# courses pinned in this channel if you do not understand how to assign a value

polar acorn
bold solstice
#

the 1 answer

slender nymph
#

that's not at all what you have

polar acorn
#

Okay but where in that question do you see that first line

bold solstice
#

idfk then

#

i forgot at this point

iron wing
#

okay basically im using the freelookcamera cinemachine camera for my third person game, but i dont really know how to adjust the values through code considering its an extenral package and i dont have access to it's class. specifically i have a camera sensitivity slider in my menu. how can I make this affect my cinemachine camera?

strong wren
#

Typing out one of the classes and using your IDE's quick suggestions/fixes or right clicking a component, clicking "Edit Script" and looking at the code are also options.

north scroll
#

hii im making a local multiplayer game and Im having trouble with my gamemanager script calling an UpdateTimer() on my playerscript. Each player has their own timer UI but the timer itself is being run on my gamemanager script (its split screen). I'm getting a null exception on:

//Player Script
public void UpdateTimerUI(int timer)
{
    timerText.text = timer.ToString();
}

Thats being called from this:

//GameManagerScript!!!
IEnumerator UpdateTimer(int seconds)
{
    int count = seconds;

    while (count > 0)
    {
        yield return new WaitForSeconds(1);
        count -= 1;
        foreach (GameObject p in listOfPlayers)
        {
            p.GetComponent<PlayerScript>().UpdateTimerUI(count);
        }
    }

    gamestate = GameState.End;
    StartCoroutine(EndGame());
}

void StartGame()
{
    gamestate = GameState.Running;
    StartCoroutine(DelayedStartTimer());
    //GameVisualManagerScript.instance.DisableTimer();
}

IEnumerator DelayedStartTimer()
{
    yield return new WaitForSeconds(0.1f); // Give PlayerScripts time to initialize
    StartCoroutine(UpdateTimer(timer));
}

I have a delay because I feel like its got something to do with the ordering of the Player's Prefab Start() and thought it would help but it didnt, not sure the fix

strong wren
north scroll
#

in my player's Start()

private void Start()
{
    myStats.score = 0;
    myStats.lap = 1;
    myStats.stunned = false;
    myStats.firstLap = true;
    myStats.finishedTrack = false;

    playerCamera = GetComponentInChildren<Camera>(); // Find the camera in the prefab

    //playerIndex = GameManagerScript.instance.AddPlayer(this.gameObject);
    //AdjustUIForPlayer();

    myCanvas = GetComponentInChildren<Canvas>();

    scoreText = myCanvas.transform.Find("MoonshineScore").GetComponent<TextMeshProUGUI>();
    lapText = myCanvas.transform.Find("CurrentLap").GetComponent<TextMeshProUGUI>();
    timerText = myCanvas.transform.Find("Timer").GetComponent<TextMeshProUGUI>();

    Debug.Log(timerText.name);

    UpdateUI();
    UpdateTimerUI(60);
}
strong wren
#

That log should be throwing too if it's null

north scroll
#

its not though, the timer works fine on the player script and anything its being referenced in there

strong wren
#

Can you send the full error message

north scroll
#

I am starting the StartGame() function that chains the coroutines in my GameManager script once the player count reaches 2:

 public void AddPlayer(GameObject player)
 {
     listOfPlayers.Add(player);

     if (listOfPlayers.Count >= 2)
     {
         StartGame();
     }
 }

which is fired from the new input system's detecting a player joined

north scroll
#

im like 99% sure its this weird internal thing with how the player's Start() works in the innerds of Unity since the player is a prefab that gets instantiated by the New Input system detection thing, but im not sure how to fix it

strong wren
#

Yea I imagine that Timer text should have popped for each player object instance. One potential fix could be to switch from Start to Awake to initialize these fields earlier.

north scroll
#

alls I did was change Start to Awake and it didnt work :C

slender nymph
# north scroll

you're passing the prefab to the GameManager's AddPlayer method, not the instantiated player

#

the PlayerJoinedEvent passes the PlayerInput instance but you are throwing that out and passing a prefab instead. and since prefabs don't exist in the scene they've never had Start or Awake called on them so any variables initialized in those methods are still their default values (which is null for reference types)

north scroll
#

null for reference types... that makes sense

slender nymph
#

i sincerely hope that isn't the only thing you took away from all of that

north scroll
#

the PlayerJoinedEvent passes the PlayerInput instance but you are throwing that out and passing a prefab instead

What does this mean tho

#

i was thinking!

#

:/

slender nymph
#

that means you are not passing the spawned object, you are passing the prefab

north scroll
#

i didnt know there was a difference... How do I fix it though? The reason I added that parameter was so I could store it in the list

#

passes the player input instance.... how do I reference that player input instance then instead of the prefab

slender nymph
#

the PlayerJoinedEvent is a UnityEvent<PlayerInput> which means when it is invoked it will normally pass the PlayerInput reference to the listeners, but you have added a listener that does not accept that object and instead have selected to pass the prefab.
The method you are subscribing should accept a PlayerInput parameter (which you can then get the gameObject from if that is what you need from it) and you need to subscribe using the Dynamic option
https://unity.huh.how/unity-events/dynamic-values

north scroll
#

oh so the actual prefab's playerscript component into that ?

slender nymph
#

no, that is not at all what i said

thorn tree
#

how do i change centre of mass of a 2d sprite guys?

thorn tree
#

there is nothing there

north scroll
#

she's workinnn

slender nymph
lapis yew
#

You neede to put in the object that's present in the hierarchy

humble hound
#

hello everyone, im new to unity and im following the rollaball tutorial. just reached the movement creation part, i did everything as the instructor said but my ball is not moving like hers

#

mine is not moving at all

slender nymph
#

show relevant !code and the relevant scene objects

eternal falconBOT
visual linden
queen adder
#

yo hello, I am new to unity and started on the Roll-A-Ball game as instructed by my instructor. I just coded a new feature in my Roll-A-Ball game, basically its a timer feature that would spawn the enemy. However, when the enemy spawns, it isn't being destroyed once the game is won and doesn't follow me around. Don't know exactly why it stopped working. Here is what its looking like:

Enemy is a Prefab so that it spawns
EnemySpawner Empty GameObject is used for a place on where is spawns and also has the script attached, which is responsible for the timer. If i input 3, then in 3 seconds, the enemy will spawn. But the thing is that it doesnt follow around me anymore, nor, dies when game is won.

#

this is the console

#

video includes all scripts, and demo

#

thats what i followed

#

if you prefer text here is it:

#

EnemySpawner.cs```
using UnityEngine;

public class EnemySpawner : MonoBehaviour
{
public GameObject spawnedEnemy;

public float timeToSpawn, spawnCountdown;


void Start()
{
    spawnCountdown = timeToSpawn;
}

void Update ()
{
    spawnCountdown -= Time.deltaTime;

    if (spawnCountdown <= 0)
    {
        spawnCountdown = timeToSpawn;
        Instantiate(spawnedEnemy, transform.position, transform.rotation);
        
    }
}

}

humble hound
#

and everything is linked appropriately

humble hound
visual linden
# humble hound and everything is linked appropriately

In your screenshot of the code you can see OnMove is greyed out slightly- This is Visual Studio's way of telling you that the method is Unused, meaning that there's no other code calling it (so it never runs).
I suspect this could be part of the reason it's not working?

humble hound
#

how do i call it

visual linden
#

I would hope the tutorial would explain that at some point :D

humble hound
#

it doesnt

celest jackal
#

hi, very new to unity. Im trying to create a script which drags 2 objects at the same time and returns them to the original position once the mouse is let go.

#

Cant find anywhere that does that

humble hound
visual linden
# humble hound they just write and the code works

Sorry, I was reading the transcripts of the tutorial :)
It looks like the PlayerInput script will "magically" call the OnMove function for you with the correct input- This seems to be some nice helper stuff they've got going on for beginners.

#

That all seems fine though

slender nymph
slender nymph
celest jackal
#

alright, ill try that

humble hound
#

so i delete the xrcontroller

slender nymph
#

that is not the issue, you have 4 bindings in your Move action, that is just one of them

#

they have a WASD binding on the Move action

humble hound
slender nymph
#

there it is, the rigidbody is kinematic so it isn't affected by forces

humble hound
humble hound
slender nymph
queen adder
#

so anyone got any idea on how to fix my issue?

subtle osprey
#

for some reason even if i give the correct name for the script to run off of the multiplier and streak wont show up on the hud

slender nymph
supple sand
#

You are referencing the prefab, which is like a template. You need to reference the one that is used during the game

subtle osprey
slender nymph
#

screenshot it at runtime when this code is not working

subtle osprey
#

the score works

visual linden
#

But also, where are the PlayerPrefs values being read and displayed from?
( This feels like a typical job for the Debugger. Slap a breakpoint in your scripts and see where the call trace takes you )

slender nymph
# subtle osprey

and is the GameManager object entering a trigger to cause that ResetStreak method to be invoked?

vast fern
#

I am getting a weird error and i do not understand what it means "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination (UnityEngine.Vector3) Enemy:Update () (at Assets/Scripts/Enemy.cs:31)

slender nymph
#

also you assign 0 to streak right before calling UpdateUI which then uses the value of streak to set the player pref

slender nymph
#

or it isn't active

vast fern
#

but it works D:

#

oh wait i think i understand

#

bcz its on enemies, and when i kill an enemy it dissapears

#

i have a like if(player != null)

#
        {
            enemy.SetDestination(player.transform.position);
        }```
nimble apex
#

lots of ppl said setting the value to "-1" can actually turn the checkboxes off, but when i did that with code, i cant

#

how can i turn off the active checkbox

#

wait that only works on width??

#

strange

grand snow
#

If we look at it in debug mode -1 is the default so must be something else you did

nimble apex
#
    private void Update()
    {
        if (recordCount != textCount)
        {
            GetComponent<LayoutElement>().preferredHeight = -1;
            GetComponent<LayoutElement>().preferredHeight = GetComponent<RectTransform>().rect.height;

            recordCount = textCount;
        }
    }```
#

this script will run in editor mode

#

and it is the only thing affecting the preferred height

slender nymph
#

if the rect transform's rect.height isn't -1 then naturally that would result in preferredHeight not being -1

subtle osprey
#

the object is below the notes

slender nymph
#
  1. how have you confirmed that
  2. read the next message i sent
subtle osprey
#

i just ran it and missed a note after getting atreak

nimble apex
#

i found out the problem, it was the checking lol

subtle osprey
slender nymph
subtle osprey
#

but thank you for the help

slender nymph
#

that is not what a reference is, that is simply calling a method. and for future reference, you should provide much more detail about what you expect to happen since all you had said was "streak wont show up on the hud" and you were only updating the value stored in the player pref when OnTriggerEnter2D was called i assumed you wanted it to only update after that point

burnt vapor
simple vine
#

guys can anyone help me fix this pls

wintry quarry
simple vine
#

i do have the right photon vr

dusty geode
#

Is GcsWardrobeButtonManager your script?

simple vine
#

and plus i cant complain to the owner of it becuase he banned me

simple vine
simple vine
#

trust me dont beg and ask for help he doesnt like it

wintry quarry
#

My recommendation then would be to learn C#

simple vine
#

how tho because im not good at learning scripts

hexed terrace
#

You don't "learn scripts" .. you learn the language (C#). !learn 👇 and see pinned msgs

eternal falconBOT
#

:teacher: Unity Learn ↗

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

simple vine
#

i dont get it

dusty geode
# simple vine no i found it in discord why

Because the problem is in that script, because it doesn't know what Saving is from Photon.VR. Either it used to exist in an earlier version and was removed/renamed or it just doesn't exist outright.

simple vine
#

there is none

dusty geode
simple vine
#

wydm

dusty geode
#

It can't find a type or namespace named Saving in the Photon.VR namespace. If you don't understand what that means, you need to learn the basics of C#

simple vine
#

soo how do i get the saving or do i deleted the saving in the script

#

so i deleted and now i got 18 errors

dusty geode
simple vine
#

how do i update it

dusty geode
simple vine
#

oh man

mint sky
#

t:material shader:Universal Render Pipeline/Lit"

i want to search for materials that are lit , how can i do this in editor ?
this doesnt seem to work

can anyone let me know how this works?

dusty geode
#

So either you don't actually have the asset imported into your project, or you have corrupted it in some way

simple vine
#

it look like i dont have it

#

where do i import it

dusty geode
dusty geode
ashen violet
#

Hello, trying to create a main menu for my game. For some reason my OnClick won't work for my buttons. I have tried everything on the internet with no luck
The button seems to be clickable

simple vine
dusty geode
simple vine
#

IT FIX But then gave me 3 more erros

dusty geode
simple vine
#

can i have some help and pls

astral flume
#

i need help with installing unity on linux
my unity goes not responding forever on splash screen. and it doesn't show me any error message.
the version is Unity-2023.2.20f1. and operating system is Ubuntu 24.10 Oracular.

dusty geode
simple vine
#

how

hot laurel
#

and the first version was corrupted

simple vine
#

ok i deleted it and now i got 10 error

dusty geode
simple vine
#

it was the first one there was 2

ashen violet
# dusty geode You need to provide more info, code, screenshots, etc.

This is my working tree:
Buttons are interactable, the text meshes inside them do not have raycasts
I added a script to the MainMenu object which contains the functions the buttons should call when clicked and attached the functions to button OnClick on editor
I created the debugger object to attach a script which tells me which button I click (previously the buttons were not even detectable)

Some more info, when I am on Play Mode, the EventSystem won't say anything on **Selected: ** no matter where I click

simple vine
ashen violet
#

if you need more details, please let me know

mint sky
simple vine
dusty geode
simple vine
#

errors

dusty geode
simple vine
#

ok

thin fiber
#

why am i not able to trigger animation:

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

public class NewBehaviourScript : MonoBehaviour
{
    [SerializeField] private float move_Cat_Speed = 0.4f;
    private Rigidbody2D rb;
    private Animator anim;
    private GameObject player;

    private bool isPlayerNear = false;
    private bool isAnimationRunning = false;
    private float catXPosition;

    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");

        if(player == null)
        {
            Debug.LogError("No");
        }
        rb = GetComponent<Rigidbody2D>();
        anim = GetComponent<Animator>();
        catXPosition = transform.position.x;
    }

    void Update()
    {
        if (isPlayerNear && isAnimationRunning)
        {
            float playerXPosition = player.transform.position.x;
            float xDifference = Mathf.Abs(playerXPosition - catXPosition);

            if (xDifference >= 2f)// Cat walking animation stops once the condition is met
            {
                anim.SetBool("cat_walk", false);
                isAnimationRunning = false;
            }
        }
    }
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !isAnimationRunning)
        {
            anim.SetBool("cat_walk", true);
            isAnimationRunning = true;
            isPlayerNear = true;
        }
    }

    public void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            isPlayerNear = false;
        }
    }
}

// The cat walking animation triggers once the player enters its collider and the animation happens only once, doesnt repeat again if the player triggers the collider again```
keen dew
#

You have two conditions and two booleans and they're conflicting with each other. You'll have to decide if you want to stop the animation when the player leaves the trigger, or when the player is 2 units away, and remove the other one. Or if you want both conditions then the conditions in Update need to be redone.

thin fiber
#

how do i redo it in the update

#

T-T

visual linden
#

Why did you write it like that in the first place? I'm having a hard time understanding the logic there.

keen dew
#

So do you want both of those conditions? Is it that both have to be true or that either one has to be true?

visual linden
#

Can't you do without the Update method all together?

keen dew
#

Then the condition should be if (!isPlayerNear && isAnimationRunning)

thin fiber
#

oh yea T-T

#

but still doesnt work

visual linden
#

// The cat walking animation triggers once the player enters its collider and the animation happens only once, doesnt repeat again if the player triggers the collider again
I assume this is the task?
Wouldn't the OnTrigger methods already fulfill this?

thin fiber
#

lemme check

visual linden
#

Well, you'd have to set anim.SetBool("cat_walk", false);in OnTriggerExit

#

As long as you have exit time ticked in the animator, I believe it should play until the end before stopping.

keen dew
#

That would ignore the > 2 units away condition

thin fiber
#

yup

keen dew
#

So in what way does it not work now?

thin fiber
#

the walk animation doesnt get triggered at all, it's at idle animation even after the player enters the collider

#

the animator is set correctly.

keen dew
#

Not even the first time?

thin fiber
#

Nope

#

u mean the idle or the first walk trigger?

keen dew
#

The walk animation

thin fiber
#

nope

keen dew
#

What did you change in the code?

keen dew
#

And if you remove the ! again does the animation work?

thin fiber
#

nothing works

#

T-T

keen dew
#

You're not making it easy to help you

thin fiber
#

lemme tell u, apart from the code

#

what i did

#

and maybe then u can find the fault

#

and help out

#
  1. Made the cat idle and walk animations, made transitions to occur depending on cat_walk
keen dew
#

Just show the code

thin fiber
#
  1. Added a 2d rectangle trigger to cat that looks like this:
#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class NewBehaviourScript : MonoBehaviour
{
    [SerializeField] private float move_Cat_Speed = 0.4f;
    private Rigidbody2D rb;
    private Animator anim;
    private GameObject player;

    private bool isPlayerNear = false;
    private bool isAnimationRunning = false;
    private float catXPosition;

    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");

        if(player == null)
        {
            Debug.LogError("No");
        }
        rb = GetComponent<Rigidbody2D>();
        anim = GetComponent<Animator>();
        catXPosition = transform.position.x;
    }

    void Update()
    {
        if (!isPlayerNear && isAnimationRunning)
        {
            float playerXPosition = player.transform.position.x;
            float xDifference = Mathf.Abs(playerXPosition - catXPosition);

            if (xDifference >= 2f)// Cat walking animation stops once the condition is met
            {
                anim.SetBool("cat_walk", false);
                isAnimationRunning = false;
            }
        }
    }
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !isAnimationRunning)
        {
            anim.SetBool("cat_walk", true);
            isAnimationRunning = true;
            isPlayerNear = true;
        }
    }

    public void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            isPlayerNear = false;
        }
    }
}

// The cat walking animation triggers once the player enters its collider and the animation happens only once, doesnt repeat again if the player triggers the collider again```
#

this is the code.

keen dew
#

Ok and in the original code you showed earlier, // The cat walking animation triggers once was what happened?

rain ginkgo
#

is there any better way to do this then a cast?
Im trying to utilize a enum

thin fiber
#

same code with this change !isPlayerNear

nocturne parcel
cosmic dagger
rain ginkgo
#

ah, thank you

keen dew
thin fiber
keen dew
#

In the original code that you showed earlier, did the cat walking animation trigger once?

thin fiber
#

nope

#

the cat_walk bool gets checked and un-checked in the animator window during the game

rancid tinsel
#

!code

eternal falconBOT
thin fiber
#

and doesnt get re-checked even after the player re-enteres the collider area

keen dew
thin fiber
#

wait

#

that comment was to basically lets others know what the code was gonna do eventually

rancid tinsel
thin fiber
#

T-T

rancid tinsel
#

it works perfectly fine in editor

thin fiber
#

also i made another fix to the code

keen dew
#

Sorry, I don't have time or interest to try to dig for what actually is true or not when you're not able to give straight answers. Good luck

thin fiber
#

its alr

#

thank u anyways

thin fiber
visual linden
#

I get that it can be uncomfortable not knowing certain things and having to ask for help, and maybe not receiving the help you need. But I think we should try to be grateful that there are people here at least willing to try.
Since this is mainly an animation related question, you might want to try posting in #🏃┃animation , there might be people lurking there with more ideas on what you can try.

polar acorn
#

No one here actually cares if your game works, we're doing this for fun, if you're gonna be difficult there's no reason to try

cosmic dagger
ashen violet
#

Hello, here I am, AGAIN
So I found out that my buttons wont work specifically because of the new input system, when I use the old one in the EventSystem everything works.
Nothing is blocking my buttons....

wintry quarry
#

The default one usually works best

ashen violet
wintry quarry
#

Well it works in general so something else about your setup must be causing it

rancid tinsel
ashen violet
wintry quarry
wintry quarry
ashen violet
polar acorn
grand snow
polar acorn
visual linden
wintry quarry
ashen violet
wintry quarry
#

Yeah so that wasn't the default before...

ashen violet
#

Still same issue though

grand snow
#

i use the new input system with canvas on android and it works just fine

#

i use the new input system only however

wintry quarry
queen adder
#

hello

ashen violet
queen adder
#

anyone know how I can add a custom json to AddInventoryItemOptions

polar acorn
visual linden
queen adder
#

trying to dynamically add json to a single type of inventory item from that economy package

cosmic dagger
ashen violet
#

and it detects the buttons and stuff

visual linden
polar acorn
deft loom
#

What’s the most straightforward way to accurately measure the execution time of a single function?

#

Trying to optimize a maze generation algorithm

deft loom
#

Oh I thought you were joking LOL

#

I’ll check that out thanks

visual linden
#

One might call it, comedic timing

deft loom
#

ba dum tsh

scarlet skiff
#

whats the easier way to duplicate an instance of a class? is there a unity method for it or like yea whats the most effective way, and i want them to be seperate not work as a pointer or whatever

cosmic dagger
timber tide
#

copy constructor

ashen violet
#

does the old input system work with touch controls?

cosmic dagger
#

Yes . . .

ashen violet
#

Good, what are the drawbacks of the old input system really?

timber tide
#

Nothing really

#

More work to switch keybinds I guess

scarlet skiff
ashen violet
#

Then why is Unity trying to shove it up my ass

#

=]]]]

timber tide
#

ikr

ashen violet
#

then I will just use that since every possible tutorial out there uses the old system..

#

Thank you guys for all the help

tender stag
#

my ProgressBar seems to instantly jump to 100%

wintry quarry
ashen violet
#

which it does with the old system

cosmic dagger
ashen violet
swift crag
#

This will only preserve fields on the class that are serializable by unity, of course, and it won't preserve references to any other objects

scarlet skiff
swift crag
#

Right.

#

Note that you'd need to know the exact type here

#

You wouldn't be able to just do IState copy = new IState(original);

#

If you need to be able to clone any IState, make it implement ICloneable

tender stag
#

is there a moment in this code where no scene is loaded?

#

if so how can i fix that

#

u can see after i host the game its there for a split second

rancid tinsel
#

from what I gather I can't ~~read ~~ find these text files in WebGL, at least not the same as on Windows where I just check the folder?

swift crag
#

It looks like you'll use UnityWebRequest to fetch files

#

Note that if you just need text data, you don't need to use StreamingAsset at all

#

just chuck the files into the assets folder and reference them as TextAssets

rancid tinsel
#

oh nice

#

is that serializable?

swift crag
#

yes, the file gets imported as a TextAsset

grand snow
#

its just an asset you can get the text (or binary data) from?

rancid tinsel
#

and wow i had no idea

timber tide
# tender stag

I've noticed that too lately, but usually I keep my main camera non-destroyable so I don't run into it much. In builds you wouldn't get the warning there's no rendering if you want to just ignore it.

tender stag
timber tide
#

Possibly unless you need to clear any buffers?

#

Actually it may just keep the previous frame data

tender stag
#

its probably the order im running the code, there is a moment where the scene hasnt loaded yet

timber tide
#

Well, if the async is giving you the OK, I don't see what would be the problem

swift crag
tender stag
#

i fixed it

swift crag
#

I don't see the "no cameras rendering" screen after you host a game

tender stag
#

i'll show you how

tender stag
#

its barely visible

#

was

#

this is how i fixed it

#

just changed the order so that there is never a moment where some scene isnt loaded

queen adder
#

sorry im really, really new to unity

#

just started like 2 weeks ago

visual linden
# queen adder how can i do that

You need to store a reference to the spawned instance

Say you have a GameObject myPrefabObj
You spawn an instances of that
var myNewInstanceObj = Instantiate(myPrefabObj);
Now, when the game is over, you destroy your spawned instance
Destroy(myNewInstanceObj);

queen adder
#

okay so basically, instead of making an empty object to control the prefab, I actually use the prefab

#

correct?

#

This is the current code for the timer spawn feature:

using UnityEngine;

public class EnemySpawner : MonoBehaviour
{
    public GameObject spawnedEnemy;

    public float timeToSpawn, spawnCountdown;


    void Start()
    {
        spawnCountdown = timeToSpawn;
    }

    void Update ()
    {
        spawnCountdown -= Time.deltaTime;

        if (spawnCountdown <= 0)
        {
            spawnCountdown = timeToSpawn;
            Instantiate(spawnedEnemy, transform.position, transform.rotation);
            
        }
    }
}```
#

or

#

can add the EnemyMovement to the EnemySpawner game object maybe?

#

nope my second one doesn't work

tender stag
#
GameObject newEnemy = Instantiate(spawnedEnemy, transform.position, transform.rotation);
newEnemy.GetComponent<EnemyMovement>().whatever```
wintry quarry
#

spawnedEnemy would be the thing that Instantiate creates

rich adder
#

pretty rare needing to spawn something as GameObject

queen adder
#

idk i just followed a tutorial and it just messed it up

queen adder
rich adder
#

if you want to access component from your spawned object then yes

tender stag
#

but yeah good point

rich adder
# tender stag really up to what ur doing

true but pretty much every Component has access to GameObject property and Transform so it usually can just be accessed that way for things like SetActive or anything GameObject specific

queen adder
#

okay so as I was putting your code in there, it tried to auto-fil the bottom line

timber tide
#

Find + Update = bad

rich adder
# queen adder

just store the player in the Spawner since thats part of the scene and should already have player there

#

[SerializeField] private Transform player

#

newEnemy.player = player

#

doing a Find each enemy spawn, especially by name is not very efficient

queen adder
#

alright

rich adder
#

btw make sure you put the prefab back in the slot after you change spawnedEnemy prefab to EnemyMovement

queen adder
#

I've only been with unity for 2 weeks, and know almost nothing about the language or anything so thats why struggling a bit

rich adder
#

also you should indeed change that name to enemyMovementPrefab
make it more clear what it is

queen adder
#

😂

rich adder
queen adder
#

yes but our teacher is requiring us to follow the tutorial, just to get the hang of Unity basics and stuff

rich adder
#

ohh alright. Cause Unity basics stuff is pretty extensive ontop of knowing regular c#

#

Unity is basically an API

robust harness
#

How should i go about referencing 7 more different skills in a similar manner to this? (for example, lets say i need to define "battle.nameText.text = battle.skill2.name;" and so on) cs public override void EnterState(BattleStateManager battle) { battle.nameText.text = battle.skill.name; battle.descriptionText.text = battle.skill.description; battle.attackIcon.sprite = battle.skill.attackIcon; battle.mpText.text = battle.skill.mpCost.ToString(); battle.healthText.text = battle.skill.healthCost.ToString(); }

wintry quarry
#

or store a reference to it as a field elsewhere and use that .e.g. Skill currentSkill

#

You can also use an array and keep track of what the current index into the array is

#

and you can combine these things

#

As a rule of thumb if you ever have a variable named with a number like skill2 you should be swapping those individual variables out for an array or a list