#💻┃code-beginner

1 messages · Page 816 of 1

subtle mulch
#

second, to check why, you have to debug

#

i would start with checking the conditions for the IFs

granite elk
#

isnt it the same thing as before?

#

i mean, the && does the same thing, no?

subtle mulch
#

because, after the first time it runs, grabJoint will then not be null

#

so the if will go to the else statement

#

and start applying force to the object that is now attached to the joint

#

while, with the edit i did, if the distance is close enough to be attached, it will always go in that case (and then check if a joint needs to be created)

granite elk
#

This is hard... to learn i use ai, and ai told me to make this code (obviously i didnt copy + paste, i can explain all the things that are there), and many times makes wrong things, do you recommend something else to learn Unity or am i just using it wrong?

subtle mulch
#

!learn

radiant voidBOT
subtle mulch
#

but i would check the distance calculation

#

that is probably what is wrong there

#

bc the object gets attracted

#

but it doesn't get merged

#

so check the distance

zenith temple
#

can someone help me with this string?

#

using UnityEngine;

public class PlayerController : MonoBehaviour
{
private Rigidbody2D rb;
private float walkSpeed = 1;

private float xAxis;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
Rigidbody2D = GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
GetInputs();
Move();
}

void GetInputs()
{
xAxis = GetInputs.GetAxisRaw("Horizontal");
}

private void Move()
{
rb.linearVelocity = new Vector2(walkSpeed * xAxis, rb.linearVelocity.y);
}
}

subtle mulch
granite elk
subtle mulch
#

the way you are doing

#

so maybe get the length or width, cut it in half and sum it to half the width of the magnet

#

and then maybe add a + 0.1 to that

#

and use it as the min distance to merge

radiant voidBOT
naive pawn
#

and what's the issue, don't wait for us to read your mind

zenith temple
#

i tried to boot it up but it says: Assets\PlayerController.cs(25,13): error CS0119: 'PlayerController.GetInputs()' is a method, which is not valid in the given context

subtle mulch
#

you could ask ai maybe, or look it up on YT

granite elk
#

Ok thanks

subtle mulch
zenith temple
#

exactly

cosmic quail
#

xAxis = GetInputs.GetAxisRaw("Horizontal");

what is GetInputs

subtle mulch
gloomy charm
#

Finished the getting started with unity tenplate

solar hill
#
{
    xAxis = GetInputs.GetAxisRaw("Horizontal");
}```

🧐
zenith temple
subtle mulch
#

i think he is using the wrong method

#

lol

solar hill
#

youre calling a method within itself

subtle mulch
#

it's not calling a method

#

it is missing ()

#

and it also returns void

solar hill
#

im so confused as to what this code is supposed to do ngl

#

this seems like an overcomplicated way to make a simple input system using legacy input

zenith temple
#

movements for a metroivania i'm making

subtle mulch
#

just use the new input system first of all

#

second, that function is completely wrong

gloomy charm
#

I'm confident enough to make my own thing

errant breach
#

Hello ! So im trying to make the following system :

  • i can give to a GameObject "Sphere" the amount of child (called "Muzzle") i want (1, 2, 100...)

When i run the a function "Shoot" in the "Sphere", all of the "Sphere"'s child (the muzzle) run a fonction.

So im trying to understand the getChild function but it doesnt work. Without having to give the Cube all muzzle as a gameObject, how can i make so that all the Cube's child called "Muzzle" (or with the same tag) can run the same function ? Thanks !!

naive pawn
zenith temple
#

Assets\PlayerController.cs(11,21): error CS0118: 'Rigidbody2D' is a type but is used like a variable

subtle mulch
#

yeah well

#

it tells you exactly the reason

errant breach
subtle mulch
#

change this to rb

naive pawn
zenith temple
subtle mulch
zenith temple
#

so i have to add rb at the end?

errant breach
subtle mulch
#

change Rigidbody2D to rb

errant breach
#

but i guess it is proper (and more useful) to learn how to do it properly now ?

subtle mulch
#

you cannot assign a value to a type

naive pawn
zenith temple
naive pawn
subtle mulch
errant breach
naive pawn
#

i just told you 2 ways

#

ah, the other one was incomplete.

errant breach
#

You did and you are right, the thing is that i don't know how to write it on C# 😅
(iterating the transform without using FindObjectbyType. Even with FindObjectbyType idk how to it, actually...)

naive pawn
naive pawn
errant breach
#

I do know how to do loop ! Not for "foreach" but i guess it's easy to understand 😅

#

But you are right, "foreach" look way more convenient actually !

gloomy charm
#

How do i make vs code my default editor for scripts?

subtle mulch
radiant voidBOT
gloomy charm
soft oxide
subtle mulch
#

i will still suggest you to take a look at Rider tho

naive pawn
naive pawn
# subtle mulch why vscode btw

@subtle mulch honestly can you stop with this
it's quite unnecessary and frankly annoying
we don't need IDE wars here when they're all perfectly capable

gloomy charm
subtle mulch
#

like Zeni said

midnight tree
#

Wall check

subtle mulch
#

also, i would suggest you keep auto file saving off

#

it can give you some problems, lol

gloomy charm
#

Already set up

#

Didn't really need the link tbh

subtle mulch
gloomy charm
subtle mulch
#

it helps with debugging

rich adder
gloomy charm
#

Actually i done everything in the link already

subtle mulch
#

oh for link you meant the message link, lol

#

i tought you meant like an extension XD

gloomy charm
#

Do i have to install dotnet with elevated priveleges?

errant breach
#

Hey, so i'm trying to understand FindGameObjectsWithTag to get my Muzzles. But the print only give me GameObject[] despite 4 elements in the scene having the tag "Muzzle", may i have done something... Wrong ? 😅

gloomy charm
subtle mulch
naive pawn
gloomy charm
#

Im currently updating form 6 to 10 which isn't a problem for my personal computer but when i wanna work on projects elsewhere that may be an issue

naive pawn
#

log out the length or loop to log the contents if you want to check that

naive pawn
errant breach
naive pawn
#

you shouldn't use tags tbh, magic strings are always a candidate for subtly messing up with no feedback or logs

gloomy charm
errant breach
#

Okay, here we are !
But now, how can i only scan the Sphere's child instead of the entire scene ?

naive pawn
#

use Transform.FindX (on the desired Transform) instead of GameObject.FindX

errant breach
naive pawn
#

sure, or a serialized list/array

errant breach
rich adder
#

but also with latest sdk you can make other / latest .net apps without unity. Like console apps etc

naive pawn
rich adder
#

runtime/cross scnes FindGameObjectsByType or DI
compile time , serialized reference

errant breach
#

:(
'MuzzleScript' is a type, which is not valid in the given context

#

"FindAnyObjectBy__Type__" but "type" is not valid i don't understand 😅

naive pawn
#

right, that's not how FindAnyObjectByType works

naive pawn
errant breach
naive pawn
#

types aren't first-class

gloomy charm
naive pawn
#

it takes arguments like GetComponent

errant breach
#

or use serialized list/array as you've suggested if it's simpler ?

rich adder
naive pawn
#

it's not simpler nor more complex, just a different way

errant breach
#

I see, thanks for you're time ! I will try then after reading the documentation :)

rich adder
#

searching through all object when you can easily link through inspector ya kno

naive pawn
#

(this is in the prefab so serialized could work, but also it's in a shared object so this also makes sense in a way)

dense basin
#

I couldn't save it to this shelf or add it.

rich adder
#

you still didnt configure your IDE

dense basin
rich adder
#

you were linked to how

naive pawn
naive pawn
#

you were linked to how

#

!vscode

radiant voidBOT
rich adder
#

and dont crosspost

#

stay in one channel

#

tbh you're in way over your head with project type rn..

slender nymph
#

you're only looking at the packages that are in your project

dense basin
slender nymph
#

in the unity registry. have you never installed a package before?

#

hint: you clearly have considering you have cinemachine installed

dense basin
slender nymph
#

prove that it doesn't appear there

dense basin
slender nymph
#

i told you where to find it, you said it doesn't appear there. so prove that.

slender nymph
#

lmao telling people who are actively trying to help you to shut up is a good way to not get any help at all

frail hawk
#

i agree

rich adder
#

hows it make sense to be an asshole to people who even try to help you

solar hill
#

I asked this same thing 30 minutes ago

#

why are you bothering to help someone actively insulting you

rich adder
#

yeah I just chalk some people to "hopeless to help" and move on . Its too bad it keeps showing me new messages in chat and have to read this crap

errant breach
#

Hey again, so i've finally managed to get all my GameObject's with the Muzzle tag.
I know this is a pretty messy way to do it but i'm too bad to understand any other way of doing it :(

void Start() { MuzzleAmount = GameObject.FindGameObjectsWithTag("Muzzle"); print(MuzzleAmount.Length); }

The issue is that it look for the entire scene (as it should), but i only want my "FindGameObjectsWithTag" to look for the Sphere's child. How can i achieve this please ?

errant breach
#

I would be ashamed if it was the case, i had to go very quick so i probably missed something.. Sorry ! I'll read the conversation !

naive pawn
errant breach
#

Oh, you did. The reason why i didn't used it is because 'Transform' does not contain a definition for 'FindGameObjectsWithTag' and despite watching tutorials about FindGameObjectsByType i did not manage to make it work so i was lost...

#

Sorry for the inconvenience 👍

naive pawn
#

make sure you're using an instance and not the actual type Transform

#

it's an instance method

#

also weren't you using FindObjectsByType

#

hm wait hold on

errant breach
#

Following the documentation, i did this :

`public class EnemyScript : MonoBehaviour
{
public int shootAmount;
public int shootLoop;
public GameObject[] MuzzleAmount;
public Transform myTransform; // Doesnt work

// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
    MuzzleScript MuzzleAmount = (MuzzleScript)Transform.FindAnyObjectByType(typeof(MuzzleScript));
}`

Here, my goal is to store every game object that are a muzzle.
Which give me no error, but does not really work whatsoever...

naive pawn
#

ah ok, i misremembered, only Find exists as a analogue just for children

#

this would be GetComponentsInChildren

grave frost
grave frost
#

it's not a code question per se, but about how unity renders tris so thats why i didnt know

#

ill just ask in code general and see what happens ig

subtle mulch
#

it's like normal meshes in OpenGL

#

afaik

grave frost
#

ive never done anything with mesh gen so

subtle mulch
#

it is basically a list of vertices and indices

#

and the indices make triangles

grave frost
#

ah yea, i just can't find a straight answer online about what the winding order is

subtle mulch
#

CW or CCW

#

try both

grave frost
#

some say CW some say CCW, but in the same thread people say it's CW people say CCW isn't common when afaik it is

subtle mulch
#

and see how it comes out

grave frost
# subtle mulch try both

I would but both seem to work and I don't know how to visualize the normals, and I don't want to run into issues if using a shader that needs normals, etc.

subtle mulch
#

the order should just "flip" the triangle

grave frost
#

oh actually I can just write a shader that colors it based on the dot of the view to the normal why didnt I think of that

subtle mulch
#

on which side you can see it

grave frost
#

yea, what confuses me is that I can see it with either order lol

subtle mulch
#

try to make a cube and see

grave frost
#

I'm only on quads lmao

#

also im doing it in burst which is a little nasty compared to normal probably

subtle mulch
#

nah

grave frost
#

ok well I figured out both work for me since the quad I'm drawing is done with a cross product so it can face Camera.main, so CW or CCW depends on the cross product lol... question not answered but problem solved i guess

errant breach
#

Hello, i've written this code :

    {
        allChildren = new GameObject[parentObject.transform.childCount];

        for (int i = 0; i < allChildren.Length; i++)
        {
            if (parentObject.transform.GetChild(i).gameObject.tag == "Muzzle")
                allChildren[i] = parentObject.transform.GetChild(i).gameObject;
        }
    }

    public void UseMuzzle()
    {
        for (int i = 0; i < allChildren.Length; i++)
        {
            if (allChildren[i] != null)
                allChildren[i].Shoot();
        }
    }```

