#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 585 of 1

slender nymph
#

for example, if you instantiate the prefab that object is based on, it has nothing assigned in that field

acoustic belfry
#

sorry, im just trying to make it look "simpler?". Cuz i used the variables in an npc and made it glitch, so i thought using it directly would make it easier, cuz that fixed that npc

kind spoke
#

Genius

rocky canyon
#

i think ur issue was exactly what i thought it was.. ur clip was starting over and over and over...
here in my animator u can see that the idle clip LOOPS but the transition only ever happens when we go from something else -> Idle

#

if my animator was doing the issue u were having the little arrow going from entry to idle would be flickering non-stop

proper needle
#

my oncollisionenter isnt working

slender nymph
#

read the warning in your IDE and pay attention to your console in unity

polar acorn
proper needle
polar acorn
proper needle
slender nymph
#

then look at the docs

polar acorn
proper needle
proper needle
polar acorn
rocky canyon
#

find their Example compare it to urs..

#

๐ŸŽต one of these is not like the other... ๐ŸŽถ

proper needle
#

i dont see anything useful

polar acorn
proper needle
#

nvm i see it

polar acorn
#

What does it return? What parameters does it take?

proper needle
#

its collision2d col is it

proper needle
rocky canyon
#

Collision2D vs Collider2D was the issue

polar acorn
proper needle
polar acorn
kind spoke
proper needle
polar acorn
kind spoke
proper needle
#

i gtg

frigid sequoia
#

Line 27 is causing a NullReferenceException, but.... it's intentional? Like you are not supposed to need target, it can just be null, what's causing that?

slender nymph
#

playerAggro is null

polar acorn
frigid sequoia
#

Is the marked one

polar acorn
#

Then playerAggro is null

#

You can't get .target of null

frigid sequoia
kind spoke
#

playerAgro?.target != null maybe works?

slender nymph
slender nymph
polar acorn
frigid sequoia
#

So this would work?

frigid sequoia
#

It seems to work, ya

#

Just that it's not doing like anything at all lol

#

I will check it later I guess

#

Thank you

polar acorn
# kind spoke why is that?

Unity has overridden == null for objects that have been destroyed, but not actually culled yet, that null coalescence doesn't include. So there are situations where someUnityObject == null would return true, but a null coalescence wouldn't think so

slender nymph
#

the null conditional operators do a pure null check that cannot be overridden. however UnityEngine.Objects can be a sort of fake null that happens when they are destroyed. using the == and != operators with UnityEngine.Object uses an overridden version of those operators to check for that fake null. if you don't do that proper check then something can be not null but still equate to null because it was destroyed but the variable was never set to null

ivory bobcat
rocky canyon
kind spoke
#

i thought c# didnt let you override ==,!=.

slender nymph
#

why would you assume that?

kind spoke
#

oh nvm i guess it is there...

slender nymph
#

notice how == and != are not listed there

polar acorn
frigid sequoia
#

Ok, so last one of the day. How come that the health is modified and the timeSinceLastAttack is reset, but the print nevers shows?

#

I mean, it's working, but, wtf? How?

slender nymph
#

double check your console to make sure that you don't have either collapse enabled (so that all logs with the same content from the same source only appear as one log) or that you are not hiding logs

frigid sequoia
#

Where is toggle for that?

slender nymph
#

in the console

frigid sequoia
#

Oh, ok, I did close it somehow. I remembered this just showed again whenever a new log was added

#

Thank you

ruby steppe
#

using UnityEngine;

public class CamRotationController : NewMonoBehaviour {
[SerializeFiled]
private MyCameraController myCameraController;

[SerializeField]
private float speedX;

[SerializeField]
private float speedY;

private float x;
private float y;

void Update () {
    x += speedX * Input.GetAxis("Mouse X") * Time.deltaTime;
    y -= speedY * Input.GetAxis("Mouse Y") * Time.deltaTime;

    myCameraController.activeCamTransf.eulerAngles = new Vector3(x, y, 0);
}

}

rich ice
#

!cide

#

!code

eternal falconBOT
rich ice
ruby steppe
#

I want the camera to follow the mouse ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ

#

its not working

ruby steppe
#

i did

#

this is all i got

slender nymph
#

obligatory: use cinemachine

ruby steppe
#

can someone change my script so it work ๐Ÿ˜ญ๐Ÿ˜ญ

rich ice
#

MyCameraController myCameraController;
we dont know what this is

ruby steppe
#

im an idiot

#

i know ๐Ÿ˜”

#

can someone fix my code and DM it to me

rich ice
#

no

ruby steppe
#

๐Ÿ˜”

#

but why

slender nymph
#

we don't do handouts here

rich ice
#

pretty sure there's a rule (or just general warning) about it somewhere.

  • you'll never learn to code if other people just do everything for you
ruby steppe
#

i only know javascript thoooo

slender nymph
#

there are beginner c# courses pinned in this channel. start there

polar acorn
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

ruby steppe
#

onEvent "IndubitablyITHAN" "Click" function("cry")

#

๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ

untold shore
#

Hey, quick question. I'm attempting to just think through an animated counter for my game, labeled "Bet". Whenever it goes up, similar to a hand clicker (where you click the side and the dial moves to increase the number), the number will go down, and a new one will come down in it's place. My question is more in how I should set it up. I have my code to count the bet (in changing the text), just more confused on how to continue. How would yall think through this? If it helps, the bet can only go up to 7, down to 0. Please @ me if you respond, thanks!

rich ice
#

extremely basic way of doing it but i'd think something like this would work (repeat for the rest of the numbers too

int int1;
int int2;
if(int1 < 0)
{
  int1 = 7
  int2--;
  //rest of the stuff you want to happen
}
rich adder
rich ice
cosmic dagger
green shale
frosty hound
#

I'm confused. Why is the script titled Checkpoint the one also tracking all the checkpoint transforms when the player collides with it, this doesn't make sense?

green shale
#

Don't know. My head is very saturated

#

I have tried many ways

frosty hound
#

