#💻┃code-beginner

1 messages · Page 208 of 1

frigid sequoia
#

I haven't done anything so big yet, so I was just wondering if I should start doing that as an habit

rare basin
#

doesnt matter

earnest atlas
#

He is asking us to comment the code

wintry quarry
#

As much as possible, identifiers should be self explanatory. Comments are for when there's something too complex or weird to understand at a cursory reading of the code

earnest atlas
#

Im not commenting on basic things mostly just What does this does

burnt vapor
burnt vapor
#

Writing code as a learning exercise at school is way different

#

So it's not fair to say that you should not write comments often here

rare basin
warm anvil
earnest atlas
#

now I do. so adding field makes exposes non fields in unity?

earnest atlas
#

I mean that it exposes non fields

burnt vapor
#

Even if it's super clear to you, it's now clear to the teacher

earnest atlas
#

last year I made end of the trimester project in 1 class. C# non unity.
with 0 comments.

teacher wasnt happy

#

it was like 2k lines?

rare basin
#

doing projects for school is much different than doing real projects

earnest atlas
#

So what are differences?

timber tide
#

ah, ok took me a minute but I've honestly been sticking public getters on all my serialized private variables for a while now so seeing it without is alien to me rofl

rare basin
earnest atlas
#

Im kinda here and not here. Discord is on second screen

rare basin
#

not our problem kinda

wintry quarry
#

Whatever the attribute is

earnest atlas
#

omg he is still writing

summer stump
#

What is this for?

earnest atlas
#

its getting longer xD

burnt vapor
#

Please stop spamming the chat already

rare basin
#

spam + full of errors anyway

short hazel
rare basin
#

is your IDE configured Kappa

earnest atlas
burnt vapor
#

Not only is this code completely irrelevant, it's not correctly formatted and above all full of errors. Please stop it already

short hazel
earnest atlas
#

Gl unity

short hazel
#

No because it's unusable

earnest atlas
#

use what

short hazel
#

It's not correct code

summer stump
#

Since this took so long to type, did you do it on your phone? That makes it tough for avoiding repeated stuff. Like you started update, but then opened another update for example

burnt vapor
#

It's literally broken

rare basin
#

I did

#

it's not working :/

short hazel
#

Runs code in parallel

rare basin
#

got errors

cunning raven
#

Always double update

fickle plume
#

!warn 1205955428760944743 Stop spamming on the server. If you continue you will be banned.

eternal falconBOT
#

dynoSuccess makrusbruh111_45325 has been warned.

earnest atlas
short hazel
#

I swear the code I see here gives me ideas for the worst programming language ever

rare basin
#

normal clamp

#

nothing fancy about it

#

eulerAngle.x is just a float

#

it does

earnest atlas
#

Im having issues with gun of enemies...

