#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 286 of 1

polar acorn
#

Drag in the reference directly

ivory bobcat
#

What happens if it doesn't/isn't-able-to find the object?

austere osprey
#

i fixed the issue, i'm just stupid. but i don't know why it refused to get the object since the objects were in the scene and had the correct names ๐Ÿค” ah well, if it ain't broken, don't fix it

ornate lynx
#

why does this work

#

and this doesn't

polar acorn
ornate lynx
#

oh

#

why isn't it valid tho

#

it makes total sense doesn't it?

ivory bobcat
#

Because -5 < y < 5 isn't a thing

ornate lynx
#

how?

ivory bobcat
#

How what?

ornate lynx
#

that is a thing...

polar acorn
ornate lynx
#

well

#

ok ok

polar acorn
#

if takes a boolean as a parameter. < is an operator that returns a boolean when given two numbers. x < y < z would evaulate to (x < y) < z) which would be checking if false was less than z which makes no sense

tall delta
# ornate lynx how?

because what you have is basically this:
((-5 < y) < 5)
that then get's evaled this this:
(true < 5)
and that doesn't make sense

raw kindle
raw kindle
polar acorn
# raw kindle yes

So, just to make sure, you want to run this loop over Classes.Ship.list[i].Object_List until you find any element whose type is not "Glue", then exit, right?

polar acorn
#

right?

raw kindle
polar acorn
#

that's the entire point of the middle parameter of a for loop

raw kindle
#

oh

polar acorn
#

the loop runs until that statement returns false

#

If you want to loop over everything and do something if that thing's type is Glue, just use a foreach with an if statement in it

raw kindle
hollow zenith
#

Why does

    private Vector3 GetMousePosition => MainCamera.ScreenToWorldPoint(Input.mousePosition);

Give different position every other frame?

Origin: (-319.10, -31.11, -10.00) Difference: (-259.77, -7.96, 0.00) MousePos: (-578.87, -39.07, -10.00)
Origin: (-319.10, -31.11, -10.00) Difference: (0.00, 0.00, 0.00) MousePos: (-319.10, -31.11, -10.00)
polar acorn
#

Is your camera moving

hollow zenith
#

Yes, but its uh flashing around

#

since the mouse pos is changing every other frame

polar acorn
#

If the camera moves, the world position your mouse is at also changes

hollow zenith
#

I am trying to use input system Vector as a mouse position to see if that helps.

#

oh

#

I've been following an old tutorial

#

Maybe its outdated?

#

or perhaps I have to setup my camera in a specific way

polar acorn
#

Try logging Input.mousePosition and see if it's actually moving

hollow zenith
#

its not

#
Origin: (28.22, 47.03, -10.00) Difference: (28.22, 47.03, 0.00) MousePos: (56.44, 94.07, -10.00) MouseInputPos: (633.50, 378.00, 0.00)
Origin: (28.22, 47.03, -10.00) Difference: (0.00, 0.00, 0.00) MousePos: (28.22, 47.03, -10.00) MouseInputPos: (633.50, 378.00, 0.00)
#

