#💻┃code-beginner

1 messages · Page 632 of 1

honest violet
#

looks right to me, im not the best coder so

north kiln
#

If you're not getting errors highlighted in red you need to configure your !ide

eternal falconBOT
honest violet
#

lemme do that :D

inner path
slender nymph
#

why would seeing that matter? we already know what the errors are, they just need to configure vs code so they can use the quick actions to import the correct namespace

honest violet
#

its no longer giving errors, but its not changing sadly

#

probably error on my part

inner path
#

find in Hirachey where did you use this script named "SetTurnType"?

slender nymph
slender nymph
honest violet
#

like its fixed

slender nymph
#

can you screenshot what the code looks like now after completing those steps?

honest violet
slender nymph
#

okay so you've now added the correct namespace, but if you comment out line 5 does it show errors in the code? if not then you need to go through the page i linked

slender nymph
#

okay good, it's properly configured now. so you're good to go

honest violet
#

yup :D

wintry quarry
#

Why are you using Console.WriteLine

patent hemlock
heady coral
#

Hey everyone! I am new here, and i have a quick kinda question lol.

My current bullet script (2d tower defense type game) when i'm firing a bullet it's homing on it's enemies (which is wanted) but my issue is that when the enemy turns, it's causing it to not keep up the same speed as when it's fired? if that makes sense.

#

How would i go about making it "turn" just as fast as it goes when it comes out of the firing point on my turrets gun... This is the code i'm using.

frigid sequoia
#

How could I check if the player is hovering on a specific word?

#

Can I do that?

frigid sequoia
#

Like, you know, these games that when you hover about a specific highlighted word shows a tooltip to explain it

#

Sorta of like adding a link to it??

heady coral
frigid sequoia
frigid sequoia
#

Ouh, I can use TMP_TextUtilities.FindIntersectingWord to check over what word I am hovering over

#

Ya, she's just using a lot of stuff that I do not quite understand, in a row lol

rich adder
#

I mean the main takeaway is learning about the <link> and FindIntersectingLink util func

frigid sequoia
#

So, I would add the "<link=MyLink> Whatever word <link>" on the text box and when using FindIntersectingLink I can get "MyLink" as a value when hovering over it and do whatever I want with it

#

It's that right?

rich adder
#

the rest is just finding it position wise

frigid sequoia
#

Oh, so the other returns the Link index?

rich adder
#

yea

frigid sequoia
#

I have to convert that to ID

#

Got ya

#

Thxs

#

So the index is just the position it has on the text between all other links?

#

So I could like do something if you click the third link on a text?

rich adder
frigid sequoia
#

So I am not meant to use that directly most of the time right?

#

Cause feels like SUPER specific

rich adder
#

linkInfo is an array

#

so all the links are stored in it

#

TMP_Text stored all that stuff

frigid sequoia
#

Mmm, so if it's an array, would that make so I cannot modify the text later?

#

Cause those are like fixed size, aren't they?

rich adder
#

idk exactly how Unity does it.
I'm assuming updated as you change the tmp_text it gets updated in the array if links if some are present, its whatever method they are using to do rich text and parse tags

frigid sequoia
#

Ya, seems like I don't want to get too deep into that

#

If it works, don't touch it 🤷

rich adder
#

if you change ID it probably updates accordingly thats why the index so you always get whatever ID from indices

tropic ermine
#

I saw there is an Official Behavior Package for unity 6, But my whole project is in unity 2021.3, Is there any way to use that project in unity 2021.3?

teal viper
tropic ermine
teal viper
teal viper
#

Looking at the package change logs it was supported by 2021 at some point, so perhaps you can use it.

tropic ermine
rugged beacon
#

i have a scriptable object with a id field, how do i auto increment this or auto generate unique value when create one ?

iron wind
#

Is it being unique a requirement?

rugged beacon
#

yes it is id

iron wind
#

is it fine if it's hash instead of integer?

rugged beacon
#

at least unique for this class type

#

any type just need it unquie

iron wind
#

add Reset() function
In Reset() you can get the editor unique GUID and store it as a variable using AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(this))

rugged beacon
#

i suppose just gen one in awake ?

rugged beacon
#

A new ScriptableObject is created as an asset via the Create Asset menu in the Editor

#

but seem awake with the new GUID will do

iron wind
#

That should give you GUID back, convert it to and store it as UnityEngine.Hash128

#

no Awake will not work since Awake will be called when you start the game as well

#

Reset is always called once when you create a new ScriptableObject

rugged beacon
#

reset doesnt seem to be called at all

sour fulcrum
#

how is this the documentation for this 😭

#

surely they can be more descriptive then that

iron wind
#

oh right, I might be mixing some stuff up here. You can rename the function to something else and add [ContextMenu("Initialize")] above the function name. Then you can right click the ScriptableObject after you created it and click Initialize to set it.

#

I could've sworn Reset would be called on ScriptableObjects as well 🤔

#

Not at a PC with Unity atm so can't verify on my end

teal viper
#

OnEnable might work too

sour fulcrum
#

onenable runs at runtime no?

eternal needle
teal viper
#

Should be running in the editor too(for SO, but might be for MonoBehaviour in the scene too)

sour fulcrum
cosmic dagger
sour fulcrum
#

It says it runs when it's loaded which implies yes but that details behind that not being stated made me feel iffy

eternal needle
sour fulcrum
#

probably on first de-serialization yeah

#

i assume loading an assetbundle with one procs it when the bundle loads too and such

eternal needle
#

usually I just make a button like with ContextMenu to generate an ID

#

dont think ive really used the unity messages for scriptable objects much cause i barely remember how they're called too, and it's not really needed a whole lot

willow shoal
#