> allChildren[i].Shoot();
Im trying to access the "Shoot" function of the Children with the "Muzzle" tag, but it does not work. How can i fix this please ?
naive pawn
#

that is not useful info

#

are you getting a compiler error, a runtime error, wrong behavior, no behavior?

errant breach
#

Sorry, i have the error :
'GameObject' does not contain a definition for 'Shoot' and no accessible extension method 'Shoot' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)

naive pawn
#

right, so you're storing gameobjects and then treating them as if they were something else

frail hawk
#

you have to use GetComponent

#

you cant just call a method on a transform

naive pawn
#

or.. just use GetComponentsInChildren to begin with....

#

@errant breach i gotta ask, why are you asking here if you're not gonna use the advice lol

frail hawk
#

did i say something wrong or why the double reaction

naive pawn
#

that's not correct, and that's not a transform

#

of course you can call methods on transforms?

#

was there meant to be another qualifier there

frail hawk
#

without using the Componeent name?

naive pawn
#

transform.GetComponent is itself a method

errant breach
naive pawn
#

you can call methods on transforms, you can't call methods that transforms don't have on transforms

#

and same for GameObjects which were actually used there

errant breach
#

It finally work after 5 hours...

#

Gif of a crying dog
It's so beautiful when it dare to work..

#

Thanks guys for helping beginner and be patient :) i will now try to be more careful with suggestion and be less precipitated !

gloomy charm
#

Is there a faster way to build for android? It takes up to 13 minutes to build for android.

verbal dome
sour fulcrum
#

thats just not what it says it does

brave token
brave token
#

can anyone help me get rid of this status because it's preventing autocomplete from autocompleting unity part of the code

slender nymph
#

!ide

radiant voidBOT
brave token
broken bough
#

Hey I'm trying to make a Third Person character controller for my Survival Horror game in the style of Resident Evil 2 Remake, if anyone can help I would appreciate it, I tried looking at tutorial after tutorial and none of them work or are not in the current version.

brave token
broken bough
#

Making a Third Person Character Controller in the style of the Resident Evil 2 Remake.

solar hill
#

Well for that youre really going to have to rely on tutorials or guides on how to create third person character controllers

#

nobody here will sit with you and guide you directly on what to do

#

we can help if you get stuck at any point, or have any bugs or errors you cant solve

#

but other than that, youre either going to have to find a suitable tutorial, or use an asset