Okay, scrap it:

  1. Create a CheckpointManager which will have a new array of CheckpointController[] Checkpoints and int CurrentCheckpointIndex
  2. Create a checkpoint object and give it the script CheckpointController
  3. Give this checkpoint object its collider that the player has to hit to trigger the checkpoint save
  4. Give this checkpoint a child object which is the spawn position transform and cache it as the Transform SpawnPosition in the CheckpointController
  5. Drag each of your checkpoints into the Checkpoints array on your CheckpointManager in the order the player must hit them (assuming they can't skip one)
  6. Do an OnTriggerEnter detection on your CheckpointController for the player hitting it. When it does, notify the CheckpointManager.CheckpointHit (this) function
  7. In that CheckpointHit (CheckpointController checkpoint) function on your CheckpointManager, you can check if it's the same as the next element in the array
  8. If it is, then you increment CurrentCheckpointIndex + 1 and when the player has to spawn, you can get the Checkpoints[CurrentCheckpointIndex].SpawnPosition.position
hasty dragon
#

how do i divide variable into different tabs?

#

to make them organised in the engine

frosty hound
#

You have to make your own custom drawer. Or you can use an asset like Odin Inspector which has built in [TabGroup] attributes

hasty dragon
#

how do i make a loop that loops every five seconds

rich adder
#

you can also use update

    float time;
    float maxTime = 5;
    void Update(){
        if (time > 0){
            time -= Time.deltaTime;
        }
        else if (time <= 0){
            time = maxTime;
            DoSomething();
        }
    }```
drifting cosmos
north kiln
#
float _duration = 5;
float _nextTime = 0;

void Update()
{
  while (Time.time >= _nextTime)
  {
    _nextTime += _duration;
    DoSomething();
  }
}

I also like this method

#

there's lots of ways to do it and lots of caveats for each one. Async is also a method; be it Awaitable or UniTask

rich adder
keen owl
north kiln
#

async isn't on a thread unless you use APIs that do that

#

both are just state machines, async is just much more flexible (and has more caveats)

keen owl
#

I don't see why he would use asyncs in this scenario though unless he is working with APIs or file IO

rich adder
#

you could put non-unity apis in separate threads for heavy calculations

north kiln
#

it's just as viable as coroutines. We use it in loads of places

drifting cosmos
#

ive just heard that async is better than courotines

keen owl
rich adder
#

is UniTask still useful now that we have Awaitable ?

north kiln
#

Awaitable isn't very mature, I've had teething issues with it

rich adder
#

last thing i'd want is a weird anomaly in async code lol

drifting cosmos
#

is this a true statement i dont think it is: When you create a prefab in Unity, you're essentially creating a template for a GameObject. Each time you instantiate that prefab, Unity creates a new instance of that GameObject. Each instance holds its own separate data for public variables defined in the script attached to that prefab.

north kiln
#

Yes it's true. Prefabs are an editor-only concept and everything is just instances at runtime

rich adder
drifting cosmos
#

well like if you have a public variable and you spawn multiple objects you cant have different of the variable right?

rich adder
#

yeah each one have their own value of that var

drifting cosmos
#

i thought public variables were

#

like public

rich adder
#

public just means accessed from other classes

drifting cosmos
#

ohhh

#

so you coud calll like object1.speed and object2.speed

rich adder
#

if you made them static, now thats another story. Suddenly they all share the same value cause it belongs to the class itself not an instance

rich adder
drifting cosmos
#

i dont know why people call public variables so dangerous then

keen owl
rich adder
drifting cosmos
#

well i know about instances but like what if you have a class dog and a class cat with public speeds

rich adder
#

class is just a blueprint to what an / object will be . the instance is the created object

drifting cosmos
#

ok i think i get it

#

hm wait

rich adder
#
public class Dog {
public string Name; }

Dog myDog = new Dog();
myDog.Name = "Snoopy";
Dog yourDog = new Dog();
yourDog.Name = "Fido";

etc

acoustic sequoia
#

hey everyone, how do i do something like this correctly..

var upDirection = Vector3.up;
var otherLighterDirection = Vector3.right * 0.5f;
var combinedDirection = upDirection + otherLighterDirection;```
this doesn't seem to work...why?
acoustic sequoia
# keen owl what doesn't work about it?

let me answer by saying this...

why does this:

var otherLighterDirection = Vector3.right * 0.5f;
var combinedDirection = upDirection + otherLighterDirection;```

behave the same way as this:
```var upDirection = Vector3.up;
var otherLighterDirection = Vector3.right; <-- changed
var combinedDirection = upDirection + otherLighterDirection;```
north kiln
#

It doesn't, one is 0.5, 1, 0 and the other is 1, 1, 0

acoustic sequoia
keen owl
#

not really, when you multiply the vector with 0.5 you are reducing it's magnitude essentially

#

the direction is the same, yes

ivory bobcat
#

The second:cs v1: 0.0, 1.0, 0.0 v2: 1.0, 0.0, 0.0 v3 = v1 + v2 v3: 1.0, 1.0, 0.0 The first:cs v1: 0.0, 1.0, 0.0 v2: 0.5, 0.0, 0.0 v3 = v1 + v2 v3: 0.5, 1.0, 0.0

north kiln
acoustic sequoia
#

hmm. let mesee

ivory bobcat
#

If anything, when you normalize them you'll get a magnitude of one but they do differ.

north kiln
#

Shockly I'm not lying UnityChanBugged

static cedar
#

Is LayoutRebuilder.ForceRebuildLayoutImmediate recursive?

static stag
#

after the nice help yesterday, today smth new. Have to create a Grid for my Map editor, i thinking of drawing a "grid" sprite on top, but i dont like that solution. Does some one had a similar problem?

crystal chasm
#

Use the line renderer

#

And render lines...

burnt vapor
keen owl
acoustic sequoia
#

is there something wrong with this? everything else is working except this.. logging the removal never happens...

            foreach(var enemy in separationColliders)
                if(alignmentColliders.Contains(enemy)) {
                    alignmentColliders.Remove(enemy);
                    UnityEngine.Debug.Log("found enemy");
                }
                   


            return alignmentColliders;
        }```
rich adder
acoustic sequoia
#

create a new list?

rich adder
#

you can use a reverse forloop and do the same

#

if your ide is configured type forr, hit tab

acoustic sequoia
#

yes that works.. why does the reverse work? if you don't mind me asking?

rich adder
#

if you go forward remove item it shift and can cause skip elements

#

foreach is just going through an enumerator so its expecting not to change (immutable)

acoustic sequoia
#

ahh ok thank you!

mortal breach
#

Hey, for what seems like the billionth time im trying to figure out Instantiate rotations, i just want enemy bullets to face the player when spawned but i cant get it to work, any ideas?

keen dew
#

need to see the code

mortal breach
#

One sec

#

Right now the instantiate is looking like this

#

references are set correctly

#

and the bullet has this

#

ignore the update

#

i tried to make it follow the player for debugging but still wouldnt work

keen dew
#

Using a position for LookRotation doesn't make sense, unless the bullets spawn at 0, 0.

#

Is this 3d or 2d?

#

3d apparently based on OnTriggerEnter

#
var bullet = Instantiate(Bullet, ...
bullet.transform.LookAt(M_Player.transform.position);
mortal breach
#

yeah 3d

#

oh i thought look at would do the math to look at the player

#

look rotation*

mortal breach
keen dew
#

Different from what? The Quaternion.LookRotation?

mortal breach
#

having transform.LookAt inside the bullet

#

the thing i have in update

#

it doesnt work either

keen dew
#

In what way does it not work?

mortal breach
#

it seems to not effect it in any way

#

the bullets aim correctly up or down but not left to right

keen dew
#

I don't know what that means

mortal breach
#

Well damn me

keen dew
#

can you record a video?

mortal breach
#

Your code works

#

No idea why though

verbal dome
burnt vapor
# mortal breach

I'm confused why your editor marks these methods as unused when it knows they're Unity methods

mortal breach
#

i think so yeah

burnt vapor
#

That should not happen

verbal dome
#

LookAt requires a position as argument
LookRotation requires a direction as argument

keen dew
#

You only set the velocity in Start so rotating in Update doesn't change the direction they're moving, so that's different at least

mortal breach
verbal dome
#

Yep!

#

Or wait

#

I don't know what's looking at what here

#

But it would be to - from

mortal breach
#

yeah, the negative of what i wrote

#

they would go the other way doing it my way lmao

mortal breach
#

ohhh

#

now i get it

#

been a while since i worked with rigidbodies

#

So if i understand it right, LookAt rotates it but it still had worldspace momentum so it just kept going

keen dew
#

Can you tell visually which way the bullets are rotated or are you going by the movement only?

#

because movement and rotation are different things

mortal breach
#

i suppose if i slow them down i can

#

they are elongated along the z so yeah

verbal dome
#

FYI, using anything transform related on a rigidbody object will break your interpolation and also probably introduces some physics oddities

#

Like bad collisions

keen dew
#

In the original code they should have been always pointed towards the player but moving in a different direction

mortal breach
#

all this time the project has just been character controllers and navmeshagents

verbal dome
#

It's probably not too noticeable in this case since the bullets use triggers and don't rotate too much

mortal breach
#

so rotating through transform worked

#

well now they dont need to rotate at all, they spawn correctly

verbal dome
#

True

mortal breach
#

Oh and

#

this worked too

#

Thanks so much people, you've been really helpful once again!

brisk echo
#

Hi, I was wondering if the 'proper' place to put CharacterController.Move() should be in Update or FixedUpdate?
My understanding is that physics movements should be in FixedUpdate but I'm finding if I put it in there I'm getting jittery jumping and side-stepping.
Thanks

verbal dome
#

CC is an exception, it was designed to work in Update

brisk echo
#

Ok thank you. Does that mean things like where I'm altering the gravity in FixedUpdate for it should be moved back to Update due to CC.Move() being done in Update?

verbal dome
#

Yeah makes more sense to do it all in Update

#

Remember to swap out fixedDeltaTime to deltaTime though

echo ruin
#

Typically youโ€™d use fixed update if you move things with physics. I.e. the object had and uses a Rigidbody

#

Yeah what Osmal said

brisk echo
echo ruin
brisk echo
brisk echo
echo ruin
#

Do you just move using the transform?

verbal dome
#

cc.Move does the moving

brisk echo
echo ruin
#

๐Ÿ‘

wooden nacelle
#

can someone tell me how can i see logs for each of my builds??

timber tide
#

rather it probably uses its own internal fixed loop instead of the one that rigidbody relies on

hasty dragon
#

why are the blue

#

the logs

#

theyre usually grey

burnt vapor
#

Because you selected it

hasty dragon
#

left in unselected

#

right is selected

#

how do i do random.range

#

but with integers

burnt vapor
#

Use the overload that uses integers

#

One for floating point, one for integers

buoyant finch
#

hello how to make a player move based on the grid pls someone help

silk night
buoyant finch
ivory bobcat
#

Integration is part of the development cycle - bugs/unwanted-behaviors.

buoyant finch
# ivory bobcat Lookup a youtube tutorial on grid base systems

I did but nothing too useful

 void HandleInput()
 {
     // Get input
     float horizontal = Input.GetAxisRaw("Horizontal");
     float vertical = Input.GetAxisRaw("Vertical");

     // Prioritize vertical movement to prevent diagonal movement
     if (vertical != 0)
     {
         movement = new Vector2(0, vertical).normalized;
         lastDirection = vertical > 0 ? "Up" : "Down";
     }
     else if (horizontal != 0)
     {
         movement = new Vector2(horizontal, 0).normalized;
         lastDirection = horizontal > 0 ? "Right" : "Left";
     }
     else
     {
         movement = Vector2.zero;
     }

     // Check if running
     isRunning = Input.GetKey(KeyCode.Z);

     // Move the player
     float speed = isRunning ? runSpeed : walkSpeed;
     transform.Translate(movement * speed * Time.deltaTime);

     // Check if player is walking
     isWalking = movement.magnitude > 0;

     // Reset key press mode when no movement
     if (!isWalking)
     {
         keyPressMode = true;
         keyPressTimer = 0f;
     }
 }

this is my movement rn

#

my player basically has variable speed and can wander off the grid

ivory bobcat
#

Why use strings?

buoyant finch
supple salmon
buoyant finch
supple salmon
#

If you mean that you want your player to be able to specifically travel just between squares in the grid, then I'd say the simplest way would be to Lerp between grid locations

buoyant finch
supple salmon
#

I'd put it in an IEnumerator, but if HandleInput() is called from the Update() loop then you could make it work that way

rapid laurel
#

hey guys im trying to resolve a problem i had yesterday and still cant fix it,
my character bullet only moves to ONE direction when i shoot to right or to left depending if i use the transform.right or -transform.right.

My class CharacterController have the boolean loookingRight, it switch to true or false depending on the direction my character object is looking.
So i tried to fix it by making this boolean atribute public, and creating a public CharacterController in my BulletController Class who determinates the direction of the bullet and the speed.

Then i added the object in the Inspector.
And made a condition: (mirandoDerecha its the same as lookingRight)

if (!playerController.mirandoDerecha)
{
direction = -transform.right;
}
else if (playerController.mirandoDerecha) {
direction = transform.right;
}

rb.linearVelocity = direction * speed;

and all this doesn't work, I don't understand why, if someone who has more programming logic than me knows something I would appreciate it!!

keen cargo
#

have you tried += for the direction assignments?

#

because certain rotations need to be added to your current rotations in order to make them rotate

frigid sequoia
#

If, lets say, I am trying to get a reference to an script that has been destroyed, that's not the same as null right?

smoky river
#

why can't i move my character? is it a problem with the code or?
here is the code:

using System.Collections.Generic;
using UnityEngine;

public class movement : MonoBehaviour
{
    [SerializedField] 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);
    }

}```
frigid sequoia
#

Like this is not null right?

grand snow
frigid sequoia
grand snow
#

then yea it will == null

keen cargo
smoky river
keen cargo
#

yeah one sec

#

so it's within the Update() part

it's not how you work with rigidbody.velocity, it just needs a direction and then the movespeed

#

you have some kind of.. other thing going on

smoky river
#

im following a 4 year old tutorial so maybe thats the problem?

keen cargo
#

naw it's not the age of the tutorial, it's how the function works

smoky river
#

well it works for the guy but not for me ๐Ÿ˜ญ

keen cargo
#

maybe it could work, have you put the script on the object that you want to move?

keen cargo
#

and have you changed the speed variable in the inspector

smoky river
#

i just have to drag and put it on the right after selecting the player right

keen cargo
#

i mean yea

smoky river
keen cargo
#

as long as it shows up on your inspector

smoky river
#

it doesn't show up

keen cargo
#

i see why, you don't need the private after [SerializeField]

#

[SerializeField] already is innately private

#

you're basically doubling down on the private

smoky river
#

even after i removed private

keen cargo
#

you have an extra d in there

#

[SerializeField]

smoky river
#

oh damn

keen cargo
#

also was that error there before

smoky river
#

like how before

keen cargo
#

when you first asked about your issue

smoky river
#

yeah

#

the movement still doesn't work btw

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

public class movement : MonoBehaviour
{
    [SerializeField] 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);
    }

}
#

how much am i supposed to set the speed as

keen cargo
#

and do you have anything in the inspector

smoky river
#

speed popped up now

keen cargo
#

now change that

smoky river
#

should i set it at a certain value

keen cargo
#

it's for you to test

smoky river
#

YOOO

#

it works now

#

thank u sm

keen cargo
#

np, btw pay attention to the errors they will tell you a lot

smoky river
#

but how did the dude in the tutorial still do it even if he put [serializefield] private

smoky river
keen cargo
#

honestly it might still work even with the private keyword just fine

#

it's just that private is unnecessary

#

your core issue was that it was a typo

#

well lets look at your error again

#

Type or namespace name "SerializedField" could not be found

#

it just means that it doesn't know what the hell it is

smoky river
#

i thought it was some computer thing i don't understand ts bro rap_sobblur

keen cargo
#

you can usually ignore the address and the code number (address is useful if another script is giving you the issue so you know where to look)

smoky river
#

oh alr

#

thanks

keen cargo
#

what IDE are you using?

#

because it should have flagged you the typo in your [SerializedField]

#

like so

smoky river
#

whats an ide

#

im using visual studio

#

if thats what u mean

keen cargo
#

that's your IDE

#

coding environment basically

smoky river
#

oh ok

keen cargo
#

is it visual studio CODE or visual studio COMMUNITY

smoky river
#

what are the best ides

keen cargo
#

visual studio CODE is with the blue logo

COMMUNITY is the purple one

smoky river
keen cargo
#

ok so you have the best one

smoky river
#

are there any better ones

keen cargo
#

it's up to personal taste really

#

i use community myself, because it's just pretty versatile and I can do c++ coding

#

and most people use community here as well

grand snow
#

its VS and VS code

smoky river
#

i hate c++ with a passion

grand snow
#

community is just the free version of vs

#

no one likes cpp we just put up with it

smoky river
#

anyways finally my paracetamol moves

keen cargo
#

eh yeah tomato potato

keen cargo
#

do one thing for me, send a screenshot of your code with the [SerializeDField] typo

#

lets see if it flags it

smoky river
#

do i have to save it or no

keen cargo
#

no it should do it automatically

#

you should see it basically immediately

#

like this

smoky river
#

it doesn't

keen cargo
#

ok something's up with your visual studio, you may need to do some setup

#

!vs

eternal falconBOT
#
Visual Studio guide

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

โ€ข Visual Studio (Installed via Unity Hub)
โ€ข Visual Studio (Installed manually)

keen cargo
#

you want it to flag mistakes like these or else you're going to waste a lot of your time asking and waiting for answers

smoky river
#

whats the fastest way to do it

keen cargo
#

use the links

burnt vapor
#

You're also required to have a properly configured IDE to be helped

smoky river
#

cuz i gtg in a bit

burnt vapor
#

Takes 2 minutes if you know what to look for

#

2 steps, maybe three. You have to download a workload if you installed VS manually which can be sizey

smoky river
#

yeah im doing ts tmrw its hurting my brain

hasty dragon
#

how do i select the function i want

grand snow
#

er do you have debug mode on?

hasty dragon
#

no

#

im on unity 6

frosty hound
#

The animation event has to be on an animation clip, while you have the object selected in your scene that has an animator controller with this clip on it.

#

Also you need to actually start learning the basics of Unity instead of posting questions here every few minutes.

frigid sequoia
#

Guys, I am suprerusty, how was that, I add stuff to the Update method of a child class without replacing the superclass one?

naive pawn
#

you don't; you just call the superclass one as well

#
override T SomeMethod() {
    base.SomeMethod();
    // own logic
}
#

you can't if the method is private, however

#

but i would maybe reconsider that hierarchy thonk

frigid sequoia
#

How was to make it only redeable by childs?

#

protected?

naive pawn
#

yes

hasty dragon
naive pawn
hasty dragon
naive pawn
#

i don't know what line 17 is there

hasty dragon
#

oh sorry

#

gamelogic.health -= 1

#

the last one

rich adder
grand snow
#

then gamelogic is null isnt it?

#

ops you have gameLogic and gamelogic ๐Ÿ˜

rich adder
#

you never actually check the local var

#

also what is even the point of that public var

naive pawn
#

the other object in the collision doesn't have a GameLogic then

frigid sequoia
#

What is causing this? I have no compile errors. It's cause it's not using the MonoBehaviour?

rich adder
#

if not try Reimport the asset, right click it -> Reimport

cosmic dagger
# hasty dragon

Null reference error means a reference type variable is not assigned or its value is null

Look on the error line to search for all reference typesโ€”one by oneโ€”and check if they're null . . .

hasty dragon
#

but i have another problem

#

i tried every gameobject in my game

cosmic dagger
hasty dragon
#

all of them are mistaches

rich adder
#

asssuming this is a prefab

rotund osprey
#

Hello! I'm trying to follow a Unity Learn tutorial and things are working okay so far but I'm having trouble getting the hierarchy and properties window to show an updated part of the script, instead it only shows 1/2 properties despite being both classified as public. I've done something wrong or it's not refreshing. I have to go afk for a while smh

hasty dragon
rich adder
burnt vapor
eternal falconBOT
cosmic dagger
rich adder
#

your changes seem unsaved

#

unsaved color

frigid sequoia
frigid sequoia
rich adder
#

had to trigger a recompile basically

proper flint
frigid sequoia
#

So it's just Unity being weird?

proper flint
#

ye

swift crag
#

It may have missed a file change

#

See if the text displayed in the inspector for the script asset matches the contents of the file

rocky canyon
#

if i disable Directory Monitoring i don't really need to worry about Refreshing correct?
like when i go into playmode it should all update?

#

trying to speed up my editor just a tiny bit.. i dont really wanna do the Full Domain Reloading thing.. but i found out about this directory monitoring.. wonderin if its useful?

astral falcon
#

oh, windows only, explains why I have never seen it ๐Ÿ˜„

hot laurel
astral falcon
#

What you speed up is the check for changes, the event will get fired anyways

hot laurel
#

so if you disable directory monitoring it will probably still enumerate whole directory and compare against stored timestamps on unity window focus

meager raven
#

does anybody know a really simple way to move the player in 2d unity?

#

ive been looking for a while and i get way too confused

astral falcon
meager raven
astral falcon
#

honestly, to learn the basics, stick to !learn instead of youtube. Lot of the tutorials are outdated or just bad in general when it comes to coding habits and setups

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

rich adder
#

the new essentials courses takes you to how to move a basic rigidbody

meager raven
#

thanks alot guys, ive been stuck on this for a few days

rocky canyon
#

but then again.. im not fully versed on this part.. I'm more familiar with domain reloading. and how that works.. but not the auto-refresh and directory monitoring

astral falcon
#

I think, its two parts, not one with two variants. THe one is the detection of the changes, which can be auto or manual and how it detects them, via directory or files. And the second part is the actual reloading in unity, the domain reloading to be able to test them. Thats how I understand those settings

rocky canyon
#

well these two options were found under Preferences

#

domain reloading under ProjectSettings

#

so. in my head they were different from each other

astral falcon
#

Thats what I meant. THats two parts of the asset handling

rocky canyon
#

but i do know i dont wanna worry about domain reloading and whatnot..
sounds too much for me dealing with static classes

#

and initialization stuff

#

Assembly Defs may be a middle ground

astral falcon
rocky canyon
#

so in my head the way i think of it.. the first image is the Directory:

  • this means the progress bar that progresses when going from IDE to editor.. or minimized editor to focused editor
    then the other settings are to do with PlayMode:
  • this means the progress bar that progresses when going into PlayMode from EditMode
#

thats my starting generalization anyway..

rich adder
#

how often you really mess with static vars ?

#

just be mindful to reset those

#

if you use static events, clean them up

#

the time you going in and out of play is wasted time lol

astral falcon
#

but the list what happens when turned off sounds to be like a good source of failure when observing and debugging things.

rocky canyon
#

im pretty sure its saved me more time than i can imagine

#

used to every little change i made i'd play-mode..

astral falcon
#

haha yeh, you get used to write bunch of code before even testing

rich adder
rocky canyon
#

i like the new name navarone ๐Ÿ‘

rocky canyon
#

never will i make a new script fully before testing along the way

rocky canyon
rich adder
#

oh one time i had issues was some assets were not mindful of Domain Reloading being off with some people
(but the devs quickly patched the SDK after it was brought up)

rocky canyon
#

i may try to incorporate it into my work-flow

#

but then again i may experiment with assembly definitions.. and see how that works out

rich adder
#

if you use lots of third party assets you might have issues if oirignal asset maker didnt account for Domain Reloading being off

astral falcon
rich adder
#

took me a while to fully trust it, and like I said I don't use many third party assets that have scripts so less of a chance for me something going haywire

rocky canyon
#

ya, it is a tad scary.. especially for someone like me

rich adder
#

ironically the new unity 6 multiplayer player mode testing thing didnt like Domain Reloading off and threw weird bugs, I heard unity patched it since.. Idk I use ParallelSync which works fine with Domain Reload off

astral falcon
rich adder
dreamy wren
#

can someone help me with this code im newer and need some help, what do I put so when I press M all movement is stoped for a set amount of time?

rocky canyon
#

ah mb.. i just realized i wanted to discuss this in Unity-Talk.. mb im finished tho.. thanks for the input guys ๐Ÿ™

frigid sequoia
#

Huh, I have never seen this, why does this not have the checkbox to dissable it?

rich adder
rocky canyon
#

b/c theres nothing to disable..

astral falcon
#

!code

eternal falconBOT
rocky canyon
#

or anything of the sort?

dreamy wren
#

oh

frigid sequoia
astral falcon
#

then its not part of the unity execution loop, as no builtin methods are being used, so nothing to be disabled

frigid sequoia
#

I see...

#

I think I have never done that before

rich adder
#

these are the only methods that can be disabled

dreamy wren
#

is that good?

rich adder
#

mate did you read the "Large Code" part

dreamy wren
#

no i did not

astral falcon
#

or just remove the empty lines and it will get small enough eventually ๐Ÿ˜„

rich adder
#

general rule if its 7+ lines it should probably be in a link

rocky canyon
#

as long as it doesn't take up the entire screen

rich adder
#

my dc window already so small lol or phone

turbid prism
#

jelou

#

someone knows a good way to lear unity without brain dmg?

dreamy wren
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

turbid prism
#

i learned c# and tried unity but somehow got stuck with the new input system lol

turbid prism
#

ty

stone glen
#

hi everyone, How can I move a player from a box to another box?

#

ok i will try thx

rich adder
#

aside from horrid formatting lol

#

Oh you want to stop all movement when pressing M ?

dreamy wren
#

yes please

rich adder
#

create a bool that is tied to the M key, if its true return out of the move input capture or return out rb.MovePosition (only do this if you need complete stop)

dreamy wren
#

how do I make a bool?

rich adder
#

just like you had declared the other variables

#

declare : bool isPressingStopKey
usage : isPressingStopKey = Input.GetKey(KeyCode.M);

#
if(isPressingStopKey) return;
//stuff here only happns if isPressingStopKey == false```
#