Hmm, its still flickering.
MainCamera.ScreenToWorldPoint( this part is causing the issue, I probably need to deduct the starting position, or update starting position on each frame as I move the camera.

ivory bobcat
#

Looks like there isn't any problems with the property

hollow zenith
#
    public void OnDrag(InputAction.CallbackContext ctx)
    {
        if (ctx.started) DragOrigin = GetMousePosition;
  
        IsDragging = ctx.started || ctx.performed;
    }

    private void LateUpdate()
    {
        if (!IsDragging) return;

        DragDifference = GetMousePosition - DragOrigin;

        Debug.Log($"Origin: {DragOrigin} Difference: {DragDifference} MousePos: {GetMousePosition} MouseInputPos: {Input.mousePosition}");

        transform.position = DragOrigin - DragDifference;
    }

    private Vector3 GetMousePosition => MainCamera.ScreenToWorldPoint(Input.mousePosition);
ivory bobcat
#

What's the issue? It looks correct where your mouse in world coordinates is changing because your camera is moving.

#

If you want it not relative to the camera position, subtract the camera position from the result and you'll get the position without the camera offset.

hollow zenith
#

I am just not sure why it works in year old tutorial, but not for me.

ivory bobcat
#

Describe what you mean by work and not work?

hollow zenith
#

In the tutorial it drags the camera without flickering

ivory bobcat
#

If you're referring to the coordinate changing because your camera is moving, it's got nothing to do with versions

hollow zenith
#

in my case it changes position every second frame

#

Yeah, but the code in the tutorial works, but doesnt for me.
Even tho I did everything the same(I think codewise at least), so what could be different?

Trying to mess with z index of the mouse output based on some comments under that video.

#

I know its not the solution, but just want to see whats wrong <_<

ivory bobcat
#

Sounds like the ui isn't updating quickly enough or possibly desynchronized movement (physics step vs update)

hollow zenith
#
Origin: (746.02, 203.33, -10.00) Difference: (54.99, -40.52, 0.00) MousePos: (801.01, 162.81, -10.00) MouseInputPos: (527.50, 402.00, 0.00)
Origin: (746.02, 203.33, -10.00) Difference: (-177.28, 123.73, 0.00) MousePos: (568.74, 327.06, -10.00) MouseInputPos: (529.50, 403.00, 0.00)

You can see MousePos changing by a large amount every 2nd frame, I am using LateUpdate as in the tutorial.
I just dont know why it works for the guy in the video, but not me ๐Ÿ˜„

ivory bobcat
#

It is teleporting randomly. Not sure what you're seeing

hollow zenith
#

not randomly

#

you can see log output

ivory bobcat
#

I don't know what you mean by not working so I can't help you.

hollow zenith
#

mousePos x: 801 then 568 next frame.

#
    public void OnDrag(InputAction.CallbackContext ctx)
    {
        if (ctx.started) DragOrigin = GetMousePosition();

        IsDragging = ctx.started || ctx.performed;
    }
#

new input system -> Button -> Right mouse button

timber tide
#

could probably lerp it as a bandaid

hollow zenith
#

I will find/figure out a better solution, I am just trying to figure out why the video tutorial works, but not when I try it on my side

#

I must be doing something wrong, or my unity version is different from that video <_<

timber tide
#

ya sure it's not local to what you're dragging

hollow zenith
#

I attached this script to camera

timber tide
#

if (ctx.started) DragOrigin = GetMousePosition;
This doesn't cache if that matters since you're always getting a new point each time it's accessed

ivory bobcat
#

Maybe instead of converting into world coordinates just add the difference? position -= delta

hollow zenith
#

I think ctx.started happens only once on mouse down?

#

It seems to be the case if I hold mouse and drag far the "difference" gets higher

timber tide
#

oh, right it only should do it once

ivory bobcat
#

As your camera is moving in the world, you'll get teleporting

timber tide
#

LateUpdate is interesting but most dragging ive done is through IPointerDrag

dim bridge
#

Hello, is anyone willign to explain the axis controls for rotating character joints in better depth to me or link me to an explanation. It seems confusing and like it sometimes defys being a direction or rotation (im guessing it is due to it being local to the object transform)

hollow zenith
#

This solution from that video comments almost fixed the issue:

  private Vector3 GetMousePosition()
  {
      Vector3 MousePos = Input.mousePosition;
      MousePos.z = 10;
      return MainCamera.ScreenToWorldPoint(MousePos);
  }
#

Since my camera is at z -10

ivory bobcat
#

Things to consider Move Mouse Update Camera Position (The mouse is no longer at the assumed world location as the camera has moved) etc

ember tangle
#
{
        
    if(collision.GetComponent<BoxCollider2D>())
    {
        BoxCollider2D boxColliderCollision = collision.GetComponent<BoxCollider2D>();
        
        if(boxCollider.size.x > boxColliderCollision.size.x && boxCollider.size.y > boxColliderCollision.size.y)
        {
            _resetOnDrop = true;
        }
    }/**/

}```
Is there a reason that this if statement is not working?
timber tide
#

define not working

rich adder
ivory bobcat
#

If you just offset the camera position by mouse position in screen space, it'll not change bizarrely

rich adder
#

also collision..GetComponent is prob wrong, you prob just want collision.collider

ember tangle
fathom frigate
#

One message removed from a suspended account.

eternal falconBOT
rich adder
#

make sure you code editor is showing you these syntax errors

timber tide
hollow zenith
#

I think that I should be able to do it with just detecting mouse pos and moving camera based on that value.(difference between origin + camera pos)

timber tide
#

IPointerDrag can be used on anything, but your issue is more related to the camera anyway

hollow zenith
#

if camera is at 0,0,0 and mouse origin at 20, 20, 0 then I move mouse to 30, 20, 0. It should move camera to 10, 0,0

#

I think thats the logic.

short hazel
short hazel
#

It's the parameter name

#

Wrongly named

vale geode
#

hello im having a nullreferenceException problem and i dont know exacly how to solve it

rich adder
#

ahh wops that threw me off

#

mb then ๐Ÿ˜…

ember tangle
#

half the time I use the documentation and am told it is wrong tbh

ivory bobcat
timber tide
#

it's only wrong half the time

short hazel
rich adder
#

lol yea , no wonder collider.GetComponent wasn't throwing error for them

hollow zenith
timber tide
#

also if you are doing multiple dot access operations, then debug left to right.

ivory bobcat
#

Without all the fancy stuff it's practically just cs transform.position -= dragDifferenceInScreenSpace;

hollow zenith
#

Yeah, I will try that

#

Why in screen space tho?

#

Shouldnt it be in world space?

ivory bobcat
#

Use a scalar if you're wanting to decrease or accelerate the camera movement.

hollow zenith
#
 private Vector3 GetMousePosition => MainCamera.ScreenToWorldPoint(Input.mousePosition);
ivory bobcat
hollow zenith
#

Ah I really need to learn about screen/view/world positions -_-

#

I get the idea, but not enough to understand what I am doing lol

timber tide
#

OpenGL but similar concepts

hollow zenith
#

Thanks

final kestrel
#

Is there any way to increase the time we spend on loading screen? Right now it happens in an instant and I cannot even read what it says on the screen. Also cannot event properly see my progress bar doing its job.

hollow zenith
#

oh so just ising Input.mousePosition already made a huge difference.

#

The dragging is wrong, but its not flickering anymore

hollow zenith
#

Well its actually very wrong if I move away from 0,0,0

final kestrel
ivory bobcat
rich adder
final kestrel
timber tide
#

I add a minimal second delay

#

lerp in and out

final kestrel
rich adder
#

pretty much

hollow zenith
rich adder
#

yeah that too ^

hollow zenith
#

Actually a lot of games do that

#

civ5, warcraft3

final kestrel
#

Like I was wondering if i could like see the progress bar going.

rich adder
#

cyberpunk to

eternal needle
final kestrel
#

I do the loading stuff in coroutines

ivory bobcat
final kestrel
eternal needle
#

Should be pretty trivial to implement since you're already using coroutines here

final kestrel
#

I guess as you said, I can just do an artificial wait then

#

I was not expecting the loading and transitioning between scenes to be this hard

hot palm
#

Is it better to have a lot of scenes or as few scenes as possible? Also, how would you manage scenes in an optimized way? This will become messy with more than 10 scenes, no?:

ivory bobcat
final kestrel
#

Oh also. I need to keep some of the manager stuff persistent regardless of the scene. Should I make a seperate scene and like keep it loaded all the time? I

final kestrel
hot palm
#

Are loading and changing a scene two different steps?

hollow zenith
#
    public void OnDrag(InputAction.CallbackContext ctx)
    {
        if (ctx.started) DragOrigin = Input.mousePosition;

        IsDragging = ctx.started || ctx.performed;
    }

    private void Update()
    {
        if (!IsDragging) return;

        DragDifference = DragOrigin - Input.mousePosition;
        transform.Translate(DragDifference * Time.deltaTime * DragSpeed);
        DragOrigin = Input.mousePosition;
    }

Going back to my problem.
This "works", I just need to set DragSpeed to 200 for it to be usable, but it works well.

#

Actually removing Time.deltaTime works perfect at 1 drag speed.

hot palm
#

isn't moving in Update bad and should be done in fixed update?

final kestrel
ivory bobcat
rich adder
hot palm
#

Oh I see, should really look into to while im jamming this game jam

hot palm
#

Correct me if I'm wrong

queen adder
#

private void Start()
{
    //isGameActive = true;
}

private void Update()
{
    // Check for the Escape key press
    if (Input.GetKeyDown(KeyCode.Escape))
    {
        PauseMenu();
    }
}

public void MainMenu()
{
    SceneManager.LoadScene(0);
}

public void Play()
{
    SceneManager.LoadScene(1);
}
public void Resume()
{
    pauseMenu.SetActive(false);
}

public void PauseMenu()
{
    pauseMenu.SetActive(true);
}

public void Quit()
{
    Application.Quit();
}``` 

Anybody have any idea why my buttons in my canvas are unclickable? The same UI in my main menu scene works but not here?
rich adder
rich adder
#

the order should always be, background elements go top of hierarchy for UI (last = drawn above)

#

or on Image component disable the Raycast Target

ember tangle
#

Everything is fixed, learned much, do not what I would do without this discord ๐Ÿซก

queen adder
#

isnt working

hot palm
#

I almost threw a tantrum when my sliders had weird hitboxes once. Turns out canvas objects fuc with that stuff. Playing around with it in another scene for like an hour made a lot clear

rich adder
#

your event system is disabled..

#

thats probably why

queen adder
#

it is disabled

hot palm
#

xD

#

btw is both input system required for using an event system?

queen adder
#

ffs its always the most stupid things i waste 5 hours on

rich adder
#

tru

hot palm
#

Had error code telling me envent system runs with old input system, when I only used the new ne

hot palm
#

Yea

rich adder
#

Input module

hot palm
#

Input.GetKey

queen adder
#

yh i think both require eventsystem

rich adder
#

Input Modules requires upgrade when using new Input System

hot palm
#

I see, is that built in or do I have to change it myself?

rich adder
#

regardless event system is needed for canvas raycaster

rich adder
hot palm
#

Wait a sec Ill show u

ornate lynx
#

is it normal that when i press a button, unity does detect it but sometimes does what it's supposed to do and sometimes not?

rich adder
#

we don't know what "normal" is without context

hot palm
ornate lynx
#

is it frequent?

hot palm
#

Had multiplie UI Elements bugging my sliders or buttons

ornate lynx
#

except this is not happeneing with ui

rich adder
#

what is the actual issue in the code?

hot palm
rich adder
#

you have code using one input system while having player settings to another setting

hot palm
#

Yeah the event system uses the old input system

#

Is there a new event system?

ornate lynx
rich adder
#

this error is nothing to do with the event system

#

it tells yu Input.GetButtonDown

hot palm
#

True I misread

#

Thought this is in the event system

rich adder
#

You cannot use Input class if you have new input system selected in player settings

#

unless you had Both on (not ideal)

hollow zenith
#

Is there a way to get camera x,y position to stay consistent even after changing camera ortographic size?

hot palm
#

There is no InputSystemUIInputModule tho

rich adder
hot palm
hollow zenith
#
    private void Update()
    {
        if (!IsDragging) return;

        DragDifference = DragOrigin - Input.mousePosition;
        transform.Translate(DragDifference * DragSpeed);
        DragOrigin = Input.mousePosition;

        if (transform.position.x < 0) transform.position = new Vector3(0, transform.position.y, transform.position.z);
        if (transform.position.x > 2200) transform.position = new Vector3(2200, transform.position.y, transform.position.z);
        if (transform.position.y < 0) transform.position = new Vector3(transform.position.x, 0, transform.position.z);
        if (transform.position.y > 3000) transform.position = new Vector3(transform.position.x, 3000, transform.position.z);

        MainCamera.orthographicSize += 1;
    }

I am trying to lock the camera within certain bounds, so when I drag it, you cant go beyond those points(hardcoded for now)
But when you change its size, camera x,y wont match my previous setup.

Camera 0,0 is no longer bottom left corner of my worldmap, the corner becomes like 250,300 after resizing camera bit.
So if I force the corner to 0,0 the camera will leave the worldmap bounds.

ornate lynx
rich adder
#

they don't have much meaning, try using variables

ornate lynx
#

here's how i calculated the differences

hot palm
#

Is this on a canvas? you could try to make it scale with screen (camera) size

hollow zenith
#

Thats for me?

ornate lynx
ivory bobcat
hot palm
rich adder
carmine sierra
#

I have an issue with the mouse position being captured incorrectly when I load the scene which requires the mouse position to be captured. but when testing the scene in isolation, the mouse pos capturing feature works properly. This is probably because my camera position changes between the two scenes, but as the scene's camera is used for taking the position (not the previous scene's cameras), I don't know why it doesnt work

ornate lynx
#

wait, i just had an idea, what if i could make a 3x3 grid around the tree, and for every cel the player is in, a different animation is played

ornate lynx
#

i should be payed for this

hollow zenith
# hot palm You can reference the transform component of the camera

I already reference it I think, in my code above, but camera x,y change when you resize it(if I try to keep my camera stuck to the bottom left corner of my world map)
Is there a way to work with that?
Maybe I need to update camera position.
I think camera pivot might help, so when its resized its stuck to the bottom left.(not sure if thats the way tho, but its a start)

hot palm
ornate lynx
hot palm
#

You could make it static then

carmine sierra
#

SCENE CHANGE AND CAMERA CHANGE -> MOUSE POSITION NO LONGER BEING CAPTURED CORRECTLY

hot palm
hollow zenith
hot palm
#

Check how much the camera should be moved when changing the size by 1 and add that to the x and y

hollow zenith
#

So camera cant go outside of 0,0(bottom left), but after resizing the camera ortographic size, 0,0 is no longer the same from camera point of view(because its origin/pivot is in the center?)

#

Let me try that, I was hoping for a more automated way, but its a good start ๐Ÿ˜„

#

540.2 size is "perfect" size that match my worldspace canvas at 0,0

hot palm
#

Then have a script do something like
int size = (int)[GetSize]; (you need to implement GetSize)
float x = someValues * size;
float y = someOtherValues * size;
this.transform.Translate(new Vector2(x,y));

hollow zenith
#

yes this will get complicated, I cant calculate the size properly, even manually <_<

#

Can I/should I add collider to camera?

hot palm
#

Only if you want it to get stuck

hollow zenith
#

I can use that to detect if camera left map bounds

hot palm
#

Or to make it trigger something

#

Yeah

hot palm
hollow zenith
#

Tbh I am surprised that there areny many guides on camera drag, I remember looking for it in the past and its the same stuff.
No one needs camera drag in their games? ๐Ÿ˜ฎ

hot palm
#

You could try some cinemachine tricks

hot palm
#