broken bough
#

Well all the tutorial's that cover this are out of date with the current version of Unity.

sour fulcrum
#

in what way

solar hill
#

Out of date in which capacity

#

really the only major difference would be the input system

#

but thats a non issue

broken bough
#

In terms of the code and don't cover the current input system, as well as the code on how to implement that into the game.

solar hill
#

right, so it is a non issue

#

because A. you can just use both input systems

#

and B. its really simple to refactor it for the new input system

broken bough
#

Also when it did end up getting there, there was a bug.

solar hill
#

right, and thats what we are for

#

if you have bugs and issues in existing code, we can help you solve them

broken bough
#

When it comes to the speed and movement I set it to 5.0f and 10.0f

solar hill
#

before you continue, if its something specific

#

we would need to see the code first

#

understand what you are trying to do

#

what behaviours are happening etc.

broken bough
#

Give me a minute.

solar hill
#

take your time UnityChanThumbsUp

#

also for sending code

#

!code

radiant voidBOT
solar hill
#

👆 use the sites

broken bough
#

You know what I'm going to do the essentials pathway again, so that I can get it right.

obsidian grove
#

quick behaviour question: for some reason if the variable in the conditional branch node is false, the behaviour graph gets stuck like this forever. why is this?

#

it should just go through the false node shouldn't it?

#

if the variable is true it works fine

teal viper
#

Presumably stuck on the wait for any that never gets set to true.

#

!vs

radiant voidBOT
# teal viper !vs
Visual Studio guide

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

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

teal viper
#

Wrong one. There was a command for visual scripting I think. 🤔

obsidian grove
#

this is the behaviour package, not visual scripting (not sure how similar they are)

teal viper
#

Oh, alright. Well, might want to check their docs for what that wait node does.

obsidian grove
#

wait for any "activates its child when any parent starts this node." it's doesn't start when the parent's status is successful/true, but when the parent starts it irrespective of its status

queen vale
#

Not familiar with the visual scripting nodes so best I can say is #1390346878394040320 or what dlich is looking for.
Also your deciding and performing actions using nodes, which is visual scripting (?) I still have more to learn.

obsidian grove
#

but the branch on node gets stuck in status.waiting forever as can be seen in the screenshot

obsidian grove
sour fulcrum
#

i dont think that channel is what this is for

teal viper
#

Yeah, I assumed it was visual scripting, but that's different

queen vale
#

My bad

teal viper
#

Never used the behavior package. Might want to Google or look through the forums.

obsidian grove
#

sadly google rarely has good results for the behaviour package, it seems a bit under-used

#

I've also done pretty much the exact same thing in a different BT and it works, so I'm a bit lost lol

nocturne hawk
#

is this a help channel?

ivory bobcat
#

Yes. This is the beginner coding help channel.

obsidian grove
#

unity behaviour

scenic iris
#

i never hired about it it's something exist only in last unity version ?

to be fer the so many unity package it's only natural i don't know shome off those.

or it's in astets store ?

obsidian grove
#

google is your friend

scenic iris
#

yap it needs unity 6 and the project I'm working now use unity 2021 or something.

probably this 1 off the reason i don't using it alose for what i have seen this spefide mostly for npc behavior if understanding correctly.

serene forge
#

hey heyy, apparently my visual studio isnt connected with unity, because it doesnt show me options to choose from :/ anyone know how I can fix that?

ivory bobcat
#

!vsc

radiant voidBOT
ivory bobcat
#

!ide

radiant voidBOT
serene forge
#

thx thx

ivory bobcat
#

You're very likely missing a step. Check to see if you've got the Visual Studio Editor package.

serene forge
#

im literally sweating because of all those stupid tabs and windows and cookies and all that omg

queen vale
serene forge
#

it works noww thanks yall

midnight tree
#

**I do not understand are the async methods/tasks adapted for use in Unity? **As I know not. They seem to take more resources to summon, right? Or do I not understand anything?

For instance I use Coroutines and search an answer to my question 'cause IEnumerator is just simple and seems... not wrong and not correct used in common situations I guess? They are done for reading List, arrays and another shit in System library.

I use them as timers(sometimes not) and I think its wrong.

And yes I know about UniTask's, I want find a solution within the limits of possibilities of Unity self.

serene forge
#

guys i have a code like this:
press a = left
press w = up

press a & w = up&left ( diagonally )
but the press a & w doesnt work :/ what do I need to do?

#

if (Input.GetKeyDown(KeyCode.W) == true)
{
myRigidbody.velocity = Vector2.up * 10;
}
if (Input.GetKeyDown(KeyCode.A) == true)
{
myRigidbody.velocity = Vector2.left * 10;
}
if (Input.GetKeyDown(KeyCode.W) & Input.GetKeyDown(KeyCode.A) == true)
{
myRigidbody.velocity = Vector2.left * 10;
myRigidbody.velocity = Vector2.up * 10;
}

agile thistle
#

Youre setting the velocity to those values so they overwrite each other for diagonal inputs

serene forge
#

just & in between or is that something else

agile thistle
#

Ig for the way youre doing it now you could add the vectors together

serene forge
#

damn I'm too stupid for that, I have to learn all that first

agile thistle
#

Instead of setting it twice set it to left * 10 + up * 10

#

Should do it

sour adder
#
float up = 0;
if (Input.GetKey(KeyCode.W)) up = 10;
if (Input.GetKey(KeyCode.A)) left = 10;
//if (Input.GetKey(KeyCode.D)) left = -10;
//if (Input.GetKey(KeyCode.S)) up = -10;
myRigidbody.velocity = Vector2.left * left + Vector2.up * up;
serene forge
#

like this?

#

hm no not work

#

IT WORKSSSS

#

woah woah woah thanks!

serene forge
agile thistle
sour adder
serene forge
#

thx thx

serene forge
night raptor
serene forge
queen vale
sour adder
#

Yes, that's the next step.

night raptor
#

... or just use the new input system which can do the normalization automatically and you don't need all those ifs either

#

And even if you want to do it that way, ClampMagnitude is probably better than .normalized

agile thistle
#

Either input system would be a step up from here but I think if they dont know what a variable is what they have is fine haha

night raptor
#

That should be the first step, if you don't know variables, start by learning those and the other basics programming stuff (variables, functions, loops and branching, basics of OOP potentially)

silk night
# midnight tree Anyone?

You have the answer right there, Unitask fixes those issues, you can ofcourse rewrite what UniTask does but you would be reinventing the wheel

#

Unity has Awaitable for async methods but its still miles behind UniTask

#

Tasks in general work... dont expect them to work with everything though

#

Another method would be to use Unity's job system, which can offload work, but its not in the async style

serene forge
#

I have this here:

  if (Input.GetKey(KeyCode.W) & Input.GetKeyDown(KeyCode.Space) == true)
  {
      myRigidbody.velocity = Vector2.up * 10;
  }
  if (Input.GetKey(KeyCode.A) & Input.GetKeyDown(KeyCode.Space) == true)
  {
      myRigidbody.velocity = Vector2.left * 10;
  }

I dont want to be able to spam it, is it possible to put 0,25 sec cooldown in it?

sour adder
#

You will be needing a new variable for that.

serene forge
naive pawn
#

it's not that simple, no

serene forge
#

:c damn

