#💻┃code-beginner

1 messages · Page 571 of 1

sand moss
#

Can you explain how pirates get the benefit. I am providing subscription for ad free experience. in game I am calling the getting products from play store var subscriptionProduct = m_StoreController.products.WithID(subscriptionProductId); it will called on everytime app opens. cant we use that data to validate it?

languid spire
runic lance
#

usually the easiest option is to use Firebase Functions or similar service to provide server-side validation

#

you don't need user login for that

humble forum
#
public GameObject fullHeartPrefab; 
    public GameObject emptyHeartPrefab; 
    public Transform heartsParent; 
    private GameObject[] heartImages;


 void Start()
    {
        UpdateMoneyUI();
        SetupHearts();
    }

    private void SetupHearts()
    {
        heartImages = new GameObject[lives];
        for (int i = 0; i < lives; i++)
        {
            Debug.Log("he ik wordt aangeroepen");
            heartImages[i] = Instantiate(fullHeartPrefab, heartsParent);
            heartImages[i].name = "Heart " + i;
        }
    }
#

what im i doing wrong?

burnt vapor
humble forum
#

like the hearts don t display on the screen

#

when start is called

burnt vapor
#

This code looks wrong. Do you have errors in the console at all?

humble forum
#

noop

burnt vapor
#

Also please screenshot your editor with the code in it if possible

#

I just want to verify your editor is configured

sand moss
humble forum
burnt vapor
#

What do you want exactly? Do you want the hearts to show up in the game or in the inspector?

#

Because the former needs actual UI components to appear, or sprites to draw

#

The latter is because your array is private, and it must be public

humble forum
burnt vapor
humble forum
#

fixed it

burnt finch
#

i made a script the deletes an object when it gets touched by the pointerobject. however, if i time it correctly i can stop the objects from falling without deleting it. its like the code didnt reacted to the quick collision. how can i fix that?

#
void OnCollisionStay2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("EnemyObj"))
    {
        Destroy(collision.gameObject);
        timeManager.time_left += 5;
        scoreManager.score += 10;
    }
    
}
burnt vapor
#

Can't say where that's done, though

#

I assume your solution is to reduce it at least

burnt vapor
#

You'd still have the issue where you could touch it but not trigger the method, though

burnt finch
#

nvm i fixed it by using OnCollisionEnter2D instead

obsidian plaza
#

oh you got it alredy

burnt finch
obsidian plaza
#

yeah oncollisionstay executes every frame where oncollisionenter actually executes as soon as there is a collision

#

and physics happens before oncollision stay

burnt finch
#

oh okay

#

that makes sense

#

thank you 🙏

burnt vapor
#

I assumed it was on a similar cycle

echo copper
#

Hello, everyone. How do you do these special lines for code in discord?

eternal falconBOT
echo copper
#

well, to find this parameter (angle) i use this code:

#
ANGLE = Vector3.Angle(rotator1.GetComponent<rotator>().collisionpoint - rotator2.GetComponent<rotator>().collisionpoint, Vector3.right);
#

how to find this parameter?

#

i tried:

#
ANGLE = Vector3.Angle(rotator2.GetComponent<rotator>().collisionpoint - rotator1.GetComponent<rotator>().collisionpoint, Vector3.left);
#

but it returns me the same

#

rotator1 is this gold point in front of sonic, rotator2 is a white point behind sonic

#

anyone?

fickle plume
#

See example

echo copper
verbal dome
fickle plume
#

Resulting angle is the difference, and it seems you are feeding it the same difference just inverted.

#

resulting in the same difference angle rather

verbal dome
echo copper
#

and here he returns he 45 too, but he must return me -45

fickle plume
#

Note: The angle returned will always be between 0 and 180 degrees, because the method returns the smallest angle between the vectors. That is, it will never return a reflex angle

#

Always check manual

echo copper
#

ow... okay... maybe, i should read manual and thinking about the question before asking... my apologies

verbal dome
#

Even if you used Vector2.SignedAngle, both of these images would result in the same angle - see the red arrow. It's the same, just rotated 180 degrees

#

It's more obvious when you flip the other side

#

You can use Vector2.SignedAngle and invert the resulting angle when you are facing left

robust kelp
#

guys how can you visualise physics2d.boxcast with physics debugger

verbal dome
robust kelp
#

should it work fine on default or should i change some settings

verbal dome
robust kelp
verbal dome
#

You can use Gizmos.DrawWireCube/DrawCube to draw a box anywhere you want

#

You have to mess with Gizmos.matrix to make it rotated tho

robust kelp
#

chatgpt hallucinated that i had to change 3d to 2d debugger

verbal dome
#

Not necessarily things that exist

robust kelp
verbal dome
#

Lemme know if you have problems rotating the gizmo

fringe plover
#

Can someone help? Loading files from Application.streamingAssetsPath doesnt work properly on android

verbal dome
fringe plover
#

i make call trough WebRequest and it doesnt make the request (download handler is null)
it also uses link that starts with file:///

But when i manualy input "jar:file://" + Application.dataPath + "!/assets" it gives me 404 error

#

When using Application.streamingAssetsPath

verbal dome
fringe plover
#

okay...

snow abyss
#

Updated unity and realised that the input manager became a legacy feat
I'm still learning the new input system, just asking how is it compared to the old one?

#

Does it really provide more flexibility? Since I prefer to implement it through code

languid spire
#

New one allows you to do both, tbh, using it via code is so much easier than the crappy UI-UX unity offers

swift elbow
languid spire
snow abyss
#

I just skimmed through some bits of the input system and my head hurts
It looks so convoluted

languid spire
azure otter
#

Hi guys!
Is there any way to have a UI above any GameObject visible in the scene? I want text on a Canvas to always be visible, even if an object is in front of it.

UI Layout:

  • Canvas:
    • Panel:
      • TMP_Text

Thanks!

snow abyss
astral falcon
#

And not really a coding question

grand snow
snow abyss
grand snow
#

You can also get a certain device in code (e.g. get the keyboard and listen for key inputs this way)

astral falcon
#

100% supporting using the "new" input system entirely and do not look back into the old one. The only reason, a lot of people still use it is because of older tutorials.

#

Its also quite nice to learn about event callbacks and listening for them and so on. Win win 🙂

snow abyss
#

I recently updated my 2021 unity to the latest ver, and there's a lot of things that are already in legacy

#

I didn't know that TextMeshPro was also gone

astral falcon
#

Its not gone, but its part of unity now

snow abyss
#

oh whoops yep, misremembered

languid spire
snow abyss
#

oo that looks neat, guess there's something new for me to do this week

final kestrel
#

What is the best way to show and hide ui elements? I am using canvas group and just change its visibility via code.

swift crag
#

This would be appropriate if you wanted them to stop taking up space in an automatic layout

final kestrel
#

all right. Thanks.

cosmic dagger
final kestrel
#

Ah yeah playing with the canvas group's alpha works fine. I just wanted to know if there are better approaches. I found it myself messing with the UI's so yeah. Thanks.

tiny wind
tiny wind
wintry quarry
#

