#💻┃code-beginner

1 messages · Page 207 of 1

polar acorn
#

what

#

You can't just make up words

turbid robin
swift crag
#

you gave SceneName a value in the inspector for your Button component

summer stump
swift crag
#

My impression was that you wanted to be able to choose which scene to load over here, yes.

#

But if you just want to load a specific scene no matter what, this will work.

#

Your vocabulary is way off. That's going to make it hard for you to actually understand what people are saying.

turbid robin
polar acorn
#

So make the scene a parameter of your function

#

Then you don't even need to have multiple instances of this component

summer stump
turbid robin
warped valve
#

Hello, Can somebody help me, i need help, when i add a rigidbody and a capsule collider on my Player, if i rotate my player or move it, the "Y" Position will decrease and my player will get eat by the terrain, Do you know why ? or how stop it ?

turbid robin
summer stump
#

Yours works, but not the way you asked about earlier

turbid robin
#

oh ok

calm dust
#

im back down to 1 error

turbid robin
#

i think i need to watch a good tutorial of unity basic

summer stump
summer stump
calm dust
turbid robin
#

can i put a button here? is an ar scene

slender nymph
summer stump
# calm dust

Do you have something called OnFootActions? I remember "onfoot"

calm dust
#

let me check

#

i have OnfootActions, which i changed it too, but its still not working

storm imp
polar acorn
#

These are not the same tag

summer stump
#

A good reason to use CompareTag

slender nymph
#

and this is why we use CompareTag and not string equality

storm imp
summer stump
polar acorn
summer stump
#

Look at the tag in the inspector, see if it looks off to you

urban sluice
#

Is there a way to make like an overall script that every other script can access?

polar acorn
storm imp
summer stump
polar acorn
summer stump
storm imp
storm imp
#

it works now thank you sooooooo much for all the help @summer stump @polar acorn

summer stump
storm imp
calm dust
#

ok, this is quite the stretch, but can anyone help me in a call, i think ill understand better if i can speak to someone

slender nymph
#

you are incredibly unlikely to get help via voice call here. if you need help with something then ask a specific question using #854851968446365696 as a guideline for what to provide when asking for help

rare basin
calm dust
#

yea, i thought so too

summer stump
calm dust
#

i think i got somewhere

summer stump
#

I do recommend taking a break from this current project and going through a c# course, and then !learn before returning to it thougj

eternal falconBOT
#

:teacher: Unity Learn ↗

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

calm dust
#

but now there is a different pproblem which might be easier to fix

shell sorrel
#

think you can figure that one out reading the errror

calm dust
#

i dontknow what that means ( i know im stupid with this)

slender nymph
calm dust
#

ok\

shell sorrel
#

but it does not exist

#

so either function does not exist, or your have it but the signature is wrong

slender nymph
# calm dust ok\

make sure you pay attention to the intellisense suggestions when typing. i know your IDE is configured because you showed it was before. so let it autocomplete the correct type

vague dirge
#

Hi, I followed Brackey's tutorial to make my first chracter movement, and it starts like this float targetAngle = Mathf.Atan2(direction.x, direction.z)*Mathf.Rad2Deg + cam.eulerAngles.y; float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle,ref turnsmooth, turntime); transform.rotation = Quaternion.Euler(groundnormal*angle); the thing is it's using transform.eulerAngles.y, and I'm makink a game where you can change gravity and walk on walms, thus the .y wouldn't be relevant, and I'm trying to make a generzalized wethod depending on my gravity axis instead of the y world axis. Any idea on how I could achieve that ?

shell sorrel
#

also no need to put yourself down, the first few weeks of learning to program does not come easy to most people

slender nymph
vague dirge
#

How can I do that please ?

#

but the eulerAngles method only accepts world axis as arguments

shell sorrel
#

dont use eulerAngles directly

#

will take your euler value and make it into a Quaternion then you can shove that into localRotation

vague dirge
#

Ok I'll try that thank you 👍

calm dust
#

im so lost

#

i know onFoot is in PlayerInput

slender nymph
calm dust
#

oh

#

shit

#

ya i see

#

how do i put it in there

summer stump
calm dust
#

sorry

#

that made no sense

#

how do i put onFoot into that class

summer stump
#

Autocomplete

calm dust
#

alot of stuff

#

too much to ss

summer stump
#

Look through it

#

Find the one that sounds right

slender nymph
#

if you start typing onfoot what do you see suggested

calm dust
#

nothing

slender nymph
#