naive pawn
#

you have to write the behavior you want to achieve

#

(honestly that seems like poor UX though, you're basically introducing input lag)

serene forge
#

in other programming stuff I could do "pause all = 0.25" at the end of the if function, and it would pause the script for 0,25s

naive pawn
#

in coroutines? you could do something like that, sure

serene forge
naive pawn
#

wait hold on, i mightve misunderstood

#

is this for debouncing movement input, or having cooldown for a specific action?

#

what's "space" supposed to do there

serene forge
#

w a s d is for direction and space is to activate the dash
and I want to have a cooldown so I cant dash unlimitedly

naive pawn
#

ah ok, you could have a timer variable deciding when you can dash then

#

there's quite a few ways to do it

serene forge
#

what is the easiest to understand? :o

#

my whole pc is lagging omg

naive pawn
#

a timer based on the Update loop could store the next possible dash and check the current time against that, or store the previous dash and check if the current time is past the cooldown after that
a timer based on a coroutine could use WaitForSeconds to set a boolean field

naive pawn
serene forge
#

in my head I thought of something like:
dash as a variable = 10
and something like if I press space -> dash variable -10 & wait 0.25 -> dash variable +10

naive pawn
#

well with that you wouldn't be using a number

serene forge
#

i dont understand :o

naive pawn
#

if you just had 2 states for the variable you'd just use a boolean

#

the logic you described would be the third option

serene forge
errant breach
#

Hello, im trying to make my enemies rotate toward my player but for some reason, they look at the opposite way

        {
            Quaternion targetRotation = Quaternion.LookRotation(playerGameObject.transform.position - transform.position, Vector3.up);
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 0.1f);
        }```

After many attempts, i don't understand how to fix it. Do you have any idea ? Default enemy rotation is (0, 0, 0) in game, it is (0, 174.45, 0)
naive pawn
#

there are resources pinned in this channel

naive pawn
naive pawn
errant breach
#

Yes it is !

naive pawn
#

is the forwards direction of the enemy correct, relative to the mesh?

errant breach
#

Oh its.. Not..
But i can't fix that because it will break the animations. Can i just change the Quaternion.Slerp(transform.rotation, targetRotation, 0.1f); with like a -180 somewhere so that it rotate correctly ?

naive pawn
#

you should fix that, this'll probably keep coming up lol

errant breach
#

you're right..

naive pawn
#

if the animations are self-consistent to always be backwards, you could have the mesh have a parent that faces the right direction, and the mesh is backwards in the parent

midnight plover
naive pawn
#

the actual workaround would just be to negate the direction before you put it in the LookRotation

#

or apply another Euler rotation

midnight plover
#

If its coming from something like blender, it might also just be as easy as reexport with correct axis selection

serene forge
naive pawn
sharp cedar
#

Hello anyone can help me ?

naive pawn
radiant voidBOT
# naive pawn !ask

: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 #🌱┃start-here

serene forge
#

yeaa but I just want to make a tiny little minigame :o learning all the basics eventho I only need 5% takes way too long

sharp cedar
naive pawn
#

just ask

naive pawn
#

like here, you didn't know about booleans until i told you

#

if you went ahead and worked on it without doing any research, you'd just be shooting yourself in the foot, making your own project harder

sharp cedar
#

like i am programming my own game on unity platform soo while i was renderring it out my electricity goes and and that time my rendering was not completed soo i lost my game data how cna i recover it ?

#

🥺

naive pawn
#

the rendering data was lost? or what exactly?

serene forge
naive pawn
#

artificially giving yourself problems is fun? there's enough problems to solve already lmao

sharp cedar
naive pawn
#

us needing to help you with your own self-imposed challenges is not fun

serene forge
silk night
sharp cedar
naive pawn
sharp cedar
#

for programming full game

#

@naive pawn sir can you help me figure out thats means me alot from you

naive pawn
#

i have no idea what your question is at this point

#

also, this is a coding channel

silk night
#

Please dont randomly ping people

sharp cedar
#

who is help supporter here ?

naive pawn
#

anyone who passes by

silk night
#

Anybody who has time right now, there is no specific person

serene forge
naive pawn
#

...you asked what a boolean was...

silk night
serene forge
naive pawn
#

so, clearly, you lack some fundamentals

#

at least go skim.

serene forge
naive pawn
#

if you've already learnt some stuff, then sure, skip over the parts you know. but at least go actually check the fundamentals.

brave token
#

can someone help me fix this issue? i litterally followed the instructions of the tutorial correctly

InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.Internal.InputUnsafeUtility.GetButtonDown (System.String buttonName) (at <bb2309881ca84e6d8dece79bc84459be>:0)
UnityEngine.Input.GetButtonDown (System.String buttonName) (at <bb2309881ca84e6d8dece79bc84459be>:0)
PlayerController.Update () (at Assets/_Unity Essentials/Scripts/PlayerController.cs:26)

(ignore the rigidbody part)

radiant voidBOT
# naive pawn !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

brave token
#

thanks

naive pawn
#

you gotta give us some info to work with

frosty hound
sharp cedar
subtle mulch
frosty hound
brave token
#

is he the only guy who can help

naive pawn
#

no-one can help you if you don't give any info about your issue

polar acorn
brave token
#

what's vector2 and vector3?

serene forge
#

when my ufo bumps into a wall it starts spinning around, how do I disable that it rotates?

polar acorn
frosty hound
brave token
sharp cedar
#

soo basically i was rederring my game data in between my power gone off and due to in between shutting off my pc my data of my game was lostt

#

how can i recover it ?

frosty hound
#

Unless you have version control, you cannot.

sharp cedar
#

its beeen my 4-5 months ahrdwork

#

🥺

subtle mulch
#

unless the whole drive got nuked

frosty hound
#

Are the files literally gone off your PC?

sharp cedar
#

30gb around

subtle mulch
#

HOW

solar hill
#

Might be a hard drive failure

subtle mulch
#

yeah but it still boots

solar hill
#

Lost sectors

frosty hound
#

Well, take it to a shop and see if they can recover anything. But otherwise, there's nothing you (or we) can do.

sharp cedar
#

no just during renderring my pc shut down

solar hill
#

Hard drives can fail incrementaly

subtle mulch
#

also, is it an HDD or SSD

#

things change there

solar hill
#

Also how do you work on a project for half a year without any version control

#

Or at least any local back ups

#

That was just a disaster waiting to happen

subtle mulch
#

i still find it strange that ONLY those files got nuked

brave token
subtle mulch
#

and not anything else

solar hill
#

Did they say that?

sharp cedar
#

it was just baked and rendering and environmentoring

#

that time

solar hill
#

Or you were baking lighting?

subtle mulch
sharp cedar
#

other things gone

solar hill
#

What

subtle mulch
#

i think he means scene

sharp cedar
subtle mulch
#

it's the only file left there

sharp cedar
#

scene

solar hill
#

Theres no other files in the project?

brave token
#

how can you lose a whole 5 month project like that

subtle mulch
sharp cedar
#

the file was of 30gb and only 7gb data left

real thunder
#

what's going on

#

30 gb scene?

subtle mulch
solar hill
naive pawn
#

aren't scenes text files

how do you get a 30gb scene

sharp cedar
brave token
subtle mulch
real thunder
solar hill
#

Guys i think the entire project was 30gb

subtle mulch
#

yeah

sharp cedar
solar hill
brave token
#

for some reason

sharp cedar
#

but i dont getting you guys i just can say that during baked and renderring time my pc gonna shut

#

sooo what to do ?

#

my maps files audio files

#

alll gone

subtle mulch
#

take it to a repair shop or try with recovery apps

brave token
solar hill
#

Well i think it was almost certainly a drive failure

sharp cedar
solar hill
#

Try some recovery programs, other than that, its a lesson learned

subtle mulch
brave token
solar hill
real thunder
subtle mulch
solar hill
#

What does that even mean

subtle mulch
#

idk

#

but that's the other folder that it was gone

#

also, i never seen drives that nuke specific sectors when a power surge occurs

#

you could easily try to repair the filesystem tho

subtle mulch
#

the thing i think happened is that the indexes to those files got nuked

#

and windows now does not see the files

#

while they are actualy still there

brave token
#

20 GB can not disapear

sharp cedar
#

after power off

#

not before that

brave token
#

it's still there corrupted

#

right?

subtle mulch
#

and it will prob help

#

you have to make it repair all the indexes to those files

solar hill
#

You also have a bigger problem on top of everything else

#

Your drive might be failing

subtle mulch
#

prob not

#

if it is an HDD try to hear it when working in case

#

if you hear a clicking sound, move ALL the important data out ASAP

#

if it's an SSD, idk, prob check SMART

brave token
#

just backup anything to another drive

subtle mulch
#

i have 2 HDDs that i use for games and backups

#

while my os and dev stuff resides in 2 NVMEs

sharp cedar
#

my all unity work projects and file were saved in my hdd soo right now its not in that it almost contains of 30-40gb of materials , texture , scripts, prefab, UI, UI images, doo die sprities and more

how can i find them to re assemble ?

subtle mulch
#

google how to repair the windows filesystem and its indexes

sharp cedar
#

in recovering ?

subtle mulch
#

the files are 90% not gone

#

by doing that you might actually get them back

brave token
#

maybe some wrong 0 and 1 got changed

#

but that does not mean it's gone

sharp cedar
edgy tangle
#

Basically: if you think it’s worth the money then take it to a professional to see if the data is recoverable. Otherwise just take this opportunity to reflect and learn why you should use version control

subtle mulch
#

pls read

#

it's the filesystem

sharp cedar
subtle mulch
#

well, that's a separate thing

frosty hound
subtle mulch
#

pls re-read what i said

edgy tangle
frosty hound
frosty hound
#

And you can

sharp cedar
brave token
#

we are this close

sharp cedar
#

@subtle mulch buddy can you come in thread?

subtle mulch
#

yes

#

make one

#

we can all jump in the thread

brave token
subtle mulch
sharp cedar
true flame
subtle mulch
naive pawn
#

show code that should make it jump

#

!code

radiant voidBOT
true flame
polar acorn
radiant voidBOT
true flame
naive pawn
#

you should only have 1 Move call per Update

#

check if the if condition is passing when you expect it to. if not, check which part is false.

brave token
#

is it fine if i replace Update with FixedUpdate?

subtle mulch
#

they do different stuff

#

what do you wanna put in it?

brave token
#

a collectible rotating

subtle mulch
#

if it's physics stuff, then yes it was made for it

brave token
#

nah it's just transform.Rotate

subtle mulch
#

then keep it into normal Update

brave token
#

is there a particular reason? cuz i don't want it to turn at the speed of sound when you have 300 fps

subtle mulch
#

that's why you use Time.deltaTime

brave token
#

ooooh that's why it's multiplied by that

subtle mulch
#

yep

naive pawn
granite elk
#

hello, how do i make the object i grab be more attached to the magnet? I used a fixedjoint for the object, and i cant make that the magnet will have more force because it has similiar results, and changing linear damping doesent work either

twin pivot
granite elk
#

no or else the object will trapass walls and be too rigid too

twin pivot
granite elk
brave token
#

how can i make night more dark? i want the objects to appear darker when the Directional_Light faces north (already fixed skybox)

stark helm
#

Why can't I destroy my gameobject...?

using System;
using Unity.Mathematics;
using Unity.VisualScripting;
using Random = UnityEngine.Random;
using UnityEngine;
using System.Collections.Generic;

public class MapTileGeneration : MonoBehaviour
{
    public GameObject Tile;
    public Material TileMaterial;
    public float ColorVariation = 3f;
    public int MapSize = 0;
    public Transform Map;

    private Transform CurrentMap = null;

    [ContextMenu("Generate Map")]

    private void GenerateMap()
    {
        if (Tile == null) return;
        CurrentMap = new GameObject().transform;

        for (int x = 0; x < MapSize; x++)
        {
            for (int z = 0; z < MapSize; z++)
            {
                float CellDiameter = 2;
                Vector3 TilePosition = new Vector3(x * CellDiameter, 0, z * CellDiameter);
                GameObject NewTile = Instantiate(Tile, TilePosition, Quaternion.Euler(-90,0,0), CurrentMap);

                NewTile.GetComponent<Renderer>().material = TileMaterial;

                float RedA = TileMaterial.color.r + Random.Range(-ColorVariation, ColorVariation);
                float GreenA = TileMaterial.color.g + Random.Range(-ColorVariation, ColorVariation);
                float BlueA = TileMaterial.color.b + Random.Range(-ColorVariation, ColorVariation);
                float AlphaA= TileMaterial.color.a;

                Color32 NewColor = new Color(RedA, GreenA, BlueA, AlphaA);

                NewTile.GetComponent<Renderer>().material.color = NewColor;

            }
        }
    }

    [ContextMenu("Destroy Map")]

    private void DestroyMap()
    {
        if (CurrentMap != null)
        {
            
            Destroy(CurrentMap.gameObject);
        }
        
    }
}
#

When I try to destroy CurrentMap, nothing happens

#

I debugged.log and it did print something so the condition is met

#

But it isnt getting destroyed

naive pawn
#

if you add a debug.log containing context, does it point to the gameobject you expect? also consider giving that gameobject a name so it's easier to identify

stark helm
wintry quarry
naive pawn
#

that's not what i asked

wintry quarry
#

anything in the console window? Show it

stark helm
stark helm
wintry quarry
queen vale
#

when is GenerateMap called?

wintry quarry
#

you said you put a log - where?

stark helm
wintry quarry
stark helm
wintry quarry
#

but... we're in the middle of debugging

stark helm
wintry quarry
#

I think the fix here is to serialize this reference

stark helm
stark helm
#

How tho

wintry quarry
#

make it public or add [SerializeField]

queen vale
wintry quarry
#

it is

#

context menu

#

shown in the video

queen vale
#

Hard to tell, the drag click made me think 'destroy map' was selected, my bad.

naive pawn
#

context is the second argument

stark helm
polar acorn
stark helm
#

And it printed its name

polar acorn
#

You're getting an error

#

You've hidden errors

stark helm
polar acorn
#

This ticks up to 18 when you try

polar acorn
stark helm
#

OH MY

#

I dont know what half of those mean bruh

#

Ok so it tells me that materials are wrongly used

queen vale
# stark helm

ah misread initially thought you had an issue with GenerateMap not destroymap

stark helm
#

and that I should do this during play mode

naive pawn
#

well, there's your answer

stark helm
#

Ok it works

#

Thanks guys

#

I could not have figured this out without you

polar acorn
queen vale
#

*once visible. <- coming from the guy who misreads lol

cosmic pumice
#

Any idea why setting Camera.scene does not limit the rendering to the assigned scene?

From Unity Docs "scene - If not null, the camera will only render the contents of the specified Scene."

I am creating a new scene in code, moving the camera and objects I want to render to that scene and then setting camera.scene to that scene
The camera outputs a render texture, which I display in UI

But it always renders from every scene, not just the one I am trying to limit it to

wintry quarry
#

You didn't read the rest of the page

#

It's basically an editor only feature they hacked in to support the editor preview scene stuff

#

The correct way to cull things is to use layers

cosmic pumice
#

Ah yeah I should have clicked through
Sucks that its not useable outside of editor preview

I was hoping to avoid having to resort to layer masks

wintry quarry
#

That would certainly be an interesting feature to have

cosmic pumice
#

The way I usually do it is I just offset the transform root by a large number
Like 10,000

#

I was hoping this would be a cleaner approach 😛

wintry quarry
#

YOu can do that too but that has floating point precision issues doesn't it?

cosmic pumice
#

Not really

wintry quarry
#

at least with a super high distance like that

cosmic pumice
#

Yeah if I had like 1,000 cameras I want to render and offset them by a crazy high amount then maybe

#

The 10,000 was an exaggeration anyway

safe root
#

!code

radiant voidBOT
safe root
#

I'm having a problem with my object rotation not being moved. I use [[[ transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, roombaRotateSpeed * Time.deltaTime); ]]] and for some reason the rotation it does is so small that it's basically not even rotating to the target. Can someone help me figure how what's going on with it?

https://paste.ofcode.org/cdbrX78wG9bwXWHzXFwNfF

wintry quarry
#

that means it would take 90 seconds (a full minute and a half) to fully turn around which is 180 degrees

#

Not only that

#

but you are only calling transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, roombaRotateSpeed * Time.deltaTime); ONE TIME

#

so you are only getting one frame worth of rotation. So you'll only really rotate something like a fraction of a degree, and only once.

#

Then you're waiting 6 seconds and doing the movement

#

you need to use a loop here (with a yield return null inside it to wait one frame each time) to continue rotating each frame until it is complete

#

so you have two problems - your code is wrong, and your rotation speed is tiny

cosmic pumice
wintry quarry
errant breach
#

Hello everyone, where can i ask questions about Splines ? I cannot find documentation online so i dont know how to start my splines when StartOnAwkae is false ! Thanks

slender nymph
#

and presumably you are referring to the SplineAnimate component, which does have a PlayOnAwake property (which you referred to as StartOnAwake) as well as the Play method

zenith temple
#

how do i make this work? private float jumpForce = 45;

slender nymph
#

make it work how? that's just a declaration of a float variable

zenith temple
#

do i need a following string to it?

slender nymph
#

wtf does that mean

brave token
#

be more specific dude

queen vale
#

You declared a variable, what people need to know is how you use it. Within update, etc.

brave token
#

if you want other classes using it, make that class a child class or set the variable to public

zenith temple
#

i don't know how to write the line for it to work fine

slender nymph
#

what does it mean to "work fine" here?

queen vale
brave token
#

bro explain how do you use that variable

zenith temple
#

using UnityEngine;

public class PlayerController : MonoBehaviour
{
private Rigidbody2D rb;
private float walkSpeed = 1;

private float jumpForce = 45;

private float xAxis;

// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start() => rb = GetComponent<Rigidbody2D>();

// Update is called once per frame
void Update()

{
GetInputs();
Move();
}

void GetInputs()
{
xAxis = Input.GetAxisRaw("Horizontal");
}

private void Move()
{
rb.linearVelocity = new Vector2(walkSpeed * xAxis, rb.linearVelocity.y);
}
}

slender nymph
#

!code

radiant voidBOT
zenith temple
#

do i missed something?

radiant voidBOT
#
<:error:1413114584763596884> Command not found

There's no command called screenshot.

slender nymph
brave token
#

i don't see jump force ANYWHERE

queen vale
#

jumpforce is never used in the aforementioned script.

lofty sequoia
#

I think he's trying to jump

#

but doesn't have a listener for spacebar or any up input

wintry quarry
zenith temple
#

i'm making a metroidvania. i was making the jump code but i don't know how to write the rest

wintry quarry
#

Ok then why didn't you ask "Hi how do I make jumping work in my metroidvania"?

zenith temple
#

sorry

brave token
#

did you set up the input action map correctly

zenith temple
#

input action map? you mean input manager? then yes i did

brave token
#

it's the thing where you bind buttons in unity

#

not a cs script

slender nymph
#

they aren't using the input system

brave token
#

oh ok

queen vale
zenith temple
#

how do i write it?

wintry quarry
queen vale
#

if(input.getkeydown(keycode.a) { // do thing }

zenith temple
#

i did but it only wrote this single line

wintry quarry
slender nymph
#

unless the tutorial was just an ai overview of something, then you didn't actually pay attention tot he tutorial. there's no way an actual tutorial would only show a single variable declaration as "how to jump"

brave token
#

what kind of tutorial was it? a video or a website?

zenith temple
#

Download the project files here: https://www.patreon.com/posts/81074402
Read the accompanying article here: https://blog.terresquall.com/2023/04/creating-a-metroidvania-like-hollow-knight-part-1/

Ever wanted to create a Metroidvania like Hollow Knight? In Part 1 of our tutorial series, we will go through how to create the basic walk and jump mo...

▶ Play video
#

this was the video

brave token
#

Part 1?

#

did you watch the other parts?

wintry quarry
zenith temple
#

this video is only basic movement (walking and jumping) and camera

brave token
#

maybe he said something he forgot in the comments or the other parts

wintry quarry
#

Seeems like you didn't watcht the video

#

because it's all here

#

My suggestion, go back and watch the whole video

zenith temple
#

i'm literally watching step by step

#

he wrote jumpforce 45 nd then he showed it jumping

polar acorn
# zenith temple i did but it only wrote this single line
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 201
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2026-03-02
brave token
#

maybe you put the code in the wrong brackets

wintry quarry
#

Keep watching lol

subtle mulch
polar acorn
#

You should try actually listening to the words instead of just vomiting the code onto your IDE

zenith temple
#

okay and? it's my first time coding. a little bit of understanding on my side instead of making fun of me

slender nymph
#

honestly, if you think that declaring a single variable and doing nothing else is enough to make it jump you should really consider learning the fundamentals of the language because you seem to be at a level of understanding below where you need to be in order to follow this tutorial

brave token
zenith temple
frosty hound
#

"And then he set the oven to 400F and showed a cake. I tried it, but when I opened my oven, there was no cake inside."

#

I'm not sure what it is about game development, but in any other skill, following the instructions from the start just seems like the most common sense thing to do.

queen vale
fickle plume
#

And you'll know how to ask correct questions as well

polar acorn
#

Every single number is an actual person doing the same thing that I, personally, have seen in this server

mental raptor
#

Hi all!

queen vale
zenith temple
#

i fixed it but now it says this: UnassignedReferenceException: The variable GroundCheckPoint of PlayerController has not been assigned.
You probably need to assign the GroundCheckPoint variable of the PlayerController script in the inspector.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at <dc764b59c049482b93bebc78a7e33a04>:0)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <dc764b59c049482b93bebc78a7e33a04>:0)
UnityEngine.Transform.get_position () (at <dc764b59c049482b93bebc78a7e33a04>:0)
PlayerController.Grounded () (at Assets/PlayerController.cs:43)
PlayerController.Jump () (at Assets/PlayerController.cs:57)
PlayerController.Update () (at Assets/PlayerController.cs:28)

sour fulcrum
#

have you assigned the GroundCheckPoint variable of the PlayerController script in the inspector?

slender nymph
#

You probably need to assign the GroundCheckPoint variable of the PlayerController script in the inspector.

zenith temple
#

but it doesn't work

slender nymph
#

that is not the inspector, nor is it the variable you need to assign

polar acorn
wintry quarry
#

The key is to just follow the tutorial closely, don't skip anything

wintry quarry
#

the part where he assigns it in the unity editor

#

at 8 minutes 13 seconds

sour fulcrum
naive pawn
#

yeah that's vscode isn't it. vs would have white fields

#

!vscode

radiant voidBOT
naive pawn
#

configure your ide @zenith temple 👆

real thunder
#

please check where my angular math isn't mathing
oversimplification:

  centripetal_force = getHomingVector(target);
  centripetal_force = Vector3.ProjectOnPlane(force, rb.linearVelocity);
if(centripetal_force.magnitude / speed) > max_angular_velocity * Mathf.Deg2Rad)
  {
    Vector3.ClampMagnitude(centripetal_force, max_angular_velocity * speed * Mathf.Deg2Rad);
  }
rb.AddForce(centripetal_force, ForceMode.Acceleration);
rb.linearVelocity = rb.linearVelocity.normalized * speed;

turns much sharper than

Vector3 to_target = target.position - transform.position;
Quaternion target_rotation = Quaternion.LookRotation(to_target);
transform.rotation = Quaternion.RotateTowards(transform.rotation, target_rotation, max_angular_velocity * Time.fixedDeltaTime);
rb.linearVelocity = transform.forward * speed;

while I expect that to be the other way around

#
if(centripetal_force.magnitude / speed) > max_angular_velocity * Mathf.Deg2Rad)
  {
    Vector3.ClampMagnitude(centripetal_force, max_angular_velocity * speed * Mathf.Deg2Rad);
  }

trying to clamp angular velocity here
should that work like that?

queen vale
#

I might need sleep, shouldn't it be centripetal_force = Vector3.Clamp etc

errant breach
#

Hello everyone !
I have a script, EnemyScript that make private AttackScript attackScript; on start.

EnemyScript & AttackScript are both on the same gameObject.
But when i try to do :

attackScript.timeSinceLastAttack += Time.deltaTime;

I get the error :

NullReferenceException: Object reference not set to an instance of an object
EnemyScript.FixedUpdate () (at Assets/_Scripts/Enemy/EnemyScript.cs:114)

Which is surprising as the link is well made... Do you have any ideas how to fix it please ? As always, thank you !

real thunder
sour fulcrum
#

components don't magically fill references just because there on the same gameobject

#

you need to connect them via assigning in inspector or in code with getcomponent

#

@errant breach

errant breach
#

oh i might have misunderstood how it work then, thanks !

polar acorn
errant breach
#

just like that, hoping that "components magically fill references just because there on the same gameobject "

solar hill
#

yeah youre either going to have to manually assign it in the inspector if its a serialized field, or assign it in the code

#

you just created a field for attackScript, its current value is null

real thunder
#

you can also do both via assingning components on OnValidate

sour fulcrum
#

OnValidate() is not ideal for that

real thunder
#

nullcheck and then trygetcomponent

real thunder
sour fulcrum
#

public assignment or in awake

real thunder
#

if by public assigment you mean assinging that in the inspector, onValidate would do that?

#

noticable downsides?

polar acorn
real thunder
#

but why

sour fulcrum
#

OnValidate() runs common-ish enough to where it's unneccasary code being run that could scale up in certain scenarios

polar acorn
#

Because OnValidate runs in the editor which can slow down your editing, and can lead to stale references for things like prefabs getting copied around

real thunder
#

I don't get the stale reference thing but I guess it make sense that OnValidate runs freuqently but... I thought it's meant for that sort of stuff

naive pawn
real thunder
#

what for is it really

naive pawn
#

validating inspector values

errant breach
#

Im also breaking my mind on such a werid error...
AttackScript tries to acces a function in EnemyScript with a parameter.

The EnemyScript is supposed to take the parameter, and use it to change the animation.

  • Usually, i don't have to put the parameter as "string". I tried but it got me error "cannot find animation with that name". Do you know why it happens ?
    ⚠️ i TRIED using string !!

Not : es is the reference to EnemyScript, and it's not properly defined 👍

polar acorn
naive pawn
#

like what Range/Min/Max do, but with more control

queen vale
naive pawn
polar acorn
errant breach
naive pawn
polar acorn
naive pawn
polar acorn
naive pawn
errant breach
#

The issue being that i have this error..

polar acorn
naive pawn
errant breach
#

And putting "es.<function>" give me that

errant breach
naive pawn
polar acorn
real thunder
errant breach
naive pawn
#

so they're separate contexts, hence the initial error

errant breach
naive pawn
#

const is similar to static+readonly

errant breach
polar acorn
errant breach
#

oooh, so i can only read it (as said by Chris) but i cannot modify it or execute it in any way ?

naive pawn
#

that's unrelated to what digi's saying

#

stuff that's static or const belong to the type, aka EnemyScript in this context
stuff that aren't static nor const belong to the instance ("instance members"), aka es here

queen vale
#

Could be wrong but is the enum public?

naive pawn
#

it's not an enum.

solar hill
#

it would be better if it was one for this no?

#

there are animation states?

errant breach
#

They are ! But i think i don't really understand the logic behind all of this

naive pawn
#

c# enums are backed by integrals, that could work for managing transitions but not for playing specific states as they're used here

polar acorn
sour fulcrum
#

consts are a little confusing if your newish to c#, so if it feels a little scary thats normal

errant breach
#

Hmmm... So in my case, what would be the proper way to make my code work so that es (EnemyScript) can change the AnimationState ?

naive pawn
#

this is one of them

queen vale
#

this is a shot in the dark but can we/I see the ChangeAnimationState function?

errant breach
naive pawn
#

you're already pretty close to one working solution

errant breach
sour fulcrum
naive pawn
#

yeah this was already really close to working, idk why you'd change the part that didn't have errors so it had errors

sour fulcrum
#

just learning things

errant breach
#

I FOUND IT !!!!

errant breach
#

😂 Thanks !

errant breach
sour fulcrum
#

learning a whole new language is hard

errant breach
#

Or stress, maybe. ATP im developping 10 hours a day to give the game on Thursday so.. Maybe it make me take bad decisions 👍

errant breach
#

So again

#

thank you 🫶

polar acorn
queen vale
errant breach
#

Ahah i do learn a lot here, which is something AI cannot replicate so im happy there's still community centered about helping :)

sour fulcrum
#

people here are happy to help anyone willing to learn and putting effort into their questions/responses

#

it's no biggie 😄

errant breach
#

That's a good thing, maybe one day i'll help too 💪

grave frost
#

is Awake not called after a domain reload for AlwaysExecute scripts?

#

whenever my code recompiles or domain reloads I need to delete and ctrl+z my object with the script on it

naive pawn
#

have you tried Start

grave frost
#

yea

#

only OnEnable works not start or awake

hexed terrace
#

Awake and Start only get called once at runtime, perhaps it's the same for during edit mode with that attribute too

sour fulcrum
#

i wonder if scene reloading bool plays into it?

swift crag
#

oh yeah, i'm pretty sure i ran into this recently

grand snow
#

ExecuteAlways my guy

kindred blade
#

whats the difference of saying private void or js void

wintry quarry
wintry quarry
rocky wyvern
high mauve
#

Hey I need some help

#

Is any one avalible

#

I want to detach parts of plane that collide with the ground but don't know how to do it for physics I am using rb and applying for at different position like wings tail ets but if I am to remove a wind like during crash the rb freaks out and the plane start uncontrollably spin

#

What should I do

eternal needle
high mauve
#

All movement script and rb is on the aircraft game object and I am using the gasgiant airplane physics from git

midnight plover
#

😄 random paste from old device

alpine dew
#
materialInstance = new Material(colorMaterial);
materialInstance.SetColor("_BaseColor", Color.red);

for some reason I can't manage to get a script to change the color of this material texture. On a different script I changed the texture the same way with the BaseMap property but it seems like neither _Color nor _BaseColor work for this. Any ideas?

#

there's no reference errors or anything

alpine dew
#

thanks I'll try there

queen vale
#

Also need more context, you made a variable and assigned a value to it. As far as I know you just set a value to a variable and never applied it to the actual material/component.

#

Dj brewing up a correction, lmao

errant breach
#

Hello !
So i want an Enemy to collide with everything that has the "aiZone" tag.
Here's the code :

    {
        
        if (other.gameObject.tag == "aiZone")
        {
            print("collision");
            inTheGameZone = true;
        }

    }```

