#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 474 of 1

static wasp
#

oh

rich adder
#

it should already be doing that based on your code

#

it just wont ever hit anything less than 0

glad wagon
#

and I'm afraid to tell AI this and it burns out

rich adder
#

because back to my question about , what absolute is doing

#

absolute value, count from 0 how many spaces your negative value is

#

-1 , 1 space.. 0 + 1 = 1

#

you could never play backwards animation

static wasp
glad wagon
#

this is what Mathf is doing?

rich adder
#

Mathf is a utility struct

static wasp
#

Mathf.Abs not Mathf, but yes

rich adder
#

for built in math functions that return/work w float

rich adder
#

has a whole bunch of stuff math related

#

Unity specific, lots of them are just float versions of the built in System ones
math actually closer to mathF but more functions

glad wagon
#

damn

static wasp
#

what is the difference of Vector2.MoveTowards and Vector4.MoveTowards, they both have the same description

rich adder
#

vector4 is just 4 floats, like vector2 is 2 floats

#

color is usually a vector4 etc.

static wasp
glad wagon
#

poor ps1 mia goth...will never rotates in the same place

rich adder
polar acorn
glad wagon
#

sorry it was a joke

maiden chasm
#

@azure sail can yoi help me to Code unity haha

rich adder
glad wagon
rich adder
glad wagon
#

I'm pretty old too, but mia goth is a nice new revelation actress for horror fans

maiden chasm
#