only whats underneath

rocky canyon
#

clearly u need to organize it in a way tha works

rich adder
#

ugly nesting prevention

rocky canyon
#

dont early return at teh very top for no reason..

rich adder
#

early return pattern ftw

rocky canyon
#

it just depends on the use-case

rich adder
#

You can also put it in a method inside Update to not disturb Update

rocky canyon
#

but its way superior to long-nested if/else statements

#

"go home early today"

rich adder
#

game canceled, heavy snow

rocky canyon
#

grandpap and ma will disappointed

#

no..

rich adder
#

you shouldn't actually

rocky canyon
#

do Move() in update

rich adder
#

CC should be moved in Update

rocky canyon
#

its built to handle it..

rich adder
#

Rigidbodies should be in FixedUpdate though

rocky canyon
#

i still set velocities in update to match my inputs

rich adder
#

CC is like a weird kinematic controller that Nvidia Physix has made unity just adapted the api

rocky canyon
#

u can set velocity every frame..
it'll still only get applied on the appropriate physics tick

#

but.. be mindful ofc

rocky canyon
#

if im using a rigidbody.. theres times i'll still put rb.velocity = input; in the update loop

#

it'll still only get applied on the next physics tick..

#

soo its still possible

rich adder
#

ohh what does that do though instead of putting in fixed?