It doesn't work. Both `Enemy` and `aiZone` have : 
> - A RigidBody
> - A BoxCollider (Trigger ✅) (tried disabling it)

When i tried creating a random box and giving the collision script, it worked **perfectly**. 

By the way, the entire code is actually the following. For the playerProjectile it work fine so i can't explain my incomprehension. 

Do you know how i could make it work please ? Thanks !
queen vale
errant breach
#

This code, that i just copy pasted, work just fine btw

sour fulcrum
#

Log outside of your if statements, does it run?

queen vale
#

You can use code and tags to determine things but if you're talking about physical interactions, bouncing off of, colliding with, etc. I'd point to layers.

errant breach
#

No it's just to determine things, no colliding 👍

errant breach
midnight tree
errant breach
#

Here's the box !

midnight tree
#

Okey, and colliding object also?

sour fulcrum
#

(CompareTag is just a minor optimisation, it won’t be your problem)

errant breach
#

Here's the colliding object !

queen vale
midnight tree
#

Trigger detects objects with collider, not a trigger

sour fulcrum
#

triggers are collliders and afaik triggers should react to other triggers

errant breach
queen vale
#

I could be wrong but from my experience, triggers do not interact or trigger other triggers.

errant breach
#

So that's very strange like... I dont understand

#

Let's see what get returned if i remove all "if" and just wait for any collision..