Ps do you blocken me :(

rich adder
maiden chasm
#

:((((((

rich adder
#

idk lol

maiden chasm
#

He blocken me :((((

static wasp
#

navarone

#

is there a way to make something point at another thing

static wasp
#

how

rich adder
#

subtract the two positions assign it as pointing direction

rich adder
static wasp
#

positions?

#

3d

#

i only need it to rotate in the y axis tho

rich adder
#

if its 3d you could just use look at

static wasp
#

LookAt?

#

ok thanks

rich adder
#
  [SerializeField] private Transform target;
  private void Update()
  {
      var targetPos = new Vector3(target.position.x, transform.position.y, target.position.z);
      transform.LookAt(targetPos);
  }``` should only rotate on Y
static wasp
#

i have a Transform, not a Vector3

#

or actually, lemme try something

#

i got it working i think

#

the console is spitting 2 warnings but it works

#

and i reduced a line

#

nvm i reduced another line

#

now it's only one line

#

now it's still one line, but the console isn't spitting warnings

#

thanks for the idea tho

rich adder
#

idk what these cryptic messages mean lol

static wasp
#

Incase you are wondering, instead of making a variable for it, you can just plug it in

rich adder
#

i mean you can but one liners tend to look like shit after a while

#

actually even what i wrote looks like shite
I would do

var targetPos = target.position;
targetPos.y = transform.position.y;```
static wasp
slender nymph
static wasp
slender nymph
#

you're the one that has to read it in the future, so do whatever you want. but don't complain when your choice to make the code less readable does exactly that

static wasp
#

I think it has the same level of readability in this case, also I put comments anyways

glad wagon
#

@rich adder are you going to make more videos about resident evil games? like, how to add running anim, aim anim, etc

rich adder
glad wagon
#

nice, please do it!

rich adder
glad wagon
#

that's nice...I wish I could learn it all...

rich adder
glad wagon
#

lol I'm going step by step, never giving up

rich adder
#

IK just makes things a bit more interesting and easy for modular animations

glad wagon
#

well, my idea is to make something very simple and retro, maybe this is too advanced for my game

#

not retro, more like classic

#

like parasite eve 2 my favorite game in ps1

rich adder
#

mine was RE and Dino crisis

#

later on was Blue Stinger (underrated gem)

glad wagon
#

maybe I will play on emulator

rich adder
#

its very good

glad wagon
#

modern games don't give me joy, only the classic one lol

rich adder
#

yeah they have a certain charm

rich adder
lapis frigate
#

when I switched to community version in visual studio my code wont show complition errors again and when I tried to fix that with the Ide tutorial I saw that the visual studio editor package dont show up for me

slender nymph
#

go to the unity registry to install it (dropdown in the upper left that current shows In Project)

glad wagon
#

looks like a very nice tool...I'm using triggers to switch cameras, gives a lot of work

rich adder
#

been there done that.. this component is goated

lapis frigate
slender nymph
#

i don't know what tutorial you are looking at, but presumably it's a matter of different versions

lapis frigate
#

this one

#

!ide

eternal falconBOT
lapis frigate
#

isn't it up to date?

slender nymph
#

well your external tools menu is going to look different until you actually select visual studio there

rich adder
slender nymph
#

probably the one that has been renamed to "Install Editor"

lapis frigate
#

n3

rich adder
#

you said Vscode

slender nymph
#

that guide is using information from an older version of the unity hub. don't think so hard about it

#

they didn't actually. they said "in visual studio my code wont"

rich adder
#

oops I need my eyes checked

lapis frigate
#

umm but I sitll dont know what to do though, last time I just had to install the work with unity from the workplace but now its installed and a lot of the stuff in the tutorial looks diffrent in the current version so im confused

slender nymph
#

you do know that the instructions you are asking about are for installing the unity editor (which you already have installed and open), right?

#

skip that section since you have the editor installed and move on

lapis frigate
#

ye but last time I had this problem someone told me to go over this

#

ok

slender nymph
#

yes, follow the instructions. but obviously don't bother with reinstalling the unity editor

lapis frigate
#

same stuff later tho, I litterly dont have the Coomon7/IDE directory

#

or I cant find it

slender nymph
#

was visual studio not listed as an option?

lapis frigate
#

it does but they said to select browse

slender nymph
#

please read the words on the page

lapis frigate
#

oh

#

its vor other versions mb

slender nymph
#

yes, specifically for if a version "isn't listed"

lapis frigate
#

well then this is it tho cuz I completed every other step that is relevant for me

slender nymph
#

regenerate project files and restart visual studio

lapis frigate
#

where do I do that

#

I dont have that button in the external tools tab

rich adder
slender nymph
#

you do have the visual studio editor installed and up to date?

lapis frigate
#

yes I checked for updates

#

it said version is up to date

slender nymph
#

show it in the package manager as well as what your external tools menu looks like

lapis frigate
slender nymph
#

restart the editor

lapis frigate
#

u mean restart the visual studio?

rich adder
#

unity

lapis frigate
#

ok

#

ok now its normal

#

like the external tools tab I mean

#

ok it fixed it

#

now the code is back to normals

#

tnx mates

vocal urchin
#

this is kind of a general question and apologies if it's too vague for a meaningful answer but what kind of changes should you expect to break saves? a lot of early access games will occasionally have updates which require saves to be wiped. Is it generally just any large refactoring of existing systems?

languid spire
vocal urchin
languid spire
eternal needle
# vocal urchin this is kind of a general question and apologies if it's too vague for a meanin...

sometimes its just not worth catering for, especially if these saves are small things like a roguelite game. it could even be a very small change but something thats just easier to say "old saves wont work on this version" to encapsulate ALL potential bugs.
simple example, you have a deterministic algorithm for where stuff will spawn in a world. you save the seed for that so the player can re-enter the game and have the stuff in the same locations always. Now suddenly you want to update the game, you want to generate new objects in the world that didnt exist previously. A person using the old save suddenly doesnt generate the same world anymore.

vocal urchin
# languid spire I cannot speak directly of that asset but I doubt it will do all the work for yo...

certainly not. I can think of some instances, like if I refactored items from some generic item class to a bunch of different classes that inherit from the item class, that would likely break saves and may not be worth the headache of refactoring. Just curious if there may be some obvious examples I'm not seeing. Maybe it's a silly question. Any time the data that is saved is no longer relevant to the scripts using it, the saves either needs converted to a new version or they're unusuable.

languid spire
vocal urchin
#

having some method of referencing a version number for a save seems essential the more I read. Thanks!

weak cedar
#

How to edit the rotation values seen in the inspector

night raptor
weak cedar
dry spruce
#

hello everyone, i have created egg_catcher game and exported as APK but eggs are not spawning in apk

silk night
#

Please show us your code

dry spruce
languid spire
# dry spruce

Have you run using the Android LogCat package to see if any errors are being thrown?

dry spruce
#

no

languid spire
# dry spruce no

I suggest you do so as that is the tool for debugging Android builds

dry spruce
silk night
#

!code

eternal falconBOT
silk night
#

I can also recommend SR Debugger, its not free but it helps with inbuilt cheats + error log

dry spruce
silk night
#

Thats not an error, thats a warning and that shouldnt break your game

#

it basically just tells you "hey you got a field here thats only written to, its never read somewhere"

dry spruce
silk night
#

Where do you call GameStart()?

languid spire
#
 //StartCoroutine("SpawnEggs");

Somewhat odd, no?

dry spruce
silk night
#

Hmm first hunch would be the eggs are either spawning behind your background or outside the screen

#

So a list of things to check:

  • Image of the egg breaks on build (invisible), add something else you can see to the egg like text
  • Egg behind background, not sure how you do your background
  • Egg outside of screen left/right
weak cedar
#

@dry spruce does it work normally in the inspector though?

weak cedar
#

then it seems like a texture issue to me maybe

#

because the egg is there, u just dont see it

dry spruce
silk night
#

Are you building to mono or il2cpp?

dry spruce
#

Il2cpp

silk night
#

can you show us the inspector of the egg texture?

short hazel
#

The fact that you're using strings inside StartCoroutine might have to do with the issue (code stripping).
Use the method directly: StartCoroutine(SpawnEggs()) or reference the method name using nameof: StartCoroutine(nameof(SpawnEggs))

silk night
#

so it seems to be spawned, just not visible

short hazel
#

Better fix the code anyway. It's not fully resistant to renames

languid spire
#

It's a simple check, add a debug.log to the spawn coroutine. But the chances are using strings in StartCoroutine will definitely cause problems when the code is stripped

silk night
#

the thing you have in sprite there

dry spruce
silk night
#

in your project click on the image, you should get a window like this

dry spruce
silk night
#

hmm nothing weird in there, yeah then last guess would be that its somehow off-screen

dry spruce
weak cedar
#

Next to Display 1, click "game"

#

then choose simulator

#

maybe that could help troubleshoot

languid spire
# dry spruce

Add a Debug.Log to the SpawnEgg method which outputs the spawnPosition.
Do a Build and Run and see what comes out in the Android LogCat window

#

Also is LimitX set to the same value as maxPos?

terse spindle
#

how to make a force that will make the character always standing

#

in ragdolls

#

angular drive or somethig

eternal needle
# terse spindle how to make a force that will make the character always standing

The basic way is through configurable joints and set the target rotation. that target rotation could be gotten through another object who is using animations in the way you would want to move.
Though this really isnt an easy task, and you'll need to fine tune A LOT. Do you really need a character that is a ragdoll and moving around? Or do you just need a character which can ragdoll

jaunty bay
#

lets say that i want a GameManager to exist across all scenes with DDOL.
can i make it so that if i start a scene that doesn't have GameManager it creates a new one?

terse spindle
#

Im editing angular limits now

#

but somehow

#

it looks like he broke every bone

short hazel
jaunty bay
#
if (FindAnyObjectByType(typeof(GameManager)) != null)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);

will this work?

short hazel
#

That works yep.
Though prefer using the generic version of that method, it's prettier: FindAnyObjectOfType<GameManager>()

marble hemlock
#

ive been struggling to find an inventory system tutorial and i just want some opinions

#

would it be a bad idea to do everything else except the inventory system, and then come back to it at a later date?

#

for the time being i could just have it so the player can only hold one item at a time

eternal needle
# terse spindle it looks like he broke every bone

I believe when you use the ragdoll wizard to create one, it makes limits for you. Then just create the configurable joints manually and copy those values over.
And yea this is still all gonna be fine tuning for a long time, it's a pain in the ass to setup. Just wait until you get to the joint forces

marble hemlock
#

or sometimes they'll change something, but not mention it, so you just gotta do your own stuff for a bit to try to figure it out

but im just starting out with this system so i dont fully understand how exactly its doing what its doing, but i feel like everything else can get up and running beyond the inventory system

#

its not required, but its convenient, as allowing the player to hold more than just one object allows them to actually move efficiently without having to do a lot of back and forth

eternal needle
terse spindle
terse spindle
#

which Im folliwing a tutorial

marble hemlock
#

i guess my biggest problem is trying to learn how to get it to store data
i really could just work around this for the time being but i dont want to code everything, and then decide to go back for an inventory system, and oop everything is too complicated to integrate it properly

queen adder
eternal needle
eternal needle
jaunty bay
#

i want so that:

every time the player enter a scene, it will spawn to a spesific destined spawnpoint

i did it by:

private SpawnHandler spawnHandler;

///Start function
spawnHandler = FindObjectOfType<SpawnHandler>();
Transform playerSpawn = transform;
playerSpawn = spawnHandler.spawnTransform;

changing the player's coordinate to a spesific coordinate that has been set by the GameManager. it did not work. anything wrong here?

scenic saffron
#

why is collision detector not working? (I have tried both enter and stay)

silk night
languid spire
silk night
jaunty bay
#

i refered the player's transform as Transform playerSpawn, in which just creates a new Transform variable rather than the player itself i assume?

#

tysm <3

silk night
#

you just wrote the players transform and then the spawner transform into the same variable, overriding it in the process, you never applied anything to the player

marble hemlock
#

how would i go about having an object know its being hit by a raycast

#

not the raycast know its hitting an object

silk night
#

the raycast hit will output the object you hit, then you get the script off that object and call a function on it

marble hemlock
#

thank you

#

i can already tell this system is going to start leaving me confused

#

trying to follow this tutorial for an inventory system but i have to readjust the entire thing for A) 3D, and B) actually fitting how i want the collection system to work

silk night
#

You can even abstract it with a "IRaycastHittable" then you can do something like this:

public interface IRaycastHittable {
  void OnRaycastHit();
}

public class ObjectToHit : MonoBehaviour, IRaycastHittable {
  public void OnRaycastHit() {
     Debug.Log("Hit by raycast");
  }
}

public class RaycastSender : MonoBehaviour {
  public void SendRaycast() {
    // raycast stuff here -> raycastedObject
    raycastedObject.GetComponent<IRaycastHittable>().OnRaycastHit()
  }
}
#

Just make sure only one script on each object has IRaycastHittable otherwise you only get the first

languid spire
#

lol, Null Ref Exception just waiting to happen

silk night
#

explain ๐Ÿ˜„

languid spire
#

if it hits an object without the interface

silk night
#

oh yeah ofcourse you put checks in

#

its pseudo code

languid spire
#

the check should be in a TryGetComponent

marble hemlock
#

i have to have 4 scripts interacting for this one system i can already tell its going to be a pain notlikethis

#

too much back and forth perhaps

#

perhaps ill do better if i write down a flowchart to visualize whats going to happen

silk night
#

If you are just beginning its fine but if you feel like you have too much back and forth an abstract data layer like ECS or models might be your prefered way

wintry quarry
#

However, appropriate use of composition can often simplify things.

languid spire
#

Personally I'd use the observer pattern for this situation, especially if the raycast is executed frequently

marble hemlock
#

one day this will make sense

#

i think im getting it together now

silk night
#

yeah dont complicate things for yourself by prematurely diving into those things, finish it your style until it works and if you want go back afterwards to see if you can clean it up and implement a pattern

scenic saffron
#

how do i get the distance between two Objects?

silk night
#

2d / 3d?

scenic saffron
#

3d

#

as a float not as a vector

silk night
#

Vector3.Distance(...)

languid spire
scenic saffron
#

thx

naive lion
#

Hey guys! my upgrade hub screen is not recongnising the 'PointerDown' or 'PointerClick' event trigger. The 'PointerEnter/Exit' events are firing however which makes it strange. All 'Raycast Targets' have been checked and theres nothing blocking it.

    {
        Debug.Log("Test");
        //Logic
        });
    }```
silk night
#

if he didnt his hover would not work either

naive lion
#

i didnt know they conflicted

#

it works

#

thank you

silk night
#

๐Ÿ˜„ thats just experience, had that happen plenty

#

the button already catches the on click and doesnt propagate it as it is seen as handled at that point

naive lion
#

AHHH so frustrating my mind was going crazy

signal mantle
#

Hi, can someone tell me why my prefab isnt being destroyed, and this DontDestroyOnLoad thing appears when i run the game?

silk night
languid spire
burnt vapor
eternal falconBOT
signal mantle
#

Sorry give me a second

vocal marlin
#

newChoice.GetComponentInChildren<TextMeshProUGUI>().text = currentDialogueSentence.choices[i].choice;
newChoice.GetComponent<Button>().onClick.AddListener(() => SwitchBranch(currentDialogueSentence.choices[i].branchToSwitch));
For some reason, out of these two lines of code, the second one give an IndexOutOfRangeError. I'm not sure how that's possible, can anyone help me?
For context, the second line is directly under the other in a for loop.

#
public void DisplayChoices()
    {
        if(currentDialogueSentence.choices.Length == 2)
        {
            buttons.GetComponent<GridLayoutGroup>().spacing = new Vector2(0, 40);
        }
        else
        {
            buttons.GetComponent<GridLayoutGroup>().spacing = new Vector2(0, 10);
        }
        dialogueText.text = "";
        for(int i = 0; i < currentDialogueSentence.choices.Length; i++)
        {
            GameObject newChoice = Instantiate(button, new Vector2 (0, 0), Quaternion.identity);
            newChoice.transform.SetParent(buttons.transform, false);
            newChoice.GetComponentInChildren<TextMeshProUGUI>().text = currentDialogueSentence.choices[i].choice;
            newChoice.GetComponent<Button>().onClick.AddListener(() => SwitchBranch(currentDialogueSentence.choices[i].branchToSwitch));
        }
    }

Here's the whole function if needed

signal mantle
# signal mantle Hi, can someone tell me why my prefab isnt being destroyed, and this DontDestroy...
 public void RangedBasic()
    {
        RaycastHit hitInfo;
/*        GameObject Test = Instantiate(LinePrefab, new Vector3 (0,0,0), Quaternion.identity);
        Test.GetComponent<LineRenderer>().SetPosition(0, this.transform.position);
        Test.GetComponent<LineRenderer>().SetPosition(1, this.transform.position + this.transform.forward * 20);*/
        Physics.Linecast(transform.position, transform.position + transform.forward * 20, out hitInfo);
        StartCoroutine(BulletSpawn(hitInfo));

    }

    private IEnumerator BulletSpawn(RaycastHit hitInfo)
    {
        if (hitInfo.collider != null)
        {
            LineRenderer bulletLine = Instantiate(BulletPrefab, new Vector3(0, 0, 0), Quaternion.identity).GetComponent<LineRenderer>();
            bulletLine.SetPosition(0, this.transform.position);
            bulletLine.SetPosition(1, hitInfo.transform.position);
            yield return new WaitForSeconds(1f);
            Destroy(bulletLine);
        }
        else
        {
            LineRenderer bulletLine = Instantiate(BulletPrefab, new Vector3(0, 0, 0), Quaternion.identity).GetComponent<LineRenderer>();
            bulletLine.SetPosition(0, this.transform.position);
            bulletLine.SetPosition(1, this.transform.position + this.transform.forward * 20);
            yield return new WaitForSeconds(1f);
            Destroy(bulletLine);
        }
    }

Here the code for spawning and destorying the prefab, should i also provide the inspector for the prefab?

rocky canyon
#

then theres no Button on it ๐Ÿค”

silk night
vocal marlin
rocky canyon
#

then its not that line.. and more likely something in the SwitchBranch(currentDialogueSentence.choices[i].branchToSwitch

rocky canyon
#

try narrow down whats missing

vocal marlin
#

yeah i set currentDialogueSentence.choices[i].branchToSwitch to just a random number and then it worked

rocky canyon
#

aye!

vocal marlin
#

and the error points to that line as well

languid spire
#

it's lambda completion

SwitchBranch(currentDialogueSentence.choices[i].branchToSwitch));

i will contain currentDialogueSentence.choices.Length when the code is executed

rocky canyon
#

lambda completion

vocal marlin
#

I'm not sure what that is

rocky canyon
#

me neither.. i figured id say it out loud just in case it rang a bell

vocal marlin
#

haha

languid spire
#

basically i is passed by reference not by value, so the last value it has is what the method gets

vocal marlin
#

no but

#

each time it instantiates a new button

rocky canyon
#

ohh yea!!

#

u need to store the current index in a local variable to capture it

silk night
#

oh yeah write the value of currentDialogueSentence.choices[i].branchToSwitch into a new var before that lambda and use that variable

#

yeah what spawn camp said ๐Ÿ˜„

signal mantle
languid spire
#

doesn't matter you are still passing the same i to each button

rocky canyon
vocal marlin
rocky canyon
#

lambda completion .. it makes so much more sense now thinksmart

vocal marlin
#
      int branchToSwitch = currentDialogueSentence.choices[i].branchToSwitch;
      newChoice.GetComponent<Button>().onClick.AddListener(() => SwitchBranch(branchToSwitch));

Just to make sure I understood what you said, should I do it like this?

silk night
#

yep that looks correct

rocky canyon
#

or just currentIndex = currentDialogueSentence.choices[i];

vocal marlin
#

Ok, thanks

rocky canyon
#

and then currentIndex.branchToSwitch

#

either or works

vocal marlin
#

Yeah it did work, thanks!

rocky canyon
#

woop woop!

#

stevesmith ftw

vocal marlin
#

is there any reason why I have to do that for the second line and not the first?

rocky canyon
#

i was gonna have u debug every variable ๐Ÿ˜…

#

its b/c the lambda

vocal marlin
#

lmao

languid spire
#

Have we learned something today?

rocky canyon
#

the => part

rocky canyon
vocal marlin
#

oh, ok ty for the help and lesson

languid spire
#

this is why I hate lambdas

rocky canyon
#

lambda's are cool for basic stuff

signal mantle
rocky canyon
#

i use em for returns religiously

burnt vapor
#

What is inside the scene anyway?

#

The DDOL scene

languid spire
#

syntax sugar can oft lead you astray

rocky canyon
#

sometimes unity will create its own DDOL for certain things

#

Debugger or some crap

#

i cant remember

signal mantle
languid spire
#

URP makes a DDOL scene

rocky canyon
#

^ thats it

brave compass
rocky canyon
#

i could be.. u right

burnt vapor
rocky canyon
burnt vapor
#

See what's in it

rocky canyon
#

expression body i guess @brave compass

signal mantle
#

DebugUpdater

rocky canyon
#

thats normal.. ignore it

signal mantle
#

Odd that it just spawned in aft im encountering the destroy issue, but it wasnt the cause lol

brave compass
rocky canyon
#

it was probably always there.. u just didnt notice it until u startd looking @signal mantle

signal mantle
#

Thanks for the help

#

๐Ÿ™‚

rocky canyon
#

๐Ÿ’ช

#

gotta calm my jets w/ the syntax sugar tho

steep rose
#

you get a good workout via syntax it seems

rocky canyon
#

i love syntax

#

i sometimes write 2 or 3 methods various ways..

steep rose
#

we see that ๐Ÿ˜‚

rocky canyon
#

and then comment out the ones i dont want

#

always more than 1 way to skin a cat

brave compass
#

Lambdas are also pure syntax sugar for a feature that existed before them called anonymous delegates. You used to have to write this:

Func<int, int, int> sum = delegate (int a, int b) { return a + b; };

But with lambdas, you can get the same compiled output with this:

Func<int, int, int> sum = (a, b) => a + b;
rocky canyon
#

ahhh the Func part scares me

steep rose
#

yeah i have zero clue what that is

rocky canyon
#

for some it still is ๐Ÿ˜‰

vocal marlin
rocky canyon
steep rose
brave compass
#

Same thing with the more familiar Action.

Action sum = delegate { Debug.Log("hello"); };
Action sum = () => Debug.Log("hello");
#

Both valid C#, both result in the exact same compiled output, the first is just older, more verbose syntax.

rocky canyon
brave compass
#

Other languages might just remove the old syntax, but Microsoft is very serious about backwards compatibility.

vocal marlin
#

I post in code beginner or code general depending entirely on how I'm feeling

rocky canyon
#

i see.. isn't Microsoft the ones that updated the new VSCode plugin?

#

seems to me they stepping up to pick up the slack or something to that nature

brave compass
rocky canyon
#

cant say im a fan of microsoft.. but i will give them credit where due

steep rose
rocky canyon
#

windows 11 has been an epic trade from win10

#

even if its b/c i get 5x fewer updates

silk night
rocky canyon
#

๐Ÿคฃ

vocal marlin
#

joking

#

I know a bit of unity

rocky canyon
#

tbh there should be a lower channel..

vocal marlin
#

lmao

steep rose
#

i disagree

#

then it would be impossible to help others

rocky canyon
#

#unconfigured-ide-code-beginner

silk night
#

#posts-code-as-screenshot-beginner

steep rose
#

sad, but true

rocky canyon
#

yup.. see sidia knows

silk night
#

extra points if its a phone picture

steep rose
rocky canyon
silk night
#

there are fantastic OCR apps

rocky canyon
#

i'll look past a unconfigured ide before i look past a mobile picture

steep rose
rocky canyon
#

mobile picture gets hard ignored

silk night
#

or that ๐Ÿ˜„

rocky canyon
#

then u have guys that absolutely struggle w/ configuring they're ide..

steep rose
#

so fair

rocky canyon
#

then to me thats a red-flag right off the bat..

#

kinda like.. u sure u wanna do game-dev?

silk night
#

in german we have an abbreviation for such users, DAU (dรผmmster anzunehmender nutzer) = dumbest user you can assume

rocky canyon
#

im fond of PEBCAK, or PEBKAC

#

even have a Dbug.PEBCAK() exception ๐Ÿคฃ

silk night
#

my favourite is error 40, when the error sits 40cm from the screen ๐Ÿ˜„

rocky canyon
#

ohh thats a good one lol

steep rose
#

or when they just dont have a console

#

ive seen that before

rocky canyon
#

dรผmmster anzunehmender nutzer
even not being a German speaker i can tell this is an insult

silk night
#

tbf hearing any german word sounds like a curse word for most people

rocky canyon
#

lol. fair

steep rose
#

when they scream at you its terrifying

rocky canyon
#

Konfigurieren Sie Ihre Idee

#

is this proper ^?

silk night
#

well i dont know any other language that can curse your whole family tree with a single word, no whitespaces needed!

steep rose
eternal falconBOT
silk night
rocky canyon
#

dumb google translate

#

Konfigurieren Sie Ihre integrierte Entwicklungsumgebung

wet path
#

hi, my unity is giving me trouble at login

rocky canyon
#

@ login?

steep rose
#

that isnt code related

rocky canyon
wet path
#

oh sorry i wasnt aware of that

#

thank you

vocal marlin
#

I don't speak arabic though but that's what they do

languid spire
silk night
lapis frigate
#

yo does any1 knows for how long the !code saves?

eternal falconBOT
teal viper
lapis frigate
#

for how long I can use the link

#

does the code saves in the link forever?

languid spire
#

can't spell either

rocky canyon
#

each website is different.. it'll tell u somewhere

#

or just assume its forever

burnt vapor
#

Paste sites are usually for temporary sharing

steep rose
#

you could use github if needed

sleek isle
#

bro i cant get my script working

steep rose
#

we need details

sleek isle
#

i added a gun controller which is the best one i have ever used and now my camera keeps snapping back to centre when i move it left and right

#

i cant find any solutions in words i understand this is my first game idk what im doing

steep rose
#

i would recommend !learning unity

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

steep rose
#

and you should also show your !code so we can help

eternal falconBOT
eternal falconBOT
cosmic dagger
#

use one of the paste sites. not everyone can the code โ€” from mobile โ€” and it doesn't contain lines numbers . . .

sleek isle
novel blaze
#

hey guys can someone help me make a script which when we hold an item and we colide into an object while holding the item it makes the item disseapear and triggers a sound because i cant find any tutorials on youtube

cosmic dagger
rocky canyon
#
  • pickup / hold item
  • oncollision/ontrigger enter
  • disable/destroy object
  • play sound
novel blaze
#

and how do we do that ๐Ÿ˜ญ

cosmic dagger
sleek isle
sleek isle
novel blaze
#

like how to hold an item.. how to make an item disseapear on collision? and trigger a sound when the item is gone?

cosmic dagger
novel blaze
#

are there tutorials for that on youtube?

novel blaze
#

ill try

cosmic dagger
sleek isle
cosmic dagger
#

i would direct the paste link toward instead of pinging me because others will think it's just for me (though i don't know anything about your question) . . .

sleek isle
#

ok thx

novel blaze
sleek isle
novel blaze
#

alr

cosmic dagger
novel blaze
#

on youtube or something

cosmic dagger
#

yes, there are tons for doing the stuff you need. you're trying to find one video that does everything which is very specific to your case/game. you need to search for tutorials that do one thing, then you combine those tasks to work together . . .

novel blaze
#

is this good?

rocky canyon
#

no normally it older posts dont matter (most still work)
but that one is soo old it using Monoscript / javascript

novel blaze
#

2010 damn

rocky canyon
# novel blaze is this good?

ya, but like i said normally that dont matter.
u see where it says function thats not the syntax for that anymore

novel blaze
#

lua uses function

rocky canyon
#

its private void OnTriggerEnter()

polar acorn
novel blaze
#

Ik

hexed terrace
#

What Spawn means is, you can't use function in Unity anymore. It's still the syntax for JS..

ember tangle
# novel blaze is this good?

That will destroy a specific game object after a collision, which may or may not work for the system that you are wanting to build.

lethal meadow
#

how do i make it so it cuts the tree where ever the mouse is

#

instead of a fixed point

#

because i could do a fixed position where it cuts even if the mouse isnt on it

wintry quarry
#

Without seeing code, can't get more specific than that

lethal meadow
#

but how would i split the model at that point

wintry quarry
#

How are you splitting the model now?

lethal meadow
#

not my game its inspiration

#

ill get a better clip

wintry quarry
#

Runtime mesh modification presumably

#

It's not really beginner stuff

#

There are assets that will do it too

#

You could use one of those

lethal meadow
#

it makes the cuts wherever you are

#

but i'd only know how to make one preset cut at a location that starts even if the mouse is at the opposite side of the tree

wintry quarry
rich adder
wintry quarry
#

in this case actually the tree seems to be made of simple rectangular prisms though

#

so you could do this with:

  1. a little texture magic for the black cut line
  2. spawning two new smaller pieces in place of the large trunk, just scaled properly
#

That's perhaps a simpler alternative to modifying the mesh.

terse spindle
terse spindle
#

when my character ragdolls

#

its wing's tip stays like that

#

how can I fix it

mint remnant
#

he needs to lay off hte donuts

terse spindle
#

thats a bird

mint remnant
#

where there ya go, your solution is remove the hands, birds don't have hands!

terse spindle
mint remnant
strong wren
#
            {
                XCretionsCanShop = true;
            }
            else if (Hit.collider.transform.name != "XCretions")
            {
                XCretionsCanShop = false;
                Debug.Log("Not Hitting XCretion");
            }``` would anyonre know why this isnt working
#

wait i should prolly provide more code

#
        {
            if (Hit.collider.transform.name == "XCretions")
            {
                XCretionsCanShop = true;
            }
            else if (Hit.collider.transform.name != "XCretions")
            {
                XCretionsCanShop = false;
                Debug.Log("Not Hitting XCretion");
            }
        }```
#

im using a raycast right, and the if statement works but no the else if

mint remnant
#

first you don't need to check if something is not in the else

polar acorn
strong wren
strong wren
mint remnant
#

if(condition) { do something } else { do something else }

strong wren
#

i also tried using just an Else Statement but that doenst work either

polar acorn
#

Which is not the same as when it doesn't hit an object with that name

strong wren
#

should i just remove the else?

mint remnant
polar acorn
polar acorn
strong wren
polar acorn
#

the raycast or the name check

strong wren
polar acorn
# strong wren the name check

Okay, so you want that code to run when the raycast does hit something, but that thing doesn't have that name "XCretions"

strong wren
#

when the raycast hits smth named "XCretions" i want a bool to be turned on, if it isnt then i want it off

polar acorn
#

Do you want the code to run when the raycast does hit something with a name that isn't "XCretions"

strong wren
polar acorn
#

If you want the code to run when the ray does not hit something

#

then you would want to put the else on that condition

#

not the name check

strong wren
#

ok

#

i think that way would be better yes

abstract copper
#

you need to know what you want before you code

obsidian granite
#

for a racing game, is there a way i can get navmeshes to pathfind where there's no mesh? for example, if there's a ramp, i want the pathfinding to recognize that it's allowed to move off of the ramp to move forward

#

not even just navmeshes, how would you do that with a*?

#

oh that's off mesh links

#

duh

#

i forgot they existed ๐Ÿ˜ญ

strong wren
#

i want an raycast that looks for a gameobject that is infront of it, and if that gameobject has the name "XCretions" then i would want the bool "XCretionsCanShop" to be true and if that smth infront is either empty or isnt named "XCretions" then i would want it to be off

obsidian granite
polar acorn
languid spire
strong wren
obsidian granite
polar acorn
strong wren
obsidian granite
#
bool thing = raycasthit.transform && raycasthit.transform.name == "name here"
languid spire
polar acorn
obsidian granite
polar acorn
#

If the raycast has nothing, there's no object to check the name of

obsidian granite
strong wren
polar acorn
#

There are many ways to do this, actually.

obsidian granite
#

yeah

languid spire
obsidian granite
polar acorn
strong wren
obsidian granite
strong wren
obsidian granite
#

if you have the code, what do you need help with? is it not working?

polar acorn
obsidian granite
#

the relevant section

strong wren
#
    public void RaycastManager()
    {
        if (Physics.Raycast(RayCastGameObject.transform.position, transform.forward, out RaycastHit Hit, 5, Interactable))
        {
            if (Hit.collider.transform.name == "XCretions")
            {
                XCretionsCanShop = true;
            }```
abstract copper
#
XCretionsCanShop = false;

if (Physics.Raycast(RayCastGameObject.transform.position, transform.forward, out RaycastHit Hit, 5, Interactable))
{
    if (Hit.collider.transform.name == "XCretions")
    {
        XCretionsCanShop = true;
    }
}

Is this what u want?

polar acorn
abstract copper
#

i edited like steve showed

obsidian granite
polar acorn
#

You set it to false once. When the object is created

obsidian granite
#

if you put it in declarative space, it won't get set back to false

strong wren
obsidian granite
#

when the method is called again

obsidian granite
polar acorn
obsidian granite
#

right now it won't get reset because declarations in declarative space happen before anything else

#

and they only happen once

ember tangle
#

Do you need the bool to be class level or should you put it into a function? Read into the concept of scope.

obsidian granite
#

wait is it called declarative space? one of my professors used that term like 2 years ago but i've never heard it since

#

the area where you declare fields and methods

languid spire
#

in C# we call it scope

strong wren
#

neat

#

i did it

#

my inbred ahh got it

polar acorn
#

You mean we did it

obsidian granite
mint remnant
#

how amny coders does it take to make an if statement lol

strong wren
obsidian granite
#

O(n!) because it becomes
"hi can someone help me"
"ok so my problem is that i'm trying to get a struct buut like a reference type"
"why doesn't my code work? doesn't post code"

strong wren
#

wait quick question how can i make the stuff only run once?

polar acorn
strong wren
#

for exmaple the ray thing is in a loop, so it just loops forever if i place a Audio.Play(); thing it it, it will play the sound infinitly until i stop looking at the gameobject how can i make it do it once

strong wren
#

the thing will run every frame

polar acorn
ember tangle
polar acorn
#

If you don't want to run this every frame, when do you want it to run

strong wren
polar acorn
ember tangle
#

you didn't post anything with a while loop, are you referring to running it in the Update() function?

strong wren
# polar acorn Forever?

no, look for example when i look at that gameobject i want
an audio to be played and an animation once
and when i look away i want it to play another audio but im having issues

strong wren
ember tangle
#

only play the audio when your conditions are met.

polar acorn
strong wren
mint remnant
#

you need to focus your efforts on learning basic code flow a bit me thinks

polar acorn
# strong wren no like a hi, and bye then no more sound

Listen, if you want to program, you're going to need to actually know what you want to happen

You need to be able to put into words on what conditions things occur. You can't just give general "vibes" to code. You have to define things.

ember tangle
#

call a function that plays the sound once when you look at it, and once when you look away.

polar acorn
#

So, question:

Is it now off forever, to never play again?

Answer this question specifically. Not the question you think I'm asking. This one.

polar acorn
ember tangle
polar acorn
ember tangle
#

lol true

strong wren
ember tangle
#

so check for that bool and only play The Greetings when it is true

polar acorn
strong wren
polar acorn
#

This is a condition you've never mentioned until now

strong wren
#

oh

polar acorn
#

When I say when do you want to be able to play it again, you need to be specific

#

this is a condition you'd want to be true before the sound can play again

#

this is, in fact, the exact condition I was trying to get you to realize you needed to specify by asking leading questions

#

You have to tell the code that. It doesn't just know what you want

#

So, start the sound when the condition is met and a certain boolean is not set. Then, set the boolean. When the sound ends, un-set the boolean

#

and no, I will not translate this into code for you. This is the exact solution and learning how to translate thoughts into code is something you are going to need to learn on your own

strong wren
ember tangle
#

try to write it out as pseudo code and use the unity documentation to slowly transform it into something that works. Maybe use Debug.Log(""); as a placeholder for systems you dont understand.

#

focus on the basic programming logic for now

strong wren
#

wait a sec i think i got smth going ion

#

looks like its working

#

i just need to tweak it a lil and it might work

#

i did it guys

rich adder
eternal falconBOT
rich adder
strong wren
#

oh

#
    public bool XCretionsPlayed = false;
    public bool XCretionGreet = true;
    
    public void AudioPlay()
    {
        if (Movement.Instance.XCretionsCanShop == true)
        {
            XCretionGreet = true;
        }
        else if (Movement.Instance.XCretionsCanShop == false)
        {
            XCretionGreet = false;
        }
        if (Movement.Instance.XCretionsCanShop == true && XCretionsPlayed == false)
        {
            XCretionsWave.SetTrigger("Waving");
            XCretionsVoice.clip = XCretionsHi;
            XCretionsVoice.Play();
            XCretionsPlayed = true;
        }
        if (Movement.Instance.XCretionsCanShop == false && XCretionsPlayed == true)
        {
            XCretionsVoice.clip = XCretionsBye;
            XCretionsVoice.Play();
            XCretionsPlayed = false;
        }
    }
#

heres the codeรข

abstract copper
#

whats the isssue now?

strong wren
#

which is unexpected

#

there has to be a hidden error

ember tangle
#

why

strong wren
#

its working il just leave it at that

ember tangle
#

why does there have to be a hidden error

strong wren
ember tangle
#

you dont need to trust yourself, you just need to understand the code.

strong wren
#

i wrote it

#

i mean it works il just leave it at that

#

thanks for the help guys

mint remnant
rocky canyon
#

it depends.. it cant hurt.. assume I can't do deductive reasoning

if (x < 10) {
    // x is less than 10
} else {
    // well, x apparently is greater than 10
}```
#

well hold on a minute...

#
if (x < 10) {
    // x is less than 10
} else if (x > 10) {
    // x is greater than 10
} else {
    // x is exactly 10
}``` there we go
#

but yea.. i know what u mean..

mint remnant
#

he's doing if (condition == true) {} else if (condition == false) {} which will work sure, but is redundant and shows he doesn't understand how it works

rocky canyon
#

ya, that is a bit too much lol

#
if (bool == false) {
    
} else {
    // bool == true
}``` and viceversa
#
if(!bool) return;

// bool is true
// do everything you need to do
// for a true bool down here``` ofc my favorite
tacit crystal
#

hey guys i need to make new string using script only after i press a button how do i do that?

vocal marlin
#

you need to make a method such as public void MakeNewString()

#

it has to be public

#

then in that function you should put what you want to do, which is make a new string

#

then in the unity inspector

#

you should attach this script to an object

#

such as the button

#

and then on the button you should see a 'Button' component

#

on that there is a menu where you can attach an object and access a function from one of its scripts

#

attach the function you just made and it should work

tacit crystal
#

thank you gonna try it now

#

how should i make the string? i wasn't coding for a while so i forgot some things

carmine narwhal
#

Noob Questions. Iยดm trying to make a pingpong game and i cant get the ball bounce to work as i want it to. i have tried to make a picture(i paint like a 3year old) how can i go about making it so it workse like the green arrows?

polar acorn
#

You're gonna have to explain more the relationship between your start angle and result, because I don't see anything consistent between the green arrows

#

They seem to be completely arbitrary

carmine narwhal
polar acorn
#

Well, in order to implement it, you're going to need to understand it.

carmine narwhal
polar acorn
#

This isn't really a "Remembers" thing, you are going to need to decide what you want to happen

rich adder
carmine narwhal
tacit crystal
#

i need to use the string how should i do that?

solar torrent
#

alright alright alright guys i have a issue where when i click play my player model spawns in the air like a sigma

vocal marlin
#

This might not be a code issue and more an animation issue

tacit crystal
#

type in inputfield and make the string what i typed in the inputfield

polar acorn
polar marsh
# solar torrent

Your collider is too big and intersecting with the ground, so its pushing the whole object up

#

Make your collider smaller so that it lines up with the bottom of your character

tacit crystal
#

have different value

vocal marlin
#

I'm not really sure what you mean by infinite strings

polar marsh
#

Do you need to store the string somewhere?

tacit crystal
#

but infinite amount of strings

vocal marlin
#

you could put them in a list

#

as a field

#

instead of them just being a local variable

polar marsh
#

Cant blame you

vocal marlin
#

smooth

heady egret
#

Any wizard with unity able to assist me with a box collider issue?

eternal falconBOT
#

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #๐Ÿ”Žโ”ƒfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696

vocal marlin
ionic zephyr
#

If I want my game to restart (remove previous entities and instantiate new ones, generate new terrain) how can I "remove" everything that was previously on the map (trees, entities, bushes which are not part of the tileset. I thought of Destroying every object but that is surely not efficient

wintry quarry
ionic zephyr
wintry quarry
#

If they're GameObjects, sure.

ionic zephyr
#

Oh, okay then, thanks as always!!

scarlet bear
# ionic zephyr If I want my game to restart (remove previous entities and instantiate new ones,...

Can you simply restart the scene? Objects that were instantiated wouldn't be there if the scene is fresh. Another idea besides making a list would be to give them all a tag and then destroy gameobjects with that tag when you are ready. A third idea, instantiate them all under the same parent when you spawn them and then simply destroy the parent. Not talking about deep nesting, just 1 layer... parent and children.

terse spindle
#

guys,
how do I make my ragdoll character balanced in the t-pose, its in the t pose but how do I add forces to him that the forces will make the character balanced

#

I think I made a basic topic more contrevortial by writing so much but I need help

#

using slerp drive dont work

#

sorry guys I didnt do the rotation drive mode to slerp

#

but now

#

it still falls forward

#

and looking like this

teal viper
eternal needle
# terse spindle sorry guys I didnt do the rotation drive mode to slerp

I dont think you specifically need it on slerp. I think I mentioned this earlier to you, the target rotations should be set based on whatever pose you want it to be in, likely gotten from a separate object using animations.
Then it's really all fine tuning to get it to move how you want

silent valley
#

!code

eternal falconBOT
silent valley
#

Hi. I have everything i want to work. only thing is. When i select another item without placing it. It will briefly show the "not enough resource" message. I'm aware it's simple. just need an if statement or something but just cant figure it out

young smelt
#

Where do I go to in order to talk about a multiaim constraint problem

#

I'm guessing here

#

So basically Iks are not working on my characters with their avatar set to humanoid but for some reason works on characters with the avatar set to generic

cosmic dagger
young smelt
#

ok

static wasp
#

cs List<string> player_is_dead = [ "No", "No", "No" ];
i was trying to add this line, but i got this error, anyone knows a fix without updating?

teal viper
static wasp
teal viper
static wasp
#

thx

cosmic dagger
void thicket
#

Itโ€™s valid in newer C#

#

But Unity is still C#9

vernal bone
#

hello, quick questions

is there a big difference between UnityAction and C# Action?
And what is better to use?

slender nymph
#

there is no "better", it entirely depends on your needs. a UnityAction can be assigned to in the inspector, a regular System.Action cannot

vernal bone
slender nymph
#

there are some other minor differences, but they are used for very similar purposes

void thicket
vernal bone
#

alright, i'll settle with c# for now.
big thanks to all UnityChanThumbsUp

ivory bobcat
#

Unity Action has integration with the Unity inspector. C# Action has an unlimited number of type arguments whereas I recall Unity action only has a certain amount - don't recall exactly how much, but there would be enough.

slender nymph
#

System.Action can actually only have up to 16 arguments rather than an unlimited number. I think UnityAction is something like 4

void thicket
#

Delegate has much generic purpose, and is not necessarily event handler, could be used just anywhere you want to pass lambda or method

ivory bobcat
rich adder
#

I thought it was UnityEvent inspector not UnityAction

sick storm
#

hi i have just changed my dash code to limit my gravity while dashing but now while i am grounded i cannot dash can anyone help me: https://gdl.space/uzonurijoh.cs

burnt vapor
left lake
#

Hello everyone, I'm starting with Unity and 3D video games in general. In my project I would like to make a modular construction system. I'd like to know if you have any resources to give me (Docs/Discussion/Tuto) about it?

wispy finch
left lake
#

TIn fact, this is an example, but I'd like players to be able to set up their own sound system or concert stage, but to do it in their own way. Without too many limits.

#

Above all, I'd like the speakers to snap together, but without the grid system, so that players can orientate the object in their own way.

#

Here's where I'm at, and yes I've done research before, but this is particular... At least I think it is, I'm just starting out.

magic panther
#

I have an object that stores level data, and a static function that changes scenes. I'd like to run a function inside that stored level data object which is in the scene transitioned to, passing the previous one's data.

I don't know how to explain this. Basically, in every scene there is an object of LevelData class, and it has a ReadLevelData(LevelData previousLevelData) function, which does stuff with the previous one. The SetLevel(...) function changes scenes, and I'd like to pass LevelData from the object from the scene transitioned from into the ReadLevelData function of the LevelData object in the scene transitioned to, and immediatelly run the function.

If this needs any further explaination or any code, let me know.

#

So for example, during a level the LevelData stores how long it takes you to beat the level. When you finish it and switch scenes, the next scene reads that data, and updates your best time on that level (level select scenes are also levels (or hubs))

#

So to do that we need previous LevelData

#

Or is there a much better way to do that?

hallow apex
#

Your LevelData is a class

#

Right

#

It contains information about that level

left lake
magic panther
#

Like the name, parent hub, id

hallow apex
#

Add a property of type TimeSpan that stores how much time had passed during a specific level

#

Then store that class in a static List that spans across your assembly

#

When a new level loads, it checks that list for the LevelData of the previous level

#

And displays the according information on the screen.

magic panther
#

I don't think I understand. You mean store all leveldatas in a list?

#

I think for all this I'd need a json file or something, to store progress

#

like is a secret found already, if yes, specific objects will appear around levels or stuff like that

#

Do yall know a reliable tutorial on things like that?

hallow apex
#
public static class AssemblyStaticCache
{
    public static List<LevelData> Levels { get; set; } = new List<LevelData>();

    public static LevelData GetLevelData(int levelNumber)
    {
        return Levels.FirstOrDefault(level => level.Number == levelNumber);
    }
}
#

Either store that in memory cache

#

or the storage of your choice

abstract copper
#

how would i link my interaction keys with my games localization so it says "Press [interaction key] to use"

hallow apex
#

The best way to self-implement a localization technique is through a string, string key-value pair Dictionary

#

Seriously?

abstract copper
#

lmao

hallow apex
#

Anyway, I'm pretty sure Unity has a built in localization solution

#

Check the docs.

abstract copper
#

Ok

hexed terrace
#

It's a separate package you need to import

hallow apex
#

So not built in

#

Can't question their decision

languid spire
burnt vapor
hallow apex
#

If it's to prevent spam, it doesn't really do much

burnt vapor
#

You'd be surprised how much it helps a conversation

#

Most people don't know how context works in questions (when they come here as a beginner)

languid spire
worthy tundra
#
    void Load()
    {
        if (Application.dataPath + "/levelSave.text" == null)
        {
            return;
        }

        string saveString = File.ReadAllText(Application.dataPath + "/levelSave.text");

        LevelJsonTemplate saveObject = JsonUtility.FromJson<LevelJsonTemplate>(saveString);

        unlockProgress = saveObject.unlockProgress;
    }

i want to check if a json save file even exists before loading (i want it to be empty when you play the game for the very first time), how do i do that?

hallow apex
#
if(File.Exists(fileName))...
worthy tundra
hallow apex
languid spire
hallow apex
#

You can always WriteAllText with an empty JSON class.

#

And then use that.

worthy tundra
burnt vapor
#

It's a skill by itself, make sure you use it and learn how to search properly

#

In this case, see the second result.

worthy tundra
burnt vapor
worthy tundra
burnt vapor
#

For example, don't google "Check if json exists on system". Instead, google "check if file exists"

#

Considering the main issue is finding a file, and not the json specifically

quick pollen
#

so I'm trying to get the DOTS system working in my project, but the tutorial I'm following just does this and it works while mine doesn't?

quick pollen
#

do I seriously have to make a forum post for a beginner question?

verbal dome
#

Show the tutorial, and what is Baker?

#

If it ends up being DOTS specific then yes it goes to the dots channel/forum

quick pollen
quick pollen
#

it just says "yea just do this" fast forwads by 30x and doesn't properly explain anything, so I'm not sure what to do

torn bobcat
quick pollen
#

the tutorial I watched said you need 2020+ and Entities version 0.50

#

and the other one said 2022+ and Entities version 1.1

chrome fern
#

guys do any one know a platform to learn c# for unity

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

chrome fern
burnt vapor
#

As for c#, plenty of resources online really

chrome fern
#

oh thanks

quick pollen
chrome fern
quick pollen
#

and it explains how it works

quick pollen
#

i think it asks you like 30 times to pay but theres a free version

fickle ermine
#

Hey guys!

#

I wrote a function which works when button clicked (I added listener from script)

#

But when I click any of the buttons, it destroys only Button2

#

As you can see, I tried to check by names etc.

#

Buttons are stored in a list currently

wintry quarry
#

that would be the first question

#

becauase you haven't explained that

#

you almost certainly do not need those individual if checks inside the loop

#

Also please share code via !code not screenshots

eternal falconBOT
fickle ermine
#

Oh sorry, I'm trying to make a 2d target system but with buttons. When I click to the enemy (or its button), it will get destroyed.

wintry quarry
#

you would need to call the function with a parameter of some kind to indicate which button you want to destroy

#

right now there's no way to tell

#

typically for this kind of thing you would instead iterate over the buttons in Start and set up a listener in code that calls it with the right parameter

#

for example:

[SerializeField]
Button[] buttons;

void Start() {
  for (int i = 0; i < buttons.Count; i++) {
    GameObject obj = buttons[i].gameObject;
    buttons[i].onClick.AddListener(() => Destroy(obj));
  }
}```
fickle ermine
#
        butt = GameObject.Find("EnemyParent").GetComponentsInChildren<Button>();
        
        foreach (var item in butt)
        {
            if(item.name == "Button0"){
                GameObject.Find("Button0").GetComponentInChildren<Button>().onClick.AddListener(() => {CrossClick(GameObject.Find("Button0").GetComponent<Button>());});
            }
            else if(item.name == "Button1"){
                GameObject.Find("Button1").GetComponentInChildren<Button>().onClick.AddListener(() => {CrossClick(GameObject.Find("Button1").GetComponent<Button>());});
            }
        }
#

finally i did it

#

๐Ÿ˜›

languid spire
#

you do not need to keep repeating the same code. You have the reference already

#

although why you are passing the same object as a parameter into the script you are calling is on I'm not sure

wintry quarry
hollow zenith
#

I am having trouble with Canvas component sortOrder property.
My button cannot be clicked even if I set sortOrder to 520, which is higher than any other canvas component.
Button can be clicked properly if I remove Canvas component from it, but I can't position it on top of another element that has sortOrder at 500.

#

I need sortOrder for my UI, so I can position things behind/on top of my UI without worrying about hierarchy order.

hollow zenith
#

After doinng some tests, it seems like Buttons are just not clickable with Canvas on them

hallow apex
hollow zenith
#

ok so I have to add GraphicRaycaster to each button in order for them to use Canvas component properly

cosmic dagger
wintry quarry
#

Using a whole canvas for each individual item is not a typical use case

hollow zenith
#

Yeah It wasnt added automatically, this isn't a whole canvas afaik, it's Canvas component but if applied to an object manually(?) it becomes something else

#

Maybe it detects a parent canvas, not sure.
But this is recommended, for sorting UI on Z axis which is what I need.

#

So this canvas is inside a canvas basically for the sake of override sorting

novel blaze
#

Hey guys can someone help me with how to make a pickable item cuz tutos on youtube dont work with the specific item i have (which isnt a block)

polar acorn
#

The code shouldn't care what the item is

novel blaze
#

well it doesnt work

#

i followed tutorials

polar acorn
#

Then you're going to have to actually say what the problem is

novel blaze
#

wait i might need a pickup text

#

wait a moment

#

ill keep you updated

rich adder
terse spindle
#

hello guys,
I made a walk cycle with code in a normal character

but I try to make an active ragdoll so I wanna make a ragdoll to walk too but the ragdoll becomes a ballerina when played
(also the foot should follow the spheres, [there is no sphere colliders so ragdoll wont touch it])

#

I can send code if you want

atomic holly
#

Hello,
When I start my game, I have this error : ArgumentException: Value does not fall within the expected range.
I use a script in attached to a GameManager to use all inputs functions.
My error is in these lines :

private void OnEnable()
{
    inputSystems.Player.Jump.performed += PlayerMovementV2.instance.OnJump;
    inputSystems.Player.Jump.Enable();
}

The function OnJump :

public void OnJump(InputAction.CallbackContext context)
{
    if (isGrounded)
    {
        rb.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
    }
}
rich adder
atomic holly
rich adder
#

areyou sure PlayerMovementV2.instance is assigned by the time you hit OnEnable?

atomic holly
languid spire
#

so instance is null

rich adder
#

can you show where you assign it

atomic holly
#

I assign the function OnJump when the InputManager is enable

rich adder
#

wat?

#

I'm talking about instance for playerMovementV2

#

show where you assign it

atomic holly
#

Where I assign it ?
Like that ?? (sorry I'm not fluent in english :/) :

public static PlayerMovementV2 instance;
private void Awake()
{
    if(instance != null)
    {
        Debug.Log("+ d'une instance de PlayerMovementV2");
        return;
    }

    instance = this;
}
rich adder
atomic holly
#

It says Null ๐Ÿ’€

rich adder
#

can you show both logs in console

atomic holly
#

I have Player (PlayerMovementV2) after the line instance = this

#

But I don't have the one in OnEnable()

rich adder
rich adder
#

one in each

#

okay can you screenshot the console then when they print

atomic holly
#

But I thinking, do I need to create a variable PlayerMovementV2 and assign the instance in the awake and after use this variable for the input ?

rich adder
#

lol overcomplicating such a simple request myguy

atomic holly
#

The fourth is an another issue

atomic holly
rich adder
atomic holly
#

Maybe create an InputManager is not a good idea ๐Ÿ’โ€โ™‚๏ธ

languid spire
atomic holly
#

Because before this, it worked

atomic holly
#

It's in the OnEnable()

rich adder
#

i wanted to see if awake was running after this scripts OnEnable..

#

whatever it seems like it is

#

script order issue

languid spire
#

The solution is script Execution Order but I hesitate to suggest it

spiral quest
#

i want to receive data in unity through serial connection to raspberry pi pico ...i am able to open port but data is not being received

rich adder
atomic holly
#

OnEnable is after Awake no ?

spiral quest
rich adder
rich adder
#

You could change the execution order ig, i try not to do that . Input setups should be ok, but if this object is part of the scene already instead of using a singleton maybe you can do a inspector reference assignment ? (this guarntees its not null on Enable)

#

singletons are handy but if those two objects are part of the same scene , ie not a prefab vs scene object then just make serialized reference