#

isnt Input already captured in Update anyway

rocky canyon
#
private Vector3 targetVelocity;
private Rigidbody rb;
void Update()
{
    float horizontal = Input.GetAxis("Horizontal");
    float vertical = Input.GetAxis("Vertical");
    targetVelocity = new Vector3(horizontal, 0, vertical).normalized * speed;
}
void FixedUpdate()
{
    rb.velocity = targetVelocity;
}``` and
```cs
void Update()
{
    ...
    targetVelocity = new Vector3(horizontal, 0, vertical).normalized * speed;
    rb.velocity = targetVelocity;
}``` will function the exact same
#

but it is based on what ur doing and how ur doing it ofc..

rich adder
#

I had weird results at different FPS when using Raw in Update, so I used GetAxisRaw in FixedUpdate and fixed the inconsistent speeds

rocky canyon
#

something simple as this.. (no worries)
something a little more advanced (with multiple forces possibly external forces) maybe not

rocky canyon
rich adder
rocky canyon
#

ya, like the first example..

#

thats probably the most proper way tbh

#

Input in update
applied in fixed

rich adder
#

applying speed in fixedupdate vs update does it matter ? lol its been a while since I did those small test

#

I dont even use Update anymore for inputs thats why

#

new input system is event based

#

no polling

rocky canyon
#

its because u can set the velocity of the rigibody in update as many times as u want...
it really wont matter until the fixedupdate runs.. (then w/e value is there At that exact moment will be used)

rich adder
#

I think it doesnt matter because the rigidbody velocity doesnt deal with mass and forces

rocky canyon
#

but yea.. for most cases for rigidbodies u want to be doing the actual logic in Fixed..

#

but u can get away with simple stuff in

rich adder
#

but for AddForce you probably do want FixedUpdate for sure

rocky canyon
#

u could ya..

#

Dotproduct maybe?

night mural
#

this looks like a job for โœจ dot product โœจ

rocky canyon
#

๐Ÿ’ช nailed it

night mural
#

but yeah angle would probly work fine too

rocky canyon
#

u'd get teh smallest angle

#

closest angle to zero i believe.. it could be the opposite but yea look into Angle functions

#
  Vector3 towardsObject = (obj.transform.position - viewer.position).normalized;
  float angle = Vector3.Angle(viewer.forward, towardsObject);```