private void LookAtPlayerWithGun()
{
    var playerPos = _enemyController.Target.transform.position;
    var y = playerPos.y;
    var yClamped = Mathf.Clamp(y, -10, 10f);
    var targetPos = new Vector3(playerPos.x, yClamped, playerPos.z);
    _gunObject.transform.LookAt(targetPos);
}```

I wanted lookAt to not look directly at ground or 90 up
rare basin
#

then you just pretty much answered yourself

languid spire
#

actually, they dont, they resolve to 0-360 but if you want -270 you can have -270

gaunt ice
#

angle%360

rare basin
#

then maybe finally show how did you do it

#

instead of us guessing whats wrong

gaunt ice
#

just depend on the range (-180 to 180 or 0 to 360 or whatever you like)

languid spire
#

and yet you post no code

summer stump
#

I will just point out that it's common to do it the way they're talking about. If it didn't work, it's because of implementation

rare basin
#

tf

languid spire
#

you do if you expect any kind of help

rare basin
#

then what's the problem

#

you know everything

#

if you want to get help, show the code

#

we are not wizards

#

we dont see your code

#

you said eulers go between 0 and 360

#

that is incorrect

#

already explaind to you by 3 people

#

ok

#

im tired of you 😄

#

you can do whatever range you like

#

-180 to 180

#

0 to 360

summer stump
#

Ok then, all of us doing it that way are just imagining it I guess

rare basin
#

do you have some issues with reading things with understanding

earnest atlas
#

What is this lookup overload with second parameter?

languid spire
#

It does work, what you have done may not work but if you refuse to show us the code then you are on your own

rare basin
#

it does work 😉

burnt vapor
#

Otherwise, google

rare basin
#

doesnt work for you != doesnt work

earnest atlas
#

Im looking at docs

#

Then it rotates the transform to point its up direction vector in the direction hinted at by the worldUp vector. If you leave out the worldUp parameter, the function will use the world y axis. The up vector of the rotation will only match the worldUp vector if the forward direction is perpendicular to worldUp.

timber tide
#

just use the world y axis up

short hazel
#

It's basically which way is considered up. If you look at someone while standing on your hands with feet up, the up vector will be pointing down

earnest atlas
#

yeah not what I needed sadly

timber tide
#

for the majority of cases it works, but say you're tilted at a 45 degree angle and you now want to say hey, my transform up direction is now the world up direction

#

something like that

earnest atlas
#

yeah I understand

rare basin
#

im done talking to you at this point

#

you dont understand a single word

#

we just said

languid spire
#

roff, do you know how Quaternions work?

summer stump
#

No...

short hazel
#

-1 to 1

rare basin
#

angleDegrees = (angleDegrees + 360) % 360

languid spire
#

so what do you think you get when you convert a Quaternion to a Euler, which is what localEulerAngles is doing

dapper zenith
#

Yo, im trying to set up some simple A* pathfinding but im having issues getting it to Scan Obstacles.

  • Layer is set to Obstacle on 'ObstacleTest' GameObjects/Prefabs.
    -Obstacle Layer Mask set to Obstacle in pathfinder script inspector for A*

Scan still wont recognise the GameObjects with Obstacle Layer Mask :(((

Not sure where to go, from here. Tried adding various components it might need such as Colliders etc and still no luck.

I've 1:1 did everything in the Brackeys tutorial so not sure why :/

languid spire
#

yes, but probably not the ones you are expecting to get

short hazel
#

Quaternions are complex objects internally, but it's better to work with them compared to Euler angles. They have less limitations.
As long as you know the 4 or 5 methods to manipulate quaternions it's not that hard to deal with them

summer stump
#

But that mistake exposes your misunderstanding about eulers.

Here's all I know. I have clamped eulers before. It works as I wanted. If it did't work for you, you should show the code

rare basin
#

no clue why are you still discussing with this guy

#

he is CERTAIN it doesn't work

languid spire
#

Euler -> Quaternion != Quaternion -> Euler

rare basin
#

and refuses to share code

#

so what's the point

#

either a troll or idk

#

then why are you discussing

#

if you already know the answer

timber tide
#

angle axis is another method you can look into if you can't figure it out

rare basin
#

but regarding to your knowledge

#

it wont work

#

because you cannot clamp it from negative to positive

#

and you are CERTAIN you cannot

#

so how do you want to fix something, that's impossible

#

i've counted 4 people in this chat

#

told you that this is possible

frigid sequoia
rare basin
#

and yet you are arguing with everyone

#

and refusing to share the code

#

so stop wasting our time or just show the code

dapper zenith
languid spire
short hazel
#

You're better off storing the X/Y angles in variables in your script, instead of reading the Euler angles from the Transform, operating on them, and applying them back. This is because for one rotation, multiple Euler angles can represent it. So on two consecutive frames you might get two different vectors

frigid sequoia
polar acorn
#

Degrees can and regularly do go to negative numbers. Unity fucking loves turning euler angles into negative numbers

frigid sequoia
#

I think you can find it on the package manager if you search for NavMesh or something like pathfinding, I don't remember

timber tide
#

similarly, angle axis and store rotational degrees and append the difference in rotations

rich adder
#

its AI Navigation

azure dust
#

2.5D its like 2D game with 3D objects right?

frigid sequoia
rich adder
summer stump
#

Also, not a code question

azure dust
#

but tnx any way

#

for answer

frigid sequoia
azure dust
azure dust
#

Sorry i aks here again, but i want make sure

#

tysm

summer stump
#

All good!

polar acorn
#

What you've read is wrong, and you can prove that by just trying to rotate an object in code and looking at the inspector.

To clamp euler angles, the best way is to add 360 to your angle, min, and max, then do the clamp. Unity will handle the rotation being "out of bounds" and convert it back

frigid sequoia
short hazel
#

You need to post your new code

eternal falconBOT
short hazel
#

Okay I expected much more lol

languid spire
#

man, at this point you are just trolling, either shit or get off the pot

short hazel
#

The usual way of applying a rotation is done with the quaternion. At least, that's how I've learnt it and been using it since

thing.localRotation = Quaternion.Euler(-40, 0, 0);

There's also .rotation if you need it in world space.
Quaternion.Euler() constructs a quaternion with the specified angles in degrees

#

Okay so yeah the lines above are really important, since they also modify the rotation

#

Until line 13, where you read back the Euler angles despite the advice against doing that

#

Seems like you're not using two variables like you told me you'd try doing

languid spire
#

what did I tell you about this?
Vector3 localRotation = cameraTs.localEulerAngles;

#

no, that it will not return the values you expect it to

polar acorn
#

So despite your constant insistence of the latter, the code you've been refusing to show is the source of your problem.

When you get local rotation, you are getting one of infinite possible euler angles that express that orientation. You can do .Rotate on only the X axis, then when you do .localEulerAngles, you could get back an angle entirely in Y and Z

languid spire
#

exactly what SPR2 told you to do

fringe plover
#

I made some simple data save system that saves values from Item class, there is a list of Items that i load, but, i also want to save extra data for manager like LevelSettings, and it should not be in list, can i do that?

timber tide
#

sure why not

fringe plover
#

Am i just need to make another class like Item and put it in file? Or some extra code?

languid spire
timber tide
#

otherwise I just serialize the ID of the SO and make a lookup table of SO/Prefabs

fringe plover
timber tide
#

Thing with SOs is you don't usually serialize by the type, but rather the ID that specifies that specific asset instance.

fringe plover
#

Oh okay..

languid spire
#

you need to store the start rotation in a Vector3, modify that in Update and assign it to euler angles

timber tide
fringe plover
#

Thanks for advice

timber tide
#

and on start of the game I generate a lookup table with keys being the GUID and the instance that it points to

fringe plover
#

Okay ill try

timber tide
#

this way works for most presets, but if you do have settings like a volume slider (some float value) that you want to save, then you go with adding these values into a struct which you would serialize instead.

fringe plover
#

Thank you... i didnt even know about structs lol😅
It will help me a lot

timber tide
#

So for example, you have a GunSO that has instance Glock, you'd have a ID that refers to that Glock instance and a struct that has previous session values of upgrades, loaded ammo, ect.

fringe plover
# timber tide So for example, you have a GunSO that has instance Glock, you'd have a ID that r...

Ye i do same ig, but instead i save pos, rot, and id, and when player load file it create new objects by IDs, ill may add some extra data soon, like customString1/2/3 and etc, cuz i dont want to create tons of code just to keep some stuff, like, if there is a specific item to use with object, ill just get that custom string, and i have different class that get all data from Item and does stuff, so, if ID = 19 it will just add component, and values like object to unlock and etc will be just these custom strings or etc.
Is it good idea? Im still not that good at code..

fierce sonnet
#

hi, i am currently programming a evolution simulation and i have problems with the field of view always outputing angle = 0 even though the direction changes. I have print multiple values and aslo tried Vector3.Angle and inputting vector 2 to vector2.angle or vector 3 to vector2.Angle.

// Method to check if a given position is within the angle of view bool IsWithinAngleOfView(Vector2 position) { Vector2 direction = position - new Vector2(transform.position.x, transform.position.y); float angle = Vector2.Angle(direction, transform.forward); return Mathf.Abs(angle) <= angleOfSight / 2; }

timber tide
#

then let your load manager handle how this object should be constructed with the limited data saved

fringe plover
#

Oh okay, thanks

timber tide
#

Enum and strings like you've mentioned can be another way to identify what components will be needed to construct these objects.

mortal bridge
#

is this a big deal?

queen adder
#

Ur I.D.E is saying that doesnt make any sense

#

Why have a parameter when ur just gonna hard set the value anyway?

languid spire
rich adder
# mortal bridge

setting a method parameter to not use it anywhere makes no sense

mortal bridge
#

but I am using it

rich adder
#

no ur not

mortal bridge
languid spire
#

you are setting the parameter timer not the class variable timer

mortal bridge
#

ohhh

#

wait this doesnt work

languid spire
#

so why have a parmeter if you dont use it?

mortal bridge
#

I am planning to tho Im confused

#

researching paramters now

rich adder
#

do yourself a favor and take a basic c# course

mortal bridge
#

I did myself that favor years ago just gotta remember now

#

Ive not used this in a long time

languid spire
#

this is very basic programming, perhaps you are well named

mortal bridge
#

😂 thanks

burnt vapor
#

Not just with this., private fields should start with an underscore

languid spire
#

not the style police, again

rich adder
#

oh please, they're missing basic of c# you think that code style is relevant now ?

mortal bridge
#

Ive done the int part succesfully

burnt vapor
#

The issue is having similarily named variables, and this fixes it. Get off my back

mortal bridge
#

float part is kinda rough for me

mortal bridge
rich adder
#

they should learn what is even the point of having method params UnityChanLOL

nocturne parcel
#

the c# president?

burnt vapor
rare basin
burnt vapor
#

And considering the issue is similarity of variable names, worthy to point out

nocturne parcel
#

Basic convention is starting a function with a capital letter. Underscore is definitelly not enforced.

mortal bridge
rich adder
#

yes _ is def for private but no one forces you and you should not care to enforce it

mortal bridge
#

I was planning on using it later

burnt vapor
languid spire
#

The style police, people who cannot think for themselves and want to impose their misguided view on everyone else

burnt vapor
mortal bridge
#

you shouldnt argue here please

#

he gave me a recommendation taking it or not taking it is up to me

rich adder
#

guys look

#

lets not argue over code style

#

its not relevant here

hybrid gust
#

How do I check if the PlayerInput.currentActionMap == a certain action map. I'm having trouble actually referencing the target map I want to check the epression on

burnt vapor
# rich adder guys look

Code style is a fix to the issue they were facing, see the exception to the rule you just pointed out

#

Now stop the bickering unless you're actually here to help, both of you

rare basin
nocturne parcel
#

Yes, an _ will fix his problem.

languid spire
#

rolf, no it wont

rich adder
queen adder
#

Thats not his problem

nocturne parcel
#

Exactly, that's the point.

queen adder
#

His code doesnt make any sense

rich adder
#

their original issue is they dont understand how method params work

rare basin
queen adder
#

He has a float parameter he then hard sets the value anyway making the parameter portion make no sense

earnest atlas
#

https://hatebin.com/lnaifawrvh
For some reason healthbar appears really suddenly.
Even with _timeAlfaChange set to 1 second. It shoud take 10 seconds to appear instead it appears instantly.

rare basin
#

for that

earnest atlas
#

dot?

rich adder
#

DO Tween

queen adder
#

Pronounced Dough Tween

rich adder
#

not dot

rare basin
#

healthbar.DOFade(0, 1)

#

will make your healthbar

#

fade to 0 alpha

#

in 1 second

burnt vapor
earnest atlas
#

Oh

rare basin
#

it's a free library

#

from asset store

burnt vapor
#

That's why the underscore fixes it

rich adder
#

I mean this.varname works fine to fix it..

#

but not original issue

rare basin
#

DOMove, DOFade etc

burnt vapor
#

Let's drop the argument here

rich adder
rich adder
earnest atlas
#

In packages?

rare basin
#

in asset store

queen adder
#

Yeah its a pretty popular package

rare basin
#

used in every of my project

hybrid gust
rare basin
#

you have very nice function you can chain like

#

.OnCompleted() etc

hybrid gust
#

thx

earnest atlas
#

And how Im supposed to add functions from it?

rare basin
#

so you can do

healthbar.DOFade(0, 1).OnCompleted(/* do stuff after the fade is completed here */);
queen adder
#

I would check the docs as well as the new Input System is pretty complex

earnest atlas
#

Just download and import?

rich adder
rare basin
#

then you can use it

#

just add the namespace

mortal bridge
#

Ive fixed it

queen adder
#

Lets see the new code

earnest atlas
#

namespace? like using DOTween?

rare basin
#

yup

#

IDE might add it automtically tho

#

when you'll try to dotween functions

rich adder
#

the only thing shitty about dotween is the documentation

mortal bridge
rare basin
queen adder
#

Fair enough tbh

rare basin
#

anything in particular?

rich adder
rare basin
#

well yea

rich adder
#

and linkable snippets with explenation of methods properly

rare basin
#

@earnest atlas

#

DOTween is the very first thing I install upon creating a new project. Animate your position, rotation and scale in a single line of code, with all the customization you could hope for... and that's only scratching the surface.

For the full documentation: http://dotween.demigiant.com/documentation.php

❤️ Become a Tarobro on Patreon: https://ww...

▶ Play video
#

watch this

#

should help you get started with dotween

#

amazing asset ngl

#

and for free

rich adder
#

they should use something like DocFX

queen adder
#

Unity community stay making unity useable No offense mods

rare basin
#

can be litearlly just

#

healthbar.DOFade(1, duration);

#

instead of doing coroutine + while loop

earnest atlas
#

yeah Im implementin it

sleek notch
#

Hi, I want to do equip backpak but if it spawn it spawns somewhere else where I don't want it. How can I spawn object where is his parent?

summer stump
eternal needle
languid spire
sleek notch
sleek notch
#

by code

rare basin
#

why are you instantiating a object and destroying it at the same time

languid spire
eternal needle
sleek notch
#

okay

nocturne parcel
#

Then they are destroying the original

summer stump
nocturne parcel
#

The clone stays

summer stump
#

They just want to parent the object to themselves

#

They are destroying one instance and creating another just to parent it

nocturne parcel
#

Yeah, just answering that it is not destroying the same object

summer stump
#

Oh, I see

#

Yep, valid

honest haven
#

i see loads of people in tutorials do this, is there any point when its false already

eternal needle
languid spire
#

or not serialized, it could generate a not initialized compiler error

honest haven
#

ah ok thanks, i just do it cuz they did it

languid spire
#

tbh it's not a good idea to initialize serialized variables, they can give you a misleading idea of what the value actually is

sacred harness
#

why is it when slerp is 1 its giving me the wrong angle instead of 45 its giving me 60 while 0.1 gives me around 45 i got two objects that rotate on the x axis [0,90] average should be 45 https://pastebin.com/enBYahjA

honest haven
#

yh makes sence

#

sense

rare basin
#

couple of hours ago

sacred harness
#

yes the other guy just left and it didnt answer why 1 was giving me 60

rare basin
#

everything got explained here

#

he did

#

you even confirmed your mistake

#

lol

sacred harness
#

no it didnt we just said 0.1 was updating every frame which did work like i said but didnt explain why 1 is giving me 60 if i missed it do tell

rare basin
#

read the convo again

#

where i linked

sacred harness
#

where do we talk about 1 giving me 60 when it should be giving me 45 am i blind?

rare basin
#

it shouldnt give you 45

sacred harness
#

exactly

rare basin
#

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

#

you are changing transform.rotation every frame

eternal needle
#

Using quaternion and attempting to read the euler value is a bad idea. I dont know what these magic numbers are of 0.1 60 etc but dont trust the inspector values. These are euler angles converted from the quaternion

sacred harness
#

but within 1 frame they both should be at 45 which the average just repeats itself to 45

languid spire
#

not this bloody conversation, again

summer stump
sacred harness
#

i did i was just answering the other guy but ill just leave it

languid spire
#

do not ever expect a Quaternion to give you understandable or expected results

naive lion
#

Anyone know how to safely exit this infinite loading loop or is alt + f4 fine?

#

also anyone know what causes this

earnest atlas
#
    private void LookAtPlayerWithGun()
    {
        var playerPos = _enemyController.Target.transform;
        _gunObject.transform.LookAt(playerPos);
    }```