queen vale
errant breach
#

Yes, both have a rigidBody !

queen vale
#

Are both set to IsTrigger = true?

sour fulcrum
#

Do you have any collision matrix settings changed

errant breach
#

The collision is not even detected

#

But the collision with everything else is (His own bullet, player's bullet, other enemies, ...)

queen vale
queen vale
#

🥲 Ah, kinematic was my issue

errant breach
tranquil forge
#

is there any api let me toggle these 2 in code

errant breach
#

i just lost 30 minutes and your time on this

sour fulcrum
#

you spent 30 minutes learning to check it next time 🫡

errant breach
#

First day we did remove collision between wall-type and enemies and i completly forgot about that 😭

sour fulcrum
#

It happens

errant breach
sour fulcrum
#

Thats why you should debug without conditions asap to see if it’s code or object setup related then work from there

errant breach
#

Hope no one in my class will see this conversation because otherwhile... I'll look dumb xd

errant breach
queen vale
errant breach
#

We all learn here i guess ahah x)

lusty panther
queen vale
# alpine dew

No worries but where/how are you applying the value to the object's material?

alpine dew
#

well I tried two different places. One is the Awake function in the script itself on an object in the scene

#

the other was in a function tied to a button

#

basically just creating a new instance of the material and then attempting to change the property