note that you should be doing this on PlayerInput. (or whatever your player input class is actually called

calm dust
#

i am

slender nymph
#

did you go and do something silly like remove your on foot action from your input action asset?

calm dust
#

no, i dont think so

slender nymph
#

at this point you should go and learn how c# works. then go rewatch the tutorial because it seems like you are not understanding anything at all that you should be doing or what is being suggested

shell sorrel
#

did code gen for the inputs get turned off

short hazel
#

Jumping in now so it may have already been suggested, but did you name your asset PlayerInput? It's required for it to detect the correct class. Otherwise it gets Unity's built-in PlayerInput script, which definitely doesn't have an onFoot property

slender nymph
#

no they had it on. their issue has been just constant spelling mistakes and randomly guessing at how to fix them

#

and like 99% of it has just been capitalization. they had everything correct except capitaliziation before, but now they've gone and changed so much who even knows what they have right

summer stump
short hazel
# calm dust

Right. So the error they get here is because they pick the wrong class...

calm dust
#

hold on, i think i fixed it

#

well, you guys fixed it

#

ok, so there are no more errors, but my character wont move

slender nymph
#

show the code

calm dust
#

ok

#

all of it?

#

all 3 things?

slender nymph
#

all of the code relevant to moving it, yes

calm dust
#

ok

#

gimme a sec

slender nymph
#

and you have attached these objects to your player object in the scene?

calm dust
#

yes

short hazel
#

Seems like you just renamed class PlayerMotor, seeing the dotted outline around the name. Make sure you also rename the file, both must be identical

#

Example: class Sample in file Sample.cs

slender nymph
short hazel
#

They lifted the file name must match class name restriction?

slender nymph
#

sort of, yes. if you have only one MB in a file it will add that, otherwise if you have more than one MB in a file it will add the one that matches the file name or the first one it finds

short hazel
#

Anyway even if they did, the C# standard is still to have one type per file, with the file name identical to the class name, for organization purposes

calm dust
#

SPR2 was right

#

its moving now

rare basin
calm dust
#

thank you so much

rare basin
#

only for the newer 2022 versions and above

#

its not mandatory

slender nymph
#

right, i think it was added in one of the 2022.2 versions

rare basin
#

yea

calm dust
#

ok, so this one should be an easy fix, instead of my character going forward when i press w, it just gos straight up

slender nymph
#

you should be putting input.y in the z axis not the y axis of your moveDirection variable

#

forward is along the Z axis in unity

calm dust
#

ok

#

lemme try that

calm dust
slender nymph
#

no

#

because input does not have a Z axis. it only has an X and Y axis on account of it being a Vector2

calm dust
#

so, what do i do?

stable crystal
#

Spawning objects based off camera direction / mouse location

calm dust
#

im sorry, but i dont understand

#

its ok if you dont want toanswer

slender nymph
#

input.y goes in the Z axis of the moveDirection vector3

calm dust
#

what would that look like

#

would you klike a photo of my code

slender nymph
#

literally just one letter off

calm dust
#

so "moveDirection.z = input.y;"

slender nymph
#

yes

calm dust
#

is that an extra line or just edit the existing one

slender nymph
#

edit the existing one unless you want to move upwards with forward input

calm dust
#

fair enough

fierce sonnet
#

I have a huge scale evolution simulation and I am currently using Ray cast for their vision. Are there any more efficient options or is Ray casting the best option, which requires the least processing power

calm dust
#

it worked, thank you so much

summer stump
wintry quarry
opaque fox
#

This helped, was able to find the correct distance.

However, now it endlessly loops the "Timer breached" statement after triggering two times, which causes endless chasing no matter the distance.

opaque fox
#
 {
    // Wander();
     if (Vector3.Distance(transform.position, player.transform.position) < viewDist && !lookingAtPlayer)
     {
         Debug.Log("Player spotted");
         Debug.Log(agent.transform.position);
         Debug.Log(firstPos);
         transform.LookAt(player.transform.position);
         timer += Time.deltaTime;
         firstPos = player.transform.position;
         destSet = false;
        // lookingAtPlayer = true;
     } 
     else
     {
         Wander();
        // lookingAtPlayer = false;
     }

     if ((timer >= stopTimer) && !destSet)
     {
         Debug.Log("Timer breached, begin charge.");
         Debug.Log(agent.transform.position);
         Debug.Log(firstPos);
         lookingAtPlayer = true;
         agent.SetDestination(firstPos);
         agent.velocity = (player.transform.position - transform.position).normalized * chargeSpeed;
         // destSet = true;
         // timer = 0;
         // lookingAtPlayer = false;
         // destSet = true;
         Debug.Log("Position: " + transform.position + " // Target Position: " + firstPos + " // Distance:  " + Vector3.Distance(transform.position, firstPos));

     }

     if (Vector3.Distance(agent.transform.position, firstPos) < 0.02f)
     {
         Debug.Log("Reached player position");
         destSet = true;
         timer = 0;
         lookingAtPlayer = false;
       //  agent.ResetPath();
     }
 
 }```
#

i think what's happening is firstPos only gets updated once, so it keeps going no matter what because of the final if block only checking for the distance of the first spot firstPos is assigned to

#

The distance debug line you gave me correctly measures the distance between the AI and firstPos, but firstPos is only calculated once and never again

frigid sequoia
#

Half of the code is just commented out or is Debug; the if (timer >= stopTimer) && !desSet) seems to remain true cause the timer is never reset and the destination is probably reset each frame

opaque fox
#

sorry, my bad about the comments, i've been adding and removing lines

frigid sequoia
opaque fox
#

Right

#

I kinda want the behavior to repeat

  • See player
  • Charge
  • Stop once destination is reached
  • Repeat
frigid sequoia
#

If you want the enemy to swap between behavoirus, I will heavily encourage to have each one on a different method, and check which one is meant to be using in the update

opaque fox
#

Fair

frigid sequoia
#

It would be much cleaner and you would spot mistakes way easier

opaque fox
#

Right

frigid sequoia
#

Also, you can have a debug variable that is just a string that tells you which state is currently being used

craggy oxide
#
public float jumpHeight; // This is currently set to 25.

void Update()
{

if (Input.GetKeyDown(KeyCode.Space))
{
transform.Translate(jumpHeight * Time.deltaTime * Vector3.up);
}

}
#

so like

#

the jumping is really stuttery and not smooth whatsoever

#

and very buggy

#

the player character does have a rigidbody attached if you're wondering

#

what do I do to make the jumping smooth

frigid sequoia
craggy oxide
#

see i tried that, i dunno if i was just doing something wrong but it kinda broke the whole script, like the spacebar input wasn't being detected

#

ill rewrite it to be sure and send you the alternative code if it doesn't work still

#
private Rigidbody rb;

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

public float jumpHeight; // This is currently set to 25.

void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(jumpHeight * Time.deltaTime * Vector3.up);
}
}
#

alright yeah it's doing the same thing again, the force just isn't being added whatsoever

#

as if the input isnt even detected

#

so, theres the alt code above, what do i do

frigid sequoia
#

I am pretty sure the input is being detected

#

Just that AddForce needs more force

#

Multplying forces by deltaTime usually doesn't do anything, cause it turns it into way to little force to change anything

#

Also, you proballbly want to use FoceMode Impulse

#

But that depends more of what kind of jump you want

summer stump
#

But yeah, Impulse mode is a good idea

small mantle
#

How can I easily make a better movement system. Something that can easily be done with if statements.

summer stump
small mantle
summer stump
#

I guess construct a vector with GetAxis and pass it directly into Translate...
Simple, but not great

small mantle
#

I am currently using rb.velocity. I was wondering how I can use AddForce that is less robotic.

summer stump
#

See what daleo and I were saying above about how to use AddForce

#

With AddForce you would want to use GetAxisRaw instead of GetAxis, since AddForce is already kinda floaty

small mantle
#

Is there a way to add a max force easily? I want the player to stop adding force at a certain point and stay at its max.

frosty hound
#

Clamp the magnitude of the rigidbody velocity

small mantle
#

I found an example online and they are doing this: rb.velocity = Vector2.ClampMagnitude(rb.velocity.magnitude, maxForceSpeed); Why is there an error?

summer stump
#

Oh, no it's because you clamp the vector, not the magnitude property

#

rb.velocity only, not rb.velocity.magnitude

small mantle
summer stump
#

Hmmm, I would guess you have to just use Mathf.Clamp on the individual parts of the vector, and the plug them back in?

#

so like
Vector3 newVelocity = rb.velocity;
Mathf.Clamp(newVelocity.x, min, max)
rb.velocity = newVelocity;

#

or something

#

Phone coding sucks

#

oh, mathf.clamp returns the value

#

so that is wrong

nocturne parcel
#

Why are you clamping velocity anyways? It is already an instantaneous thing

summer stump
small mantle
nocturne parcel
#

You are already overriding the velocity to the given value, constantly. Clamping makes more sense for AddForce, no?

nocturne parcel
#

Oh, I see

frail star
#

I'm making a calendar in my unity app , Does anyone know how I can correctly line the days of the month up with the days of the week?

summer stump
#

Vector3 newVelocity = new Vector3(Mathf.Clamp(rb.velocity.x, min, max), rb.velocity.y, 0)
rb.velocity = newVelocity

#

I dunno, something like that

small mantle
summer stump
#

And probably need to clamp z as well if it's 3d

summer stump
#

Then may as well set z velocity to 0 then haha

nocturne parcel
#

Either way, I still wouldn't change anything on velocity.
You could do something like AddForce(maxVelocity - rb.velocity).

#

This way, if you get to max velocity, you add 0 force

small mantle
summer stump
#

I'm sure there IS a way better way than what I did though haha

frigid sequoia
nocturne parcel
#

This way the Y axis doesn't have a max value

copper perch
#

I am learning each keyword and function day by day in the Weapon script, and the UI Manager script.
I walk around with a print out of the weapon script, and the UIMnager script, and look at it while I am at work so it goes in my head.

small mantle
#

What is this ? called in C#?

summer stump
small mantle
summer stump
#

Ternary operator

#

that would be invalid syntax though

#

because it has to assign to something

#

variable = condition ? true assignment : false assignment

cosmic dagger
frail star
frigid sequoia
#

Like, what is generating the squares of the day in the calendar and putting them in place?

frigid sequoia
#

But how are you turning that into an interface?

#

For what I see here you could take the day of the week the month should start for each one and add a bunch of empty containers before that as needed

frail star
cosmic dagger
#

Unity only uses C#, your best bet is looking for JS tutorials online or a JS discord . . .

frigid sequoia
#

I would add a method that just adds X amount of empty containers to the grid and set manually how many I need for each month; probably not the most efficient

#

You could calculate how many it needs by knowing the start day and the days of the previous month, but I don't think it is needed unless you want to overcommit to it

cosmic dagger
#

i do not know what PlayCanvas is or if that is related to Unity. You will have to search online for tutorials or materials. Are you new to Unity components? If so, check out !learn to get started with learning Unity . . .

eternal falconBOT
#

:teacher: Unity Learn ↗

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

frail star
frigid sequoia
# frail star I'm I've committed to it already.

Well then you could calculate automatically the offset needed for the next month by adding the base offset (which I think you have to take manually? not sure) and the number of days of the month and subtract seven for it until it is lesser than seven, that's the number of days the next month needs as offset

cosmic dagger
#

This is not a teaching or tutoring discord. The channel is for help with Unity coding errors, bugs, and system architecture. If you want to learn a concept, check out tutorials online or the link I sent previously . . .

abstract pelican
#

Is this some kind of joke?

summer stump
eternal falconBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

summer stump
#

Try redoing the guide

abstract pelican
#

vscode?

#

i using Rider

cosmic dagger
#

Rider, i presume?

summer stump
eternal falconBOT
summer stump
#

Rider is there

abstract pelican
#

How to solve the problem?

cosmic dagger
abstract pelican
#

I restarted unity and rider, it didn't help.

abstract pelican
#

for some reason it says this

cosmic dagger
#

well, you never answered my question from earlier . . .

rich adder
#

did you save?

summer stump
#

Don't blindly copy from the docs 🤷‍♂️

#

And yeah, don't ignore people

abstract pelican
#

I don't have any options for some reason.

rich adder
eternal falconBOT
summer stump
#

Alright well, if you're not gonna respond to anyone, I wish you the best of luck! Seeya

abstract pelican
#

Dude, I use this a lot and it worked, now for some reason it doesn't work after I decided to copy from the docs

abstract pelican
# rich adder !ide

Why do you advise me to use an IDE when I already use ade on 5 projects?

cosmic dagger
#

that's dandy and all, but did you happen to create your own class named Time?

rich adder
abstract pelican
cosmic dagger
abstract pelican
#

It's set up and was working fine, just now there's a problem with Time

abstract pelican
calm dust
#

why does my code look like this:

#

when it should look like this:

summer stump
#

The absolute most important question gets ignored the whole time, while other suggestions go completely misunderstood lmfao

abstract pelican
calm dust
#

ive done tha

summer stump
abstract pelican
rich adder
cosmic dagger
abstract pelican
#

I don't understand why he's suggesting I write like this?

calm dust
#

i configured my ide, but there is no option to regenrate project files

rich adder
#

if you had configured it you should know where it is

calm dust
#

oh wait lol

#

im not in unity

#

im stupid

cosmic dagger
rich adder
#

prob because you have another class named Time?

abstract pelican
summer stump
abstract pelican
#

I'm already using it, why would I use it again?

summer stump
# abstract pelican

Maybe because of what Random has been asking this whole time which is still unanswered

abstract pelican
#

there's only a folder

rich adder
#

this is a folder not a class

cosmic dagger
summer stump
calm dust
#

i found the regenerate, should i do all of them?

abstract pelican
summer stump
frigid sequoia
#

It is fine if I have an exploding enemy and when it explodes it activates a collider attached to it (to deal damage), and then it is destroyed after a 0.1 sec delay or relaying on this arbitrary timers for all to work properly is kinda messy?

cosmic dagger
rich adder
calm dust
#

i clicked it but nothing happened, is that normal?

rich adder
calm dust
#

no

summer stump
#

This is just like when you were calling Pinballkitty names because of your own misunderstanding...

unreal imp
#

guys how is possible a camera recoil?

calm dust
rich adder
#

prob child mind hasnt developed yet

calm dust
#

me?

abstract pelican
#

Oh, my God, the problem was the folder

#

you don't seem to know

calm dust
#

@rich adder i didnt close vs before doing it

rich adder
abstract pelican
rich adder
calm dust
#

ok

rich adder
abstract pelican
summer stump
#

Using pictures instead of words makes things super confusing

abstract pelican
#

I asked you about the folder, you said it had nothing to do with it.

summer stump
#

Ah, more lashing out

#

They asked if it was an asmdef, but you sent random pictures and refused to answer anything

rich adder
calm dust
#

tysm

#

navarone

rich adder
#

is working?

abstract pelican
rich adder
#

aw I cant clown emoji they blocked me

#

boohoo

abstract pelican
#

What did I do? I said he was wrong.

summer stump
frosty hound
#

I'm not going to read through all this, but if you have it working then move on.

rich adder
sour ruin
#

hi. if you have a value, say a boolean that is dependent on the result of a raycast called every frame, is it better to continually update said value regardless of whether it has changed from the previous check or have a conditional along the lines of: if (variable != newValue) variable = newValue;

#

or is the difference negligable

rich adder
#

negligable

sour ruin
#

aight

#

thanks

#

also negligible for an animation parameter?

simple sun
#

ok i havent been in unity for quite some time now and chatgpt is very useless sometime
im making 2d game, trying to detect when an apple is being collided with

this is my snake and apple in inspector
https://pst.innomi.net/paste/czyjxxkse63g4d4rm7563xfs

the collision is not being detected

rich adder
#

you mean SetBool ?

sour ruin
#

yeah

rich adder
#

if you care to optimize it , best to use the string to hash

sour ruin
#

i gotchu king

rich adder
#

drop the gpt if you want to learn properly

simple sun
rich adder
simple sun
#

nop

rich adder
#

if you have a rigidbody you shoud not directly set the transforms

simple sun
#

apple does not have a rigidbody

#

only boxcollider2d

rich adder
#

wheres the movement script then

simple sun
#

the snake moves, not the apple in that sort of way

#

i dragged the snake around manually when the game was running, no physics detection

rich adder
simple sun
#

ive dragged gameobjects around in 3d before in the same way, and that detection worked perfectly

rich adder
#

doubt it and this is a different physics engine

#

and ur rigidbody is not even dynamic, its kinematic

#

dragging it arround wont give you any OnCollision

simple sun
#

i changed it to dynamic while the game was running and continued dragging it over the apple, still no detection

rich adder
#

ur moving the transforms 🤷‍♂️

simple sun
#

fairly certain that is fine, but ill try do it using rigidbody

rich adder
#

if you let go of it it might work if they are intesrsecting already and tries to push itself out, but if its dynamic

rich adder
simple sun
rich adder
sturdy drum
#

Hello, I'm trying to make a grappling hook Metroid style, but the ray line will only go diagonally up right, even when my character is flipped and looking left. I think it's because my Player's Scale's are static and wont change no matter which direction I look, even though the grappling hook is programmed to make a diagonal up left line when I'm looking left. Is there a way to make your Scale go negative when turning left?

rich adder
#

should rotate the player 180 on Y

simple sun
#

@rich adder well you were correct with the 2D engine, it does collide if i move using the Rigidbody
maybe its just different between Rigidbody and charactercontroller, as its a charactercontroller body ive moved in 3d before with no problem

rich adder
sturdy drum
#

That's true, I have it set as sprite.flipx. In game though, when I look left, Unity shows X as checked. Is that only applying for the sprite as well then and not the Player object itself?

rich adder
#

rotate 180 so your transform.right is always facing correct, much easier to work with rays n stuff like that

sturdy drum
#

so something like this?

#

if (dirX < 0f)
{
playerTransform.right = Quaternion.Euler(0, 180, 0) * playerTransform.right;
}

rich adder
#

no?

sturdy drum
#

hmm, ok. Is there a better method then?

rich adder
sturdy drum
#

After some testing, the rotation itself works, but seems to override the Sprite flipping left, so it stays looking right

#

I've tried adding the sprite.flipX to the if statement, as well as before and after, but the results stay the same 😦

rich adder
sturdy drum
#

Does rotation of the object flip the sprite as well?

sturdy drum
#

you're a genius

#

thanks man lol

fickle plume
#

This is Unity server.

sour ruin
#

Is it possible for an animation event to specify an enum constant as a parameter to a function? It sort of looks like im passing the enum type as is (see reference images)

teal viper
sour ruin
#

ok thanks

thorn kiln
#
    public Rigidbody2D myRigidbody;
    public CircleCollider2D myCricleCollider;
    public float flapStrength;
    public LogicScript logic;
    public bool birdIsAlive = true;
    public GameObject gameOverScreen;```So, with this stuff, how do you determine what the... I wanted to say "green text", but apparently discords code formatting doesn't colour it like visual studio. Anyway, how do you determine when to use stuff like Rigidbody2D, CircleCollider2D, LogicScript, etc should be. I know they're components on the object, but can you not the transform properties when you just reference it as a game object?
turbid robin
#

in unity i see this, but when i try to put on my phone i dont see the black background all in the square

#

ehat can i do? the canvas is resized by screen size

#

This is in phone

fringe plover
#
    public void Start()
    {
        CR(1);
    }
    public void CR(int i)
    {
        CR(i++);
    }

Is my code good?

modest dust
#

If you plan to crash your editor then yes

#

You'll be calling CR with params of 1, then 1, then 2, 3, 4... it's a recursive loop which doesn't end.

fringe plover
ivory bobcat
modest dust
gaunt ice
#

tail recursion will end because of stack overflow

keen dew
#

obvious shitpost is obvious

gaunt ice
#

sometime it is easier to spot out the problem

public struct TreeNode{
  TreeNode* parent;
  TreeNode* children[number];
}
dfs version of go to child:
int dfs(TreeNode* node){
  dfs(node->children[x]);
}

iterative version:
int traversal(){
  while(1){
    TreeNode*child=node->children[x];
  }
}

if you mis assign some child eg circular reference
recusive version will end but iterative will stuck
```ofc it is just one while loop so you may not see the different, but at least stack overflow can tell yousome pointer address is wrong
thorn kiln
#

For years we've wondered, now we'll have an answer

teal viper
thorn kiln
#

Damn

timber tide
#

https://i.imgur.com/uwwDQaQ.png
Rewriting some of my UI for how I've got references linked with slots for when I decide to drag them upon each other with mouse/touch controls. Currently I use #2 here where each SlotUI has a reference to slot, this way when I drag a SlotUI onto another SlotUI I immediately know the reference of the slot they point to and similar to the Slot that I am currently hovering over (thanks to the event system).

Now, for #1, instead of directly referencing the slots, I could instead implement callbacks and resolve it through the managers (Inventory class) instead. This does seem like the more correct way to do it, but I would require mapping each Slot to each Slot UI by indices instead (I guess I can just couple by references similarly in a container)

So I guess the question is, should SlotUI have a reference to the slot it's representing, or should I have these references mapped via container on the managers?

#

I've rewritten all this stuff like 5 times already

#

looks like it's going to be a 6th

teal viper
#

Either is fine imho. Maybe using indices decouples the logic from presentation a bit better though.

sleek notch
#

Can someone please explain why it isn't working? Even if I did some boolean variable it wasn't working

#

and still not working. When I remove the second if, then it works. I don't know

teal viper
timber tide
#

what's the warning

#

or underline

sleek notch
#

No warning. It works with only one if

gaunt ice
#
  1. log if update runs
  2. update wont run in inactive gameobject
sleek notch
#

I had it on my player with GameObject ui; and same results

timber tide
#

your first screenshot logic is off such that if it goes into the first it always goes into the second

#

probably what the warning is telling you

sleek notch
#

This is all my code for UI inventory and it is attached to Player

#

still doesn't work

mortal bridge
#

somethimg underlined hmm

tawdry rock
#

I need a little help. I want to make a hitbox system but my rays can't detect the trigger colliders. They marked as 'is trigger'. im using hit.collider.isTrigger in a if and in my physics settings i checked 'queries hit triggers' but still nothing happens.

sleek notch
# mortal bridge somethimg underlined hmm

No. They are cool because I need to check if it is active and it works. It just tells that I can use .SetActive() but it is function and I'm not able to check if it is active

tawdry rock
mortal bridge
#

my mannyou say

#

second ssbfixxed it

#

and you see undeeline in 2nd

#

no

#

just give these IDES some kredit please

#

theydeserve better

tawdry rock
sleek notch
mortal bridge
#

look you have same keycode for two

#

uou see that

#

that maybe why 2 ifs dont work

tawdry rock
#

i would also cache it in awake as a singleton refference instead of using .Find so you can turn the gameobject off by default

mortal bridge
#

computer is confsed

sleek notch
tawdry rock
#

because the function gets called in every frame, and as soon as you open it it hide it. it works.. just only for 1 frame

modest sage
#

Hello guys, can anybody help me with my problem? I am trying to make map preview with clickable objects. I have orthographic camera, canvas set to screen space - camera. In another (menu) canvas i render this orthographic camera. On picture with selected mousePosition object in scene, my mouse is on the red clickableObject :/

fervent abyss
#

Hi, im trying to AddListener to event in OculusSDKManager in Start() function, but in the Unity editor, I get a null reference exception error

ivory bobcat
#

Either the instance hasn't been assigned yet and throwing null or the credentials hasn't been initialized yet.

north kiln
tawdry rock
#

is the navmesh agent function as a collider? like the character controller?

teal viper
#

Although, it probably does account for colliders during active avoidance.

tawdry rock
#

thanks, so i became crazy soon. I can HIT triggers, but if i put them on navmeshagent i can NOT longer hit them even if i put a ignore raycast mask on the navmesh. also doesnt matter if i put the trigger as child or on the bone

#

like.. how do you make a hitbox system?.. if i change the triggers to colliders the navmesh agent gets crazy for obvious reasons so i can only use triggers but they suddenly wont work on them.

teal viper
tawdry rock
#

do i have to put also on the trigger collider?

teal viper
#

It depends. Maybe explain your setup a bit better. What are the trigger colliders for?

tepid summit
tawdry rock
teal viper
tawdry rock
tawdry rock
#

i moving them by SetDestination and feeding the player position to them (in update, i know its expensive but i must). edit: even if i give them 1 sec delay to update the destionation in every 1 sec still not detecting the trigger.

tawdry rock
#

`
timertest -= Time.deltaTime;
if (timertest < 0)
{
ChasePlayer();
timertest = 1.0f;
}
} // endof Update