Why this happening?? LookAt works weirdly
summer stump
#

And yeah, just kill the program any way you wany

harsh sandal
#

If you didnt save, your scene will revert to the last save

naive lion
#

speaking of which

#

i just found the loop culprit

earnest atlas
summer stump
#

There is a single backup you can retreive if you don't open unity again, so you don't lose your progress

naive lion
#

okay yeah just checking if hard closing is fine

harsh sandal
#

When its entering play mode like that, your fine to close it. When its doing other things like compiling the project, i wouldnt risk it and just let it sit personally.

naive lion
#

awesome, thanks

summer stump
#

For compiling, it's actually safer. The code is saved externally

#

If it is compiling, it is already saved

harsh sandal
sly wasp
eternal needle
summer stump
#

The only thing lost is the unity side of things when closing unity

earnest atlas
#

What to do with look at when transform front is Y axis and not Z one?

polar acorn
earnest atlas
#

How to rotate this?

rich adder
eternal needle
#

Either parent it to a empty GO and rotate that so that it aligns, or fix the model properly and rotate it in like blender

sly wasp
polar acorn
#

Main texture changes a texture parameter of a specific name

#

You can see what that is in the documentation for it

sly wasp
#

WOWW hmm is blocked

#

so i think i see what youre saying

#

one sec