I would think this is a problem with whatever code is supposed to set that "CLIMB" parameter, not the boxcast itself (which theoretically is the same for both)

tiny wind
tiny wind
#
        anim.SetBool("CLIMB", OnWall());
wintry quarry
#

can't do anything with this

#

show the full script ideally

#

!code

eternal falconBOT
tiny wind
#
using System.ComponentModel;
using UnityEngine;
using UnityEngine.UIElements;

public class Animate : MonoBehaviour
{
    [SerializeField] private LayerMask groundLayer;
    [SerializeField] private LayerMask wallLayer;
    private Animator anim;
    private BoxCollider2D boxCollider;
    private float wallJumpCooldown;
    private float horizontalInput;
    private double integer;
    private void Awake()
    {   
        //Grabs references for rigidbody and animator from game object.
        anim = GetComponent<Animator>();
        boxCollider = GetComponent<BoxCollider2D>();
        integer = 1.5;
    }
 
    private void Update()
    {
        float horizontalInput = Input.GetAxis("Horizontal");

        //sets animation parameters
        anim.SetBool("RUN", horizontalInput != 0);
        anim.SetBool("GROUNDED", IsGrounded());
        anim.SetBool("CLIMB", OnWall());

        if (OnWall() && ((Input.GetKey(KeyCode.Space)) | ((Input.GetKey(KeyCode.LeftArrow)) && (horizontalInput < 1f)) | ((Input.GetKey(KeyCode.RightArrow)) && (horizontalInput > 1f))))
        {
            anim.SetTrigger("jump");
        }
        if (Input.GetKey(KeyCode.Space) && !OnWall())
        {
            anim.SetTrigger("jump");
        }
        if (OnWall())
        {
            Debug.Log($"on wall ong fr fr");
        }
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
    }

    private bool IsGrounded()
    {
        RaycastHit2D raycastHit = Physics2D.BoxCast(boxCollider.bounds.center, boxCollider.bounds.size, 0, Vector2.down, 0.1f, groundLayer);
        return raycastHit.collider != null;
    }
   private bool OnWall()
    {
        RaycastHit2D raycastHit = Physics2D.BoxCast(boxCollider.bounds.center, boxCollider.bounds.size, 0, new Vector2(transform.localScale.x, 0), 0.1f, wallLayer);
        return raycastHit.collider != null;
    }
wintry quarry
tiny wind
#

thats just for the animation,

wintry quarry
#

We need to see the wall climbing logic because basically you should be using the same logic

tiny wind
#

wait, I think i see the problem? idk how to describe it

cosmic dagger
verbal dome
#

FYI, Rigidbody2D.linearVelocityY/X exists now if you want to just change one axis of your velocity

burnt vapor
north scroll
#

where is the freezing xyz positions? Im pretty sure ive used this option before but I cant find it in the rigidbody or box collider, and online sources have it through code instead of inspector

verbal dome
#

Your inspector is in debug mode

north scroll
#

my hero

#

no clue how I got that going though lol, whats the difference

rich adder
#

Debug mode will show all the private fields among other things

obsidian plaza
#

its helpful for certain things like in a scrollbar when choosing how many steps you want

#

its capped at 11 outside debug mode

#

thats what i use it for mainly off my head

swift crag
#

the debug mode skips all of the normal editor and property drawer code

#

it just kinda...shows every serialized field, in order

#

They're completely transparent

#

The scene view is drawing an outline around the particles

#

what does it look like if you turn off outlines?

#

They won't run outside of Play Mode when not selected

#

hm, so they appear in the game view, but not in the scene view?

fervent abyss
#

i can see in main camera

#

awesome unity features

swift crag
#

I haven't observed that before. I wonder if it's a rendering-order problem

twin bolt
#

Yesterday, i was getting help from some people here, and i was told to change my method of closing the doors in my game. So far, there is no more "Shaking", BUT now the door is rotating like this, and i stopped getting help. Here is the code: https://hastebin.com/share/rigapegomi.csharp

languid spire
twin bolt
#

This is the code after i fixed it how praetor told me.

verbal dome
#

I think StartRotation should be cached in awake/start instead of ontriggerenter

languid spire
#

I'm pretty sure there was a lot more to it than that, I suggest you revist the conversation

twin bolt
swift crag
#

I don't like how you're trying to remember a starting rotation at all, really

wintry quarry
swift crag
#

Just operate in local space. The door should only care about changing its local rotation.

#

That makes it trivial.

verbal dome
#

I had the same thoughts

swift crag
#

You're piling on a bunch of complexity by trying to use a world-space rotation

#

Set up the door so that it is closed when its local rotation is [0,0,0]

#

(or, heck, any other y-axis rotation -- just plug that value into closedAngle)

#

and then put angle = closedAngle into the Start method in that case

wintry quarry
#

you never showed that

#

and that's working fine

swift crag
#

It does seem odd that the door's opening has nothing to do with the door's closing, yes

#

That implies you have multiple components all trying to spin the door in various ways

#

which sounds nightmarish

wintry quarry
#

indeeed

swift crag
#

the door should have one component whose sole job is to rotate the door based on its current state.

#

Other components can tell the door to change it state.

#

But they shouldn't be trying to fuss with its rotation

languid spire
verbal dome
#

Why does it have a hinge joint

#

You can't mix both physics and transform

swift crag
#

Uh Oh

#

💥

twin bolt
twin bolt
swift crag
#

You can ask the hinge joint to move to a certain angle using its Motor setting

verbal dome
#

If you need it to be physical then yeah that^

swift crag
#

er

verbal dome
#

Or limits
Nvm yeah just use the motor

swift crag
#

its spring position property

#

Joints are a whole bundle of joy

twin bolt
swift crag
#

Fun fact: if you have Scene Reload disabled, then joints will remember things from prior play sessions

#

You'd want to add a torque!

#

But yes, you can do that

#

In that case, you'd write a function whose job is to apply torque until the door is in the right orientation

twin bolt
swift crag
#

(it should also give up after a period of time)

swift crag
twin bolt
verbal dome
#

Always good to show the components when debugging

#

I just happened to see it flash in the beginning of the video

twin bolt
#

Thank you.

feral moon
cosmic quail
verbal dome
#

Are you setting timescale to 0?

feral moon
cosmic quail
#

then gravity will still work

verbal dome
#

You need to set your movement input to zero obviously

feral moon
fickle plume
#

@feral moon Keep media Unity related, please.

gloomy cosmos
#

Hello, are there any cool tips on how to make functions with loads of parameters more readable? (this is me with having definined a bunch of stuff in vars before hand to shorten it)

#

I wish I could make radius and center have default values, but since Vector2.zero is not compile time constant you can't

cosmic dagger
#

the parameters should describe what it's used for in the method . . .

slender nymph
gloomy cosmos
#

oh parameters is a dictionary, its used to pass extra data to the bullet scripts (dw about it)

gloomy cosmos
#

but I'll do it, thanks

cosmic quail
cosmic dagger
#

yeah, overloads with default (optional) values are pretty common . . .

gloomy cosmos
gloomy cosmos
cosmic dagger
gloomy cosmos
#

Doesn't localization package handle that automatically? Anyway if you're going custom I think there's a setting for that on TMP Text (I could be wrong)

(btw localization package is the best thing ever, like the only thing I import everytime)

cosmic dagger
languid spire
#

do you not have a programmer on your team, this is pretty trivial

gloomy cosmos
languid spire
#

if this is modding or decompiling you are in the wrong server

gloomy cosmos
#

ok buddy use pastebin atleast, i cant even look at all that in discord (without downloading file)

#

also what is Token? I've legit never seen it

#

anyway you should probably learn unity or get a friend to help, its kind of hard for anyone here to help with such a specific issue if you dont know what you're doing

cosmic dagger
feral moon
crimson pike
#

any concerns about using UnityEvents from a singleton?

cosmic dagger
# crimson pike

unity events are only used if you need to hook up events from the inspector. if not, use a regular event (action) instead . . .

crimson pike
#

Action<object[]> but yeah ok

#

ah wait, actually i kinda might want that too

#

this one is programmatic but you're saying i can configure them in the editor this way? like if i made a public or serialized field list for them on my GameData?

#

mainly want a way to allow entities to call out to other entities. in this case it's setting the background terrain scroll speed (nested in a TerrainManager) from an actor in a cinematic sequence

cosmic dagger
#

the UnityEvent will appear in the inspector, then you would drag a GameObject with a MonoBehaviour script attached to it that has the method you want to invoke. using the drop-down, you select the method from the script

if you're not going to do that then there isn't a reason to have/use a UnityEvent instead of an Action . . .

crimson pike
#

Yeah that sounds perfect actually. Thanks

lapis veldt
#

Hello. This is my first time when I want to put some scripts to an downloaded asset (character, animal etc.). I have a small problem. I made an HP script where the character will take damage when hit (in this case, the tiger is hit by a projectile), but it's HP isn't dropping or dissappearing. Where should I put the HP script?

glossy turtle
#

What is the git URL for socket.io package do you know any.

cosmic dagger
lapis veldt
cosmic dagger
lapis veldt
#

idk why, but I though when I download a character asset, it would come with a collider in it

glossy turtle
slender nymph
#

have you bothered googling it?

glossy turtle
#

I tried but not finding.

#

I installed one but it has errors.

#

Rochet

obsidian plaza
#

or did u figure it out

gleaming turtle
#

i've got a question i know for a fact has been asked a million times & i bet is simple but i can't find anything simple online to fix

i am trying to throw projectiles in my game, specifically spears & i need the flight path of the spear to follow the head, image in case i'm not explaining myself very well. it's all physics based & there is no script on each object that gets launched

lapis veldt
glossy turtle
#

There are only two persons who are offering socket.io package on GitHub but they are full of errors. The other one is nan but i didn't tried it.

obsidian plaza
#

and in this case that means making the spearhead the heaviest part

#

which would make it do this naturally

glossy turtle
#

Few sites are showing to install it through git URL so are there any git urls for socket.io or socket.io client package.

slender nymph
#

seems like you've already found the available ones. i don't know what else you are expecting to hear

woeful bridge
#

I'm really confused