```cs
        Vector3 towardsObject = (obj.transform.position - viewer.position).normalized;
        float dot = Vector3.Dot(viewer.forward, towardsObject);```
#

i believe Dot is faster than Angle

#

"if this object is more aligned with the viewers forward direction"

void thicket
#

Angle is dot product with some more calculation to convert it as angle

rocky canyon
#

ahh okay ๐Ÿ‘ that makes sense

#

i was just reading up on it..

swift crag
#

acos(dot(a, b)) is the angle, assuming that a and b are normalized

void thicket
#

Then Rad2Deg

swift crag
#

The angle is ideal if you want a linear response -- e.g. 30 degrees is exactly twice as far off as 15 degrees

#

the dot product is the cosine of the angle, so 0.9 -> 0.8 takes a different amount of rotation than 0.8 -> 0.7, for example

rocky canyon
#

i heard someone say once u could optimize it even further using a Cosine threshold.. or something like that

swift crag
#

you could take the cosine of an angle to get the threshold for your dot product

#

so that you aren't computing acos every time to get back to an angle

rocky canyon
#

but tbh im not too sure about it b/c my geometry isnt that strong

rocky canyon
#

is this Trig or Geometry?

#

oh nevermind ๐Ÿคช

void thicket
#

Linear algebra

rocky canyon
#