void ChasePlayer()
{
agent.SetDestination(Refferences.Instance.FPSC.transform.position);
}
`

teal viper
#

Okay, use debug rays to see if your raycasts are intersecting the triggers.

tawdry rock
#

i do, they do

teal viper
#

Pause the game when you're supposed to hit a trigger and check the scene view to see if it intersects any trigger.

#

Take a screenshot if you already do.

tawdry rock
#

this is when a trigger set on the world but on the agent it doesnt. ( will make a new ss)

#

nothing on the console

#

don't want to celebrate early, but after restarting unity it seems like its working, (maybe some prefab was not updated correctly?) i will need to test with animations and stuff. thanks for your time @teal viper for now.

#

never mind, i found it. if the navmesh agent's rigidbody gravity is set to true it won't detect the trigger even if the trigger doesnt fall off as it seen on the screenshot. if the gravity is unchecked it detects... anyone can explain this?

quaint terrace
#

I have gameObjects that have a script OnMouseDown() but I don't want them to be clickable when they are behind the grey image. How would i prevent the gameObjects from responding to clicks received while behind the grey image?

timber tide
#

allow it to block raycasts

quaint terrace
#

ive selected the grey image and unchecked the Raycast Target and Maskable, ive also check it but the items are still being selected through the image

timber tide
#

Actually you may be mixing two different raycasts which is a problem

#

one being the graphics raycaster and OnMouseDown() is a physics raycast query I think?

hard sigil
#

Hi, can someone tell me how do I disable monster to follow player (Script) when monster turn into a ragdoll?

quaint terrace
#

oh, so my script is stronger than the image raycast, so i would have to change my OnMouseDown?

frosty hound
timber tide
#

buttons would work too

quaint terrace
#

so if i turn off the Box Collider the OnMouseDown stops working, theres a Layer Override Priority, but I think thats for if multiple box colliders are on top of one another

#

ha! i just put a box collider on the grey image and it fixed my issue -.- im stupid.

timber tide
#

technically the image already has a collider, but it does not block the physics raycast

quaint terrace
#

Thank you for the help, if i didnt talk it out here id probably would have started rewriting code ._.

quaint terrace
hard sigil
#

Oh, whats the script? (I'm new)

quaint terrace
candid roost
#

@timber tide thank you you smart

rare basin
#

you can enable/disable component

ruby python
#

Hi all, I'm playing around with a sort of factory idea (not really a factory but some of the principles of are the same, crafting etc). I'm wondering what you guys think would be the best approach in terms of recipes/material input/compnent output would be? (ie, how to structure the whole thing etc.)

rare basin
#

i'd make recipes as a scriptable objects

#

where you have list of items needed for that item you want to craft

#

success craft chance (if you want that)

ruby python
#

So, the scriptable object would be the item you want to craft, and contain the recipe data in that?

timber tide
#

yeah, I'd stick the crafting requirements on the ItemSO itself

rare basin
#

not an actual item

#

but a recipe for that item

ruby python
#

Okay cool, thanks. Maybe this time I'll actually get my head around how to use SO's lol. (I know how to 'make' them etc. for some reason I always struggle/fall over when it comes to actually getting the data/using them. lol.)

rare basin
#

it's pretty straight forward

#

some basic tutorials about SO should help

#

basically it's just a data containers

#

just be careful and don't modify them (unless you know what you are doing)

timber tide
#

I was thinking having separate SOs for the recipe and item, but that just kinda makes more assets.

rare basin
#

i usually make properties for SO

#

with private set

#

[field: SerializeField] public int BaseHealth { get; private set; }

timber tide
#

an itemSO with an inner class for crafting as that crafting recipe should just be unique to it

rare basin
#

for example

sacred harness
#

why does slerp behave this way i have two objects that rotate in one axis x they have the rotation of [0,90] i find the average total/count then i use slerp to rotate to that target but it ends up as [45,67.5] the 67.5 is the average of [45,90] this works with rotatetowards but not slerp (im using atan2 to find the rotation of the objects)

rare basin
#

what's the last paremeter?

sacred harness
#

one

rare basin
#

show the slerp code

sacred harness
#

full script? or just the line

rare basin
#

just the slerp line

sacred harness
#

transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(averagerotation / (LIST.Count + 1), 90, 180),1);

ruby python
#

I'll be honest, one thing that I haven't been able to get my head around in terms of SO's (and please forgive me if this comes across as reeeeeeally ignorant), but what is the 'benefit' of SO's over Enums or just a basic script that holds the data? I've never seen/read/heard it explained so I don't really understand the benefit tbh.

rare basin
rare basin
#

it is not relevant to enums in any way

#

watch some SO tutorials first

#

and it will clarify most of your questions

rare basin
#

last paraemter is the interpolation point

#

you cannot just pass 1

ruby python
#

I honestly have, but it's not really been explained in the stuff I've watched/read. It's basically just a 'these are great' kind of thing if that makes sense?

rare basin
#

it's super designer friendly

timber tide
rare basin
#

more GC friendly

#

and just comfortable to work with

timber tide
#

1 data script can become multiple different variations. Good workflow utility

#

serializable in the editor

queen adder
#

why there is no texture

late bobcat
#

Guys i'm currently working on a grappling hook that let the player spin around the targeted enemy. Right now it's kinda of working if it wasn't for the orbital trajectory that keeps spinning even tho it shouldn't. So everytime the gorilla shoot the grapple it start spinning from where the "current orbital imaginary position is" and not from the gorilla position, like in the video.
Here's the code: https://hatebin.com/ldajccqhhe . Can someone help me understand what's the problem? ty

rare basin
queen adder
rare basin
#

not in code related channel

queen adder
#

yes but whre !!!

#

where

rare basin
#

you can see all the channels on the left?

queen adder
#

no i can't

rare basin
queen adder
#

tell wath is the chanel for hlep

rare basin
#

browse the channels

#

each channel is for different topic

#

this is channel for code

sacred harness
rare basin
#

it would

#

1 would result the 2nd parameter

#

you pass

#

0 would result the 1st

#

0.5 would resoult between

sacred harness
#

then why did you say it was wrong

ruby python
#

Okay, I know about the whole inheritence thing and variations. So for example.....in terms of crafting things, would this 'tree' be okay?

`Item

  • Sustanance
    ---Food
    ---Water
    ---Oxygen
  • Component
    ---Component #1
    ---Component #2
    ---Component #3 (etc. etc.)
  • Tool
    ---Tool #1
    ---Tool #2 (etc. etc.)
  • Weapon
    ---Weapon #1
    ---Weapon #2
    ---Weapon #3 (etc. etc.`