    private void DefaultListener(String string)
    {
        Debug.Log("Default listener triggered!");
    }

    // Update is called once per frame
    void Update()
    {
        onCustomEvent?.Invoke("Rats");
    }```
How can I do something like this
slender nymph
#

what about that is not doing what you want?

woeful bridge
#

I can't pass parameters to my listener

#

how do I do that

slender nymph
#

use a delegate that has parameters

cosmic dagger
#

you do that part yourself . . .

woeful bridge
#

I gotta type the fucking listener??

#

oh brother

obsidian plaza
#

what

slender nymph
#

how about you show where you've declared the onCustomEvent so someone can point out what you've done wrong since you clearly don't understand the information that was provided to you

woeful bridge
#

public UnityEvent onCustomEvent;

#

onCustomEvent.AddListener(DefaultListener);

obsidian plaza
#

lol

languid spire
cosmic dagger
glossy turtle
woeful bridge
#

I miss non typed languages

#

ok I'll type it

obsidian plaza
#

lol i think ur missing something

slender nymph
slender nymph
woeful bridge
#

Do be what I'm doing

slender nymph
woeful bridge
#

Using C# is learning it lol

cosmic dagger
languid spire
#

it's exactly because of lazy programmers who wrote shitty code that type safe languages were invented

slender nymph
# woeful bridge Do be what I'm doing

seems more like you're skipping the "learning how c# works" and going straight for "brute forcing your way through c# and expecting everything to work like lua"

woeful bridge
#

Wtf more am I suppose to do? Learn C?

#

Like I learned C#

slender nymph
#

did you though

woeful bridge
#

I can take a college class I guess

naive pawn
#

or like, free online guides

woeful bridge
#

I did

cosmic dagger
glossy turtle
slender nymph
#

copy/pasting what you see in tutorials is not the same as actually learning and understanding

gleaming turtle
woeful bridge
#

I'm looking at docs not tutorials

cosmic dagger
woeful bridge
#

True!!

slender nymph
untold shore
#

Okay, having some difficulty just…thinking through a plan. I want to remove all children of an object in one frame, then in the next, have two objects added as children to that original object. This would be in a method whenever a button is pressed. What would y’all’s process be? Don’t want yall to code for me (I need to learn), but would you start with a method? Coroutine? How would yall think through it?

naive pawn
slender nymph
obsidian plaza
untold shore
cosmic dagger
languid spire
cosmic dagger
#

if so, use a coroutine . . .

#

ahh, too slow . . .

untold shore
obsidian plaza
slender nymph
# untold shore I do, so would I just do a coroutine?

yes, a coroutine would be the easiest option here. or you can always go and refactor your code so that it isn't relying on the number of children an object has and instead is using some collection to track the number of objects

languid spire
cosmic dagger
#

its at the end of the frame . . .

mighty compass
swift crag
obsidian plaza
#

or nvm lol its probably end of frame as they said

untold shore
#

Alright, thank yall. Going to look at the docs boxfriend sent me yesterday on coroutines, still getting used to them. Thank yall!

swift crag
#

it would be complete insanity for C# to grab random methods by name and subscribe them to the event

obsidian plaza
#

i just know it was annoying to check if something existed when it wasnt actually destroyed yet

mighty compass
#

I was pretty lost in Unity until til I started college tbh lol

slender nymph
#

yeah that was their issue two days ago

swift crag
#

oh, you mean "give it the correct type", not "type it with your keyboard"

obsidian plaza
#

lol

rich ice
untold shore
#

Surprised yall remember this. It’s very sweet tbh

swift crag
#

my response remains roughly the same. static typing keeps me sane.

mighty compass
#

No way to really know shit about what’s going on unless you do some learning about the language and concepts of programming

swift crag
#

I've worked on game written in javascript before, and it's hideous

#

It's so nebulous and ill-defined

woeful bridge
#

I got the brain chip to type my listeners

swift crag
#

Does it work? I don't know!

#

Runtime error!

#

💥

#

Being able to do static analysis beyond "I think this variable probably exists" is so, so helpful

slender nymph
swift crag
mighty compass
#

Yeah I made a simple rogue like in html,css,JavaScript, it’s unnecessarily unorganized

swift crag
#

The TS type system is really cool

woeful bridge
#

typescript was nice tho

mighty compass
#

I think js can be nice if you include a database

glossy turtle
#

I liked js.

slender nymph
#

one thing about js that is absolutely baffling, is that when calling a function with a string literal you apparently can just leave out the parentheses

mighty compass
#

Yeah i dont know about that lol

naive pawn
#

do you mean a tagged template? that's a bit more involved than "pass a string without parens"

mighty compass
#

Js doesn’t specify type so technically you can pass any type to a function, doesn’t mean it will work though lol

glossy turtle
#

There is one bit annoying about js is you have figure out runtime time errors.

slender nymph
#

i mean, this is valid: console.log`hello world`

mighty compass
#

Oh I see

naive pawn
#

but it's specfically for template literals, not string literals

#

and it does more work when you actually use templates

#

console.log isn't written to use them, it's just allowed and happens to work

#

split and join also work like this, handy tips for golfing

mighty compass
#

One thing I always wondered is what is the point of arrow functions in js

swift crag
swift crag
#

they're wildly useful

mighty compass
#

Yeah

swift crag
#

just as they are in C#

#
() => Debug.Log("Hiiiii");
naive pawn
#

@slender nymph

mighty compass
#

Can’t u just do the same thing by leaving the function parameters empty

swift crag
#

are you comparing it to a named function?

naive pawn
#

it's syntactic sugar

swift crag
#

the point of an anonymous function is that it has no name -- it's just an object

mighty compass
#

But what’s the point of it lol

#

You can just write its contents on its own to execute

naive pawn
#

a => b is syntactic sugar for function(a) { return b; } in js

swift crag
naive pawn
mighty compass
#

I fail to see its benefits

naive pawn
swift crag
#

been a hot minute

mighty compass
#

What does it look like in c#?

#

I’m a Java/python andy atm

verbal dome
#

void a() => b();

naive pawn
#

if you want to add 1 to each element of an array, you can't just map(+1), you have to do write a function for it, like one of these

function increment(x) {
  return x + 1;
}
map(increment)
// or write a function directly
map(function(x) { return x + 1; })
map((x) => { return x + 1; })
map((x) => x + 1)
swift crag
#

ah, i see

swift crag
#

interesting

naive pawn
mighty compass
#

That looks wild

slender nymph
swift crag
#

yes

naive pawn
gleaming turtle
mighty compass
#

I haven’t used the arrow in Java

naive pawn
#

have you done streams in java

mighty compass
#

I’ve done things like generic, making interfaces, abstract classes

#

I never learned about the arrow

#

Streams???

naive pawn
#

streams are where you utilize lambdas the most so if you never touched on streams then you probably wouldnt have had to use them

mighty compass
#

By streams are you talking about cryptography? Lol

naive pawn
#

no

slender nymph
#

bascially java's equivalent of linq

naive pawn
#

yeah, fp-style manipulation of collections

#

(in comparison, js has this built into Array, python has map/filter, and also comprehension)

mighty compass
#

I dont know what linq or fp is

naive pawn
#

have you ever used Array.map in js or comprehension in python

mighty compass
#

No

obsidian plaza
mighty compass
#

Does that have to do with dictionaries?

naive pawn
naive pawn
slender nymph
gleaming turtle
mighty compass
#

Ohhhh

#

Just queries

naive pawn
#

map/Select, filter/Where/select, reduce/fold, flat, etc are operations on collections

mighty compass
#

That’s basically what the arrow is?

slender nymph
#

well no, but it's used frequently with those

naive pawn
#

no, that's just where arrows are utilized a lot

#

lambdas are functions as objects

mighty compass
#

What is the arrow doing syntactically

naive pawn
#

it creates a function

mighty compass
#

Like if you could write it in code

obsidian plaza
#

think its just { }

mighty compass
#

What would the arrow look like

slender nymph
mighty compass
#

Thx I’ll check that out haha

naive pawn
obsidian plaza
#

i use it a lot in something like a list of a script where i need to find the first thing in a list where x is true, i can do it in one line

mighty compass
#

I kinda get it

#

What is with the <> in

Func<int, int> square = x => x * x;

slender nymph
#

generic type parameters

mighty compass
#

In Java that specifies generic

#

But this is specifying such a primitive data type for a generic

naive pawn
#

fyi: these are broadly called anonymous functions or lambdas/lambda functions/lambda expressions, for example python has the keyword lambda which does the same thing but it doesn't use an arrow

naive pawn
mighty compass
#

It’s just weird haven’t seen that much lol

naive pawn
#

c# just doesn't restrict generics to reference types

swift crag
#

You want weird?

mighty compass
#

I would always see a generic with a class name not a primitive

swift crag
#

C++ templates let you do crazy stuff like Foo<3>

swift crag
mighty compass
#

That is true

swift crag
#

Nothing weird about a List<int>

naive pawn
mighty compass
#

Man there’s a lot more to c# than I thought, I thought it was basically the same as Java lol

#

But there’s namespaces that apparently act a lot different than packages

#

And some other stuff

naive pawn
#

java doesn't let you use primitives with generics and instead provides wrapper reference types
c# doesn't separate primitives in this way, users can define value types themselves (struct) so it wouldn't make sense to restrict value types, so c# doesn't have wrapper types

swift crag
#

Ah, that is an important thing

#

Java doesn't let you do that, yeah

mighty compass
naive pawn
#

java doesn't have structs or this concept of value types

slender nymph
swift crag
#

I believe that's because each instasntiation of a generic type with value-type parameters winds up affecting how much memory the type requires

#
public class Holder<T> {
  T item;
}
naive pawn
swift crag
#

The size of a Holder<MassiveStruct> is larger than a Holder<int>

#

Bit of a headache.

naive pawn
#

java's type erasure kinda breaks that i guess

swift crag
#

it's different in a way that's entirely unlike Holder<Foo> vs Holder<Bar>, where both of those are reference types

naive pawn
swift crag
#

The C++ template section opens up with talking about how you can't use floats

naive pawn
#

array<int, 5> moment

swift crag
#

like, it's the first thing it talks about

#

as if this were normal

#

and that we all wanted to do that

naive pawn
#

and anything else is fair game? 😰

swift crag
#

That was the only section of the C++ standard that I could not understand by reading it

mighty compass
#

How do you define your own type in c#??

naive pawn
#

struct/class/interface/enum

mighty compass
#

Java just has references to objects yeah

slender nymph
#

every class, struct, enum, interface, etc is a type definition

#

damn too slow again lol

mighty compass
#

Lol

naive pawn
#

same as you would in java/js/python

mighty compass
#

Wait so it’s basically the same in Java

naive pawn
#

you define a class, or similar constructs

#

yeah

mighty compass
#

You have to make a class and reference it

#

Or any of those other obects

naive pawn
#

you, or someone else, has to make everything you want to reference

#

no language will automatically know what you mean by some given name unless it's defined

mighty compass
#

Is Unitys source code in c++ or c#?

slender nymph
#

yes

#

and by that i mean, it's both

mighty compass
#

Hahaha

#

Howcome they chose to abstract to c#

naive pawn
#

why did you choose unity?

mighty compass
#

Someone told me it’s better for solo devs lol

naive pawn
#

damn, wasn't what i was expecting

mighty compass
#

And apparently offers more freedom

naive pawn
#

ok that's more like it

mighty compass
#

You can do more custom things with it

#

Which doesn’t make sense

naive pawn
#

so a variety of reasons, yeah?

mighty compass
#

Because it’s abstracted to a higher level language

naive pawn
mighty compass
#

Unity seems somewhat user friendly though

naive pawn
#

i mean, so are all the other engines, they gotta be to be usable

mighty compass
#

And I was told that Unreal offers a ton of prewritten templates which I didn’t like

#

I like doing everything from the lowest level, and from scratch

#

Because I’m still learning programming, and I need to learn that way

cosmic dagger
#

you can write your own stuff in Unreal if you want . . .

mighty compass
#

Probably lol

slender nymph
#

and you can use templated stuff in unity too (hence the entire asset store)

mighty compass
#

I opened unreal and had no idea how to access anything, like scripts or anything

burnt vapor
#

Isn't an Engine by itself technically a prewritten thing?

mighty compass
#

When I opened Unity I saw the scripts at the bottom of the screen

#

Yeah, I’ll probably attempt making my own engine at some point 😂

burnt vapor
#

Like, if you truly want to do things yourself use a C# base and write an engine yourself

naive pawn
mighty compass
#

I know in one of my classes they make you write a basic 2d engine in c++

burnt vapor
mighty compass
naive pawn
mighty compass
#

I just want to make a working 3d multiplayer fps in unity before I do anything else

naive pawn
gloomy cosmos
#

Hello, I'm currently baffled at C#, and would very much appreciate help.

This is the print:

Processing task at index 0```

Error cause by RemoveAT:
```ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index```

How? The list is private, nothing outside can access it, I do reverse indexing to ensure no problems when removing elements while iterating, yet it breaks. How is this possible?

This is the code:
mighty compass
gloomy cosmos
#

also before anyone mentions using fixedTime in Update, this is not a monobehaviour, be sure that this function gets called externally in FixedUpdate

burnt vapor
gloomy cosmos
burnt vapor
#

Can't you just reverse the list, do a normal foreach, then remove all?

naive pawn
#

or use a queue to let the removal of items be managed

gloomy cosmos
burnt vapor
#

A queue is even better here, yes

#

Removes basically any trivial operations apart from just iterating

untold shore
#

Hey, quick question. Currently attempting to call a coroutine in another script, but it won't "call" it. Still new to all this, so if this is idiotic I understand, but when you call a coroutine, does it have to be inside another coroutine? Here's the code calling the coroutine:

public void ResetCurrentHand()
    {
        PlayerDeckManager.GetComponent<DeckManager>().ResetPlayerHand();
        DealerDeckManager.GetComponent<DealerDeckManager>().ResetDealerHand();
    }
``` and the coroutine itself:
```cs
  public IEnumerable ResetPlayerHand()
    {
      Debug.Log("Reseting Player Hand");
      foreach (Transform child in transform)
      {
        Destroy(child.gameObject);
        Debug.Log("Destroyed an object");
      }
      yield return null;
      Debug.Log("Coroutine ended");
      handManager.cardsInHand.Clear();
      Debug.Log("Cleared cardsInHandPlayer");
      StartCoroutine("DestroyPlayerHandObjects()");
      hand.GetComponent<CardValuesScript>().handValue = 0;
      Debug.Log("Number of children in handtransform before waiting: " + hand.transform.childCount);
      DrawCard(handManager);
      DrawCard(handManager);
    }
``` Thanks
gloomy cosmos
#

Sure I can make a queue instead, but like why does this cause an error? I can't think of any reasons

burnt vapor
#

Alternatively if you need a LIFO collection, use Stack

gloomy cosmos
naive pawn
gloomy cosmos
naive pawn
gloomy cosmos
untold shore
# gloomy cosmos you have to use StartCoroutine

That's the thing, whenever I try to, it won't call it. I've done StartCoroutine(ResetPlayerHand()), in which it will say it is not a string or inside the script currently opened, and when I do the string (StartCoroutine("ResetPlayerHand") or ("ResetPlayerHand()"), neither will work

gloomy cosmos
# naive pawn *right before* you remove

I just realized what's going on, when my object is destroyed it clears the list (to ensure no schedules run after), but it happens before the update... Fixed and very stupid of me

obsidian plaza
naive pawn
gloomy cosmos
slender nymph
rich adder
obsidian plaza
burnt vapor
untold shore
#

That makes... a lot more sense. Thank you.

#

Real quick though, it still says I need a string when using StartCoroutine?

naive pawn
#

it needs to be IEnumerator, not IEnumerable

burnt vapor
#

Your Coroutine needs to be an IEnumerator

#

IEnumerable is for collections

untold shore
#

Yeah, that checks. 😅

burnt vapor
#

It's just that a Coroutine using a string is probably the first signature defined to it errors mentioning that one

woeful bridge
#

I did research on get and setters since I made it to the part I needed them and there kinda awesome so thanks theres way different than I thought so very cool

slender nymph
#

yeah but that was javascript syntax which are anonymous methods

slender nymph
verbal dome
#

Ah okay, got it

#

Haven't really touched JS and from everything i've seen/hear I hope I never will

slender nymph
#

it's a crazy language that i wish i didn't need to know about

burnt vapor
#

I feel like you guys have had a bad experience with an actually interesting language

gloomy cosmos
#

Hello, apparently my problem was not fixed. I removed the clear code, it was not the issue. The only thing which affects the problem is whether I call Invoke or not. I commented out ALL the code in the function getting invoked, it still causes the error only if invoke is called. Even if it's called AFTER I call RemoveAt

burnt vapor
#

It's just that everything around the language is trying to be the best

gloomy cosmos
#

Take a look at this:
it prints "a 1", then immediately throws error at RemoveAt. If I comment out the task.Task(), then no error occurs. The task getting called is literally empty.

burnt vapor
#

C# also has these

naive pawn
#

(yes, but it's funny)

burnt vapor
#

Yes, it's very weird

naive pawn
#

i do use quite a few languages and passively hate all of them 🙂

gloomy cosmos
burnt vapor
naive pawn
#

i had that vibe from the original code but i can't pinpoint it

gloomy cosmos
#

i have no idea what kind of c# illuminati bs is going on, Im gonna make it store things to remove in a list each frame and remove that stuff at the end of the frame

naive pawn
#

wait what's task there

cosmic dagger
gloomy cosmos
cosmic dagger
#

wha? confusing AF . . .

gloomy cosmos
#

Hope this clears it up

gloomy cosmos
#

literally thats all it is

cosmic dagger
naive pawn
slender nymph
gloomy cosmos
# gloomy cosmos this

Bullet.Schedule is the schedule function from above, RunSpawner is task, 1f is delay

gloomy cosmos
cosmic dagger
naive pawn
#

!code

eternal falconBOT
slender nymph
#

should share the full class tbh

gloomy cosmos
#

like this?:

private class ScheduledTask
    {
        public float TimeToRun;
        public Action<float> Task;
    }
gloomy cosmos
slender nymph
#

and just to confirm, the exception is being thrown on line 40 and not line 41 now?

gloomy cosmos
#

the print in the task never runs at all

naive pawn
#

yeah that seems like it'd break on line 41

#

have you tried adding a Debug.Log between the remove and the call

gloomy cosmos
#

as I said, I'm baffled. SOmehow commenting out code that hasn't yet ran fixes it

naive pawn
#

you're referencing tasks[i] there

#

after it's removed

slender nymph
gloomy cosmos
#

Ill add

gloomy cosmos
slender nymph
#

make sure you've saved

gloomy cosmos
#

I will run with print in between

rich ice
#

i haven't chat. so, im not sure if this is what you guys are currently talking about. but, does anyone know of a shorter way of doing this?

    public float time;
    
    float t;

    private void Update()
    {
        t += Time.deltaTime;
        if(t >= time)
        {
            //code here
        }
    }
swift crag
gloomy cosmos
#

Very strange, I added the inbetween print now unity repots the print line causes the error. I guess you guys were right, no clue why its showing wrong line

naive pawn
slender nymph
#

again, make sure you've actually saved and recompiled. and if you have any assets that fuck with compilation like hot reload, then disable them or restart the editor

gloomy cosmos
naive pawn
#

generally "shorter" is not the right direction to go it

gloomy cosmos
#

I thought that using var element = List[i]; would cache it, but I guess not. Thanks for the help, I think it's fixed now

naive pawn
#

you should go for stuff like more readable, more generalizable, more elegant, more flexible, etc
you could use coroutines for example

naive pawn
#

with this approach, you could set t as some time in the future and check that against deltaTime instead of adding to it, for example

slender nymph
gloomy cosmos
cosmic dagger
verbal dome
swift crag
#

The object isn't getting magically destroyed

#

it's just being removed from the list

#

element remains exactly as valid as it was before removing something from the list

gloomy cosmos
naive pawn
swift crag
gloomy cosmos
#

swapping the two in order (removing and calling) fixes the problem

swift crag
#

Yes, because you're accessing List[i]

naive pawn
#

of course it does, but task isn't relevant, tasks[i] is

rich ice
gloomy cosmos
#

wait

gloomy cosmos
#

I just realizes List[i] was used in there, I am so silly for noticing earlier

naive pawn
#

...we told you bruh

slender nymph
gloomy cosmos
cosmic dagger
#

this is the culprit: tasks[i].TimeToRun); . . .

rich ice
gloomy cosmos
#

anyway now its fixed, thanks a lot people, (I really do feel stupid tho lol)

naive pawn
verbal dome
#

Yeah don't

swift crag
#

let's goooo

rich ice
#

g u h

swift crag
#

this code is bad because it is framerate dependent! ✨

#

nothing else wrong here, no sir

rich ice
swift crag
#

there's a line from Jurassic Park that comes to mind

#

and it's not the one about how smart the dinosaur is

rich ice
#

i've never watched jurrasic parkwoe

naive pawn
swift crag
#

yeah

#

for MAXIMUM time

naive pawn
#

i hate you so much right now

swift crag
#
t = t++;
naive pawn
#

noop in plain sight

swift crag
#

your IDE will probably correctly determine that this doesn't do anything

naive pawn
#

may your ide forgive you because i sure won't [racks shotgun]

rich ice
#
        t += t *= t -= t += - Time.deltaTime;

finally, readable code

untold shore
#

Hey boxfriend, don't know if you're still in the chat, but wanted to thank you for the help for the past couple of days. Helped so much, and finally got it to work out!

frigid sapphire
#

Hey, I'm making a clicker at the moment and I am trying to make some sort of golden waffle flying aroudn that you have to click for some extra cash, when it was forced to spawn in 1 place it would work but when i added that it spawns in a random spot on the canvas it stopped spawning at all (can't even see it on the list of objects), debug log still says spawned but its nowhere to be found https://paste.ofcode.org/nFTZq92TJGHhPsQqCN5X9U

naive pawn
#

wow why is it not formatted at all

slender nymph
#

tab key machine broke

frigid sapphire
#

Who needs that anyway

naive pawn
#

you don't even need to tab to format stuff

#

it just happens

frigid sapphire
#

And I remove it:)

naive pawn
#

why are you starting Chance every physics tick

naive pawn
frigid sapphire
#

While loop caused some problems earlier so I changed it

slender nymph
#

your while loop should just be in the coroutine which could then just be started in Start instead of every 0.02 seconds

#

your yield break and yield return null are also pointless because they don't do anything after they yield

#

as for why it doesn't show up, instead of spawning the object up to 900 units away from the origin in world space then setting it's parent to the canvas, spawn it as a child of the canvas immediately

frigid sapphire
#

Oh god I thought I have to use either for the enumerator to end

naive pawn
#

you aren't yielding the WaitForSeconds so you're spawning it and immediately destroying it

stable shoal
#

Can someone please help me?
For some reason my player doesn't jump, even though in the debug, I added debug.log to show when the space button is being pressed, and it shows it but I don't know why it doesn't jump.

I can provide my code, a screenshot of the interface.
also I'm using a camera holder which maybe is the problem

slender nymph
#

just noticed that too lol. so there's literally no waiting happening

frigid sapphire
naive pawn
naive pawn
slender nymph
stable shoal
#

how can I paste it in a way that it will not look like a lot of text, but rather as a formated code

charred heart
#

I'm facing an issue where an anonymous function passed as a parameter become null, but the value 5 (another parameter) works as expected.

private void Update() 
{
    if (Input.GetKeyDown(KeyCode.F))
    {
        _objectDetected.Interact(() => {
            _isInteracting = false;
        }, 5);
    }
}

// objectDetected
public override void Interact(Action action, int a)
{
    Debug.Log(action);   // this become null
    Debug.Log(a);        // and this still 5
}
eternal falconBOT
naive pawn
#

Surround code with three backquotes. Not quotation marks.

charred heart
#

use this ```csharp

slender nymph
#

but also more importantly

📃 Large Code Blocks
Use links to services like

stable shoal
naive pawn
#

you didn't save the paste

slender nymph
verbal dome
stable shoal
slender nymph
#

don't save the webpage, press the save button on the page that stores the paste on the site and generates a link to share it

naive pawn
#

...why would you ping me twice for that

stable shoal
#

Does it work now?

slender nymph
#

wait nvm i read it wrong

naive pawn
stable shoal
#

Ohh wait, It shows me the cooldown and the state of "Grounded"
I dont think it's working

frigid sapphire
#

Got the waffle to spawn now (thanks Chris) but after a few times it just spawns outside the canvas even tho the Vector3 is set to the corners of it

naive pawn
stable shoal
charred heart
stable shoal
#

do you think that is the problem?
I can try that out!!

slender nymph
naive pawn
charred heart
naive pawn
#

but you never reset readyToJump, still

slender nymph
stable shoal
naive pawn
#

what does readyToJump even mean
you already have cooldown and grounded checks

stable shoal
#

It's for checking the state of the jump and if the "Player" can jump or not

naive pawn
#

what defines if a player can jump or not

stable shoal
#

I dont think that even If I will delete that, then it will work

stable shoal
naive pawn
#

ok, so that's handled by grounded and jumpCooldownTimer

#

what does readyToJump do then

stable shoal
#

So it doesn't do anything

naive pawn
#

exactly

cosmic dagger
stable shoal
#

I have no Idea why it's not jumping

naive pawn
#

well look at your logs

#

are the 3 conditions met?

stable shoal
#

It did show the player velocity this time, but it showed this

naive pawn
#

and your player is on the ground?

stable shoal
#

what all the 0 means?
that It's probably a problem in the jumping function?

naive pawn
#

player velocity isn't relevant here

#

that's a postcondition, what comes after the action

#

what you need to focus on are the preconditions

#

Input.GetKeyDown(jumpKey), grounded, jumpCooldownTimer <= 0f

#

so the input and cooldown work

#

is your player on the ground in that screenshot?

stable shoal
charred heart
naive pawn
cosmic dagger
naive pawn
stable shoal
#

falling from the air to the ground

naive pawn
#

ah ok

#

so have you set playerHeight and whatIsGround appropriately

charred heart
#

I checked before coming here, and there was a 5, but now it's gone. Let me check again. Thanks everyone for the help 🤯

stable shoal
#

yep
player height is 2 in capsule collision, 3 in general and in the code it's 3 as well

frigid sapphire
naive pawn
#

what's your current code

naive pawn
stable shoal
#

yes

frigid sapphire
naive pawn
#

there's probably a button in your ide to autoformat your code

naive pawn
stable shoal
#

yes, the ground layer is
whatIsGround

frigid sapphire
#

Shouldn't hurt as much now

naive pawn
#

thank you

naive pawn
frigid sapphire
stable shoal
#

Chris what do you think I should do?

frigid sapphire
naive pawn
# frigid sapphire yep

that's gonna be the relative position, but transform.position is the worldspace position

frigid sapphire
#

So how could I get the worldspace pos of the canvas edges?

naive pawn
#

it'd just be the position of the canvas

#

but you can just assign to localPosition instead

frigid sapphire
#

Alr i will try that

naive pawn
frigid sapphire
stable shoal
#

It doesn't even show that it went to the jump method

naive pawn
#

right, because the conditions aren't fulfilled

#

you need to debug why grounded is false right now

stable shoal
#

sure

#

I will try to figure out why

#

this is to check the grounded

grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.3f, whatIsGround);
Is this good?