lmao touche

frigid sequoia
#

Is there a way to stop just the Update method of a script for a while?

rocky canyon
#

wrap its contents in a boolean

#

or an early return with a negated bool

frigid sequoia
#

Mmmmm, ya makes sense

rocky canyon
# frigid sequoia Mmmmm, ya makes sense
    void Update()
    {
        if (!proceed) { return; }
        wasGrounded = characterController.isGrounded;

        ProcessPlayerInput();
        GroundCheck();
        JumpCheck();
        Move();

        GetPlayersSpeed();

        if (!wasGrounded && characterController.isGrounded)
        {
            headbob.CamRebound();
        }
    }```
frigid sequoia
#

So if proceed is false it would just skip the rest of the update right?

rocky canyon
#

yup

frigid sequoia
#

Cool

#

Pretty much what I want

rocky canyon
#

u could disable the script entirely for a bit..
but that may not be viable in ur situation

astral pine
#

Hi! I've been trying to use my camera feed on mobile but it doesn't overlap with what my actual camera feed looks like. It's more zoomed in than it should be and thus when I click on the screen it takes the info from my actual camera feed. Due to this it's inaccurate.

rocky canyon
#

not sure i understand exactly what ur saying.. but if its to do with UI and the canvas u need to make sure its scaling and set correctly...

astral pine
#

Yeah I've been trying that but the raw image remains zoomed in compared to my actual camera feed

night mural
#

where's your 'actual camera feed' coming from? just the camera app?

astral pine
#

Yeah

#

I look at it to compare it and the input unity gets touchscreen wise is from the actual camera feed. I'm trying to make a thing so that you can click on the screen and it shows you the color it is. But it doesn't use the raw image camera feed you see

rich adder
astral pine
#

Oh that makes sense. How do you select the right one in your code then?

night mural
#

yeah that's what I'd guess too, there's probably some option you need to set

rich adder
astral pine
#

Not sure I understand. I'm just using my own phone which is connected with an USB cable

astral pine
#

yeah

rich adder
#

ok so if you are, then you have the available devices

astral pine
#

Alright

rich adder
#

trial and error or check names, test each one and see which one you need

astral pine
#

Thank you very much!

fickle plume
rotund osprey
eternal falconBOT
rich adder
#

show in Unity ->Preferences -> External Tools window rq

rich adder
# rotund osprey

close VS, click Regen project Files button right there, once thats done double click script from unity again. Wait till VS loads

rotund osprey
rich adder
#

show me VS again

#

also you need to check Console window for compile errors and if the script was actually saved.

#

having a configured IDE has nothing to do with fixing the field not showing up..

#

its just a requirement to get help here

rotund osprey
#

I don't know how to get that "On Collect Effect" Field to show, idk what's wrong

rocky canyon
#

did u save the file and add it to a gameobject? can u show your inspector? and not the video's inspector

cosmic dagger
eternal falconBOT
rocky canyon
rotund osprey
echo kite
#

why does my bullet not collide even tho i have rigid body

rocky canyon
#

OMG i just noticed.. Unity 6 actually debugs the name of the script if it has a missing script..
No more guessing!

echo kite
cosmic dagger
rotund osprey
cosmic dagger
cosmic dagger
cosmic dagger
echo kite
rocky canyon
rotund osprey
rocky canyon
#

heres how u could easily tell if it is or not

rotund osprey
#

idk how to then

rocky canyon
#

yes we know.. its just a step of the process

cosmic dagger
cosmic dagger
cosmic dagger
rocky canyon
#

sometimes u may need to restart, atleast the IDE once u do the other steps to make sure its working
along w/ sometimes needing to regen project files

rocky canyon
#

is there a collider?

echo kite
cosmic dagger
echo kite
rocky canyon
#

i must be blind..

#

thats not a collider

cosmic dagger
#

your wall GameObject has a Collider. does that make it a Rigidbody? no . . .

echo kite
#

ty i fixed it

#

i thought all mesh had it before

cosmic dagger
#

you can easily tell by looking for a Collider component on the GameObject . . .

rocky canyon
#

nah.. if its a mesh it can have a mesh collider

#

primitives usually do come with a collider tho..

#

Create > Cube, Sphere, Etc

frigid sequoia
#

If I Destroy a gameObject that was part of a List, although it essentially becomes null, it's still part of the List and therefore counting for stuff like .Count right?

naive pawn
#

yes, the list doesn't care what the stuff inside is

frigid sequoia
#

Mmm... that kinda makes annoying for me

#

But okay

keen cargo
#

I mean you could call the list counting every time something's destroyed

#

So the list counts what actually exists even if you destroy stuff

frigid sequoia
#

Yeah, just that getting a reference to the actual List is like 6 script jumps lmao

keen cargo
frigid sequoia
#

And it's part like for 3 different lists

naive pawn
#

you could make it managed, instead of Destroying the gameobject, you tell the script that owns the list to remove it, and that handles both the Destory and the Remove

#

oh

#

well, that could be difficult.

timber tide
#

keep wrap it in a struct with the list ref ;)

frigid sequoia
#

Could I like... get a reference to a misisng script?

cosmic dagger
#

why is it a part of three different lists?

naive pawn
frigid sequoia
#

Like if I get this, can I get it from there and remove it from all lists that may be in, although it's not there anymore?

naive pawn
#

when that happens it means the serialized reference is still there but the thing it's pointing to isn't

cosmic dagger
#

the reference itself will be null . . .

frigid sequoia
# cosmic dagger why is it a part of three different lists?

So, this works like this. I have a reference to all present entities on the scene, stored on an empty on top of all. All entities get the reference of what they should be targeting from there. But then, for example enemies, each have 2 Lists that basically derivate from the other, a List of HeavyAggroPlayers and another with all the rest, it would always try to get their target from the HeavyAggro first. I would have to remove it from the top of the List and make sure it's not present on any of the other Lists that each enemy has

#

Could I just iterate the list in search of nulls to remove them?

#

To much to check each frame I would say

#

Could I check for specifically a missing script rather than a null, so I can update the List only then?

timber tide
#

you can iterate and clear nulls but you gotta ask yourself when do you do that

#

best way to handle it is remove it from the list when you destroy it

naive pawn
#

you could use OnDisable or OnDestroy on the thing being destroyed
but i think it'd be better to handle it from the list side

cosmic dagger
frigid sequoia
#

Yeah, there is no way EVERY enemy has a reference of what just died to remove from their lists specifcally

naive pawn
#

then those enemies can ignore that

frigid sequoia
#

It would be too demanding

timber tide
#

Some ideas is don't let the object destroy itself but use a manager type system to handle it, another is wrapping it in a struct with a list of lists that it is occupying. Or, just make a variable on the object itself that has references to all lists that it's included into and iterate through those on destroying.

cosmic dagger
#

i would use events to trigger the update . . .

frigid sequoia
#

Ok, I think I know how

timber tide
#

Best case -> events

#

or some subscription service to alert all lists that it's been destroyed at object level

#

really direct references are fine too... it's just events are fancier and encapsulates it a bit more tightly

frigid sequoia
#

The aggro manager checks first for the heavyAggroPlayers, then for all the rest, but will be stucked trying to get it from the List that just contains a null cause it sees it as containing something. I am gonna make so if after checking the lists it still has a null target, to just update the list, since something was clearly removed

naive pawn
#

but will be stucked trying to get it from the List that just contains a null cause it sees it as containing something
you could just make it check for null right there

cosmic dagger
#

wait, do all enemies have the same list of aggro players?

naive pawn
#

im not saying that's a bad solution; but the cause you mentioned is not really a problem

frigid sequoia
frigid sequoia
#

That's fine

#

This is what I am doing rn, so u can visualize it better

cosmic dagger
#

also, did you try using events? i can give an example . . .

frigid sequoia
#

Also, I have absolutely no idea of how to manage events

cosmic dagger
frigid sequoia
#

It does contain all active entities, whenever one is missing, it's removed

swift crag
#

You could skip over invalid targets and make a note that you need to prune the list

night mural
# frigid sequoia It does contain all active entities, whenever one is missing, it's removed

yeah I haven't read all the context but I often suggest solving this kind of thing by not deleting stuff so that there are never any nulls. Like if the problem is 'dead things need to be removed from everyone's target lists' you could reframe that to 'everyone's target list should handle the possibility that there are dead things in there' and that way 'cleaning up those lists' becomes its own task and you can do it whenever you want (this is basically garbage collection)

swift crag
#

indeed

#

i've been dealing with this on my own -- I have a lot of places that care about lists of Entities, and outright destroying them means I need to either:

  • immediately stop tracking them (which could cause concurrent modification problems)
  • check every entity object before trying to use it
frigid sequoia
#

Actually this one line seemed to do wonders

swift crag
#

I wonder if I should have a "cleanup step"

#

instead of immediately firing EntityManager.OnRemove, I would do that near the end of the frame

night mural
#

a long time ago I found that 'have corpses' solves a lot of these problems in a way that feels intuitive

cosmic dagger
#

!code

eternal falconBOT
ripe shard
swift crag
#

yeah

#

a dead entity is still an entity

night mural
#

and may even be valid for some things to target!

swift crag
#

even an entity whose physical form has been mega-deleted may still "exist" in the form of memories, relationships, etc.

ripe shard
frigid sequoia
#

If iterating through the List I see a null I remove it straigh up

night mural
#

shouldn't that yell at you for removing while iterating?

swift crag
ripe shard
night mural
ripe shard
#

if you want to remove stuff from a list while iterating, use a regular reverse for loop, not a foreach

night mural
#

if your method starts with 'Calculate' it should have no side effects imo

swift crag
#

yeah

night mural
#

finding the closest target and keeping the closest target list properly updated are different concerns

swift crag
frigid sequoia
#

I could do it outside the method before calling it, but... kinda.... why? Is gonna do pretty much the same loop

swift crag
ripe shard
#

you should not have nulls in that list anyway, looks like a code smell to me

swift crag
#

well, they aren't really "null"

#

they're destroyed unity objects

ripe shard
#

well, then you need to observe that destroy event, not be surprised by it

night mural
cosmic dagger
swift crag
frigid sequoia
night mural
night mural
frigid sequoia
#

Well, I am actually getting some exceptions, but it's working

cosmic dagger
rocky canyon
#

how u moving it?

#

transform.position = ?

vocal wing
#

im not using rigidbodys

rocky canyon
#

well, that's y it doesn't collide

vocal wing
#

anyway to collide with transform.position?

rocky canyon
night raptor
vocal wing
#

oh I see ty

night raptor
#

Especially if you are every frame overwriting the positition, the physics can do very little to prevent that

astral falcon
#

what are you doing?

cosmic dagger
# vocal wing anyway to collide with transform.position?

The GameObjects must have colliders, and then you use physics methods to check for collisions. Basically, you do your own custom collision detection because manipulating the transform does not involve the physics engine . . .

astral falcon
vocal wing
astral falcon
#

only the positioning. In what method and how

#

is it a 2d space overlay canvas?

verbal dome
#

Maybe you are moving the camera every frame, after doing that?

cosmic dagger
# frigid sequoia What again?

This was an example of using events. The player script would have the event on it. The GameManager and Enemy scripts subscribe to it (the event). When the event is invoked, the methods attached to it are called (+= Player_OnDestroyed). They remove the player from the list on those scripts . . .

daring oasis
#
Vector3 cursor = Input.mousePosition;
cursorPos = mainCamera.WorldToScreenPoint(cursor);

why does cursorPos return valuez such as (-4371.42, -12528.05, 10.00)

polar acorn
daring oasis
daring oasis
naive pawn
polar acorn
verbal dome
#

So the UI is moved in Update.
Where is the camera moved? Update? LateUpdate?

proper needle
#

.tag doesnt work

verbal dome
#

Move the UI in LateUpdate

#

Tbh the drifting is not too visible in the video you sent

#

I do see these weird black streaks though

astral falcon
#

I think, because you are trying to render on screenspace, the updat eof the canvas is falling behind the camera movement render

proper needle
#

why doesnt my col.tag work

astral falcon
#

First of all, why not use a 3d space canvas instead? And, you could try to force rebuild the layout with every update (not sure, thats a good idea performance wise, but you could test it)

verbal dome
verbal dome
#

@proper needle You can get the collider from the collision and get the tag from that though

proper needle
verbal dome
#

A collider is solid if you uncheck "trigger" in the inspector

proper needle
verbal dome
#

You'd use OnCollisionEnter2D

#

Which you already are

proper needle
cosmic dagger
proper needle
#

alr imma try

astral falcon
#

What issues, I guess meshes overlapping the button?

proper needle
#

this happens

astral falcon
#

at least on the canvas, yes.

cosmic dagger
# proper needle

The parameter is a Collision2D type, not a Collider type . . .

astral falcon
#

Is Unity.UI not a thing anymore in Unity 6?

rich adder
#

the name is col

#

collider is an old(obsolete) property of monobehaviours

cosmic dagger
# proper needle

Look at the type in the unity docs to see what properties it has (you have access to) . . .

verbal dome
astral falcon
#

The sorting layer is only "internally" for UIs. It will not let you draw the UI above your meshes. THerefore you would need an extra camera if you want it to be always on top

#

Thats why I suggested to try the forcerebuild layout

#

I am using Unity UI in 6, so its there, even if not in the docs weirdly enough

proper needle
#

now i have this error

astral falcon
#

you know what a parameter is?

proper needle
#

alr thanks

astral falcon
#

Its in the docs I pasted. You give it the recttransform of your canvas as a param

#

did you try it in update?

#

I think, they dont do it with world canvas, as there is no perspective to the item. You just dont see the offset (if there is one), because there is not an object as close to it as on your example

cosmic dagger
astral falcon
#

What you also could try is to use screen space camera instead

#

Maybe that changes how things are rendered

proper needle
#

how do i make this so it actually works

astral falcon
#

It might just be unity being unity sometimes

cosmic dagger
#

OnTriggerEnter2D uses Collider2D, not Collision2D . . .

astral falcon
cosmic dagger
proper needle
#

i used oncollisionenter2d

verbal dome
astral falcon
#

guess you had it as world canvas and now the scale is messed up? ๐Ÿ˜„

proper needle
#

i learned that from javascri[t

#

javascript

cosmic dagger
astral falcon
#

reset your transform of the canvas ๐Ÿ˜„

proper needle
astral falcon
#

Thats just the result of drag dropping back and forth between screen and world ui

proper needle
#

so now im stuck in this loop

astral falcon
proper needle
#

alr then

astral falcon
#

There are pathways on learn platform now, which will guide you

#

Right click on the component, reset

#

yeh, because its driven by the canvas now ๐Ÿ˜„ try to make it a world canvas again, then reset and then back to screenspace camera.

#

ah no wait, thats intended. because your camera is rotated. all should be fine. I guess your button is messed up

#

can you show the inspector of your X button?

proper needle
#

i need the c# documentation for oncollisionenter2d

astral falcon
#

and when setting camera, it gets huge out of a sudden? ๐Ÿ˜„ try to make the plane distance something small to see if that changes

astral falcon
proper needle
#

thanks

proper needle
astral falcon
#

so, lets get back to your topic, which is not code related anymore, but whatever ๐Ÿ˜„

proper needle
#

bruh i look up unity documentation and go from there

astral falcon
#

Can you show your scene view with the camera attached?

#

read again ๐Ÿ˜„

#

There is Game View and Scene View

verbal dome
astral falcon
#

wait, two cameras?

#

Could it be, that you assigned the wrong camera while looking through the other one?

#

or was that screenshot with that huge UI from your scene view?

#

ah okay

#

and when assigned the main one, how does it look like?

#

Okay, that feels like some querks with cinemachine

#

when back to camera overlay, where do you set the positions? In lateupdate?

#

And what is your cinemachine brain set to update?

#

CInemachine Brain component

#

Yep, you could try to use another method so cinemachine is done with repositioning the camera before you calculate the UI. Otherwise, you take previous frame positions and that will result in that lag

#

at least worth a try ๐Ÿ˜‰

grand snow
#

btw be warned there are differences between v2 and v3 of cine machine

#

but v3 has some nice newer stuff so do upgrade to it if not already

astral falcon
#

Is it part of unity 6 release or also usable in previous versions?

#

ah, just seen, its already in 2022

grand snow
#

it says 2022+ but projects I work on had v2 still but probably cus lots of common stuff comes from like unity 2019 and earlier

#

cinemachine is great it will make cool camera stuff super nice

astral falcon
#

Best of luck and success with your first project then ๐Ÿ™‚ Im out for today, happy developing

#

There are plenty of people around ๐Ÿ˜„ Just ask and youll get answer sooner or later

grand snow
#

fun fact, cine machine was "ported" to unreal engine cus its soo good

astral falcon
#

happy to help ๐Ÿ™‚

zinc trellis
#

Hey, any good courses i can follow for unity? Im a total beginner and would love to try game dev. Its been my dream

verbal dome
#

You using cinemachine would've been good info when I asked when you update the camera ๐Ÿ˜ฌ

astral pine
#

@rich adder had to alter the code a bit but just wanted to say thank you. Everything works now ๐Ÿ™

ember tangle
#

Im building a mesh via script and I am looking for learning resources on how to apply textures or materials to specific sections of the mesh

earnest wind
#

different from build to editor

#

in editor, all of the lines get executed

#

but in build, from like 66 it just stops

#

im building with IL2CPP

wintry quarry
earnest wind
wintry quarry
#

Where did you look

earnest wind
#

let me try and make a development build

#

5 min-15min, i will come back

wintry quarry
#

Anyway what populates that list or array

#

It's probably just empty

earnest wind
#

keyMeshifSkinned?

#

that one is empty

#

yeah but in unity editor it works, why would it not in build..

#

@wintry quarry

#

yeah but like if it were to be a object reference, why does unity editor allow it

#

its weird

#

i guess i just do that?

#

oh also, this script has been here for a long time

#

there were no issues with it, untill i switched to IL2CPP

cosmic dagger
#

your camera shouldn't be attached to the player . . .

#

also, use !code to format and post correctly . . .

eternal falconBOT
timber tide
#

overlay shouldnt be moving regardless or am I misunderstanding

#

overlay canvas renders after main camera

#

unless you mean world space

#

you're saying UI elements are drifting this is this irrelative to the main camera

grand snow
#

ideally you have cine machine update in Update, the UI pos stuff is LateUpdate

#

or if you need both to be late update try to change the monobehaviour orders or as you said, use an event

cosmic dagger
#

what are you trying to do with the UI? what is the goal? i'm not understanding what is happening . . .

timber tide
#

is this like a 3D object being converted to screen space when you pick it up?

grand snow
#

the problem is the world -> screen pos must be before the camera changes in this frame

#

well you want the camera transform to have changed already, THEN do the world -> screen pos conversion

#

otherwise its going to be "out dated"

#

so you want:
player moves -> cinemachine updates stuff -> worldscreen pos for UI element

timber tide
#

yeah that's probably it. Cinemachine has a few options for when it should be ran too somewhere on it which you can screw around with