rare basin
#

transform.rotation = Quaternion.Euler(averagerotation / (LIST.Count + 1), 90, 180)

#

you could just do it like that

#

why did you do slerp

#

when you are not using it

sacred harness
#

because i was going to do it through a duration i just put 1 as a test

dim pendant
#

is this the right channel to ask for a little help

late bobcat
rare basin
#

this is code related channel

dim pendant
#

yeah im having trouble with pointing in direction of cursor

late bobcat
eternal falconBOT
dim pendant
#

ye gimme a sec

#
using UnityEngine;

public class shooting : MonoBehaviour
{
    public Transform firePoint;
    public GameObject bulletPrefab;

    Vector2 lookDirection;
    float lookAngle;
    public float bulletSpeed;

    void Update()
    {
        lookDirection = Camera.main.WorldToScreenPoint(Input.mousePosition);
        lookAngle = Mathf.Atan2(lookDirection.y - firePoint.transform.position.y, lookDirection.x - firePoint.transform.position.x) * Mathf.Rad2Deg;

        firePoint.rotation = Quaternion.Euler(0,0,lookAngle);

        if(Input.GetMouseButtonDown(0))
        {   
            //Debug.Log(Input.mousePosition);
            //Debug.Log(Quaternion.Euler(0,0,lookAngle));

            GameObject bullet = Instantiate(bulletPrefab);
            bullet.transform.position = firePoint.position;
            bullet.transform.rotation = Quaternion.Euler(0,0,lookAngle);
            
            bullet.GetComponent<Rigidbody2D>().velocity = transform.up * bulletSpeed;
        }
    }
}
#