polar acorn
# sly wasp

Did you name your texture property correctly
Main texture changes a texture parameter of a specific name
You can see what that is in the documentation for it

sly wasp
#

so
customMat.SetTexture("Texture2D", customTex); ?

#

I tried that and it didnt work

short hazel
# sly wasp I tried that and it didnt work

The name displayed in the graph and the property name are different. Make sure you use the property name, you can see it when you open the settings of your parameter.

short hazel
#

That's the display name

#

Open the settings and you'll see there's two

sly wasp
#

WAIT I GOT IT

#

I put an _ before Texture2D and it worked!!!

#

Thanks

short hazel
sly wasp
#

Ok

cobalt creek
#

i made script that change var from other scriptwithout drag, is this fine or is there better/shorter way?

mainScript main = GameObject.Find("Canvas").GetComponent<mainScript>();
main.health--;
short hazel
#

The better way is to drag-drop

cobalt creek
#

thank

cobalt creek
small mantle
#

I have this object as a child, so when the bullet is spawned in it moves with the player. How can I make it spawn outside the Player but still at that position? cs Instantiate(bulletPrefab, firePosition);

Edit: It was wrong because I needed to do cs Instantiate(bulletPrefab, firePosition.position, Quaternion.identity);

timber tide
#

there's like 8 overloads

small mantle
#

I want to know how I can simply make my direction for where the Player shoots change according to its Y rotation. 2D (Currently I have a script for Bullet and Movement script which is where I flip the Player)

earnest atlas
#
        GameController.Instance.GunRotation = _gunObject.transform.rotation;
        Instantiate(_bulletPrefab, _gunObject.transform.position, _gunObject.transform.rotation);```

Im thying to spawn a bullet with same rotation as the gun. And its not rotating for some reason?
#

The gameController one is me trying to force the rotation

timber tide
#

What I like to do is get the forward direction of the player and use lookrotation to initialize the rotation of the projectiles

earnest atlas
#

its enemy rotation and I need gun rotation

#

the gun has LookAt

rocky canyon
#

or u can just match the rotation and then launch it forward.. same thing

earnest atlas
#

Im smelling some bs

rich adder
#

jesus that non-uniform scale

#

hope ur not rotating it, that will cause issue

earnest atlas
#

Its just to make it in a form of a long bulleyt

#

let me guess I need normal object to rotate it correctly...

rich adder
#

make sure u only modify the visuals then, never modify scale of the Main root object

#

ie visuals always go as child of root

#

and be scaled individually

#

idk ur original issue though lol just butting in to say that reminder

earnest atlas
#

yeah I know that issue

#

I made the prefab now in normal object lets see if it commits die now

#

Ask

crisp moon
#

I have some questions that are probably common?

ok what are some good beginner projects for a beginner and should i go with 2d or 3d?

what is the best way to learn without become reliant on videos and such?

what version of unity should i be using and how do i know if unity is for me or not?

i might have some more questions latter down the line too?

earnest atlas
#
  1. I started with basic 2d then moved to 3d.
  2. Do things. You will always be reliant on google.
  3. Dnno download it form unity web. Im using the standart.
crisp moon
#

is there anything else you would like to add or tell beginner in the world of unity gamedev?

earnest atlas
#

I hate bullets. Im going for raycast

#

But with raycast enemy is just gonna shred the player omg

rocky canyon
# crisp moon I have some questions that are probably common? ok what are some good beginner ...
crisp moon
#

Thank you both for telling me theses things.

rocky canyon
#

np, good luck 🍀

crisp moon
rocky canyon
#

make sure to get ur IDE up and running w/ unity.. it'll help you along the way by highlighting errors as you code.. !ide

eternal falconBOT
rocky canyon
#

visual studio community is my pick of the litter

earnest atlas
#

What you think about this?

rocky canyon
#

if u do the (via Unity Hub) method.. it'll be easier as u'll be downloading unity anyway

rocky canyon
#

but thats just personal preference stuff

earnest atlas
#

Well imagine your enemy has raycast hit detection

rocky canyon
#

could be simpler.. "what that function does"

#

ReturnRandomVector()

earnest atlas
#

Im just taking a piss at that name

short hazel
#

Do not use var when the type on the right of the = is not apparent.

rocky canyon
#

^ good tip

earnest atlas
#

Well there is kinda aparent due to naming

#

also whatever Extension I have is telling me to throw var everywhere

rocky canyon
#

w/o the tooltips u have enabled. it'd be harder for someone to glance and know

crisp moon
#

Im curious but what was all of yalls first unity game/build? if you dont mind me asking that is or is this the wrong channel for that?

earnest atlas
#

Platformer 2d

short hazel
#

I think the random can be simplified to return player.position + (Random.insideUnitSphere * 5);
But yes it does require you to deduce the type by looking at the expression

crisp moon
earnest atlas
#

Random.insideUnitSphere * 5);

What does this do?

short hazel
#

InsideUnitSphere gets a vector that points randomly, and its length is between 0 and 1

#

Multiplying by 5 extends the radius to 5

rocky canyon
# earnest atlas What you think about this?
private static Vector3 GetRandomOffset(Vector3 startingPosition)
{
    float xOffset = Random.Range(-5f, 5f);
    float yOffset = Random.Range(-5f, 5f);
    float zOffset = Random.Range(-5f, 5f);

    Vector3 newPosition = startingPosition + new Vector3(xOffset, yOffset, zOffset);

    return newPosition;
}```
this would be my version.. pretty similar
#

Passing in a vector3 instead of a transfomr.. since thats what id be grabbing anyway

short hazel
#

Also you would use -5f, 5f otherwise it only returns integers

rocky canyon
#

ahh true

earnest atlas
#

yoinked

crisp moon
rocky canyon
#

yea, highscore games are the easiest to start with

earnest atlas
#

Pretty much the same first project

#

but in 2d

crisp moon
#

i have abunch of ideas but they seem hard and i dont have time to do them, which i heard all coders struggle with at first.

rocky canyon
#

ya, i didnt move over to 2d until here lately.. (2 years in unity)

#

angry birds / flappy birds are also a common starting project

crisp moon
earnest atlas
#

Okey adding that random vector

#

Is too funnny

rocky canyon
earnest atlas
#

How to upload a video?

rocky canyon
crisp moon
rocky canyon
#

u don't have to know modelling to do a 3d game

crisp moon
earnest atlas
rocky canyon
crisp moon
rocky canyon
#

theres chances u might not be able to find what ur looking for... but as a beginner ur probably not gonna wanna be too worried about how it looks

#

cubes and spheres will suffice

rocky canyon
earnest atlas
#

Never something backfired so fast and so bad xD

crisp moon
#

my dream games are either an open world game or a visual novel and im not sure how to work towards that or if its possible for me to do.