You would think it'd automatically install while restarting the editor tbh

ancient trench
#

why people always uses vector3 while creating character rotation? if it is 2d platformer for example

#

why we cant use vector2? why we need z

rich adder
hot palm
#

To turn it sideways?

ancient trench
hot palm
#

Like tripping

slender nymph
#

Well for starters in 2d you are rotating around the z axis

hot palm
#

Yep

ancient trench
#

but isnt z a depth

hot palm
#

Z axis is actually the best as you won't ever lose sight of your 2D characters regardless of the z rotation

rich adder
#

you only use a float if you use rigidbody which is prob how you should move/rot character

#

no v3 needed

hot palm
#

It's about rotation

#

I mean if a ball is rolling in 2D it's rotating around the z axis

rich adder
hot palm
#

If you rotate around x or y you can't see them near -90 and 90 degrees

ancient trench
#

okey next question

hot palm
rich adder
#

made plenty of faux 3d topdowns by using the Y axis as camera forward

#

so plane was Z,X

hot palm
#

But you will always move on the 1 and 2 axis, while rotating around the 3 axis

rich adder
#

rotating on Y

ancient trench
#

why we using vector 3 while turning character sideways? ```private void Turn()
{
Vector3 scale = transform.localScale;
scale.x *= -1;
transform.localScale = scale;

    IsFacingRight = !IsFacingRight;

}```

#

for example here

hot palm
#

I would use flip sprite

ancient trench
#

just cause localscale is vector3 by default in unity?

rich adder
rich adder
#

V3 and V2 can be plugged in the same

ancient trench
#

i mean i just wanna know WHY we use vector3 in turning 2d

rich adder
#

they just can't be in the same operations

ancient trench
#

only because scale is vector3 by default kk, ty

rich adder
#

so it only makes sense rotation happens in that axis

hot palm
#

Well I don't know how thin a 2D character is, but if the Z axis is 0 it wouldn't be visual

rich adder
#

but again since its 3D engine you can rotate on Y axis and still get a flip effect (side scroller flip)

rich adder
slender nymph
rich adder
#

the only differences is 2D uses box2D for physics and 3d uses physix (so obviously you cannot mix match colliders / rbs)

#

but they pretty much have the same method thanks to unity's api

hot palm
#

Don't they work the same just forgetting about the 3rd dimension?

ornate lynx
rich adder
#

hence why Rigidbody2D has no Vector2 for rotation

#

there is only Float needed for rotating 2D

ancient trench
rich adder
rich adder
#

but typically you are doing it on Z axis

#

because the default view is Looking in the Z+ direction

ancient trench
#

i tried to represent this

#

like i and -i are moved

rich adder
#

unity inspector uses Euler angles, and so should the methods you use . Unless its a rigidbody 2D which again you need Float

ancient trench
#

okey

#

ty a lot

steady lichen
#

hello can someone help me figure out why these things wont show up? im trying to follow a tutorial and this isnt mentioned in the tutorial

eternal falconBOT
steady lichen
#

thank you very much

steady lichen
#

So after looking around a bit it seems like i dont have unity api to use its IntelliSense

#

i dont fully know why i dont have unity api since i installed from unity and my code even says its using the unity engine

north kiln
#

What does that even mean

#

Configure it by following the steps in the above link for your individual IDE and it will work.

steady lichen
#

ill try to follow it again

#

but from my understanding intellisense is what this is and it requires unity api

#

idk if that made anymore sense ๐Ÿ’€

north kiln
#

It doesn't

#

There is no such thing as requiring/having an api

steady lichen
#

oh

#

well dang ๐Ÿ˜ญ

#

that was just the little info i gathered from the link

north kiln
glass ivy
#

how do i paste code blocks?
''' public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
Object prefabSource;
SerializedProperty prefabProperty;
prefabProperty = property.FindPropertyRelative("prefab");
EditorGUI.BeginChangeCheck();
{
prefabSource = null;
EditorGUI.BeginProperty(position, label, property);
// Draw the prefab field
EditorGUI.BeginDisabledGroup(true);
EditorGUI.ObjectField(position, label, prefabProperty.objectReferenceValue, typeof(Poolable), false);
EditorGUI.EndDisabledGroup();
if (GUILayout.Button("Store Prefab")) {
var targetObject = property.serializedObject.targetObject;
prefabSource = PrefabUtility.GetCorrespondingObjectFromOriginalSource(targetObject);
}
EditorGUI.EndProperty();
}
if (EditorGUI.EndChangeCheck()) {
Debug.Log($"set by hand");
Debug.Log($"auto set {prefabSource}");
prefabProperty.objectReferenceValue = prefabSource;
}
}'''

north kiln
#

you've been here for years, why is this a question now? !code

eternal falconBOT
steady lichen
glass ivy
#

i always used a pastebin

#
//nice```
sullen epoch
steady lichen
#

im new to coding so i dont fully understand what that means ๐Ÿ˜ญ

#

but the code does say monobehavior

sullen epoch
#

Can you share your entire VS Code Window?

steady lichen
#

sure where is that

sullen epoch
#

The IDE youโ€™re using

#

Where youโ€™re writing your script

north kiln
#

That looks like VS, not VS Code, but I might be mistaken

steady lichen
#

like this? its on visual studio 2019 btw

north kiln
fiery notch
#

https://hatebin.com/wziljhqdll looking for a small fix, in my code I have different movespeeds for 4 states, in the air, sprinting, walking, and crouching. Everything is working fine, except my player is not switching to the crouch speed that is set when I hit the crouch key. The crouch happens still, but the state doesnt switch to crouching in the inspector.

steady lichen
#

is this what you mean

north kiln
#

No. You would know what it was if you followed the instructions

steady lichen
#

it doesnt say vs anywhere but i just searched external tools in visual studio and foudn it

teal viper
sullen epoch
steady lichen
steady lichen
#

thank you both for your help ๐Ÿ™

#

and sorry vertx i guess i missed some stuff ๐Ÿ˜ญ

#

i assumed that since i already installed visual studio through unity i could skip that first section and went to whatever looked like my problem

north kiln
#

Next time don't just randomly skip instructions

steady lichen
#

i will and sorry again

sullen epoch
# fiery notch https://hatebin.com/wziljhqdll looking for a small fix, in my code I have differ...

Inside of StateHandler there are two if statements, the first if statement will check if the crouch key is pressed and override the โ€œstateโ€ variable to crouching. The next if statement, then does a few more checks and overrides the โ€œstateโ€ and move speed variables to something else. Iโ€™m not sure this will solve your problem entirely however it may fix the issue of the state not updating in the inspector

#

Inside of the StateHandler Function

kind sail
#

Quick question, If i need to have a killzone that resets multiple peoples positino on trigger how woudl i do that? thanks

sullen epoch
kind sail
#

one person triggers it and everyone resets

sullen epoch
#

Ah then I would recommend looking into Unity Events, here Iโ€™ll post a good video, gimme a sec

kind sail
#

thanks!

sullen epoch
kind sail
sullen epoch
#

Yes

kind sail
#

alright thanks

fathom frigate
#

One message removed from a suspended account.

scarlet skiff
north kiln
eternal falconBOT
north kiln
teal viper
scarlet skiff
#

it shouldnt be null

scarlet skiff
north kiln
#

This could also occur if you created an instance another way, or already had one in the scene.

scarlet skiff
#

but it doesnt

scarlet skiff
#

but there wasnt a second instance

north kiln
#

How are you confirming that there's not a second instance of MagicBall in the scene that wasn't created by Wizardy?

#

You could also destroy the Movement instance to cause this exception

scarlet skiff
#

oh u meant second instance of magic ball

#

oh there is a second

scarlet skiff
#

only change is giving it a reference with getCOmponent in start() in wizardy

north kiln
scarlet skiff
#

wait no, there shouldnt be other gameobject woith wizardy

#

my mistake

#

only wizardy script can create magic balls and only mages have that script, and there are none of them in the scene, they get spawned in

north kiln
#

Then pull out the debugger and take a look at what's happening or not

frigid sequoia
#

How do... I get a collision normal? is that a thing?

#

I know it is for raycast

teal viper
#

I bet code running in prefabs is involved somewhere.๐Ÿ˜ฌ

north kiln
#

The info gets passed into the event

scarlet skiff
north kiln
sleek orchid
north kiln
sleek orchid
sleek orchid
frigid sequoia
#

Like I this for a laser that bounces out of walls, it send a raycast to see where it should stop expanding and then at the normal of the wall detection it sends another bounce. Now I want to do this but for bullet instead of continuous laser so it has to happen at the collision with the wall getting the normal of the collision but no idea from where to get that

#

Is that even possible?

north kiln
frigid sequoia
timber tide
#

collisions have points that have normals

north kiln
frigid sequoia
#

I am actually using OnTriggerEnter, is that an issue?

north kiln
#

Trigger events don't have normals, no

timber tide
#

You dont have points with trigger so raycasts is still the idea

#

with closest point method I think?

#

it's probably more accurate to just raycast ahead honestly (well, I guess if it gets hit on the sides then maybe the ray wouldn't be ideal)

frigid sequoia
#

So.... I should send a raycast just before the collision?

carmine sierra
#

Hi guys, I made a grid and want a way for objects which are following the mouse to follow within the constraints of the grid. I have asked this many times before but I really am not at the stage where I know how to progress after implementing the sized grid, any pointers or ideas would be appreciated

timber tide
#

probably should give some idea of your implementation

#

or what you have done so far with your grid