idk if thats too much lol

languid spire
#
Camera.main.WorldToScreenPoint(Input.mousePosition);

should be ScreenToWorld

dim pendant
#

💀

#

ah thats embarrasing

#

cheers a bunch

noble summit
#

where do i find the input axis's in unity

short hazel
#

Edit > Project Settings > Input

#

(if using the legacy input manager)

noble summit
#

thanks what about the new input system

short hazel
#

It's an asset in your project files

#

.inputactions I think that's the extension it's using

#

You created it yourself, a blank project does not come equipped with one

noble summit
#

thanks

scarlet skiff
#

spear: https://gdl.space/aruqowiteb.cs
warning: https://gdl.space/ufejihibep.cs
their spawner: https://gdl.space/anozisecor.cs

spawner is supposed to spawn a warning and a spear, once the warning animation is played, it sets the spears canMove to true, which then allows it to move towards the player. but it just won't accept my way of giving it a reference.
no matter what i do it wont give it the reference... even tho spear does have a reference when i check with debug.log

short hazel
scarlet skiff
#

thank you very much

noble summit
#

what is the difference between force and velocity

burnt vapor
swift crag
#

didn't you ask this a day or two ago

rich bluff
languid spire
#

force is what applies when someone pushes you, velocity is how much it hurts when you hit the ground