frigid sapphire
#

me again, I'm getting the error "The name 'ggg' does not exist in the current context" it's an Instantiated game object and I'm trying to Destroy it when pressing the button using a function https://paste.ofcode.org/H55FhtnnpyY85N9TFbFkWR

polar acorn
frigid sapphire
modest dust
#

Yes, make it a class-level field

#

Not a local variable

polar acorn
#

If you store it in a field variable, whenever you call MoneyGoBig, that would destroy the most recent object that ggg refers to

#

There's a missing piece here: What calls MoneyGoBig and when

frigid sapphire
#

The prefab button

#

When clicked it's supposed to destroy itself

#

But the script is on another game object

frigid sapphire
modest dust
polar acorn
#

Why is an object sending a message to a different object to destroy itself?

#

That'd be like me writing a letter to someone in another town to come and bring me a coke from my own fridge

frigid sapphire
#

To be fair I forgot I could even do that since I don't really understand prefabs

#

I will try that

polar acorn
#

A prefab is just an object that exists as a file instead of in a scene

modest dust
#

A prefab is the same thing you have in your scene, just existing as a file instead, to be instantiated in any scene

gleaming turtle
#

Is there inherently anything wrong with this code?
It's causing seriously glitchy behaviour with my projectiles but i haven't the slightest on how to fix it

    void FixedUpdate()
    {
        if (rb.linearVelocity.magnitude > 1.1f)
        {
            transform.forward = rb.linearVelocity;
        }

    ```}
polar acorn
#

What is the "glitchy behavior" it is having?

gleaming turtle
#

whenever i throw my projectile spear, it will orientate itself correctly to follow the head however whenever it lands & begins colliding with the floor, it then spazms out & teleports all over the floor, i have a clip but it's too big to post, i can share a google drive link.

swift crag
#

This might wind up causing the spear to clip into the floor

#

which will then make it go flying

gleaming turtle
#

hmm so it might be just because the spear is glitching in the floor?

#

Here is a clip of the issue

verbal dome
#

The center of mass solution should be "realistic"

#

If you manually rotate it, I'd also add a speed limit below which it will not rotate

gleaming turtle
#
transform.forward = Vector3.Lerp(transform.forward, rb.linearVelocity, Time.deltaTime * 0.25f);```
swift crag
#

I guess that'll prevent it from very rapidly turning

gleaming turtle
#

it seems to have done the trick, been playing around with it for a while now & hasn't broken at all yet

static cedar
#

Unity/Visual studio dreaming about a file here.
The Workspace does not exist, and just links to WorkSpacePanel.

#

I really have to be careful with ctrl + r + r

feral moon
tiny wind
#

how do I fix this? Im trying to access CanAtk from another script, but it wont let me

wintry quarry
#

You made it private

tiny wind
#

oh, I did not follow the tutorial correctly

#

ight thanks

slate haven
#

I want to make a game like this, if you can notice the blocks above look 3D, so like shall i make a 2D project or a 3D project?

crimson pike
#

2d

teal viper
#

Or 3d

crimson pike
#

you can pull it off either way really

frosty hound
#

The fact there are real time shadows in this, use 3D.

scenic saffron
#

how do I get the ground that a wheel Collider is colliding with

slate haven
scenic saffron
#

yes

slate haven
scenic saffron
#

yeah you can do that with UI

slate haven
teal viper
slate haven
teal viper
slate haven
#

so how do I start? like a grid system is needed for this game?

teal viper
slate haven
#

I mean im approaching a game like this the first time

teal viper
#

Maybe look up tutorials on similar games/mechanics

slate haven
#

Yeah

scenic saffron
teal viper
#

But basically break it down. The top grid could be just an empty game ojbect with a script that instantiates the blocks in ordered fashion and controls them if needed.

teal viper
tiny wind
#

how do I make this a chain(sorry if its not the right term, if there is one)? like if I press left click, it will trigger Attack, and if I press right click within a certain timeframe after I trigger attack, its triggers Attack2

#
    private void Update()
    {
        if (Input.GetMouseButton(0) && cooldownTimer > attackCooldown && playerMovement.CanAtk())
        {
            Attack();
        }
        if (Input.GetMouseButton(3) && cooldownTimer > attackCooldown && playerMovement.CanAtk())
        {
            Attack2();
        }
        if (Input.GetMouseButton(2) && cooldownTimer > attackCooldown && playerMovement.CanAtk())
        {
            Attack3();
        }
        cooldownTimer += Time.deltaTime;
    }

    private void Attack()
    {
        anim.SetTrigger("attack");
        cooldownTimer = 0;
    }
    private void Attack2()
    {
        anim.SetTrigger("attack2");
        cooldownTimer = 0;
    }
    private void Attack3()
    {
        anim.SetTrigger("attack3");
        cooldownTimer = 0;
    }
}
rich adder
slate haven
untold shore
#