#

I would have gotten the renderer component of the object and tried to do it that way, but I'd like this material's color changed for every object that uses it

queen vale
#

I hate to be a broken record but if a person did

int _reference
int a;

Start()
{
a = _reference;
// then said
a = 2;
// _reference would still be it's original value
}
alpine dew
#

yeah I figured it was the instancing that was the issue so I tried just setting the original reference's color without making a new material instance and that doesn't work either for some reason

#

is it possible you need to set both the _Color and _BaseColor properties for it to take effect? I was looking in the .mat file itself and saw that when the color was changed in the inspector both of those properties reflected the change

#

I don't really understand the difference between them in this case

queen vale
sour fulcrum
alpine dew
#

it should be the property itself since it's the .SetColor() method which takes a property name

queen vale
#

Batby may correct me, but if I made a Transform 'A' and A.SetPosition, I'd only be adjusting the position of A, not the actual object.

naive pawn
alpine dew
naive pawn
#

@alpine dew batby is asking what you're doing with the material after you've changed the color

sour fulcrum
#

If your making a new instance of a/the material, you have to actually use that material somewhere. Otherwise it’s a random material unrelated to any renderer

If your attempting to modify a material that is actively being used by many objects, you wouldn’t be making a new instance of a material, you’d be modifying that material directly

queen vale
#

won't affect _thing

naive pawn
#

it will

#

because Transform is a reference type

#

that's the same as doing _thing.transform.SetEtcEtc directly

queen vale
#

You're making a variable and setting it's value equal to the other, then adjusting it...(?)

naive pawn
#

mutating it

#

reassignments and mutations are different things

queen vale
#

You're never applying that new value to the _thing itself(?)

naive pawn
#

well, you're applying it to _thing.transform

alpine dew
naive pawn
# queen vale You're never applying that new value to the _thing itself(?)

A and _thing.transform don't actually hold the transform. Transform is a reference type. the actual transform is somewhere on the heap, and _thing.transform/A hold references to that transform on the heap

when you do A = _thing.transform, you're just copying that reference. so when you mutate A, you're mutating that object on the heap, which is shared by _thing.transform

this is how reference types work

sour fulcrum
alpine dew
#

hang on I'm trying something

queen vale
#

Am I going insane? Lol, I'm also gonna try something

alpine dew
#

Is this not fine as is?

colorMaterial.SetColor("_BaseColor", Color.red);```
naive pawn
sour fulcrum
#

Seems fine in isolation

alpine dew
#

I feel like something weird is happening with it