wintry quarry
#

The end result of a force is a change in your velocity. That's the only thing force does.

rich egret
#

!code

eternal falconBOT
rich egret
naive lion
#

Can anyone see why my prefab is being spawned infinetly:

    {
        _forcefield = Instantiate(forceFieldPrefab, self);
        LeanTween.scale(_forcefield, new Vector3(6125, 6125, 6125), 1f).setEase(LeanTweenType.easeOutQuart);
        base.Execute();
    }```

This is where execute is called:
```    private void RunStateMachine()
    {
        TitanState nextState = currentState?.RunCurrentState();

        if (nextState != null)
        {
            //Switch State
            RunNextState(nextState);
        }
    }


    private void RunNextState(TitanState nextState)
    {
        currentState = nextState;
        currentState.Execute();
    }```
burnt vapor
honest haven
#
        {
            if (GameManager.instance.cratingItemsHeld[i] == "Wood" && GameManager.instance.numberOfCratingItems[i] >= 1)
            {
                
            }
            if (GameManager.instance.cratingItemsHeld[i] == "CementMix" && GameManager.instance.numberOfCratingItems[i] >= 1)
            {
                
            }
            if (GameManager.instance.cratingItemsHeld[i] == "Caffine" && GameManager.instance.numberOfCratingItems[i] >= 1)
            {
                
            }
            if (GameManager.instance.cratingItemsHeld[i] == "Batteries" && GameManager.instance.numberOfCratingItems[i] >= 1)
            {
                
            }
        }``` whats a clean way to do this. i need to check them all at once and a nested loop wont work as the index would be different each time. need them all in one if statement but not look so messy
#

i need to do somthing if they are all true

burnt vapor
rich egret
burnt vapor
honest haven
#

i need to do it at run time and the list grows

burnt vapor
burnt vapor
honest haven
#

as in the value of the items change

burnt vapor
#

Perhaps make a system where you store a list of required items in a list, and then have a CheckIfPlayerHasItems() method that takes a unique identifier which then iterates the items

#

A list of strings is not going to care about your item count

#

You want to have a way of checking if those four items exist in the array, right?

#

In cratingItemsHeld

#

Another easy way would be using Linq's Any call. Make a method that takes the string and use Any to check if any item in your array is of that item name

rare basin
#

is this code running in Update?

#

put a debug.log in Execute() so you can track the stack trace

rare basin
naive lion
#

not really sure why this is not correctly set up tho

rare basin
#

can't tell without knowing your code architecture

#

and your state machine

#

but follow the stack trace

#

and debug it piece by piece

frozen phoenix
#

Hello, I wrote a movement code, but it gets stuck on the steps and stairs, I need a suggestion on how to solve the problem with a code, I couldn't find much content on youtubeda.

ruby python
#

Depending on your game, usually you would use a 'sloped' collider instead of a collider that conforms to the stairs.

naive lion
queen adder
#

how can I do so that when I press start I appear on the map and I can move around?

rare basin
gaunt ice
#

that means your run next state return itself

burnt vapor
rare basin
#

weird question

queen adder
rare basin
#

wdym how

burnt vapor
# frozen phoenix thanks

What I would maybe do is have a sphere cast spawn in front of you that is then moved down, to determine if you should move the player upwards, maybe. Requires some maths

rare basin
#

make a player prefab, instnatiate it on start (or just place it on the scene view)

#

and make movement logic

sacred harness
#

xaxup i did the timed thing which did work but its because its giving me smaller values which is ending up being closer to the end than the start like 0.1 or did i miss something in the video?

sacred harness
#

in the link

rare basin
#

the lerp thing?

#

as i said last lerp parameter is the interpolation point

sacred harness
#

YES i know and its slerp

rare basin
#

0.5f - between 1st and 2nd param

#

doesnt matter

#

parameters stays the same

#

slerp is just mostly for rotations

sacred harness
#

which i am doing

rare basin
#

both are just finding a percentage position between two points

#

slerp just does it on a circle

sacred harness
#

then tell me why its not working 1 is giving me 60 between 0 and 90 but 0.1 is giving me 45