earnest atlas
#

Im interested in working on voxel

#

7dtd type of game.

crisp moon
earnest atlas
#

It is, but most likely is on levels of insanity

crisp moon
earnest atlas
#

same

crisp moon
#

do i need to know 3d modeling to make a 3d interior (like inside a house), or is that what free assets are for?

rocky canyon
#

theres free assets for that too.. maybe not a house

earnest atlas
#

free assets are pretty much the only assets you gonna use when you study

rocky canyon
#

but interior spaces.. besides u can make a house w/ blocks..

#

1 big block for the wall.. and 2 smaller blocks for the baseboards and crown molding 😄

earnest atlas
#

Enjoy you house

languid spire
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rocky canyon
crisp moon
sterile radish
#

how can i make a static integer not save between scenes?

rare basin
#

you cant

sterile radish
#

alr shouldd i just set it to 0 on start()?

rare basin
#

just dont make it static

dense cypress
#

        //raycast direction
        Vector3 rayDir = transform.TransformDirection(new Vector3(0,-0.75f,0));

        //actual raycast
        if (Physics.Raycast(rayStart, rayDir, out RaycastHit stepLocation, 1.5f))
        {
            //make bottom of player teleport to point
            Vector3 stepLocation2 = stepLocation.point + new Vector3(0, 1, 0);


            transform.position = stepLocation2;
        }```

Trying to recreate cc step going up and with this I just fall through the floor. I think the problem is it's just putting me down constantly but I don't know how to fix it.
summer stump
sterile radish
#

it is an integer representing how many enemies are currently alive in the current wave

rare basin
#

just have some kind of WaveManager

summer stump
rare basin
#

and make normal int

#

making it static is just you having no idea for good architecture

eternal needle
#

Also use the debug draw ray methods to visualize where your ray is

dense cypress
#

I did not know debug draw was a thing but I will be using this constantly for the rest of my days

#

thank you good sire

queen adder
#

What is the difference between **ExecuteAlways **and **ExecuteInEditMode **Attribute?

queen adder
#

It seems the main difference is ExecuteAlways executes even in prefab mode while ExecuteInEditMode protects you

sweet osprey
#

I'm trying to store multiple scripts into a single List.
I'm getting an error about how each script in the list is a "type which is not valid in this given context"
What might be a fix?

summer stump
#

Oh, and you don't store the type

sweet osprey
summer stump
#

You store an instance

rich adder
summer stump
summer stump
#

And doing what you are doing is c#

sweet osprey
frozen stream
#

If I invoke a function in update, and the timer for it to start is longer than the update cycle, will it make multiple calls of the invoked function, or will it wait for it to end first?

frozen stream
#

thanks

short hazel
#

Multiple calls, as Update will run a few times before the first invocation

spiral narwhal
#

I'm having an issue where transform position is the position of the layout game object, not the item in that layout.

        public void AddCard()
        {
            Assert.IsTrue(_handCardViews.Count < PlayerHandService.MAX_HAND_CARD_AMOUNT);
            var newCard = Instantiate(_handCardPrefab, transform);
            newCard.Create(this);
            _handCardViews.Add(newCard);

            RecalculateTransformsAndIndexes();

            var drawnCardPrefab = Instantiate(_drawnCardPrefab, _drawnCardTransform);
            drawnCardPrefab.MoveTowardsCard(newCard); // <---- Passes the instance of the created card in that layout
        }

        // MoveTowards:

        public void MoveTowardsCard(HandCardView cardView)
        {
            _view = cardView;
            _targetPosition = cardView.gameObject.transform.position; // <---- I expected this to be the position of the card (in the screenshot the one in the center right, for example). But it moves until the start of the layout object
        }
warm anvil
#

question, I'm going to start diving into menu navigation with a gamepad. Few questions:

To help prevent reinventing the wheel, is it common to use the "Input System UI Input Module" component?
If I were to use that does that mean I need to use it with buttons only? reason I ask is tutorials that I'm watching/learning involving inventory systems typically create the slots using empty gameobjects.

...start with that for now

rare basin
#

this is a code related channel

spiral narwhal
warm anvil
#

so that removes the option to use gameObjects as slots which can be navigated around, right?

#

Sorry, sound this be more in the ui-ux or ui-toolkit channel?

spiral narwhal
#

I really don't know what you mean by slots

broken trellis
#

Man, this is REALLY hard to figure out. Now my map sprite disapears and Ctrl Z isn't fixing it

warm anvil
#

think displaying an inventory grid, each one has a slot but they're really square gameObjects

warm anvil
#

I'll take this to one of the other channels though. Thanks so far

broken trellis
spiral narwhal
broken trellis
#

Even then I fixed it lel.

shell sorrel
earnest atlas
#

that random spread got nerfed a bit
||a lot||

summer stump
#

(You have inside unitY Circle)

verbal dome
shell sorrel
#

but yeah guess its box vs sphere though generally find sphere more useful

summer stump
#

And the sister method (not relevant here) OnUnitCircle is great too

#

Oh sorry. Yeah sphere

earnest atlas
#

where its long lost brother OnUnitCapsule?

verbal dome
#

Yeah I also use sphere more often

shell sorrel
#

yeah i know, edited it

summer stump
shell sorrel
#

i do that typo way to much

warm depot
#

I'm getting a "The name 'Instantiate' does not exist in the current context" error. But I have "using UnityEngine;" in the script. Does anyone know what's happening?

shell sorrel
#

you might have to do a Object.Instantiate instead

warm depot
#

it's a game object

#

GameObject.Instantiate worked

#

thank you

shell sorrel
#

i meant the script

#

its not extending MonoBehaviour if it does not have Instantiate

verbal dome
#

You are probably used to extending from MonoBehaviour.
If you don't extend from that (or other UnityEngine.Object classes) you can't just straight up call Instantiate

shell sorrel
#

looks like a class for a fsm

warm depot
#

yes its extending from FSMState

shell sorrel
#

keep in mind you also lose StartCoroutine as well, and you need a real instance for calling that

summer stump
earnest atlas
#
        _healthBar.transform.LookAt(_enemyController.Target.transform);
        _healthBar.transform.rotation = new Quaternion(_healthBar.transform.rotation.x, 0, 0,0);```

Will this make something looked at but ignore only look at it with X rotation?
#

Needed only Z one. But anyway same question

frigid sequoia
#

Is this error my fault or it just a random Unity error?

shell sorrel
shell sorrel
frigid sequoia
#

Cause I don't think I touched anything and I don't know what that message even means

shell sorrel
earnest atlas
#

?? no?

shell sorrel
languid spire
frigid sequoia
shell sorrel
earnest atlas
#

Will this work?

shell sorrel
#

just clear it and see if it happens again

shell sorrel
#

is that intended

earnest atlas
#

Yes, totally 🙂

rocky canyon
shell sorrel
#

but yeah with a regular Quaternion the x, y ,z ,w do not repersnet what most people think they do. so generally always better to work with quaterions with the static methods it provides and not new

graceful spruce
#

Hello, how can I make it so the game chooses a random scene.

For example: I have 3 scenes of different colors, I want to make it so when I click on a button it loads anyone of these 3 scenes.