Weird issue I'm having. Currently, I call on a button and it does what its supposed to do, but after I press another button, the first button acts like the 2nd? It's weird, and I can't figure out the function thats causing it when I press the button, since it works before I press the 2nd button. If it helps, here is the code that acts on the 2nd button press and repeats on 1st:
https://paste.ofcode.org/YFvpGrFgxKUvScSdnGNxYn . Any ideas of what's causing it? I've never had this problem before, and absolutely can't figure out WHY it's changing the first button function. (Please @ me if you respond)

#

Crap that code is probably a little long, moving it to a pasteofcode...

spring coral
#

is that whats happening?

untold shore
spring coral
#

how are you assigning the function call to the button?

#

are you doing it via unity events in inspector or manually assigned in code via button.onclick.AddListener?

untold shore
#

Unity events in inspector

spring coral
#

do they both call separate functions?

#

or is it the same one with a different param or something

untold shore
#

They do, they're entirely separate. Most I can think of is they are on the same script, but I don't get why it would call a different function. I'll show you a quick photo of both button function calls:

spring coral
#

send me the full script for deckmanager and dealerdeckmanager

#

throw it in a pasteofcode or something

untold shore
spring coral
#

nothing suspicious here?

#

when the issue happenns, click on the "resetting player hand" log under ResetPlayerHand and send then stacktrace screenshot here