scarlet skiff
#

this is the debug in magicball script

north kiln
#

Note how that one is not a clone

scarlet skiff
#

hmm it used to be, i tried to improve the code but here we are

#

thats a good lead i suppose

carmine sierra
# timber tide or what you have done so far with your grid

just made a grid with a correct size, I will have a placeholder which follows the mouse along the grid and will lock to the grid, the placeholder is 5 grid squares tall and one grid square wide. then when the user clicks the mouse, it will place an object at that point. I have implemented everything, apart from the locking to the grid mechanism

scarlet skiff
#

wait actually.. what does that tell us?

#

shouldnt it be a close everytime i instantiate

#

does that mean its like... trying to access the prefab or somewthing

timber tide
carmine sierra
#

I dont know though I'm just aiming for the easiest solution

teal viper
carmine sierra
timber tide
#

Oh, ok that helps then

#

You just want to snap stuff to the grid indices

astral falcon
timber tide
#

yeah, just need to find closest point and then have the object just appear in the middle of the cell

carmine sierra
astral falcon
carmine sierra
#

is there no way to leverage my already in place grid

carmine sierra
#

that makes sense to me although never rounded in c#

astral falcon
#

You might have to refactor your grid script to use round, because rounding is just math to the closest full number. so 1,2,3,4 and so on. But I guess, your grid might be some fancy .5 or whatever number?

frigid sequoia
#

If I send a raycast in the same frame that the OnTriggerEnter triggers, would it detect the collision or would it pass trough?

astral falcon
carmine sierra
frigid sequoia
carmine sierra
astral falcon
summer stump
astral falcon
frigid sequoia
carmine sierra
timber tide
#
 public Vector3Int GetTileIndexFromWorldPoint(Vector3 worldPoint)
{
    Vector3Int index = Vector3Int.zero;

    var localPoint = transform.InverseTransformPoint(worldPoint);
    var chunkIndex = GetChunkIndexFromWorldPoint(worldPoint);

    localPoint.x -= (chunkIndex.x * tilesPerChunk.x);
    localPoint.y -= (chunkIndex.y * tilesPerChunk.y);
    localPoint.z -= (chunkIndex.z * tilesPerChunk.z);

    index.x += (int)(localPoint.x / tileScale.x);
    index.y += (int)(localPoint.y / tileScale.y);
    index.z += (int)(localPoint.z / tileScale.z);


    //We should probably check valid index bounds eventually just incase of percision errors


    return index;
  }

Some code from my voxel thing I was making with grid but similar idea to how to get the index

teal viper
summer stump
timber tide
#

Oh, ignore the chunk stuff though

carmine sierra
frigid sequoia
astral falcon
carmine sierra
sullen epoch
astral falcon
timber tide
# frigid sequoia It is a trigger cause the bullets don't have any physics, so they just detect tr...
void RicochetAbility(Collider currentHitCollider)
{
  Vector3 collisionPoint = currentHitCollider.ClosestPoint(transform.position);
  Vector3 normal = (transform.position - collisionPoint).normalized;
  Vector3 direction;
  
  //Kind of a bandaid as if the position and contact are too close then the normals zero out
  if(normal == Vector3.zero)
  {    
      direction = -transform.forward;
      hitRotation = Quaternion.LookRotation(-transform.forward, Vector3.up);
  }
  
  else
  {
      direction = Vector3.Reflect(transform.forward, normal);
      hitRotation = Quaternion.LookRotation(direction, Vector3.up);
  }
}```
Here's my implementation I've done quite a while ago using triggers only but you can see that comment there which has some problems
frigid sequoia
teal viper
sleek orchid
#

I've tried to make a text be constantly changing color, but it doesn't seem to be working, any idea?

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

public class FontColor : MonoBehaviour
{
    public CanvasRenderer Renderer;
    public float timerStart = 2.0f;
    private float repeat = 2.5f;

    void Awake(){
        InvokeRepeating("changeColor", timerStart, repeat);
    }

    void changeColor(){
        Renderer.SetColor(new Color(Random.Range(0, 255), Random.Range(0, 255), Random.Range(0, 255)));
    }
}
#

It just goes back to white ๐Ÿ†’

frigid sequoia
#

Like image 1 instead of 2?

timber tide
#

Im pretty sure I got some of the info from the unity forums and I had it working

sullen epoch
frigid sequoia
#

Or I am just dumb?

undone harbor
#

Do you guys use Cinemachine for camera? Or create your own, that looks at player at all times, and can move too?

sleek orchid
#

!docs CanvasRenderer.SetColor

eternal falconBOT
sleek orchid
#

NAVARONE!

#

ey ๐Ÿ™‚

sleek orchid
undone harbor
sleek orchid
#

I want the "Brick Breaker" to be changing color

rich adder
#

tweening

sleek orchid
rich adder
frigid sequoia
sullen epoch
#

you could just change your random.range to 0f, 1f instead since these are normalized values. this is a very simple solution and wouldn't allow for much customizability though. so i would recommend doing further reasearch.

astral falcon
frigid sequoia
timber tide
# frigid sequoia Is that how you get a normal? Wouldn't that make that it always bounces off in t...

Ok, I booted up and was testing and you're right that it should give me the direction back towards the projectile, but because of the nature of the primitive colliders I was using the hit is never dead-on so it kinda works. The raycast however is the better idea because you do need that surface info usually. I was doing a bunch of things like just assuming my hit was always being reflected as an angle and other things to try to get around not using raycasts.

#

Other problems I had using raycasts though is you need to cast it a little more behind the projectile otherwise you wont hit what's in front of you. Rather I was having clipping issues a bit without moving it back.

undone harbor
# astral falcon Depends on the project.

I usually see two kinds of cameras. One that only points at the player, but can move in a sphere ig. Another that does not move, but you can look at something beside the player. Which one do you use?

frigid sequoia
timber tide
#

raycast is instant when you query it

sleek orchid
# rich adder Color32 is 0-255

I tried notlikethis

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class FontColor : MonoBehaviour
{
    public CanvasRenderer Renderer;
    void Update(){ 
        Color objectColor = new Color(Mathf.Lerp(0, 255, Random.Range(0, 1)), Mathf.Lerp(0, 255, Random.Range(0, 1)), Mathf.Lerp(0, 255, Random.Range(0, 1)));
        Renderer.SetColor(objectColor);
    }

}
#

Does not work

#

I dont understand what I am doing

#

The text turns black :/

frigid sequoia
rich adder
frigid sequoia
astral falcon
#

But you are resetting your color every frame in update

rich adder
#

that lerp is completely wrong

sleek orchid
rich adder
#

also still doing 0-255 is still wrong for Color

#

its not 32 bit but float 0-1

astral falcon
timber tide
rich adder
#

or just download Dotween and lerping colors is like 1 method, just random change the color you want to fade into @sleek orchid

timber tide
#

I just had issues on really fast projectiles and doing ricocheting logic (ive seen it done really nice though so I must been doing something wrong)

sleek orchid
#

Funny... Why do they use this is the documentation? Mathf.PingPong(Time.time, 1)

#

Why not only 0, 1?

timber tide
#

Raycasts in general just better for small/quicker projectiles from my experience

rich adder
astral falcon
#

Raycast is just a collision check without any projectile similarity

scarlet skiff
#

wait i should prob have one when attacking as well

frigid sequoia
#

At the very worst I could just literally instantiate the new proyectile with the rotation of the previous one with an offset of 90 or -90 on the Y axis, since the game is basically on a 2D plane

sleek orchid
rich adder
#

also its a property not a component

sleek orchid
#

I was overcomplicating, I had a read and I think I will be able to do it now

#

hiihi

#

Thanks, m8 โค๏ธ

scarlet skiff
#

nvm i think i found the problem

vale karma
#

I found a solution to the lambda stuff from a few days back,

    void AddCards()
    {
        for (int i = 0; i < cards.Length; i++)
        {
            Instantiate(cards[i], gridLayoutEmpty.transform);
            var local = cards[i].gameObject.GetComponent<Image>();
            MyAction += () => { CardList(local); }; 
        }
    }

    void CardList(Image local)
    {
        cardList.Add(local);
    }
}

now i can use and compare the sprites much easier ๐Ÿ˜›

rich adder
astral falcon
#

๐Ÿ˜„ You just made a little spaghetti function for the same result in your lambda ๐Ÿ˜‰

vale karma
#

unaccepttaaaaabbaaaleeeee!!!!

#

I kept feeling like i was rewriting the same thing in a different way, but idk how

north kiln
vale karma
#

The more i think about the more editor friendly having the sprite show/change in the editor, its a memory matching game, so comparing two cards would be ideal. But yea ill look at that

#

it made me more confused :{

rich adder
vale karma
#

Id love to use a scriptable object ๐Ÿ˜ฎ

rich adder
#

makes match comparison that much cleaner

vale karma
#

i want to be able to turn on and off an image, basically the front and back of a card, and when you click on it it flips, waits for a second card, then flips back over if wrong, or stays up if right

#

i watched this doodoo tutorial and a few more with weird, badly formatted ways to code it

rich adder
#

nice made this for a jam a few days ago

vale karma
#

ill play it

#

It demoralizes me that a mechanic this small of a baby card game is tripping me up so bad

rich adder
#

there are many ways to do something thats why

rich adder
misty hedge
#

What's a scriptable object?

swift crag
#

in short, it lets you create your own kinds of assets

#

ScriptableObjects are unity objects, but they aren't components -- they aren't attached to game objects

#

They're much more like a Material

real falcon
#

is there a way to mark an object as not inhereting rotation from its parent

summer stump
#

Or just forego parenting and have the previous child update its position based on the position of the previous parent (if that's the reason you wanted it to be a child)

real falcon
#

hm can I directly override the rotation

#

I seem to be able to set the rotation

#

but not use LookAt

#
            //flashlight.transform.LookAt(hit.point);```