how to fix error. i need line of code or some idea for change this script "error cs0122 inputmanager is inaccessible due to its protection level"```CS
void Update()
{
_rb.velocity = InputManager.Movement * moveSpeed;

}
public Rigidbody _rb;
[SerializeField] private float moveSpeed = 10f;

cosmic dagger
#

Facts. It's much easier to create a method that searches for the type of SO, puts them in a list, then creates an ID for those without one . . .

teal viper
cosmic dagger
willow shoal
#

i just try my self find best script for move with rigidbody

#

and i found this

teal viper
#

Then what the heck is InputManager.Movement?

#

Found?

#

Like online?

willow shoal
#

from tutorial

teal viper
#

Okay. Did you learn how it works?

#

Do they use it like you do in the tutorial?

willow shoal
#

i trying but in him screen hes code works well but when
i write to code this it dosent work

willow shoal
teal viper
willow shoal
cosmic dagger
#

Make sure you follow along and copy exactly what they wrote . . .

#

It seems you missed a step that they did . . .

eternal needle
#

I dont think they actually show that part of the code, but honestly this tutorial is one of the shittiest ones ive seen in a while

willow shoal
#

oh

eternal needle
# willow shoal oh

InputManager is probably some separate class this person wrote, I skimmed through and didn't exactly see it. Either way you'd likely want to just use the new input system and follow an actual tutorial on setting that up.
If your use case is simply enough, you could just directly assign the velocity to be the input * moveSpeed but theres a lot more to actually consider than what this tutorial is saying. And also you're using 3D from the looks of your code

#

that video above barely even qualifies as a tutorial honestly, it's just someone listing out ways that an object can be moved while giving borderline wrong information about it. it's sad what people publish

willow shoal
#

how to make Character Controller go through walls? i need script

#

i just need somethink like box colider "is trigger" but in character controler

graceful fractal
#

I just need a quick bit of help.

What is the name of this type of operator:

Float _float = _bool ? 1:0;

sour fulcrum
#

ternary

graceful fractal
#

thanks

rugged beacon
#

i thought scriptobject value can be change runtime ?, i have this one dragged onto the script
cs public PlayerDataSO playerData;
and this update it: cs playerData = SaveSystem.LoadLocal<PlayerDataSO>("Save.sav"); Debug.Log("load:"+playerData.characterId);
the debug show it get the correct value, but the scriptobject value unchanged ?

sour fulcrum
#

what is saveSystem.LoadLocal?

astral falcon
#

And scriptableobjects reset on every new runtime, just fyi

rugged beacon
#

it load the json file with this
T data = JsonConvert.DeserializeObject<T>(File.ReadAllText(relativePath));

sour fulcrum
#

thats giving you a scriptableobject

#

not setting values on one

#

playerData = is changing your PlayerDataSO reference

rugged beacon
#

not sure i understand english here.. i drag the object to the playerData, what is the reference of the PlayerDataSO you mentioned ?

sour fulcrum
#

JsonConvert.DeserializeObject<T>(File.ReadAllText(relativePath));
this is making a scriptableobject

#

it's not putting all the values from your json into one

rugged beacon
#

ok so that can create a new one, but after that playerData = should set the dragged one right ?

sour fulcrum
#

playerData = JsonConvert.DeserializeObject<T>(File.ReadAllText(relativePath));
this sets the playerData to the one it makes via code

#

whatever you drag in doesnt matter

spiral carbon
#

does any one know a active ragdoll tut that i can follow because i cant find one

rugged beacon
#

clueless

#

i guess i have to re assign individual field of the script obejct

astral falcon
# rugged beacon i guess i have to re assign individual field of the script obejct

When you drag the SO into your inspector, its an actual file holding the class with its values. When you deserialize with json using your textfile, it will create a new version for runtime. You then either have to assign every field of the json object to the inspector dragged object, so you should write your own constructor/update method or you just reassign your inspector field with your code using the new generated runtime object holding the json values. As long as you do not assign the values of your current file, your inspector dragged object is useless and not used at all. Its just another SO using your class next ot the json serialized object also using your class, but with its own values.

rugged beacon
#

ah ok so thats the reference meaning

astral falcon
#

If you use playerData = YourJsonObject, you jsut replace the reference, not assign the new loadeed to the SO, that was in there before

rugged beacon
#

actually have to re assign each field then

astral falcon
#

or just use your loaded one. Why would you reassign it?

#

are you using the dragged one anywhere else?

rugged beacon
#

yep, its the player data used to hold and update then save thorughout the game

astral falcon
#

Having a data manager loading that SO class from json into a static object would make more sense

#

so you can access it from anywhere and only update/save the values when needed to the file back

#

SOs are not meant to be data holders throughout different runtimes, they always reset (be careful, they update and save in editor but not in build)

grand snow
#

perhaps using a scriptable object for a runtime saved/loaded class is a poor design choice 🤔

#

(as its causing confusion)

astral falcon
#

I used SOs to create quests and relations upfront, and then have a json equivalent to update those SOs on runtime and save back the latest state to the json equivalent, so you can use SOs inside a custom node editor for example and update the whole quest queue with player data. But you can never rely on them to save for players. Its usually more a setup/default settings thing, using SOs rather than updated state records

rugged beacon
#

if everyone says so, cause im actually looking at a save system tutorial first time rn

fair shore
#
        this.transform.position = new Vector3(speed * Time.fixedDeltaTime, -11f, -79f);``` Why is my character move backwards in Z direction, it should move in X direction only ( The direction of left and right.)
astral falcon
#

I am sure, unity is not magically turning x into z 😉

fair shore
astral falcon
grand snow
fair shore
#

over time.

astral falcon
#

yeh, I agree, something else is moving your character, maybe its using physics and slips away slowly?

fair shore
#

It did use rigidbody tho.

astral falcon
#

if you use physics, you cant use transform.position, because thats like skipping physics and then teleporting them to a new position. so you should check, if your rigidbody is using gravity and physics and if it will just move by itself with your entire code disabled

fair shore
#

Sorry, I post the wrong function, the character is moving backwards is present when transform.Translate was used.

astral falcon
#

still ignoring physics afaik

#

and maybe show your function, so we can check against the correct one

fair shore
#

this.transform.Translate(speed * Time.fixedDeltaTime, 0f, 0f); here

#

it move my character backwards.

astral falcon
#

And if you comment that out, its not happening?

#

be sure, that your character is facing in the correct direction globally

fierce shuttle
native widget
#

Can I access this Color from the shadergrph?

astral falcon
wintry quarry
pine barn
#

Why unity is failing to recognize my script in the visual scripting global namespace?

This is my scrpit file. Am I missing any settings ?

public class TestScript : MonoBehaviour
{
    [SerializeField] private bool Check;
    public int speed;

    private void Awake()
    {

    }

    private void Start()
    {

    }

    private void OnEnable()
    {

    }

    public void PrintHi()
    {
        Debug.Log("Hi");
    }
} 
placid elm
#

Does anyone have an idea why do I have C# script in Unity as Miscellaneous Files and not Assembly-CSharp? I have Visual Studio set in my preferences in the project, and I have installed "Game development with Unity module" in Visual studio installer

wintry quarry
pine barn
wintry quarry
eternal falconBOT
#
Visual Studio guide

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

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

hexed terrace
#

go through the guide again

pine barn
wintry quarry
#

According to this is it looks like you need to use the [Inspectable] attribute, right?

scarlet skiff
#

what does this mean

wintry quarry
swift elbow
scarlet skiff
#

i think it happened when i changed this line

#

to this

scarlet skiff
#

okay thanks

placid elm
pine barn
#

Thank you 🙂

spiral carbon
sharp bloom
#

Any ideas why this works, but if I run the AddListener() in Awake function it throws a null reference?

polar acorn
sharp bloom
#

I thought you were supposed to use the Awake but nevermind I guess

wintry quarry
polar acorn
#

Rule of thumb: reference yourself in awake. Reference other objects in start

polar acorn
#

So, the Game manager would set instance in awake (a variable on its own script), while this script would add listener in start so the game manager has guaranteed to have run by then

sharp bloom
#

My game manager is instantiated in Awake as such

public static T Instance { get; private set; } 

        protected virtual void Awake()
        {
            if (Instance != null && Instance != this)
            {
                Destroy(this); 
            }
            else
            {
                Instance = this as T; 
                DontDestroyOnLoad(this); 
            }
        }
polar acorn
#

Yes, and the order objects run Awake in can't always be guaranteed

#

Another object might get initialized first, which would run their awake before this one runs to set Instance

sharp bloom
#

Yes I see thanks

grand snow
#

i bet my most said things on this server are about (T) casting and unitask 😐

raw smelt
#

HI i try a CodeMonkey Tutorail (but not copy him )

And I try make a Instance spawn OnCreate but "singleton don't exsist"
OnUpdate its ok

polar acorn
raw smelt
#

EntityRef entityRef = SystemAPI.GetSingleton<EntityRef>();

#

10

#

InvalidOperationException: GetSingleton<EntityRef>() requires that exactly one entity exists that match this query, but there are none. Are you missing a call to RequireForUpdate<T>()? You could also use TryGetSingleton<T>()....

wintry quarry
#

but really you probably just missed something in the tutorial

raw smelt
#

he did that OnUpdate

#

becouse he create a bullet

#

i want create something at the start

#