#

specifically this after clicking on the log

untold shore
#

I don't know why it would do MoveNext()

spring coral
#

is that the full stacktrace or is there more if you scroll down

untold shore
#

Thats it

spring coral
#

also MoveNext is just because fo the coroutine

#

better yet, throw a debug.log under ResetPlayerHandVoid

#

something is calling that coroutine and because its under a coroutine its not sending the source call

#

so just throw a log in there and try again

untold shore
#

Yeah, it's not even calling ResetPlayerHandVoid, it's just moving straight to the ienumator, which is really weird

spring coral
#

the yield return null means that something at least a frame before is calling the method

#

what are all of the things that can cal ResetPlayerHandVoid?

#

is it just the buttons?

untold shore
#

It's only these two, which are only called when the deckmanager or dealerdeckmanager call for them. the buttons just start the things that call these two methods

spring coral
#

and youre saying that even when you put a log in ResetPlayerHandVoid nothing comes up when you click on deal?

untold shore
#

Yeah, Here Ill get a quick video to show you the entire logs

spring coral
#

sure

untold shore
#

Alright, finally got it to show up the ResetPlayerHandVoid comment, maybe it was just slow. I think it's something with DealerDeckManager. Currently gonna try it out...

#

it was the stupid variable. playerstands, I never turned it back to 0. Ugh! So happy you helped me with that though, I NEVER would've figured that out. Finally going to go get some rest. Again, thank you!