earnest atlas
#

Array with scene names

graceful spruce
#

Any documentations or videos would be helpful

shell sorrel
#

and make a array of scenes

earnest atlas
#

Random.Range(0,sceneArray.count)

graceful spruce
#

TNG_ilikebeer thanks so much ❤️

#

have another question, I'm planning on making a level where anvils drop on players and they have to dodge it in 2D how can I make the objects/anvils drop along x axis

#

I watched videos they all explain on how to make it spawn at random positions

#

but I want it to be random along x axis

earnest atlas
#

Sometimes I wanna hang chatgtp on a rope

shell sorrel
earnest atlas
#

_healthBar.transform.rotation = _enemyController.Target.transform.rotation;

How to make healthbar rotation face player. Sets its rotation to players rotation

#

1000iq

modest dust
#

Why even use GPT for such easy tasks

#

Try actually using your brain for a change

earnest atlas
#

I dont undestand vectors like at all

modest dust
earnest atlas
#

On some absolutly subcontious level my brain denies their undesrtanding

shell sorrel
# graceful spruce YES

same function i showed you before, can use it to get a random number in a range, and feed that into the x position of the anvils

earnest atlas
#

Its like division in computer.

shell sorrel
# graceful spruce YES

so could do like float x = Random.Range(-5f, 5f);
then use that x to overwrite the x position on the objects you want to drop

earnest atlas
#

I love the fact that people are still discussing a way to get 3 random variables

orchid phoenix
#

I asked chat gpt for code that destroys objects and he just used Debug.Log("DestroyObject")

graceful spruce
earnest atlas
modest dust
earnest atlas
#

IF AI fails with vectors what Im supposed to do

modest dust
#

Learn vectors?

earnest atlas
#

That thing is consuming like thousands times of power then I do

shell sorrel
earnest atlas
#

I have better undestanding of quantum fisics then vectors

shell sorrel
#

not a concept that takes that long

earnest atlas
#

I just cant understand them, they evade my understanding

orchid phoenix
#

Guys, is it worth to buy an horror kit?

cosmic dagger
earnest atlas
#

If you have lots of money for some reason then dnno

orchid phoenix
modest dust
earnest atlas
earnest atlas
orchid phoenix
earnest atlas
#

Can you make a good horror game now without 50 bucks of assets?

modest dust
orchid phoenix
sweet osprey
earnest atlas
#

Then you dont need 50 bucks of assets

white quartz
orchid phoenix
rich adder
modest dust
earnest atlas
#

is something stolen considered stolen if its stolen again

white quartz
orchid phoenix
rich adder
#

but yeah its nonsense mostly

earnest atlas
#

The less known language is it the more it hallucinates

shell sorrel
orchid phoenix
modest dust
earnest atlas
inland cobalt
#

Hey all, say i have a ball, thats travelling in a general direction to the right, could be diagonally up/down etc. How would i go about figuring the 2D coordinate where it would pass a certain point? Hope that makes sense. I've drawn a rubbish paint diagram to try and clarify what i mean. (Using rigidbodies for assigning its velocity and gravity does not exist)

white quartz
#

if (chatgpt == true)
    IQ = 0;
orchid phoenix
earnest atlas
#

we have a pirate here

rare basin
white quartz
#

sorry lol ive been coding in python for the past week so im not the sharpest on c#

rare basin
earnest atlas
#

Once I tried to make chatgpt filter me a list from rubbish. Basically was just trying to get mod names without their descriptions.

orchid phoenix
earnest atlas
#

Dude

#

You just got told

earnest atlas
#

Facepalm

orchid phoenix
earnest atlas
#

Yep

orchid phoenix
#

Goodbye guys

earnest atlas
#

On top with at best questionably gotten assets later you wont be able to publish anything.

rich adder
#

admit to piracy , not the brightest tool in the shed are ya

earnest atlas
#

does Standard Unity Asset Store EULA allows to publish paid games if those assets are used in production?

rare basin
#

if you buy the asset

#

you can use it comerccialy

#

obviously

earnest atlas
#

Im just not sure with all that legality

shell sorrel
#

read its license

earnest atlas
#

Im reading the standart one but so far didnt see anything about sharing

rich adder
#

asking legal advice on discord would not be your best bet

shell sorrel
#

rather do that then trust random internet people

modest dust
earnest atlas
#

well its mostly just shower thought. Im not planning on releasing anything now

cosmic dagger
earnest atlas
#

And so far public free assets did the job

inland cobalt
orchid phoenix
earnest atlas
#

if you want some specific point you can just check for coordinates or trigger

chilly moat
#

My brain is failing me guys I need some quick help...

How do I get a random point around P but between two radii ?

inland cobalt
quaint crystal
#

hello. is there a component that automatically creates a bounding box of all children?

swift crag
# chilly moat My brain is failing me guys I need some quick help... How do I get a random po...
orchid phoenix
#

Anyways, Im going to buy the horror kit

rocky canyon
#

whats the problem? u cant just post random code.. and expect us to just guess and look for an unkown issue

swift crag
#

You need to pick a random angle, then pick a random radius

#

The radius sampling is the slightly involved part.

earnest atlas
#

buy 😄

swift crag
modest dust
chilly moat
swift crag
#

RM is the outer radius. Rm is the inner radius

inland cobalt
rare basin
swift crag
#

The formula is pretty simple. Most of the answer is just explaining how they got there

rich adder
#

good stuff!

swift crag
#