Its look like that that OnCreate is call before EntityRef

#

EntityRef is yet not ready

#

but how to solve that ):

wintry quarry
#

Again presumably you missed something in the tutorial

raw smelt
#

He did that OnUpdate And OnUpdate works fine too

#

but i want do it At start And only once

wintry quarry
#

then use OnCreate

raw smelt
#

I try to "change" something from tutorial

#

I did and OnCreate don't work XD

wintry quarry
iron wind
#

You can't in OnCreate since OnCreate happens before your entity world exists. First all sytems are created calling OnCreate, then your entity world is loaded by SceneSystem.

#

Only safe place to access that singleton is in OnUpdate and making sure your system has state.RequireForUpdate<EntityRef> to make it wait until Singleton has loaded in

raw smelt
#

Ok SO how can i make entitis for start ?
i don't wanna make some "IFS"

#

@iron wind Why i can't see a "cat" at console

#

Its shoule be call before OnUpdated

#

I know that its not good way to try execute that code XD but i just wanna test every "state of states "

iron wind
#

show the OnCreate function

fierce shuttle
rocky canyon
#

hopefully to God they're not actually searching "tuts"

raw smelt
#

@iron wind i have no internet now. I will give you info latter (i AM on the phone)

rare elm
#

i made a tilemap and filled it with a grass tile. unfortunately, while playing, there is occasional sparkling of gridlines, suggesting that there's some alignment flag i need to set

wintry quarry
rare elm
#

i thought that i was. i'm brand new. how do i check please

wintry quarry
#

Do you have the pixel perfect component attached to your camera?

rare elm
#

yes

#

sorry, was going through the manual page looking for things i missed

rare elm
#

pixel snapping is turned on. i don't really know what pixel per unit value to use

#

i also don't see how to set that for the tileset

#

i set the reference resolution to the game's current fixed screen resolution

wintry quarry
wintry quarry
rare elm
#

well i don't see a way to set that for a tileset, so i don't know how to assert that

#

wait ... you're not saying i have to remove the tilesets and re-add them?

wintry quarry
#

I am not saying that, no

rare elm
#

oh thank god

#

oh wait. is this grid units? is ppu just the pixel size of one tile?

wintry quarry
#

ppu is how many pixels on the sprite equals one in-game unit

rare elm
#

are grid cells one in game unit in size?

wintry quarry
#

assuming you didn't change the default on the Grid component

rare elm
#

got it. that's the (first) part i was missing.

#

okay. my tiles are 128x128. my pixel perfect camera is 128ppu. pixel snap is on. my grid is still sparkling. what's next?

wintry quarry
rare elm
#

oh, wait. my game has camera zoom effects. if pixel perfect zoom still produces grid sparkle, ... hm.

naive pawn
rare elm
#

i haven't figured out how yet

#

i thought i just learned it was just pixel count

naive pawn
#

select the asset and look at its import settings for a ppu setting

#

it kinda is just pixelcount, it tells unity how to properly scale your sprites

rare elm
#

so, the pixel perfect camera broke a different thing that i had for dynamically scaling the camera sometimes. i'm about to go just turn that off, but before i do, is the pixel perfect camera the only approach to this? there isn't like an AA mode without it or something?

rocky canyon
#
  • the pixel perfect camera's job is to ensure that movement and rendering align perfetly with the pixel grid..
    this prevents subpixel rendering that case blurriness or distortion..

  • ofc its not the only approach.. you can find other assets or roll your own solution..

  • no single AA setting will solve all the issue's that pixel-perfect camera addresses

sand flume
#

Hello, I need help. I want to create a hotbar and inventory system in my 3D first-person game, almost like in Minecraft. However, I'm not good at coding and usually follow tutorials or use AI. I've tried both methods but haven't found a good system. Do you have any tips?

frosty hound
polar acorn
sand flume
#

I don't know... maybe tutorials or assets? Sorry for just asking.

polar acorn
#

Just searching "Unity Inventory System" will provide several

frosty hound
# sand flume I don't know... maybe tutorials or assets? Sorry for just asking.