#

top line works but the next just doesn't

#

like it rotates but it doesnt look up or down for some reason

summer stump
#

Have you logged hit.point to see where it is?

real falcon
#

ah its not looking up or down either lol

real falcon
#

wait

#

maybe not one sec

#

ok I think it works :D

summer stump
#

Glad it works. Never really heard back about if you logged the value though... ๐Ÿ˜‚
Probably would have been helpful to know it

supple elbow
#

does anyone know how to make things like auto game saving, like gacha games, and you can login with your google account?

rich adder
supple elbow
rich adder
#

its part of the whole cloud eco system so cloud saving, leader boards etc

supple elbow
#

Ohh I see TYY

clever pasture
#

Having some issues with scene loading (first time trying to actually switch scenes, start menu -> game), it doesn't seem to nstantiate a slew of game objects when loading the 'game' scene, but they load fine when running the game scene directly

clever pasture
#

Sorry, working on it lol

#

I dont even know how to drop inline code in here

charred spoke
#

!code

eternal falconBOT
clever pasture
#
 void Update()
    {
        ChangeScene();
    }

    public void ChangeScene()
    {
        if (SceneManager.GetActiveScene().buildIndex == 0 )
        {

            if (Input.GetKeyDown(KeyCode.Return))
            {
     
                StartCoroutine(LoadScene());
            }
        }

       
    }

    IEnumerator LoadScene()
    {
        Scene currentScene = SceneManager.GetActiveScene();
        var myListeners = GameObject.FindObjectOfType<AudioListener>();
        Destroy(myListeners);

        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(gameScene, LoadSceneMode.Additive);
        

        while (!asyncLoad.isDone)
        {
            yield return null;
        }

     //   SceneManager.MoveGameObjectToScene(this.gameObject, SceneManager.GetSceneByName(gameScene));
        SceneManager.UnloadSceneAsync(currentScene);
     

    }
#

So i load my scene with the following code

#

And there is some code used to instantiate a bunch of blocks (Bounds Block game object), in a list called 'BoundsBlocks'

#

function for the block instantiation looks like this

private void InitBoundsBlocks()
    {

   
        int startY = (int)Math.Round(transform.position.y);

        for (int y = startY; y < startY +25; y++)
        {
            for (int x = (int)transform.position.x-1; x < transform.position.x +11; x++)
            {
                if (y == startY|| x == transform.position.x -1 || x == transform.position.x + 10)
                {
                   
                    GameObject bb = Instantiate(boundsBlock, new Vector3(x, y),Quaternion.identity);
                    print("bounds block active? : " + bb.name.ToString());
                    boundsBlocks.Add(bb);
                }
            }    
        }
    }

#

I've confirmed the bounds block code itself runs (that print after the instantiate runs for all 60 iterations as expected)

#

So after scene load, the list shows that it has 60 elements, but all references to the boundsblock game object are missing:

#

It almost seems like the instantiation is happening, but then the game objects are getting destroyed?

#

Too much info, or not enough?

clever pasture
#

I should also say, the print Shown in the InitBoundsBlock code shows the instance actuallly exists in the moment after instantiation, showing a name of "Bounds Block (clone)". So I'm scratching my head a bit here.

timber tide
#

All I could think of is the objects arent being tagged DontDestroyOnLoad but you're loading async (additive) so I'm not too sure

clever pasture
#

Does running instantiate in any of the Start or Update functions imply that they are being created after the load finishes regardless? I don't know myself

timber tide
#

I don't usually load additive so I'm not too sure but worth a shot at tagging em

clever pasture
#

Tagging them?

clever pasture
#

MAybe it wasn't the help you thought you were giving, but you've fixed my problem lol

#

I hella simplified the scene change code so I wasn't doing the additive load stuff or async etc, and... it just works

#
 public void ChangeScene()
    {
        if (SceneManager.GetActiveScene().buildIndex == 0 )
        {

            if (Input.GetKeyDown(KeyCode.Return))
            {

                SceneManager.LoadScene("Game");
            }
        }

       
    }
#

Considering my use case (literally just making a tetris clone to get some practice in), this is probably more than fine

#

@timber tide Thanks

timber tide
clever pasture
#

Always gotta remind myself to Keep It Simple, Stupid.

woven crater
#

whats the diffferent between tilemap.tile and tilemap.tilebase?

burnt vapor
#

TileBase can implement different type of tiles, where Tile implements TileBase as one of these types.

ancient trench
#

what is better, make isOnGround with collisionenter2d or make ray/box below char and checks their collision

sonic dome
#

what is the way to go bout shooting bullets
do i use a ray cast or actual bullet prefab and instantiate?

slender nymph
#

depends on how you want your game to feel. there is no "correct" answer

hexed terrace
#

Instantiated objects get spawned in the active scene, so you're spawning the objects in your menu, then they get destroyed when you unload the menu scene

#

@clever pasture โ˜๏ธ

sonic dome
slender nymph
#

again, there is no single answer to that. it entirely depends on the game. but using raycasts is typically called "hit scan" and actual instantiated bullets is "projectile" so look up your favorite games and see which of the two methods those games use

glad ore
#

` public void OnPointerDown(PointerEventData eventData)
{
rectTransform.sizeDelta = newSize;

}

public void OnPointerUp(PointerEventData eventData)
{
   
    rectTransform.sizeDelta = originalSize;

}`

this is a script to increase size of the button when touched , it does the work , is visibly larger , but it calls onPointerUp method when i drag my touch outside of the older smaller Size ,

astral falcon
glad ore
astral falcon
#

Ah got it, your UI is not reacting to the updated size. Just for curiosity, did you try to use the scale instead of the sizedelta and see if that issue persists?

glad ore
slender nymph
#

it's three backticks for code btw, not just one

astral falcon
hexed terrace
#

three backticks and 'cs' after the top ones

glad ore
#

its visibly scaled 1.5f , but not functionally

hexed terrace
#

"Always" keep UI scale to 1,1,1 .. use the width/ height fields to change the size

astral falcon
astral falcon
golden canopy
#

For some reason after adding new stuff to a level of my game the spawn system suddenly stopped working.
I tried everything i know to attempt to fix it but didn't see what was causing it to fail like this; I tried putting a normal float instead of Delaytime, put WaitForSecondsRealtime, checked if the script was still running when it was triggered but no answer
Did i suddenly do something wrong in the code or is this a matter outside of scripting?
(It stops exactly at waitforseconds, which is usually set to 0.5f)

    IEnumerator SpawnWithDelay(float DelayTime)
    {
        print("Called with delaytime " + DelayTime);
        yield return new WaitForSeconds(DelayTime);
        print("spawning after waiting");
        SpawnWave(1);
        ArenaActive = true;
        if (WillTriggerGlitchOnceDead)
        {
            GameObject.FindWithTag("musichandler").GetComponent<musicHandler>().CanGlitch = true;
            GameObject.FindWithTag("Glitch").GetComponent<CauseGlitch>().CanBeTriggered = true;
        }
    }
astral falcon
golden canopy
# astral falcon how do you start the coroutine?
private void OnTriggerEnter(Collider Collission)
{
    if (!Triggered)
    {
        if (Collission.gameObject.tag == "PlayerCollider")
        {
            if(TriggersArena)
            {
                for(int i = 0; i < DoorsToLock.Length; i++)
                {
                    print("Door locked");
                    DoorsToLock[i].GetComponent<Door>().TriggerArena(true);
                }
                print("spawning with delay");
                StartCoroutine(SpawnWithDelay(0.5f));
            } else
            {
                print("spawning wave");
                SpawnWave(1);
            }
            
        }
        Triggered = true;
    }
}

The prints have confirmed Spawning with delay and Called with delaytime

slender nymph
golden canopy
slender nymph
#

please do not edit the code when sharing for troubleshooting. how could we possibly know if something else is causing an issue? and have you checked your console for exceptions

golden canopy
astral falcon
#

so spawning after waiting is working once?

golden canopy
#

yeah

#

and the second spawn is triggered by a different object with the same script

slender nymph
#

screenshot the entire console window. and make sure that the object you are starting the coroutine on isn't being set inactive or being destroyed

astral falcon
#

On another object? whats the delaytime on that. is delaytime probably public and oyu set it to something higher in inspector?

golden canopy
golden canopy
slender nymph
#

i mean, there are 0 logs after the last (second) time the coroutine is started. are you absolutely certain that nothing is preventing the coroutine from running like the object being disabled/destroyed or the game being stopped?

golden canopy
#

I see nothing in the editor of it being disabled, destroyed and the game isn't being stopped either; I can still freely move around in the game even after it happens

astral falcon
golden canopy
#

normally my pc doesnt really affect it but ig i could try

golden canopy
slender nymph
#

check your code for StopCoroutine calls and put a log in that object's OnDisable method to make sure it isn't actually being disabled

golden canopy
slender nymph
#

and how was i supposed to know that? you've not even bothered sharing the full code for the class isn't working.

slender nymph
#

i see you haven't bothered trying my second suggestion

golden canopy
#

yeah cause i didn't see the logic in it if there was no StopCoroutine in the failing class