ha, there you go (:

earnest atlas
#

Im not exactly sure what you want

earnest atlas
#

A typo I cant make go away

rare basin
#

ohh, physics

rocky canyon
#

what does it sound like?

#

😉 lol

rare basin
#

i thought its some fisics formula like fibonnacci

#

or something lol

earnest atlas
#

.1f?

north kiln
#

How have you declared ground

rich adder
#

and assigned it?

earnest atlas
#

it will spawn the sphere exactly in middle of groundCheck.position

#

it being 0.1 it might just not reach it

rich adder
#

always best draw the Gizmos when possible to verify those

earnest atlas
#

also considered pros of a sphere allowing to stand near cliffs and such because how it detects collision.
0.1f works more like rayhit but with more calculations

trim gulch
#

Is it possible to add Corutines to events? I'm trying to do so, but it says that the return type of the corutine function is not compatible with the current event

modest dust
# inland cobalt ty!

oh and make sure to add currentY to your desiredY as well

deltaX = desiredX - currentX
desiredY = velocityY * (deltaX / velocityX) + currentY

rich adder
#
private void OnDrawGizmos() 
    {
        Gizmos.color = Color.green;
        Gizmos.DrawSphere(groundCheck.position, 0.1f );
    }```
earnest atlas
#

that ^

rich adder
earnest atlas
#

You can link an event to a function. Not sure if you can do it with StartCoroutine(smthg());

verbal dome
earnest atlas
#

When I tried to link with lambdas whatever assist I have is complainig about something

rich adder
#

you need to debug instead of just sending unrelated info

trim gulch
# verbal dome What did you try?

I have a "StartFirstBattle" event, and a "StartSpawning" function in my spawner. Originally I made it with "async" to wait between spawns, but I'm building with WebGL and it doesn't seem to work, so I just turned the same StartSpawning to a IEnumerator and try to do it with corutines, but that happens

rich adder
# trim gulch Huh

I meant cs public void StartRoutine(){ StartCoroutine(Routine()); } IEnumerator Routine(){ yield return null; }

earnest atlas
#

what the hell is on the left

rich adder
#

I said debug it first visually with gizmos

earnest atlas
#

well me go sleep

#

see ya

rich adder
#

checksphere sucks to debug because doesn't give any hitinfo , just bool

#

show the inspector for the script btw the one on the gameobject

#

ok and can you show you put the floor in Ground layers

#

send full !code with website link ⏬

eternal falconBOT
rich adder
#

use components

#

but it sounds like you need Layers here

#

for grounds

#

just put the floor in the Ground layer

#

I think with the new search

#

this thing

#

wait nvm

#

oh yeah it does work I just renamed the object

west sonnet
#

I'm using Raycast for enemy detection. Is it better to put it in Update() or FixedUpdate()?

fierce sonnet
#

hi, i am currently programming a evolution simulation and i have problems with the field of view always outputing angle = 0 even though the direction changes. I have print multiple values and aslo tried Vector3.Angle and inputting vector 2 to vector2.angle or vector 3 to vector2.Angle.

        bool IsWithinAngleOfView(Vector2 position)
        {
            Vector2 direction = position - new Vector2(transform.position.x, transform.position.y);
            float angle = Vector2.Angle(direction, transform.forward);
            return Mathf.Abs(angle) <= angleOfSight / 2;
        }```
rich adder
#

I usually just use them as NonAlloc and inside of a coroutine

#

some of my enemies have slower detection rates to keep perfomance up and dont need to be super responsive , even thought 0.1f-ish is pretty responsive

swift crag
#

You can perform raycasts anywhere. The only thing that might matter is if you've just moved a collider

formal arch
#

is there a function that will run when the gameObject becomes active? told by my lecturer there was but forgot the name

rich adder
swift crag
swift crag
formal arch
#

ty

swift crag
#

(or until the next physics update)

#

doing it in FixedUpdate wouldn't really help, since the physics update happens after FixedUpdate runs

meager raptor
#

hello, i'm playing around in the inspector and i'm having trouble having the unit going at a constant speed

it keeps accelerating, but if i set acceleration to 0 then it doesn't even move

do i need to hard code this in or is there something i need to do?

rich adder
#

Yeah I usually do them in Update or Coroutine, never done it in FixedUpdate myself

swift crag
#

If you want to minimize the amount of speed changes, set the acceleration to be much higher than the speed

#

That will make the agent very rapidly reach its maximum speed

rich adder
#

at least that helped mine when they reached corners or other agents it would slow down

swift crag
#

autoBraking controls how it behaves when approaching the destination

swift crag
#

i wouldn't expect this to change how the agents interact with corners or other agents

#

Obstacle Avoidance settings will influence this, though

rich adder
#

worked for me 🤷‍♂️

swift crag
#

(for other agents, at least)

west sonnet
#

Trying to make an enemy detection script using Physics RayCast but I can't get it to work. This is what I've got at the moment, but from what I can see, it's not doing anything. I also can't see the option to enable the Raycast gizmo during play mode. Raycast gizmo is not appearing in my gizmo list

swift crag
#

there is no "raycast gizmo"

#

you can use Debug.DrawLine and Debug.DrawRay to draw lines

#

Is 9 the ID of a layer?

#

If so, this is wrong. That fourth argument is a layer mask, not a layer ID

#

use LayerMask.GetMask("LayerName1", "LayerName2", ...) to produce a layer mask from one or more layer names.

#

LayerMask.GetMask("Enemy", "Map") would be a mask that accepts Enemy and Map layers

west sonnet
#

Oh, I see

#

When using Debug.DrawRay, why is the direction and the length of the ray determined by the same value?

#

That doesn't work, right? Because in my RaycastHit2D, my length and direction are different values

west sonnet
#

On the Unity Doc. The second value dir, determines the direction and length of the ray

west sonnet
#

Direction multiplied by length?

rich adder
#

indeed

west sonnet
#

How does that work?

#

What if I needed my direction to be 90 but the length to be 5?

frosty hound
#

Provide a direction that is length of 5

rocky canyon
#

its still the same

west sonnet
#

But 5*90 would be 450?

frosty hound
#

Normalize your direction first

#

Then multiply it by 5

west sonnet
#

Is it possible to make it so that the RaycastHit2D not detect something is there is an object with a collider between it and the target?

rare basin
#

filter the raycast by layer masks

#

and raycasthit just stores info about the hitted object by raycast

#

it doesnt "detect" anything

west sonnet
#

Well, right now the raycast only detects my player layer mask, but if I have an object between my player and the enemy, the enemy still detects the player when within range, even with the object in between the two

rare basin
#

layerMask Filter to detect Colliders only on certain layers.

rich adder
west sonnet
#

I'm using that. I have input my player layer mask, but it still detects though objects

rich adder
#

ofc

west sonnet
#

The object is in the environment layer

rich adder
#

you only made it want to detect player layer

west sonnet
#

But it should stop the raycast, right?

rich adder
#

no?

cosmic dagger
#

It will only detect objects on the layer you provide . . .

short hazel
#

Objects not in the mask will not be detected by the raycast

rich adder
#

you told it to ignore other layers besides player

west sonnet
#

Oh

short hazel
#

It's the point of a mask, to selectively ignore some layers

west sonnet
#

So, how could I go about preventing the enemy from detecting the player when an object is between them, like a wall?

cosmic dagger
#

You need to use the raycast method that returns a collider or place the group of objects on the same layer . . .

short hazel
#

Do not pass a mask?

rare basin
#

or dont pass a layermask at all

verbal dome
#

Include the wall's layer on the mask

#

Or yeah none

rocky canyon
#

craziness

west sonnet
#

But if I don't pass a layermask, how would it detect my player?

rare basin
#

jezus

rocky canyon
#

if theres a wall in the way it wouldnt

rare basin
#

read the docs

#

i sent

short hazel
#

Without a mask, everything is included

rocky canyon
#

if theres not a wall in the way it would.. it would detect everything that has a collider

rare basin
#

if you are casting it from the middle of enemy for example

rich adder
#

yup sometimes is easier to just put a ~layersToIgnore

rare basin
#

yup

rocky canyon
#

just start using the ray and debugging the hits

#

experimentation is the best method of learning

shell sorrel
#

desmos is the one i use works very similar

rocky canyon
#

ohh ill check it out.. been thinking about doing some Geometry refresher and fiddling with tools like these

opaque fox
#

Is there a way to destroy a sprite once its animation finishes?

frosty hound
#

You can use an animation event at the end of the animation to call some function that handles the result of the animation completing, which could be destroying an object.

graceful spruce
#

Hey, I made a minigame on when the anvils fall on the players and they have to dodge it. when a player gets hit the other player gets a point and I set the timescale to be 0 so it pause.

My question is how can I make it continue for 2 more rounds.

eternal needle
eternal needle
graceful spruce
rocky canyon
graceful spruce
#

What is a DDOL object

eternal needle
#

Just an object that lives inside the dont destroy on load scene

rocky canyon
#

woulda made the normal vector stuff game devs deal with daily alot easier to understand

#

to see it visualized on the fly

graceful spruce
#

oh gotcha

#

@eternal needle thanks a ton I got the plan now

rocky canyon
#

made a crossbow with vectors 😄

#

still havent figured out how to normalize one

eternal needle
#

Normalizing a vector is just a simple equation, divide each component by its length

opaque fox
hard basin
#

Hello there, can anyone help me to fix this error:

rocky canyon
shell sorrel
rocky canyon
#

this is basically what i was gonna make.. - the algorithms / equations lol

slender nymph
#

or is this perhaps when you are trying to build

rocky canyon
hard basin
#

I'm trying to build

rocky canyon
#

i was doing the simple.. 1, 1 diagonal input problem

hard basin
#

The code is not mine, but my friend is int he bed to sleep and i have to fix for the jam ):