rare basin
#

well that's not possible

#

how did you implement it

#

if you have (0,90,1)

#

then it would return 90

swift crag
#

Show your code.

#

we can't guess what you wrote

swift crag
#

so I'm very curious about what you're doing..

rare basin
#

he's changing rotation iirc

sacred harness
#

i am doing it with quaternions

rare basin
#

he's modyfing transform.rotation

#

with Slerp()

#

but please show the code finally

sacred harness
swift crag
#

this is slerping your current rotation towards some target rotation by 0.01 every frame

#

it's going to rapidly approach Quaternion.Euler(averagerotation / (objectlist.Count + 1), 90, 180)

sacred harness
#

ok thats why i was confused i didnt realise it was every frame

swift crag
#

well yes, you did it in Update

rare basin
#

as i said you're using the last slerp parameter wrong

swift crag
#

If you want to steadily rotate towards a rotation, use Quaternion.RotateTowards

rare basin
#

or use DOTween

#

free library, much easier to understand

sacred harness
#

oh shit im stupid its also changing rotation so 0.1 is different everytime lol

swift crag
#

it explains the least-wrong way to use lerp methods with a varying start value

sacred harness
#

i was thinking 0.1 would be the same value every frame but since im also changing my rotation 10% would be a different value every time that went over my head

swift crag
#

If the start and end values were constant, then there would indeed be no change from frame to frame

earnest atlas
#

Should I serialize Spirte rendered component or I can get it from an object

#

What is prefered

burnt vapor
earnest atlas
#

Im just getting sprite renderer with get component from an object

#

Im just asking what is better method

#

When all components are on same prefab

sacred harness
swift crag
#

Quaternion.Slerp will return the second argument if the third argument is 1.

#

Check that the big Quaternion.Euler(...) expression is producing the rotation you think it is

#

so, assign it to a variable and log its euler angles

earnest atlas
#

If I create variable that stores Health, will it be a local health or a reference to that GameController health?

#

left I just want to save Instance.Health to variable for cleaner code.

#

right is GameController health implementation

short hazel
#

It will be a local copy, as it's a float (a value type). Value types are pass by value, not pass by reference like class

earnest atlas
#

Yeah as I though

sacred harness
swift crag
#

A quick way to check if something is a value type is to try to assign null to it

#

The compiler will yell at you if you assign to a value type

#

(assuming it's not a nullable value type, at least)

#

i think that makes the type name appear like This?

#

so you'd be able to tell that it's the case, at least :p

earnest atlas
#

I just wasnt sure if Health was considered some sort of method or variable

#

Delegades are an interesting thing. Tho looks like overcomplicated function.

public Func<float> HealthReference { get; } = () => GameController.Instance.Health;
}```
#

But it also returns a current propiety

#

so useless

short hazel
#

Health is a property. Think of them as a pair of methods that get and set a value, and the right one is automatically selected depending on what you're doing with the variable

earnest atlas
#

I somewhat understand, I just want something sort of pointer.

#

Well it will cut down 1 entire word in my code 😄

short hazel
#

It's not possible to have those with properties

earnest atlas
#

Yeah Im looking up and this is the only way.

Im already cutting down a lot by the fact that GameController is static singleton

burnt vapor
buoyant rune
#

can someone help me , this code is meant to make my enemy object move to the right constantly but it just doesnt move heres the code

burnt vapor
eternal falconBOT
earnest atlas
#

Also that update calls events

#

That then deal with UI

burnt vapor
buoyant rune
earnest atlas
#

Thats not what I mean

burnt vapor
earnest atlas
#
public float Health
{
    get => _health;
    set
    {
        _health = value;
        HealthChanged?.Invoke(value);
    }
}```

This is my health code
short hazel
buoyant rune
#

oh

earnest atlas
#

Considered I will be getting some values out of thin air

short hazel
#

Yes, it's harder to see where something comes from

earnest atlas
#

Are pointers in C# used like ever?

short hazel
#

Yes there are supported (eg. int*), but in an unsafe context, you have to tell the compiler you know what you're doing, otherwise it errors

#

And at a higher level there's ref

buoyant rune
burnt vapor
#

Most features from pointers can be done differently in c#

#

Like the ref keyword

earnest atlas
#

passing a reference to variable huh

burnt vapor
burnt vapor
burnt vapor
#

And this is the most basic usage of pointers

earnest atlas
#

Welp I guess never going to deal with them

burnt vapor
#

Pointers are not so hard but I believe you do need to manage freeing the memory when you're done with them

earnest atlas
#

ref not working with my health rip

short hazel
#

No because pointers are only valid on value types, or inside a reference type with the fixed statement

#

The GC will still manage object lifetime

burnt vapor
earnest atlas
#

Somewhat similar

#

A little test

burnt vapor
#

That's kind of complex, maybe you should just call the original variable somehow

#

Maybe use events?

earnest atlas
#

I do use events

burnt vapor
#

If I see something like this I am thinking of just making an event to handle health changes

#

Anyway, I have never seen that error before

earnest atlas
#

What if I create a propiety with get and set where value I will use is Health from game Controller?

short hazel
buoyant rune
#

now

short hazel
#

You're better off just using the property as it's intended to be used, accessing it isn't expensive at all.