slender nymph
#

StopCoroutine has nothing to do with an object being disabled

#

so if you're just not going to follow troubleshooting instructions, i'm just not going to attempt to help you further

golden canopy
#

Look i have a brain the size of a peanut is this what you wanted me to do; this is what happens when i put an onDisable in the said script

slender nymph
#

wow crazy how i was right all along that the object is being disabled

golden canopy
#

no need to rub it in

crude prawn
#

lmao @golden canopy why are you so pressed you got an issue and hes just trying to help you

vocal marlin
#

https://paste.myst.rs/n10vqxym

yesterday i tried to split a script into two parts as it was getting too big, but this caused some problems; two line of code aren't working properly
the lines are spriteHeight = spriteRenderer.transform.localPosition.y; which just isn't doing it and Debug.Log((int)entityHeight); which is always inputting zero when that's just blatantly wrong. Both of these lines are in the new PlayerHieghtEntity script.
saying this again as i can't figure out the problem

rapid mountain
#

but try what was suggested so we can identify the problem

slender nymph
#

the problem was already identified. they are deactivating the gameobject somewhere

golden canopy
#

cause as i said, my brain's the size of a peanut

thick tartan
#

I'm trying to render particles on a "render texture" and I want to make it transparent.

How can I make this texture transparent?
I want to change the alpha value but I can't find it.

#

This is how the render texture is with my camera set to alpha 255.
The other picture is how the render texture is with my camera set to alpha 0.
The material of the particles isnt transparent so it isnt rendering.

ancient trench
#

i made movement with addforce force and jump with addforce impulse, and now my character is faster when jumping then when he is walking, how can i fix it?

ivory bobcat
#

The floor likely has friction so you'll always fly faster than slide

meager steeple
#

for some reason this isnt detecting the collision, i dont get anything back in the console and im completely stumped. I thought it was because the collider for the enemy tag doesnt actually touch the player, but when i set it to a trigger, nothing changed

public class EnemyCollision : MonoBehaviour
{
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.transform.tag == "enemy") // checks for collision with specific tag
        {
            Debug.Log("collision");
            HealthManager.health--; // calls health from other script
            if (HealthManager.health <= 0 ) // checks if health is 0 or less
            {
                // game over screen

            }
            else // player is not dead
            {
                StartCoroutine(GetHurt());
                HealthManager.health -= 1; // reducing health by 1
            }
        }
        IEnumerator GetHurt()
        {
            Physics2D.IgnoreLayerCollision(8, 9 , true); // ignoring collisions between 2 layers
            yield return new WaitForSeconds(3); // 3 second timer
            Physics2D.IgnoreLayerCollision(8, 9 , false); // stops ignoring collisions between 2 layers
        }
    }
}```
slender nymph
#

also you should be using the CompareTag method rather than string equality when checking an object's tag

meager steeple
#

well i was copying a youtube video and it seems to be working for them

slender nymph
#

that doesn't mean it's correct

ivory bobcat
thick tartan
hexed terrace
meager steeple
# slender nymph also you should be using the CompareTag method rather than string equality when ...

i have this now

private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("Enemy")); // checks for collision with specific tag
    {
        Debug.Log("collision");
        HealthManager.health--; // calls health from other script
        if (HealthManager.health <= 0 ) // checks if health is 0 or less
        {
            // game over screen

        }
        else // player is not dead
        {
            StartCoroutine(GetHurt());
            HealthManager.health -= 1; // reducing health by 1
        }
    }```
and its thrown up 222 warnings
slender nymph
#

and what do they say?

meager steeple
#

possible mistaken empty statement, and then about 200 of them say "the referenced script (unkown) on this behaviour is missing"

#

wiat a minute

slender nymph
#

yep, do you not see the squiggly line in your IDE?

meager steeple
#

yeah i had a ; after the if statement

#

got rid of it but the warnings havent disappeared

#

well the first has one not the rest

slender nymph
#

the rest of the warnings are not related to this code. you either have a compile error that broke some of your components or you renamed or moved a component without its meta file being updated too

meager steeple
#

ffs i literally didnt move anything

#

ok i think i got it

naive lion
#
            {
                canShoot = true;
            }```

is this the correct way to check a rotation has been met
hexed terrace
#

no, a rotation axis is a float, it's highly unlikely you'll ever get an exact match, when rotating between two rotations

naive lion
#

what would be the best approach to checking this via a float

#

to allow for a rounded reading

undone rampart
#

it depends on the context

naive lion
#

the player is rotating the cannon to a max (or "desired") rotation
upon reaching this rotation on the Z, they can shoot

#

mouse movement

#

the cannon will also lock in position

#

interactive cutscene ig

slender nymph
#

you almost never want to rely on the eulerAngles for logic. they are interpreted from the rotation quaternion at the time you read them and can be different from what you expect since the same rotation can be represented in a number of ways in euler angles

undone rampart
#

you can try having an invisible collider to where the cannon needs to point and shoot a raycast and lock the canon if it hits that collider

naive lion
swift vessel
#

Hello, while I was trying to build with IL2CPP in Unity, I got a error like this. It wants me to install Visual Studio, but I use vs code and I have never encountered such a problem before.

slender nymph
#

did you scroll down to see what all the options for what you must have installed are?

swift vessel
#

yes

slender nymph
#

then install one of the options because it is required for IL2CPP

swift vessel
#

it want install visual studuo 2017 or newer version

meager steeple
slender nymph
#

does either object involved in the collision have more than one collider?

meager steeple
#

ah yes my player is a circle collider and a box collider

slender nymph
#

two colliders touching another collider == two OnCollisionEnter calls

meager steeple
#

yes i understand that, how do i make it so its only affected by the circle collider

slender nymph
#

either remove the other collider or put it on a layer that does not collide with the other object(s)

meager steeple
#

it looks like just by making the box collider smaller makes it playable

#

thanks

quick cape
#

Hi!
Im following this tutorial:

https://catlikecoding.com/unity/tutorials/mesh-deformation/

I want the mesh to stay in the deformed shape.

At step 4.2, when a force is applied, the mesh starts to deform but I havent found a way to stop the deform without going back to the original shape. Even if I can slow it down it's still moving forever. The only way I made it work was by adding a return in the update but I feel like it might not be optimal (and also it didnt work that well)

I want to be able to deform the shape at runtime cause I'm trying to make a pottery game in VR for a game jam. The way I see it there would be tiny invisible spheres at the tip of the fingers which could deform the shape when theres a collision.

I'm sorry, I've tried to come up with my own answer but I feel like I don't even know where to start and everything I try seems futile because my understanding of the subject is limited.

If anyone could help me with this matter I'd really appreciate it.

Thank you so much! I'll add the code

A Unity C# scripting tutorial in which you will deform a mesh, turning it into a stress ball.

#
using UnityEngine;

[RequireComponent(typeof(MeshFilter))]
public class MeshDeformer : MonoBehaviour {

    public float springForce = 20f;
    public float damping = 5f;

    Mesh deformingMesh;
    Vector3[] originalVertices, displacedVertices;
    Vector3[] vertexVelocities;

    float uniformScale = 1f;

    void Start () {
        deformingMesh = GetComponent<MeshFilter>().mesh;
        originalVertices = deformingMesh.vertices;
        displacedVertices = new Vector3[originalVertices.Length];
        for (int i = 0; i < originalVertices.Length; i++) {
            displacedVertices[i] = originalVertices[i];
        }
        vertexVelocities = new Vector3[originalVertices.Length];
    }

    void Update () {
        uniformScale = transform.localScale.x;
        for (int i = 0; i < displacedVertices.Length; i++) {
            UpdateVertex(i);
        }
        deformingMesh.vertices = displacedVertices;
        deformingMesh.RecalculateNormals();
    }

    void UpdateVertex (int i) {
        Vector3 velocity = vertexVelocities[i];
        Vector3 displacement = displacedVertices[i] - originalVertices[i];
        displacement *= uniformScale;
        velocity -= displacement * springForce * Time.deltaTime;
        velocity *= 1f - damping * Time.deltaTime;
        vertexVelocities[i] = velocity;
        displacedVertices[i] += velocity * (Time.deltaTime / uniformScale);
    }

    public void AddDeformingForce (Vector3 point, float force) {
        point = transform.InverseTransformPoint(point);
        for (int i = 0; i < displacedVertices.Length; i++) {
            AddForceToVertex(i, point, force);
        }
    }```
#
    void AddForceToVertex (int i, Vector3 point, float force) {
        Vector3 pointToVertex = displacedVertices[i] - point;
        pointToVertex *= uniformScale;
        float attenuatedForce = force / (1f + pointToVertex.sqrMagnitude);
        float velocity = attenuatedForce * Time.deltaTime;
        vertexVelocities[i] += pointToVertex.normalized * velocity;
    }
} ```
#

    public class MeshDeformerInput : MonoBehaviour {
        
        public float force = 10f;
        public float forceOffset = 0.1f;
        
        void Update () {
            if (Input.GetMouseButton(0)) {
                HandleInput();
            }
        }

        void HandleInput () {
            Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            
            if (Physics.Raycast(inputRay, out hit)) {
                MeshDeformer deformer = hit.collider.GetComponent<MeshDeformer>();
                if (deformer) {
                    Vector3 point = hit.point;
                    point += hit.normal * forceOffset;
                    deformer.AddDeformingForce(point, force);
                }
            }
        }
    } ```
brave compass
quick cape
#

Honestly it's true it's probably gonna be easier to start from another tutorial,
Thanks!!