rocky canyon
#

or trying to visualize it atleast.. and i couldnt get the normalization to work

shell sorrel
# hard basin Yeah

those scripts are using stuff from the editor assembly which is not available while building

slender nymph
# hard basin I'm trying to build

you cannot include editor stuff in a build. either put your editor scripts in a folder called Editor or wrap the editor specific stuff in preprocessor directives

shell sorrel
#

are these tools for editor use only or required at runtime

hard basin
#

Just like this i hope XD

slender nymph
#

just note that anything in the Editor folder will not be included in the build

hard basin
#

Thank you so much!

opaque fox
#

Okay so because my player character is a prefab, I can't destroy the sprite it spawns

slender nymph
#

make sure you are trying to destroy the instance in the scene not the prefab

opaque fox
#

Not sure how to differentiate between the two

rocky canyon
#

prefab is the actual file in the project folder

slender nymph
#

Instantiate returns a reference to the spawned object, keep that reference so you can destroy that object

rocky canyon
#

instance is what you spawn into the Scene

frosty hound
opaque fox
sullen gazelle
#

Hey all. So very very new. First game here. Was hoping someone could help me with shooting my gun. Specifically, there is no muzzle flash. Here's everything I have so far. When I shoot, it does shoot, I know that because it makes the noise. But no muzzle flash.

rich adder
sullen gazelle
#

Oh let me post my script too

#

Is there a certain way I should post it?

rich adder
eternal falconBOT
rich adder
sullen gazelle
#

using UnityEngine;
using UnityEngine.InputSystem;

public class GunShooting : MonoBehaviour
{
    public InputAction shootAction;

    public Camera playerCamera;
    public float shootingRange = 100f;
    public ParticleSystem muzzleFlash;
    public AudioSource gunShotSound;
    public float damage = 10f;

    void OnEnable()
    {
        shootAction.Enable();
    }

    void OnDisable()
    {
        shootAction.Disable();
    }

    void Update()
    {
        // Check if the shoot action was triggered
        if (shootAction.triggered)
        {
            Debug.Log("Shoot action triggered");
            Shoot();
        }
    }

    void Shoot()
    {
        Debug.Log("Shoot function called");

        // Play muzzle flash effect
        if (muzzleFlash != null)
        {
            muzzleFlash.Play();
        }

        // Play gunshot sound
        if (gunShotSound != null)
        {
            gunShotSound.Play();
        }

        // Raycast from the camera's position forward
        RaycastHit hit;
        if (Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit, shootingRange))
        {
            Debug.Log(hit.transform.name + " hit.");

            // Add logic for what happens when you hit something
            EnemyHealth enemyHealth = hit.transform.GetComponent<EnemyHealth>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(damage);
            }

            // Optionally, instantiate an impact effect at the hit point
            // Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
        }
    }
}
#

I had chatgpt help me make it.

opaque fox
# opaque fox Ah, okay. I'm instantiating it but not destorying the correct one

So now I'm receiving constant errors of the animation not having a receiver. As far as I'm aware, the sprite (obviously) has an animator and it also obviously has a script attached to it that the animation calls.

I have a test sprite in the game world that calls the function just fine, but when the player spawns the sprite, that's where the missing receiver error comes in.

rich adder
#

whats with the AI code everywhere..

rich adder
#

it doesnt create one

#

or did spambot not explain that part

sullen gazelle
#

Spam bot?

#

Is that a tutorial thing?

rich adder
#

did you write code you did not understand ?

sullen gazelle
#

I didn't write it. I copied and pasted it.

#

Before today I literally didn't know what code was.

rich adder
#

you copied it from where ?

sullen gazelle
#

I already said, chatgpt.

rich adder
#

exactly why i made my comment

#

spambot did not explain to you that the particle emitter you're calling play on has to be attached already to the weapon

sullen gazelle
#

Oh

#

Spambot is chatgpt

rich adder
#

Its best you actually learn how to code properly

#

pins in this channel for resources

sullen gazelle
#

I would but I don't have nearly enough time on my hands. I mean heck it's taken me about 20 hours of figuring out how to get to where I'm at now.

#

It's been like 2 weeks.

rich adder
#

everyone says the same exact thing

#

you're gonna spend more time fixing broken code you barely understand

opaque fox
#

things take time

sullen gazelle
#

I get it. But I am just making this one game and then I am probably never going to touch unity again.

rich adder
#

making a game isnt trivial

#

especially with little to no experience

opaque fox
#

you gotta commit

rich adder
#

"im just gona make this rq" not gonna happen

polar acorn
#

"I'm just gonna cure this one cancer and then I'm never gonna use medicine ever again"

sullen gazelle
#

I picked unity because I was told it was the easiest to make games for.

polar acorn
#

Why are you making a game when you don't want to

sullen gazelle
#

I just wanted to make a game where I shoot spiders. That's it.

#

It's for my dnd group

rich adder
#

You gotta be willing to learn though..

sullen gazelle
#

Everything else is fine but coding like hurts my head just looking at it.

rich adder
#

you're lucky it aint C++

opaque fox
#

TRUE

glacial coral
#

Directly copied code from https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbWdaM0Z6YkZDZ1RpcnFwbHJweFN2cWtxZTkyQXxBQ3Jtc0trMFNPZUxKeFFiUUZFRFhCTDE5dlVreGlTaW81STNDVHY4WHFQTzJxaVVyMmtZQ25wVzVPR1RuSU1ISDZlM1VmR3p6ZndPcjlra1IxNXotMlZYTWlqbThwaHZIYVpMdGstQi11RWs4WWd0REtOcVplTQ&q=https%3A%2F%2Fpastebin.com%2FxnbsYSSw&v=qNZ-0-7WuS8. When I implemented it in unity, it has this offset from 0, 0. I don't really know how to fix it. Each tile is 36x36, and pixels per unit is set to 36. The coordinate of each tile should be correct, each is just offset by that small amount. How would I try to fix?

rich adder
#

wtf is that link UnityChanLOL

glacial coral
#

Sorry

#

Whats the markup?

rocky canyon
#

hehe, 💵

rich adder
#

lol redirect flex