earnest atlas
#
private float Health
{
    get => GameController.Instance.Health;
    set => GameController.Instance.Health = value;
}```

Will this fly?
burnt vapor
short hazel
earnest atlas
#

Yeah I think so too

#

Reading code later will be confusing

burnt vapor
buoyant rune
#

i actually cant believe my ide wasnt configured i was so confused why some stuff wasnt working properly lol

short hazel
# earnest atlas Reading code later will be confusing

I guess that works since I've just tested:

private float _health;
public ref float Health { get => ref _health; }

But the deal breaker is that you cannot have a set accessor, so it would not be possible for you to invoke the event when the value changes. Also not sure whether this kind of syntax is yet supported in Unity

earnest atlas
#

How to write 3 less words in entire code by writing 10 extra words
sadok

#

Also lack of setter makes this a dealbraker in my case

cosmic dagger
#

Why even do it that way?

earnest atlas
#

just shower thoughts

cosmic dagger
#

At that point, just use a reference type . . .

noble summit
#

why isnt it letting me put decimels in vector3

burnt vapor
#

Decimal type != float type

#

So explicitly cast it to a float

#

But know decimal types are bigger so you might lose data

short hazel
#

But I guess the issue is you've forgot to put the "f" at the end of the number to make it a float? 3.14f

noble summit
#

i meant decimal as in "."

cosmic dagger
#

Like a reactive value as a class: ReactiveValue<int>, Observable<T>, ObservableStruct<T>, etc . . .

short hazel
#

Yes decimal numbers, with the dot, definitely possible

burnt vapor
short hazel
#

As well as the affected line of code

noble summit
#

you cant put random.range in a vector3??

cosmic dagger
noble summit
#

oh nevermind it was a different error

rare basin
#

the SystemError

buoyant rune
#

I need some help , i'll show my code. the enemy objet is the blue one and the player object is the red one, the enemy object is meant to walk right and once it detects a player or edge its meant to flip and walk the other direction to the same thing btu for some reason the player jus stays here stuck like this .

#

im literally following a tutorial so i have no clue where its going wrong

#

the person in the video has set animations , i havent but i dont think thats the problemn

frosty hound
#

If an animation is modifying the position, it will lock it in place.

#

Make sure you're animating a child object, not the root.

buoyant rune
#

I havent added animations eyt

#

yet

buoyant rune
rare basin
#

ok but what are you even doing 😄

burnt vapor
#

I doubt they even know

buoyant rune
rare basin
rare basin
burnt vapor
#

Please stop spamming the chat or just write the code as a whole

short hazel
#

Makrus is a troll or a kid (or both), as demonstrated in other channels. They do nothing but flooding the channels with irrelevant or not useful information

buoyant rune
#

someone mute this makrus guy

rare basin
#

or a debugger?

buoyant rune
rare basin
#

then debug your WalkDirection

#

you are constantly telling your player/enemy to move left then to move right

earnest atlas
#

You can also serialize you walk direction variable and see its values in the unity

rare basin
#

idk if we should ping moderators or not

short hazel
#

<@&502884371011731486> Spam

#

In doubt, don't doubt

rare basin
#

wise words

earnest atlas
#

I think it was when it doubt vote someone out

copper perch
#

Chat gpt say:
Regarding your issue with the gun not firing when pressing the fire button:

  • If the gun is not firing when you press the fire button on the UI, there could be several potential reasons:
    1. The UI button might not be correctly configured to call the FireWeapon() method when pressed.
    2. The UI button might not be linked to the correct function in the Unity Inspector.
    3. There could be issues with the interaction between the UI button and the weapon firing logic in your game scripts.
    4. There might be errors or issues in the shooting logic within the Shoot() method of your weapon script.
  • To troubleshoot this issue, you can:
    • Double-check the setup of your UI button and ensure it is correctly configured to call the FireWeapon() method.
    • Check for any error messages in the Unity Console when pressing the fire button to identify potential issues with the firing logic.
    • Debug the shooting logic in your Shoot() method to ensure it is functioning correctly when called from the FireWeapon() method.
burnt vapor
earnest atlas
#

also why you even post that here

#

it tells you what you have to do

short hazel
#

It's like not even linked to the actual issue!

rare basin
#

jezus xd

copper perch
short hazel
#

What is going on with the chat rn

copper perch
#

why yall hate chat gpt
?

earnest atlas
#

poor chatGTP is trying to tell him how to debug issue

#

and he throws it here

rare basin
#

we hate begginers who use it

#

or just people who use it in a wrong way

#

chat gpt is awesmoe if used correctly

earnest atlas
#

if only if it didnt hallucinate a lot

rare basin
#

stop, please

burnt vapor
#

Please stop spamming the chat, and post the code as a whole

short hazel
#

Where are the mods when we need them

burnt vapor
queen adder
#

Hell

buoyant rune
#

in the code

earnest atlas
#

Let me throw u an examle how I did it

buoyant rune
copper perch
#

my ass get the wupped without chat gpt

rare basin
#

instead of copy/pasting the code from the tutorials

copper perch
#

chatgpt a good homie

rare basin
#

without understanding it

#

not a good way to learn things

buoyant rune
burnt vapor
buoyant rune
#

because this is a school comp sci project

#

deadline soon

#

and im gonna change code

rare basin
#

why would we waste time teaching you then

timber tide
#

whoops should have learnt

buoyant rune
fickle plume
#

!warn 952061884062896178 This is your last warning for off-topic. Don't post chat program generated answers.

buoyant rune
#

we got these hard ass exams called a levels

noble summit
#

why are 2 objects clipping through eachother when both have rigidbodies and colliders

rare basin
#

stop spamming ffs

earnest atlas
#

As you see I have header with "debug values"

I just create a variable inside the class and serialize it allowing Unity to see it. I dont need to write anything there.

Ingame it will show what are their values

buoyant rune
#

i swear makrus is so annoying

frigid sequoia
#

It feels like tossing a coin

copper perch
#

no hate

eternal falconBOT
#

dynoSuccess Warning logged for widerecieverzombie. They may not have gotten a DM.

rare basin
earnest atlas
fickle plume
#

@queen adder Stop spamming here

earnest atlas
#

Or that was me not saving th prefab

rare basin
#

with or without field:

earnest atlas
#

will test it out

rare basin
#

you also don't need [field: SerializeField] for float type variables

#

do you know what [field: does?

earnest atlas
#

that is left over code I didnt cleanup

#

before that serialize was on RobotHealth

rare basin
timber tide
#

you serialize thebacking field

rare basin
#

you can do [SerializeField] just fine for float

earnest atlas
#

yeah for that I can

rare basin
#

thats what i said?

buoyant rune
#

so where here could i add serialize here

short hazel
#

Yeah if it's a field you don't need to tell it to target the field

earnest atlas
#

For this I need field

rare basin
short hazel
rare basin
#

here

#

in both cases

earnest atlas
#

that serialize field was from propiety

rare basin
#

you dont need the field:

earnest atlas
#

I know it just leftover when serialize was on different thing

rare basin
#

alr

earnest atlas
#

what does field do btw

wintry quarry
#

Didn't we discuss this yesterday?

rare basin
#

so why are you using things without knowing what they do 😄

burnt vapor
# earnest atlas what does field do btw

It sets the attribute on the backing fields of a property. However, you put this on a field so it already applies this on a field. field: is therefore only useful for properties with a backing field.

frigid sequoia
#

As a general thougth, do you guys write documentation for your methods and variables (to show the tooltip in the inspector) or it generally takes more time than it saves?

earnest atlas
burnt vapor
frosty hound
earnest atlas
#

we are just asked to comment code

rare basin
#
private int health;

//Deals damage
public void DealDamage(int damage)
{
   //substract damage from health
   health -= damage;
}

for instance this is completetly useless comments

gaunt ice
#

i see someone do that in javascript (because of loosely typing) but i think you dont need to do this in c#

earnest atlas
#

I mostly comment these things

rare basin
#

looks completely useless to me and could even be misleading

burnt vapor
rare basin
burnt vapor
#

Problem with comments is that they can easily become outdated

rare basin
#

good code doesn't usually require comments

#

it reads itself

burnt vapor
#

And very often it's useless because people can read the code

rare basin
#

yes

short hazel
#

You do it if you make a library that's going to be used by someone else, and at this point you do it in the XML-comments /// <summary> and most editors will pick them up and display them as you type

warm anvil
#

Good morning.

I wasn't expecting this behavior/solution but here I am and I'm wondering why. There something obvious so I know?

Why does the text appear in front of the image if the hierarchy has the text lower than the image?

#

I arrived at this point when I had the ItemImage lower than the text and couldn't see the text - so I decided to flip them and that's when I didn't expect it to work

earnest atlas
#

We are just asked to comment code cause teacher will have to look at it later

rare basin
#

did your teacher request that?

wintry quarry
earnest atlas
#

yes

burnt vapor
wintry quarry
#

I recommend learning it.

frigid sequoia
rare basin
#

because as i said, good, clean and well written code in most cases doesn't require comments

#

it reads itself

earnest atlas
#

I mean imagine having to mark like 20 different unity projects done by different people with different skill levels