clever pasture
rich egret
#

I have a bug, when I look with my camera down, I see the leg of the character...

#

So does anyone know how to fix this?

hexed terrace
rich egret
hexed terrace
#

I doubt that's a camera problem.. it's a setup problem. id:browse to find channels in future, though this question can probably just go in #๐Ÿ’ปโ”ƒunity-talk (after you delete from here so you don't get told off for crossposting)

rich egret
#

ok thanks

atomic yew
#

Hello everyone. My normally running script gets deactivated for no reason. What would be the reason? I know that sometimes there is such a problem on the internet when code is written into the awake function, but when I write code from the awake function into the start function, it is not deactivated, but none of the lines of code work. How can I solve this problem? Thank you very much to everyone who has helped already.

slender nymph
#

check your console for errors and resolve those errors

fathom frigate
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wintry quarry
fathom frigate
wintry quarry
#

ok so you'd have to show how that is supposed to work and what objects and scripts you've set up for that to work

fathom frigate
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wintry quarry
#

you'd have to be at exactly the pivot of the object for that to work

#

A better option would be to use a big trigger collider and OnTriggerEnter

fathom frigate
#

One message removed from a suspended account.

wintry quarry
#

What part are you confused about?

fathom frigate
#

One message removed from a suspended account.

wintry quarry
#

I'm talking about your whole strategy

fathom frigate
#

One message removed from a suspended account.

#

One message removed from a suspended account.

atomic yew
wintry quarry
# fathom frigate One message removed from a suspended account.

Is there a way to modify this script for it to work?
Sure, by completely changing how it works.
I thought I could basically take the script for the enemy reset and just put it on something else and have it not move
But if you think about how your enemy works and how the "kill zone" needs to work, that doesn't make very much sense.

Here's an example you can learn about trigger colliders:
https://www.youtube.com/watch?v=m0fjrQkaES4

Watch this video in context on Unity's learning pages here -
http://unity3d.com/learn/tutorials/modules/beginner/physics/colliders-as-triggers

How to use a Collider as a Trigger (also known as a Trigger Zone), in order to detect when an object is within a particular space in the game world.

Help us caption & translate this video!

http://amara...

โ–ถ Play video
fathom frigate
#

One message removed from a suspended account.

wintry quarry
#

no

#

follow the example

#

Unity will call OnTriggerEnter for you

polar acorn
wintry quarry
#

No idea where you got OnTriggerEnter.Invoke(); from

sand condor
#

Hey short question, lets say I have following code:

if(cheapComparison() || expensiveComparison())
{
// 
}

is it faster to write it this way:

if(cheapComparison()
{
  if(expensiveComparison()
  {
  //
  }
}

I guess the question I have is if the first case always computes both comparisons or if it skips the second one if the first one has a definitive answer.

fathom frigate
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wintry quarry
polar acorn
sand condor
#

thanks for the fast replies

slender nymph
slender nymph
#

ah but you see, i added extra info about how that second one is not the same as the first

polar acorn
buoyant knot
slender nymph
#

ah yeah, seems they are confusing the delegate's Invoke method with MonoBehaviour.Invoke which is used to call a method via reflection after a delay

buoyant knot
#

and, to be clear, you want to use MonoBehaviour.Invoke extremely rarely if at all

queen adder
#

using a tilemap

#

for the walls

buoyant knot
#

what is the problem?

wintry quarry
queen adder
#

does pixel perfect camara work with cinema camara

buoyant knot
#

also make sure you use a sprite atlas, and set compression settings properly for your sprites

slender nymph
#

you don't actually need the pixel perfect camera to fix that. sprite atlases for your sprites should do the trick on their own

buoyant knot
#

my game has a ton of pixel art, and no pixel perfect camera is needed

#

but sprite atlas is crucial

#

need atlas and proper compression settings, or else

queen adder
#

hi what is a atlas

buoyant knot
#

a sprite atlas is like one generated image file that maps out a ton of sprites

#

you can have like 1000 PNG files with various numbers of sprites

#

an atlas is basically one image file that condenses a bunch of them, and for some reason unity isnโ€™t that smart at figuring it out without being explictly told

#

ask google how to set it up

swift crag
#

when the GPU draws a sprite, it needs to have a texture to read the pixel data from

#

the naรฏve approach would be to just upload hundreds and hundreds of tiny textures to the gpu

#

a few big textures are easier to deal with

queen adder
#

Do i list my existing tilemap for packing?

sonic dome
#
    void OnColliderEnter(Collider obj)
    {
        if(Input.GetKey(KeyCode.Space))
        {
            if(obj.CompareTag("Wall"))
            {
                rb.useGravity = false;
            }
        }
    }

the console doesnt show any error still this isnt working i tried adding a debug but still does not respond any reason why?

wintry quarry
#

you made that up

sonic dome
#

๐Ÿ˜ญ

#

my bad

#

but i cant use collider with on collision and if i use collison then compare tag doesnt work

languid spire
#

It might help if you went and read the documentation about the API's you are using

sonic dome
#

wait maybe obj.gameobject

#

worked

#

thanks

queen adder
real raft
#

Hello, i updated my unity version and now when i double click on debug.logs in the console it doesnt show or direct me to the line of the Debug.log

#

has this changed?

#

also the stack traces look much larger and low level

polar acorn
#

Show the stacktrace

real raft
polar acorn
real raft
#

it literally changed how they used to look and behave when i click on console

real raft
#

it never showed like this for me

#

and if i click it doesnt lead me to the place this code is

polar acorn
# real raft

I think this has to do with the burst compiler, there might be a way to disable it

brazen canyon
#

Hey guys, have any of you used the Offscreen Target Indicator pack on the store ?

#

Is there a guidance document on how to use this pack ?

carmine sierra
#

there is a function which finds the nearest object with a tag right?

polar acorn
#

No, there's a function to find a thing with a tag, and a function to find all things with a tag

real raft
polar acorn
real raft
#

the only thing that changed was the way Debug.log shows on console

#

after updating unity

sonic dome
#
    void SideCheck()
    {
        if(Physics.Raycast(transform.position,transform.TransformDirection(Vector3.right)*hit_distance,runnable_wall))
        {
            if(!wall_running)
            {
                if(Input.GetKeyDown(KeyCode.Space))
                {
                    rb.useGravity = false;
                    wall_running = true;
                    rb.AddForce(Vector3.left * jump_force * Time.deltaTime,ForceMode.Impulse);
                }
            }
            else
            {
                if(Input.GetKeyDown(KeyCode.Space))
                {
                    rb.AddForce(Vector3.left * jump_force * Time.deltaTime,ForceMode.Impulse);
                }
            }
        }
        else if(Physics.Raycast(transform.position,transform.TransformDirection(Vector3.left)*hit_distance,runnable_wall))
        {
            if(Input.GetKeyDown(KeyCode.Space))
            {
                rb.useGravity = false;
                wall_running = true;
                rb.AddForce(Vector3.right * jump_force * Time.deltaTime,ForceMode.Impulse);
            }
        }
        else if(!Physics.Raycast(transform.position,transform.TransformDirection(Vector3.left)*hit_distance,runnable_wall) || !Physics.Raycast(transform.position,transform.TransformDirection(Vector3.right)*hit_distance,runnable_wall))
        {
            rb.useGravity = true;
            Debug.Log("FALSE");
            wall_running = false;
        }
    }

this is the logic i m using but for somereason the ray cast is hitting the object even from really far even if the hit_dictance is = 0.001

#

why is that

wintry quarry
#

not something you multiply into the direction vector

#

check the docs

sonic dome
#

oh yea

#

my bad

wintry quarry
#

you're likely plugging the layermask into the max distance param right now

carmine sierra
cobalt dagger
#

GameObject allChildren[] = new GameObject[frame.transform.childCount]; why does this give me an error? i am trying to make a gameobject array inside of a function

polar acorn
cobalt dagger
#

Bad array declarator: To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.

carmine sierra
#

i know the if statement is unfinished, but why is points.count not valid

#

and nearestpoint

polar acorn
cobalt dagger
languid spire
carmine sierra
#

ohh right

sonic dome
#
    void SideCheck()
    {
        if(Physics.Raycast(transform.position,transform.TransformDirection(Vector3.right),hit_distance,runnable_wall))
        {
            if(!wall_running)
            {
                if(Input.GetKeyDown(KeyCode.Space))
                {
                    rb.useGravity = false;
                    wall_running = true;
                }
            }
            else
            {
                if(Input.GetKeyDown(KeyCode.Space))
                {
                    rb.AddForce(transform.forward * jump_force * Time.deltaTime,ForceMode.Impulse);
                }
            }
        }
        else if(Physics.Raycast(transform.position,transform.TransformDirection(Vector3.left),hit_distance,runnable_wall))
        {
            if(Input.GetKeyDown(KeyCode.Space))
            {
                rb.useGravity = false;
                wall_running = true;
            }
            else
            {
                if(Input.GetKeyDown(KeyCode.Space))
                {
                    rb.AddForce(transform.forward * jump_force * Time.deltaTime,ForceMode.Impulse);
                }
            }
        }
        else if(!Physics.Raycast(transform.position,transform.TransformDirection(Vector3.left),hit_distance,runnable_wall) || !Physics.Raycast(transform.position,transform.TransformDirection(Vector3.right),hit_distance,runnable_wall))
        {
            rb.useGravity = true;
            wall_running = false;
        }
    }

this is my wall running logic anyone who can sugget me a way i can make it so that the player moves up and down the wall like if i m looking up and holding w it moves up the wall

buoyant knot
#

sprite atlas references image files (which have sprites). Unityโ€™s inspector lets you define sprites also from those image files.
I forget how to rig it up, but something else in unity references the sprite atlas to render

queen adder
#

ah i see, i have since fixed this problem anyway, thank you for your help tho, it turns out it was indeed import settings.

#

"generate mipmaps" seems to have caused me some problems

buoyant knot
#

also check build. Sprite atlas is not an optional thing when using sprites

#

it might not be the cause of this problem, but it will be important

#

so you might as well do it now

queen adder
#

yeah cool

#

il try

neon marlin
#

Is there a way to track how an object gets deleted in debug?

lost anvil
#

bump

neon marlin
polar acorn
polar acorn
neon marlin
#

yup

#

thanks ill try that out

rich adder
#

true true, just making sure its not some xy thing

charred heart
#

I have A and B gameobject. what will happen if i multiply A rotation by B position?

polar acorn
# lost anvil bump

I've been seeing you bump this for quite a while but haven't offered anything because it looks like a pretty complicated setup but since no one's gotten to it I'm going to give it a once-over and see if I can find out what's going wrong

polar acorn
lost anvil
#

ok thanks ๐Ÿ‘

cobalt dagger
#

is there a way to get a certain gameobject inside of a gameobject array by its name?

cosmic quail
rich adder
#

also looking for a Tag when you have an Interface ? its pretty redundant

cobalt dagger
cosmic quail
polar acorn
# lost anvil ok thanks ๐Ÿ‘

First thing I notice is this if statement:

if (inventory.Count > 1 && !isAnimating)

It makes sense to check for more than one item, but I think when you throw the first item away, it removes it from the list, meaning the count is down to 1 and this doesn't run. Maybe instead of removing it from the inventory, you can replace it with a temporary "Blank" object that you clear out when you change away from it

#

Or, just change the if, and add in a boolean for isNothingEquipped that checks if your hands are empty

if ((inventory.Count > 1 || (inventory.Count > 0 && isNothingEquipped)) && !isAnimating
lost anvil
#

alright ill have a go thanks

neon marlin
cosmic quail
#

and click on the debug message

neon marlin
sonic dome
#
                if(Input.GetKeyDown(KeyCode.Space))
                {
                    Vector3 forwardDirection = Quaternion.Euler(0f, mainCamera.transform.eulerAngles.y, 0f) * Vector3.forward;
                    rb.AddForce(forwardDirection * jump_force * Time.deltaTime,ForceMode.Impulse);
                }

i m using this so the player jumps in the direction where the camera is facing but its not wrking any help?

cosmic quail
# neon marlin

looks like the stacktrace doesnt show what called destroy on the object

polar acorn
# neon marlin

Aw dang it doesn't show it. I thought it did, maybe that's only for DestroyImmediate?

cosmic quail
#

maybe it shows it when it throws an error

neon marlin
#

rip

dusty canopy
#

For a component that has some attributes, how does one edit those in code with some custom script? Say I wanted to change some number value in a component in a script. How do i do that? I know its like the most basic thing but ive not done unity in forever. Ignore me if i clog up chat

polar acorn
carmine sierra
#

anyone know why nearestPoint gives me an error

gaunt ice
#

use of uninitialize variable

neon marlin
#

just says null reference and the line

polar acorn
neon marlin
#

maybe there's a setting to show traces in more detail?

polar acorn
carmine sierra
gaunt ice
#

for min/max stuff i suggest you to use the first array element for "default value"
eg

int min=arr[0];
for(int i=1;i<arr.Length;++i){
  min=Mathf.Min(min,arr[i]);
}
#

then there is no uninitialized local variable

lost anvil
gaunt ice
#

also array index count from 0 to Length-1

#

and you will get index out of bound

carmine sierra
carmine sierra
#

I don't know how those functions work

rich adder
cosmic quail
lost anvil
neon marlin
#

it works fine if i remove the call to loadscene

indigo crescent
#

I do ctrl shift f in visual studio code and it searches your whole project- itโ€™s really helpful

rich adder
lost anvil
#

True

final kestrel
#

Can I ask a DOTween related question here?

wind raptor
#

MyScript.UnityEventThatPassesBool.AddListener(delegate { MyMethod(boolFromEvent) });
What's the syntax for accessing "boolFromEvent"?

rich adder
# lost anvil True

btw here for example

if (interactObj != null && interactObj.CompareTag("Inspectable"))
            {
                interactObj.GetComponent<IInspectable>()?.Inspect();
            }```
can be simply
```cs
if(interactObj == null) return;

if (interactObj.TryGetComponent(out IInspectable inspectable)
            {
                inspectable.Inspect();
            }
cosmic quail
polar acorn
#

Also, that absolutely can be empty. What happens when there's nothing with that tag?

lost anvil
#

i didnt know you could just check for an interface like that

#

thanks

final kestrel
# cosmic quail yes, also dont ask to ask ๐Ÿ˜„ just ask

Ah sorry okay. ```
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class LoadingProgressBar : MonoBehaviour
{
private Image image;

private void Awake()
{
    image = transform.GetComponent<Image>();
    
}

private void Start()
{
    image.DOFillAmount(1, 10);
}

private void Update()
{
    // image.fillAmount = Loader.GetLoadingProgress();
    
}

}

#

I could not find anything about how DOFillAmount is used i thought it was like this.

#

I'm trying to imitate a fake loading screen because the actual loading takes too little time to show my loading screen ๐Ÿ˜„

cosmic quail
final kestrel
#

Oh my god I am so sorry.

cosmic quail
cosmic quail
final kestrel
polar acorn
stable relic
#

Hello, I'm currently trying Unity for the first time, to make a 2D platformer (i suck rn) and i got my guy to move and jump, but if i hold down jump he'll just fly off into spece, would anyone know how I can add a cap to the amount of times he can jump? (just once) here's the code so far: (it's C#)

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float speed;
private Rigidbody2D body;

private void Awake()
{
    body = GetComponent<Rigidbody2D>();
}

private void Update()
{
    body.velocity = new Vector2(Input.GetAxis("Horizontal") * speed, body.velocity.y);

    if (Input.GetKey(KeyCode.Space))
        body.velocity = new Vector2(body.velocity.x, speed);
}

}

wind raptor
polar acorn
carmine sierra
polar acorn
frosty river
#

As a newbie should I be doing a regular 3d project or a 3D URP project?

rich adder
#

up to you

#

URP has more features

frosty river
#

I've been following tutorials. The first one didn't use URP but cut off part way through (they just stopped makings vids), found a more comprehensive tutorial but it's using URP

#

I suppose I'm going to upgrade my project to use URP so I can keep following

rich adder
#

it should not change anything particular how you code/make game

#

mainly the materials need to be converted

#

oh and it has its own Post Processing included so old package should be removed if present

noble forum
#

hi, this should be 1-minute fix, it never happened to me before when doing that

#
using System.Collections.Generic;
using UnityEngine;

public class EndTheTurn : MonoBehaviour
{
    private ChessGameController controller;
    private BoardInputHandler boardInputHandler;

    void Awake()
    {
        boardInputHandler = GetComponent<BoardInputHandler>();
    }

    void Start()
    {
        controller = FindObjectOfType<ChessGameController>();

        if (controller == null)
        {
            Debug.LogError("ChessGameController not found in the scene!");
        }
    }

    public void EndTurn()
    {
        if (controller != null)
        {
            ChessPlayer activePlayer = controller.activePlayer;

            controller.GenerateAllPossiblePlayerMoves(activePlayer);
            controller.GenerateAllPossiblePlayerMoves(controller.GetOpponentToPlayer(activePlayer));
            boardInputHandler.SetMoveDone(true);
            if (controller.CheckIfGameIsFinished())
            {
                controller.EndGame();
            }
            else
            {
                controller.ChangeActiveTeam();
            }
        }
        else
        {
            Debug.LogError("Controller is not initialized!");
        }
    }
}```
#
EndTheTurn.EndTurn () (at Assets/Scripts/Input System/EndTheTurn.cs:33)
UnityEngine.Events.InvokableCall.Invoke () (at <88d854ea2c91426ebc464f01cd71aa85>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <88d854ea2c91426ebc464f01cd71aa85>:0)
UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)

#

so it doesnt read the variable from other script

#

boardInputHandler.SetMoveDone(true);

#

any idea why?

#

other script with exact same things reads normally

rich adder
#

we cannot even read line numbers here dude

#

large code needs links !code

eternal falconBOT
noble forum
#

rest is for context only

#

i get it cannot access, but idk why

rich adder
#

so boardInputHandler is null

noble forum
#

yep

rich adder
#

find out why

noble forum
#

that is why i asked

#

idk

rich adder
#

show where you assign it

noble forum
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


[RequireComponent(typeof(Board))]
public class BoardInputHandler : MonoBehaviour, IInputHandler
{
    public bool MoveDone = true;
    private Board board;

    private void Awake()
    {
        board = GetComponent<Board>();
    }

    public void ProcessInput(Vector3 inputPosition, GameObject selectedObject, Action onClick)
    {
        if (MoveDone)
        {
            board.OnSquareSelected(inputPosition);
        }

    }
    public void SetMoveDone(bool value)
    {
        MoveDone = value;
    }
}```
rich adder
#

oh the GetComponent

queen adder
rich adder
#

also dont crosspost

queen adder
#

okay thanks