spring coral
#

nice, and np!

regal kettle
#

Why is this code uncreachable?

rich adder
regal kettle
#

ima ctually so stupid

rich adder
#

code runs each line top to bottom

regal kettle
#

I'm sorry the easiest things always miss me

rich adder
regal kettle
#

not in particular

#

but I'll try thgat

#

wait yeah I want to get the input not just a keycode

rich adder
#

wdym the input ? GetKey gets inputs

regal kettle
#

doesnt getkey return a bool

rich adder
#

yeah checks if ur holding the button

regal kettle
#

im trying to make sure that the button that is pressed is the same as the letter

#

does input.inputstring not suffice?

rich adder
#

which letter?

#

on the keyboard?

regal kettle
#

I currently have one M key

#

and im trying to make it so that only when I press m it changes sprite

#

is released is supposed to chjange sprite of the key to fgray

#

this is where I use checkkey

rich adder
regal kettle
#

keyboiard

rich adder
#

Input.GetKeyUp gives you when certain key was released

regal kettle
#

I have a quick nonrelated question

#

in a case like this m is a child of keys and keys is a child of keyboard correct?

rich adder
#

yes

regal kettle
#

is this the wrong approach?

rich adder
regal kettle
#

Ok so

rich adder
#

you just want to change sprite according to keypress?