You've already claimed that no tutorial was a good enough system (not believable) or AI didn't help (believable) what else can we suggest?

  1. Take the time to learn how to make games generally ( !learn ), to the point where you can confidently design and develop your own systems unassisted
  2. Buy an asset off the asset store (which will still require #1)
  3. Pay someone to do it (which will also require #1 if you want to modify it in the future)
polar acorn
#

Is the bot dead?

#

!learn

#

Bot is kill

slow knot
#

im trying to add a animation controller but i cant open the project window

#

every time i click either the hotkey or navigate through the GUI it does nothing

#

am i missing something?

verbal dome
#

If you feel like the UI is bugged, reset the layout

#

Not a code question

slow knot
#

oh sorry which channel

#

im kinda blind to these things

verbal dome
slow knot
#

thanks ill ask there, since i already tried the resettiong layout thing

prime lodge
#

can somebody explain this error i was working on something different and out of nowhere this showed

polar acorn
#

Or get rid of the namespace you didn't intend to do

prime lodge
#

i never had this issue before

polar acorn
tame gate
#

Hi, I´m sorry if this is not the channel for that, but does someone have a good tutorial, be it video or written, to recommend for dialogue systems and inventory systems? The plugins I was using are not working properly and I´m desperate enough to try to do everything from scratch...

#

I´m working on version 6000.35.f1

eternal needle
# tame gate Hi, I´m sorry if this is not the channel for that, but does someone have a good ...

there will rarely be a tutorial that does exactly what you need. if you're going to write it from scratch, well simply start writing and google what you actually struggle with. a dialogue system is a string you display on screen. an inventory is a list of items. your game design heavily changes what you actually do with these systems

also someone else asked the same thing slightly above. #💻┃code-beginner message

keen owl
shell dove
#

Hey, I am not quite sure where to ask quastions about problems on here

rocky canyon
tame gate
rare basin
#

to find the proper tutorial

#

cuz if you typed "how to make point&click game about collecting flowers" then you wont find any thing

#

just divide it into parts like "how to detect clicks in unity" etc

eternal needle
# tame gate Oh, sorry, my game is a 2D click and point where you go around collecting flower...

the code itself wouldnt be too different although I havent used unity 6 yet. i know some things got renamed like rigidybody's velocity to linearVelocity.
i really advise not following a tutorial blindly if possible. it'd be much better if you implement a feature and google or ask what you actually need help with. Like "collecting flowers" is not the problem. The problem would be like detecting if the user clicked on or collided with an object.

tame gate
#

2d Dialogue system for unity tutorial, the youguest one I found was from 2022

#

From google

rare basin
#

what is 2d dialogue system

#

how is 2d dialogue system different from 3d dialogue system

tame gate
#

The Ui I assume...

eternal needle
#

UI is UI. still, what part of the UI do you struggle with? google or ask specifics about that instead when you get to them

#

A dialogue system can literally be a list of strings, and populating a textmeshpro component with the string

tame gate
#

Yeah, I´ve made a few minigames with the colliders and rigidibody, I think the biggest problem I would have would be in the dialogue system directly since it´s from what I´ve seen mostly script based. I´ll try following the tutorials I found then and come back when I have questions on something specific.

Thank you all!

eternal needle
#

and following a tutorial where you dont actually understand what you're writing just isnt going to end well

tame gate
noble forum
#

Hi, i have found out today, that after clicking a button once, it cannot be clicked again for some reason. Not that it clicks and does nothing, it cannot be clicked, and i guess it has something to do with UI overwriting, as all my UI is non interactable all at once. I have no clue why tho, it must be something to do with the function, but that function does so many things its hard to find

cosmic dagger
keen owl
keen owl
noble forum
#

its like something that i did is blocking the raycast

#

But it was a long time ago and i just noticed it now, i don't remember what could have happened

keen owl
#

There could be 1000 possibilities as to what’s happening. As long as whatever happens is happening after you click, it’s due to your onclickevent. You would need to see what exactly it is

#

Maybe send the actual method and show the issue with a picture/video for better help

noble forum
#

I saw, and...

#

wait....

#

If i click any button once, everything becomes unable to be clicked....

keen owl
#

Do those buttons share the same onclick method?

noble forum
#

they call completely different methods unless.....
Yea, they at some point call the same function in one script

keen owl
#

Well bots down

eternal needle
noble forum
#

OHHHHHH

#

FOUND THE MOTHERFUCKER, TIME FOR TOTAL ANIHILATION

#

It was an invisible button for my menu that for designing purposes i decided to have in the same scene

#

it was supposed to be 'click to continue' kind of thing

#

i forgot to disable it

noble forum
#

Thank you both a lot

#

i would not have figured it oput any time soon

keen owl
#

Was that button on top of all of the other buttons?

noble forum
#

As you can see, this isnt part of a standard UI, so yes, i only wonder why it let me click for the first time

#

but well, i don't think i wanna know

robust schooner
rare elm
#

i added a pixel perfect camera. i set the sprite's ppu and the grid's both to 128, which matches the tile size. i set the camera's reference size to 2k, which is currently the game's fixed render size. i am still having grid edge issues. i am too new to know what to look for.

safe root
#

How would I find the Damage script without a object?

public int amount;
public override void Apply(GameObject target)
{
target.GetComponent<Damage>().damageTaken += amount;
}

wintry quarry
keen owl
safe root
#

I figured it out after a bit but I mean. Like trying to get the script itself instead of through the object cause it don't exsit

wintry quarry
keen owl
#

and about object oriented programming nature all together

keen owl
scarlet skiff
#

does setting hte velocity of an rb to something as little as 0.01f have a chance to round it down to 0? or say something near 0 like 5.960464E-08

wintry quarry
#

However it will not be rounded down to 5.96e-8, no

scarlet skiff
rare elm
#

ah, i still had anti-aliasing on

raw smelt
#

hi i got
Assertion failed on expression: 'IsFinite(distanceAlongView)'
Invalid AABB a
Invalid worldAABB. Object is too large or too far away from the origin.

And i have no idea why (there is only 15 entitis and all of them are close )

teal viper
raw smelt
#

This is in the console

teal viper
raw smelt
#

The error don't stop a program
Its still running so there is like 999+ of them XD

scarlet skiff
#

does anyone know why this enemy turns invisible when flipped o nthe x axis?

raw smelt
#

Interesting i did that
And there is no error WTF

#

no error now too

teal viper
raw smelt
#

know what ?

teal viper
raw smelt
#

its looks like that i can't do new in the LocalTransform for somereason
SystemAPI.SetComponent(ballEntity, LocalTransform.FromPosition(new float3(i, 0, 0)));
if i first make a
pos=new float3(i,0,0)
SystemAPI.SetComponent(ballEntity, LocalTransform.FromPosition(pos));
Then there is no error XD

raw smelt
#

So i don't know the "ruls" etc

#

And i need ECS for performance i already try normal gameObject and when i had like 400 object there was already less that 60 fps

teal viper
teal viper
raw smelt
#

Yep i know but i said that there is no bottom of the console XD
Becouse the bottom is in the place when i stop it
if i will stop it 2 times it will be dif

raw smelt
hidden fossil
#

guys i need help does anyone know why the win screen isnt appearing after all the waves are finished and there is no enemies left?

teal viper
hidden fossil
#

!code

eternal falconBOT
teal viper
teal viper
raw smelt
raw smelt
teal viper
# raw smelt

The part that says "assertion failed ...". This would usually have more info and/or a callstack.

#

It's the error details space.

teal viper
# raw smelt Physics + orther

Then perhaps you should have optimized the physics.
Anyways, I'm not here to change your opinion, but if you need help with DOTS(ECS), you'll need to ask in #1062393052863414313 .
Just know that it's not a beginner topic.

scarlet skiff
raw smelt
#

Am i wrong ?

teal viper
scarlet skiff
#

what do i look for

hardy bridge
#

This is a pretty basic problem but for the life of me I can't figure it out; my guy won't jump while moving and idk why. can anyone help? it's cool if not

teal viper
raw smelt
teal viper
scarlet skiff
#

i work on this project with other people, someone else is responsible for dealing with setting up the light and stuff, so i just made this material to make the object always lit so i can see it properly when testing

teal viper
# raw smelt what if there is constant collision ?

If they all overlap and collide with each other, it might, but this wouldn't be proper behavior in ecs as well. If the units can go through each other, make sure their colliders don't process collisions with each other.

#

Also, dynamic objects need an rb.

#

There are many small things like that that you need to learn. Before thinking about ECS.

polar acorn
# raw smelt

This has nothing to do with your code - you've got things that are out of scope of the physics system and causing math errors. Something's either really big or really far

#

It's trying to do math on numbers too big for the variables to hold and it's causing a cascade of problems internally

raw smelt
teal viper
polar acorn
raw smelt
#

The only object is that ball

#

Only that code create any object

#

and if i change variable "i" to that
SystemAPI.SetComponent(ballEntity, LocalTransform.FromPosition(new float3(5, 0, 0)));
there is no error XD

scarlet skiff
polar acorn
teal viper
hidden fossil
#

oh hey can anyone help me with my game why isnt the win menu opening once there is no more waves or enemies?

#

!code

eternal falconBOT
hidden fossil
polar acorn
#

How far does the code reach

hidden fossil
#

only this one at line 102 shows up Debug.Log("All waves finished! Checking win condition...");

#

the rest dont show up at all

polar acorn
hidden fossil
#

is the problem like theres too much code and its lagging the game

polar acorn
#

Try logging the values of those variables before the if

#

and see which one isn't what you expect it to be

teal viper
#

Make sure you don't have errors spamming in the console as well.

teal viper
hidden fossil
#

im only getting this log

polar acorn
# hidden fossil im only getting this log

Then if (currentWave >= waves.Count - 1 && enemiesAlive == 0 && enemiesLeftToSpawn == 0) is never true when that line runs

Try logging the values of those variables before the if
and see which one isn't what you expect it to be

teal viper
hidden fossil
#

like enable every single log?

teal viper
#

No. Take a screenshot of the whole console tab/window.

polar acorn
#

At least show that you haven't disabled errors and whether or not you've collapsed multiple logs into one

teal viper
#

If not sure what to share, it's always better to share more than less.

#

Like a whole screen screenshot can be good enough for starters.

hidden fossil
teal viper
# hidden fossil

That's still not the whole console tab, but at least we can see that you have the messages collapsed and one message has been printed 40k times. If it was in a short period of time, of course your game will lag.

polar acorn
#

Still not showing if you've disabled errors

hidden fossil
#

is that errors?

teal viper
polar acorn
teal viper
raw smelt
#

Just update for @polar acorn

    public void OnUpdate(ref SystemState state)
    {
        EntityRef entityRef = SystemAPI.GetSingleton<EntityRef>();
        float3 pos = new float3(0,0,0);
        for (int i = 0; i < 15; i++)
        {

            Entity ballEntity = state.EntityManager.Instantiate(entityRef.BallPrefabEntity);
            pos = pos + new float3(1, 0, 0);
            SystemAPI.SetComponent(ballEntity, LocalTransform.FromPosition(pos));
            //SystemAPI.SetComponent(ballEntity, LocalTransform.FromPosition(new float3(55, 0, 0)));
        }
        state.Enabled = false;
    }
Now there is no error XD look like i is illegal
polar acorn
raw smelt
#

Still strange becouse new float(i,0,0) should create object at exacly the same way
And BTW objec was fine before too (there was error but in the scene everything looks the same )

teal viper
jolly moat
#

I have an enemy prefab with an enemy movement script, it has a public GameObject player variable. The editor won’t let me assign the instance of the player object that’s in my scene. It says type mismatch. How is my player’s GameObject a type mismatch from public GameObject player; in my script? I don’t understand why the editor is complaining

#

I can drag/drop my player onto the EnemyMovement component (on enemy) but it won’t let me apply it to the prefab

eternal needle
#

you'll need to reference the player another way, could be through the singleton pattern even. although you shouldnt use GameObject, use the type you actually want to get from the game object

jolly moat
#

Dang, ok. I’ll have to rethink things. Thanks!

jolly moat
#

I had it as public Transform player; but changed it to GameObject before I knew you cant reference scene objects from prefabs. I really just want the player's transform available to each prefab Enemy object that I spawn. Would making the player prefab also work?

shell sorrel
#

have the thing that spawns enemies also set the players objects on a public field

rare elm
#

does unity do what web developers would call tree shaking? if i add some asset set into my project, and then only use half of it, do i need to manually remove the other half to keep the binary size down, or does the unity linker handle it for me

shell sorrel
#

or give it a method you call after instantiateing the enemies that you can pass stuiff they need at runtime to

shell sorrel
rare elm
#

nice.

teal viper
finite dove
#

hy i probably need a second eyes for this, do i miss something? everytime i try to catch yellow coin the debug wont show... (i havent slept now huhhu)

finite dove
safe root
#

So I have just created a power up system but now the enemies don't take any damage until after the sixth shot. I am unknow why this issue is having as the console says the damage amount is 10 but the health doesn't drop.

timber tide
#

code

safe root
#

Yeah, but nothing in it should do such a thing and the question is why it last only after six shot. Why would nothing happen till 6 shots after?

#

Could a static int do such a thing?

timber tide
#

post the codes

safe root
#

!code

eternal falconBOT
timber tide
#

watch the video and look at your hierarchy

safe root
#

What about it?

uncut shoal
#

how do I make HingeJoint2D not limit the object's position but only the rotation?

#

so like the other object can move as far away as it wants but it needs to stay within the rotation

#

I remember reading somewhere that you can do that

timber tide
# safe root What about it?

You've 2 enemies in it, but one is being destroyed which isnt the one you're targeting. Anyway, FindObjectOfType and any Find method is pretty awful and I suggest avoiding them if you can unless you know what you're doing.

shell sorrel
#

yeah find object of type in a collision enter, chances are you are doing something very wrong

timber tide
#

Ideally if you want to use a Find type of method, make sure you're using something part of the local hiearchy and not the scene. Something like:
GetComponentInChildren

shell sorrel
#

your just not targeting the right health object, since you are just searching the whole scene for hte first one it finds, not the one on the object collider with

#

if you are looking for the Health component on the thing the projectile collided with, do other.collider.GetComponent<Health>()

safe root
#

I see, but why didn't do this before?

shell sorrel
#

no clue what you had going on before, but FindObjectOfType is not what you want

safe root
#

Fair, thank you

shell sorrel
#

maybe you only had 1 enemy in the scene before

safe root
#

No, I had mutpile

shell sorrel
#

or just hit a false positive and were always shooting at the first one found by find object of type

safe root
#

I got very lucky

uncut shoal
hidden fossil
#

anyone online

slender nymph
hidden fossil
#

im getting this bug

#

and a bunch of this

slender nymph
#

show your EnemySpawner class

teal viper
hidden fossil
#

!code

eternal falconBOT
teal viper
hidden fossil
#

oh yea its also making my game lag very badly to a point where it crashes as soon as i run it

slender nymph
#

just FYI, when pasting code into a paste site you do not include the inline code formatting

#

is there perhaps more to the stack trace below what was included in the screenshot?

hidden fossil
#

nah its all the same

slender nymph
#

i'm not asking if the other errors are different, i'm asking if there are more lines in the stack trace

hidden fossil
teal viper
slender nymph
#

show where you actually invoke the onEnemyDestroy event

hidden fossil
hidden fossil
slender nymph
#

no, that is the method subscribed to the event, where do you actually invoke the event

hidden fossil
#

oh i dont think i invoked it anywhere

slender nymph
#

you clearly have

teal viper
#

The callstack implies that the event is invoked in that callback itself.

#

Was it maybe previous code and you have compile errors now?

slender nymph
hidden fossil
#

is it this part?

slender nymph
#

is that the only place it is being used? also this feels like unconfigured vs code

hidden fossil
#

yep

slender nymph
#

you're telling me that variable is being accessed nowhere else in the code base at all?

#

and by "that variable" i am, of course, referring to EnemySpawner.onEnemyDestroy

hidden fossil
#

should i move that variable to the health script?

slender nymph
#

why?

#

what you need to focus on doing right now is finding where you are using that variable

#

and if vs code is currently not able to tell you all of the locations you are using that variable in, and more importantly if it doesn't currently show errors in the code or provide autocomplete for unity types then it needs to be configured 👇 !IDE

eternal falconBOT
hidden fossil
slender nymph
#

no idea why you've decided to open that window let alone screenshot it

hidden fossil
#

its not* opening

#

is that normal?

slender nymph
#

wdym "its the opening"

#

why have you even opened that window? what instruction told you to go there

hidden fossil
slender nymph
#

there are two things wrong with this:

  1. nowhere in that page does it say to check for unity editor updates using the in-editor window
  2. you are using vs code not visual studio so that's not even the correct configuration steps, unless you've decided to install visual studio and use that instead (which is a good option as it is typically better than vs code)
hidden fossil
slender nymph
#

yes, you need to find all usages of that variable. but do so after you have configured your code editor

hidden fossil
#

does this part count as one?
private void Awake() {
onEnemyDestroy.AddListener(EnemyDestroyed);
}

slender nymph
#

have you configured vs code yet

hidden fossil
#

yep

slender nymph
#

screenshot the entire window then

hidden fossil
#

is this it?

slender nymph
#

well that is certainly the entire window, but it is also unconfigured.
go through the information on this page if following the correct instructions did not work for you (and no, the instructions for visual studio are not the correct ones as visual studio is a completely separate program from vs code) https://unity.huh.how/ide-configuration/visual-studio-code

hidden fossil
#

does install this reinstall the whole app again?

slender nymph
#

no

hidden fossil
#

just the vs code?

slender nymph
#

it does not reinstall anything, it is an extension for vs code so it only installs that extension and its dependencies

hidden fossil
#

is this it?

slender nymph
#

did you know that typically things that are red with a circled X in them means something is wrong

safe root
#

Can someone show me a video that shows how to create a area where enemies can spawn only within that space?

hidden fossil
#

why is .NET taking so long to install

safe root
verbal dome
safe root
#

Ai is how I had bad coding to begin with

hidden fossil
safe root
#

That's what I did

#

And the code was pretty bad

rocky canyon
#

search:

  • how to get a random position in area
  • how to spawn enemy/prefab
#

then combine the two.. maybe a:

  • how to chose a random position in area
frosty hound
#

It also entirely depends on what you define an area to be. Within a range? Within a box? Within an area that can be literally any shape?

hidden fossil
#

guess ai still sucks?

hazy cliff
#

hi I'm trying to edit text which has been working perfectly but today I opened my project and suddenly the box to edit text isn't showing up does anyone know why this is happening?

eternal needle
polar acorn
#

Is this something in editor or in your project?

hazy cliff
#

its in the editor

#

oh wait I'm stupid I accidently hid it

#

sorry

safe root
hidden fossil
#

does .NET SDK work with visual studios code?

safe root
teal viper
#

If you have a more specific question, it might be easier to help you.

safe root
#

!code

eternal falconBOT
safe root
teal viper
safe root
teal viper
#

So a square ring/annulus?

safe root
#

Oh, just realized what you meant. Yeah, would it be smart then to have three point for that?

lone tundra
#

I'm using raycast to find out if an object is above a tile in my project. However, when I try to detect if there is an object, it will always return false. Even if there is an object above a tile, it will return what is beneath it instead. The object is directly above the tile and the raycast position is directly above the object. Does anyone know why this happens?

sharp bloom
#

How to get the proper position of an UI element in runtime? (In order to return the element back to its place?)

originalPosition = GetComponent<RectTransform>().position;

Behaves badly in my case

#

If I set the recttransform position again, it goes partially off-screen

#

At least in some screen sizes

keen dew
#

RectTransforms are positioned using anchoredPosition

sharp bloom
#

Thanks

teal viper
lone tundra
teal viper
lone tundra
#

The debug rays don't show up even if I put it in Update().

teal viper
#

Try adding a log alongside.

lone tundra
#

The update and the script is executed. Debug.Log() also does not log when placed in the raycast method.

teal viper
#

Share the relevant script

lone tundra
teal viper
lone tundra
#

Where do I paste the code?

teal viper
#

!vodw

#

!code

eternal falconBOT
lone tundra
teal viper
lone tundra
#

This is the full script

#

The update calls coroutine Cannon() which would call PieceBelow(PieceBelowi.transform.position, PieceBelowi)

burnt vapor
#

Why is HandleRayCast a Coroutine? Are you expecting it to block Update until it finishes? I'm very confused on what the point is

#

Also just generally calling a Coroutine in Update is questionable, but in this case it doesn't do anything

lone tundra
#

HandleRayCast checks where the player is moving their mouse and what it touches in the game.

burnt vapor
#

But why is it a Coroutine?

lone tundra
#

Well I need it to be a coroutine to check where the player is moving their mouse and what it touches.

burnt vapor
#

For a single frame?

#

An update method runs every frame, just doing this in a function has the same result

teal viper
burnt vapor
#

But I digress, this is not part of the issue

lone tundra
teal viper
teal viper
teal viper
west radish
lone tundra
teal viper
west radish
lone tundra
#

I did not know I could do that

#

I have about 3-4 weeks experience on Unity and C# code.

west radish
#

It's something I wish I'd known earlier

teal viper
lone tundra
teal viper
#

With StartCoroutine

lone tundra
#

But I did start it with StartCoroutine in Update();

teal viper
#

But you don't start it properly where you debug.

#

So it's not called correctly from there.

#

Honestly, I'd tear it all down and rewrite it with less coroutines.

lone tundra
#

Oh wait no I see.

#

But is it possible for PieceBelow to be a method not a coroutine; using void not IEnumerator?

lone tundra
teal viper
lone tundra
#

Ok

teal viper
#

That's what we're fixing, don't we?

lone tundra
teal viper
lone tundra
#

I changed it into a normal method.

#

Yet Debug.Log(piecebelowi) still returns the tile below the gameobject.

#

Are there any reasons why a raycast may be ignoring an object?

teal viper
#

I feel like you're half ignoring what I'm saying...

lone tundra
teal viper
#

Before, the raycast and the debug ray were not executing though, right? Because you didn't start the coroutine correctly.

#

Does it draw now that you changed it to a normal method?

lone tundra
#

Do I place the drawray inside the raycast method?

#

I tried it in both and it still does not show up in game view or scene view

teal viper
teal viper
lone tundra
#

I added a log in both raycast method and the coroutine the method appears in

lone tundra
#

No

#

This happens when I make an illegal move. 7, 7|7, 7 is a concatenation of hoveringTile2, which is initialised in the raycast method. 7, 7 is also the name of the tile which is below the rightmost piece called Cannon. moved? comes from the MovePiece method which I need to code to move the piece to the position.

teal viper
lone tundra
teal viper
#

Make your logs more verbose. It's not clear what the message implies and where it comes from..

#

I don't see a single debug logs here:

    void PieceBelow(Vector3 tilePosition, GameObject tile)
    {
        Vector3 offset = new Vector3(0f, 5f, 0f);
        Vector3 aboveTile = tilePosition + offset;

        ray2 = new Ray(aboveTile, Vector3.down);

        if (Physics.Raycast(ray2, out hit2))
        {
            hoveringTile2 = hit2.transform.name;
            if (hoveringTile2 == tile.name)
                spaceOccupied = false;
            else
                spaceOccupied = true;
        }
        Debug.DrawRay(aboveTile, Vector3.down, Color.yellow);
        return;
    }

Am I blind or are you still ignoring half of what I'm saying?

#

Btw, you don't need a return at the end. It does absolutely nothing

lone tundra
#

Oh Debug.Log, I did Debug.DrawRay

#

It logs the position of aboveTile

#

But it still ignores the object.

teal viper
#

Make your logs more verbose.

Debug.Log("Raycasting at pos: {position}");

Or something like that.

#

Once you do, take a screenshot of the console showing that the log is printed

rare basin
#

need the $ before the first "?

teal viper
#

right.

lone tundra
#

oh ok

teal viper
#

Take a screenshot of the log showing up in the console

lone tundra
teal viper
# lone tundra

Great. Now let's find your debug ray. Check the debug ray docs. It has a parameter to define how long it would be drawn. Set it to something like 60 sec.

lone tundra
#

What are the debug ray docs?

#

Oh parameters

#

I did this: Debug.DrawRay(aboveTile, Vector3.down, Color.yellow, 60f);

teal viper
lone tundra
#

Btw I am using Unity 2022.3

teal viper
#

Doesn't matter

lone tundra
#

oh yeah i see it now

#

but they don't go all the way down?

teal viper
#

Check the method documentation. it says something about ray length

lone tundra
#

Only Physics.RayCast can change maxlength.

#

So I set it to 10f.

#

It still only goes halfway.

#

Nevermind it works

teal viper
lone tundra
#

The object still does not.

teal viper
#

Does the debug ray cross the object you expect it to collide with?

lone tundra
#

Yes it does

#

It should detect this but it still shows this

teal viper
#

Ok, take a screenshot of the object selected with collider gizmos visible.

lone tundra
teal viper
lone tundra
#

Yes it does

#

Oh wait it works now

#

Thank you so much

teal viper
#

So it was srarting inside the collider?

lone tundra
#

I changed it so it was starting outside the collider

teal viper
#

Then what was the problem?

lone tundra
#

I guess that was the problem

grand snow
#

from what i can tell you are using raycasts for selecting a tile? better to use the pointer events + event system if you can as its much more reliable @lone tundra
can be used with 3d and 2d physics to easily do click detection and other things.

lone tundra
#

I am using raycasts to check if there is anyting above the tile.

grand snow
lone tundra
#

I wasn't sure how to do that so I used rays because I've heard of it before.

grand snow
#

You can have a list of 2d arrays to create layers of grids (List<Tile[,]> tileLayers) or just have a public field/property on the tile you assign the thing above it to.

shell sorrel
#

can also just do grids as 1D arrays its pretty simple math to go from 2d coord to index if you know the width

#

easier to serialize

twilit stirrup
#

Does anyone know a model i can use to identify two difference peoples voices, and then tell me, which person is talking into the mic on unity. been trying to figure this out using sentis, and importing models, but i just cant get it to work, and i cant find anyone who has done it before.

sour fulcrum
grand snow
#

yea thats true but 2d arrays are simpler for beginners to access elements. I also prefer 1d

shell sorrel
#

yeah just mentioning find 1d is just nicer expecially once you have to save it

sour fulcrum
shell sorrel
grand snow
#

doesnt need to. can be build at runtime if the position is set on each mono instance

twilit stirrup
#

with my problem.

sour fulcrum
#

well thats rough

#

if you don't find help there you won't find help here

sour fulcrum
shell sorrel
#

you could easily have a List of struct where the struct has a 1d array and that would serialize just fine

#

or if you have a defined amount of layers just have the layers be top level

grand snow
#

if you have even a semi large grid, making the array in inspector correctly wont be easy so I would not go this route.
Games I work on with 2d grids dont serialize any of this

sour fulcrum
#

there's many solutions forsure im just acknowledging that the problem does exist because it can easily trip people up

shell sorrel
sour fulcrum
#

just depends

grand snow
#

well this is past beginner stuff so then you can do whatever you want

shell sorrel
#

it was required since each placeable object had grid data it needed to write to the main games grid so had a editor for that

#

was just letting unity do the serialization early on in dev, then once the structure for each tile was well defined changed to a custom binary format

strange sapphire
#

in 3d what's usually done to make multiple objects be the exact same distance between each other (like houses for ex.)

eternal needle
#

is there something more specific you need than adding the distance from the last object position?

noble forum
#

Hi, I'm creating a Tarot Chess game, in which you play chess with many magical effects. Today I'm working on The World, which basically works like a border, shrinking the board from 8x8 to 6x6 to 4x4 to 2x2. I have this covered, but now I want to some visual effects. I decided on particle system 'fog'. The problem is, that the fog needs to be dense, so it almost covers the entire unplayable squares, and it also cannot emit particles on the playable chess tiles. Any idea how to do that?

#

The world image vs what i did

crystal bridge
#
using UnityEngine;
using UnityEngine.EventSystems; 


public class Dialogue : MonoBehaviour, IPointerClickHandler 
{
    public GameObject dialogueBox;
    public string dialogueText;
    public Texture[] portraitTextures;

    public void OnPointerClick(PointerEventData eventData)
    {
        
        dialogueBox.SetActive(true);

        if (DialogueManager.Instance != null)
        {
            DialogueManager.Instance.DisplayDialogue(dialogueText, portraitTextures);
        }
        else
        {
            Debug.LogError("DialogueManager.Instance is null");
        }
    }

    public void OnBeginDrag(PointerEventData eventData)
    {
        dialogueBox.SetActive(true);

        if (DialogueManager.Instance != null)
        {
            DialogueManager.Instance.DisplayDialogue(dialogueText, portraitTextures);
        }
        else
        {
            Debug.LogError("DialogueManager.Instance is null");
        }
    }
}

OnPointerClick does what I want, but OnBeginDrag doesn't respond. Any ideas why?

eternal needle
verbal dome
#

You are missing , IBeginDragHandler

crystal bridge
#

Thanks!

polar acorn
# noble forum

I don't think this is a codeable solution, I think this is more of a #✨┃vfx-and-particles question. As to preventing the "live" squares from being occluded, you could put a collider over the whole playable area on a layer that only the particles interact with, and have those particles destroy themselves on collision

polar acorn
noble forum
noble forum
prime scroll
#

i need help guys

frosty hound
prime scroll
frosty hound
#

Then please don't spam here, thanks.

prime scroll
#

i need someone to join with me in a voie chat

frosty hound
#

Not how this server works.

#

If you can't explain it in text, you can't explain it in voice. If you can't ask your question, then please don't spam.

crystal bridge
prime scroll
#

the code has no errors, but the outcome isn't forming in the way i wanted

prime scroll
polar acorn
polar acorn
honest field
polar acorn
#

!code

eternal falconBOT
prime scroll
#

public class ObjectBehaviour : MonoBehaviour
{

    [SerializeField]GameObject _prefab;
    [SerializeField] private bool _gameOver = true;


    public void spawnObject()
    {
        Instantiate(_prefab, new Vector3(Random.Range(-8f, 8f), 6f, 0f), Quaternion.identity);

    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if(collision.gameObject.tag =="Player" && !_gameOver)
        {

            Debug.Log("Touched");
            spawnObject();
            Destroy(gameObject);


        }
        
        else if (collision.gameObject.tag =="Ground")
        {
            _gameOver = false;
            
            Debug.Log("GAME OVER , YOU'VE LOST");
        }
    }
}```
polar acorn
prime scroll
#

class Test : MonoBehaviour // Inheriting class (child class)
{

    [SerializeField] ObjectBehaviour Block;
    [SerializeField]private float _playerSpeed = 5f;
    private Rigidbody2D _rigidbody;
    float _inputHor;
   
    

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        
        _rigidbody = gameObject.GetComponent<Rigidbody2D>();//syncing 
        Block.spawnObject();


    }

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

        _inputHor = Input.GetAxisRaw("Horizontal");
        
        if (_inputHor != 0)
        {
            _rigidbody.AddForce(new Vector2((_inputHor * _playerSpeed),0f));
        }
        
    }
}```
prime scroll
# polar acorn Okay, so what is the issue

The second script is the most important to me. In it, when the player object touches another object, a "Next" object is supposed to spawn. However, I’m facing an issue: when I start the game, the first object spawns as expected, but when the player touches it, nothing happens. Please help me fix this.

polar acorn
prime scroll
wintry quarry
polar acorn
wintry quarry
#

use Debug.Log statements to check that it's running as expected and that the data is as you expect

prime scroll
polar acorn
prime scroll
wintry quarry
#

you need to take concrete debugging steps and show the results

polar acorn
prime scroll
scarlet aspen
#

What do you think is the best path to take to learn unity c# programming with unity learn?

polar acorn
#

is the object in the scene, or a prefab

prime scroll
#

a prefab

polar acorn
#

A player will never collide with a prefab

#

Prefabs do not exist in the scene

honest field
#

Yeah, that's your issue. You need to assign the in-scene object to the Block variable

wintry quarry
#

I don't see why that variable exists at all to be perfectly honest

#

AFAICT this whole interaction is supposed to be happening when the objects collide

#

so the focus here should be OnCollisionEnter2D

#

the Start() code is a red herring I think

polar acorn
#

Yeah, I'm assuming the _prefab variable on the block is a different object, otherwise, why would you be calling the function from this object instead of just spawning it in Test?

#

If the intention is to spawn an ObjectBehaviour, why would you call a function on an object behaviour to do so?

honest field
#

Looks like it's a game where you need to catch items in a bucket

#

So the _prefab variable would be a reference to its own prefab. Once the object is caught in the bucket, it spawns a new version of itself at a random position in the air

#

And if it hits the ground, it calls a game over

prime scroll
#

exactly

honest field
#

So there's a few issues with your code you'll need to fix

#

First, move the OnCollisionEnter to the Test script, and give the block prefab a tag to test against. Ideally you'll eventually want to move towards a game manager that handles creating these items and evaluating game state, but you're not quite at that level yet

#

Also have the game over be stored in the player. Every time you create a block, it has its own internal Game Over state that doesn't persist past the block's destruction

#

The only thing your block should need to worry about is if it's hit the ground

#

Depending on how questionable you want your coding practices to be, I'd recommend a third script called "GameManager" or something like that, and give it some static functions and variables so anything can easily talk to it

#

Then, for example, if the block hits the ground, it can just call "GameManager.GameOver()" and that'll handle everything

prime scroll
#

OnCollisionEnter is a private method

#

and i could change it to public but an error poped out to me

honest field
honest field
scarlet aspen
honest field
scarlet aspen
honest field
#

Any experience with other coding languages?

scarlet aspen
#

I'm cooked

honest field
#

lol, all good

keen owl
honest field
scarlet aspen
#

(It doesn't have to be on unity learn)

#

I can learn somewhere too

honest field
#

Youtube is usually pretty effective for general C#. The hardest part is learning how to think in terms of logic, and break your problems down into steps

scarlet aspen
#

true

eternal needle
scarlet aspen
honest field
#

(note that the intro to c# tutorials won't work in Unity. You'll need to run them in Visual Studio directly)

noble forum
eternal needle
honest field
#

Once you know the absolute basics as bawsi mentioned, come back and learn how to apply them to Unity

scarlet aspen
#

Thank you 🙂

honest field
#

No worries! Good luck 🙂

prime pier
#

how can i make mods for games

#

i wanna make just a small mod for schedule 1 but all it is that i just dont know how to mod games

slender nymph
#

modding discussions are not permitted here #📖┃code-of-conduct
find the modding community for the game you are interested in modding and learn from them

prime pier
#

okay thank you

elfin isle
#

heyyy uhm, im working on a project and im trying to get an object to move an a parabolic shape. though, when i try and write the code for it it says "MathParabola" doesen't exist, am i being stupid or uh..

(yes, i have the mathematics package)

wintry quarry
#

That's not somthing in Unity.Mathematics afaik

elfin isle
wintry quarry
wintry quarry
#

parabolas are well defined

#

Option 4 is use an animation curve

elfin isle
#

thatd probably be easier but

i dont know how id put the math into unity

elfin isle
wintry quarry
#

Asking ChatGPT "What are the parametric equations for a parabola" and going from there would get you pretty far. T is time.

elfin isle
#

no no i know the equations just im a math whiz not a programming whiz lol

wintry quarry
#

once you have a parametric equation it's very straightforward

#

you just plug the equation into the code more or less

#

they let you calculate the x and y position at a given time

#

then you just use that to position your object

#

myObject.position = new Vector3(x, y);

elfin isle
#

okay

#

how would i calculate t ime? would i j ust use Time.deltaTime?

wintry quarry
#

is tracking elapsed time

#

that would be t

elfin isle
#

oh!

#

oh

wintry quarry
#

make sense?

elfin isle
#

let me get that code back lmao

#

yeah

#

im lying im still confused on how to go about this but im trying

wintry quarry
tender gazelle
#

Hey i need really some help. I've been stuck on the same problem since 3 Weeks and don't know how to get rid of. So my Character cant jump and i don't know why. If i thinks its because of some Ground check problem but i don't really know. (and yes the code was written by ChatGpt because it doesnt work when i do it.)

wintry quarry
#

you also haven't set up your layer mask

slender nymph
#

and need to configure vs code 👇 !IDE

wintry quarry
#

That error in the console is likely because you have a second copy of the PlayerMovement script on some object in the scene where you didn't assign that variable

eternal falconBOT
wintry quarry
#

See how this says Nothing

#

that means it's not going to detect anything

#

and you will never be able to jump

tender gazelle
wintry quarry
#

x shouldn't be a parameter

#

t should be appearing in there

elfin isle
wintry quarry
#

yeah that looks more right

elfin isle
#

okay..

elfin isle
wintry quarry
#

It will tell you what's wrong

#

My guess is that Fish is not a Transform

elfin isle
#

nvm wait im just stupid sorry

#

its supposed to be fish.transform.position

eternal needle
wintry quarry
#

I see that he's factoring in x * 2

#

so it's the same yeah

#

but conceptually wrong

tender gazelle
#

so to which one should i change it?

wintry quarry
#

most likely youi should create a special layer for thje ground

#

and put the ground on that layer

tender gazelle
#

So i did all of that. Still shows that something is wrong😭

wintry quarry
#

Find and delete the extra copy of the script

tender gazelle
#

So the Error went away, but my Character still cant Jump. I think it rather lies in the code?

polar acorn
wintry quarry
tender gazelle
wintry quarry
#

only the ground should be on the ground layer

tender gazelle
#

so should i let it on Default

wintry quarry
#

sure

tender gazelle
#

ill try and see if he jumps. If he doesn't then i think it has to do with something in the code

wintry quarry
#

or your ground check object is in the wrong position

#

or the ground is missing the ground layer

#

you should be debugging your code with Debug.Log to find out which

tender gazelle
#

My ground is false. What should i do?

copper wind
wintry quarry
#

and also check that the ground has the appropriate layer as mentioned before

copper wind
wintry quarry
#

the radius is fine

#

as long as it's in the right place

wintry quarry
#

the player collider is also not relevant to this

tender gazelle
#

so my Groundcheck is right next to my character. Should i put under him?

copper wind
# tender gazelle

try setting the 0.2f radius to something really large and have the jump force be really high and see if he jumps just to test where the problem is

wintry quarry
#

what would make sense

tender gazelle
#

under him?

wintry quarry
#

DOn't be so unconfident about everything

#

try it

#

think about how it works

copper wind
tender gazelle
#

IT FINALLY WORKS. Thanks yall❤️

polar acorn
tender gazelle
#

The only problem now is the Double jumps

elfin isle
#

im having a bit of a similar problem now

im trying to make jumping, and i have it working apart from the fact that "speed" affects "y" which in turn m akes it so if im sprinting, i can jump super high

polar acorn
#

So don't multiply the Y by speed

#

Get the horizontal vectors, multiply them by speed, then add the vertical vector

#

Then move that ammount

polar acorn
#

Yeah, or just multiply it by speed in the assignment to movement

remote steppe
#

How do you setup xbox controller? Thought it was this but nada

elfin isle
polar acorn
polar acorn
remote steppe
#

I know

polar acorn
#

It's more complex for super basic things like detecting a single key press but makes different controller bindings basically trivial

remote steppe
#

If this was my personal project yea

#

But we just had to find opensource project and modify it

#

So I'm just using what they had setup.

#

I was going off this image

elfin isle
polar acorn
# elfin isle increase? sorry im not following

If your speed was 10, and your Y movement was 1, before you were moving by 10 units per second. If your speed increased to 20, you'd be moving up at 20 units per second. This is not what you want.

Now, speed is no longer a factor. If your Y movement is 1, you're moving at 1 unit per second, which is less than 10

#

So whatever numbers you were using to calculate y are now giving you a smaller result than before

elfin isle
#

i know how to do that just the problem is

#

i am now moving at insane speeds

#

like x and z values

#

like, accross the whole map in 0.01 seconds fast

polar acorn
#

Are you still remembering to multiply your horizontal speed by deltaTime

remote steppe
#

Got part of it

polar acorn
#

So, no

honest haven