regal kettle
#

Im trying to make an on screen keyboard

#

with all keys of course

#

then when I press it

#

it turns to another sprite

rich adder
#

so not when you use keyboard like you said before

#

they are UI buttons ?

regal kettle
#

sprry i meant when I press the corresponding key

#

it changes sprite to a pressed down one

rich adder
regal kettle
#

yes

#

So in this i made checkkey ourput hello in the debug log and made ispressed output lol in the debug log

#

but there is hello in the debug log but not a bye

rich adder
regal kettle
#

how?

rich adder
regal kettle
#

Key is the highlighted gameobject and it is the M key on screen

rich adder
#

are you going to manually create these? that painful lol

regal kettle
#

well how else would I do it lolo

rich adder
regal kettle
#

Im not good enough for that lol

rich adder
regal kettle
#

Yeah I should ahve

#

but its scdhool so what can I do

rich adder
#

make it simpler?

regal kettle
#

I dont know how

#

also complexity is a part of the rubric as well

rich adder
#

so you're telling me your school just throws you this project without any basic understanding of the thing you're supposed to do?

regal kettle
#

no I chose unity like an idiot

rich adder
#

so what is the assignment and why did you make it this complicated ?

regal kettle
#

IB computer science internal assessment

rich adder
#

how is that a specific project?

regal kettle
#

its not you make one up

#

look I made some mistakes but theyre not something I can fix now

rich adder
#

yeah so pick something simplified

#

like pong ?

regal kettle
#

Complexity is a criteria

#

i cant make pong and get a good score

rich adder
#

pong is still complex

#

trig math / physics / number tracking

regal kettle
#

Maybe thats true but I'd have to do all my previous work again for that

#

that'd be harder

rich adder
#

do as you wish, better than being stuck on a much more complex system / problem imo

regal kettle
#

I dont have the guarantee of my previous parts all being perfect scores

#

The code is only half of my grade and my teacher of course wont grade it again

blissful yew
#

What is it called when you use a single int to represent multiple pieces of information? For example a three digit int where the first two digits convey thing A and the last digit conveys thing B. I thought 'bitcode' but idk if that's right

#

or for example a hexcode where each int represents the state of a surrounding tile

eager spindle
#

bitflag?

north kiln
blissful yew
#

And then what's the best practice for 'cutting out' certain digits (the part of the bitmask that's needed)? Have to convert to string?