#💻┃code-beginner

1 messages · Page 818 of 1

wintry quarry
#

it doesn't look like you adjusted the size and offset of the box as in the tutorial

radiant sentinel
#

i added the componenet i needed to and it hsould work according to them

naive pawn
#

why do you have 3 box colliders

radiant sentinel
#

they had a green box appear but mine wouldnt do that

#

its just how that came i didnt make it

wintry quarry
#

but since you skipped that step, that' probably why it's not working

radiant sentinel
#

how do i check if gizmos is on

real thunder
#

I mean, each enemy gonna do that about each frame and there gonna be dozens

night raptor
#

Trying in your usecase is only way to really know. I would just assume it isn't too much of a difference. Pretty sure the physics queries do a broad and narrow phase kind of steps eliminating most of the possible collision pairs regardless of the shape

midnight plover
wintry quarry
naive pawn
#

don't worry about perf at this stage. focus on what makes sense

#

consider the unit behind the clock speed of your processor
that's in the billions

queen vale
#

just wait till we get to picoseconds B)

radiant sentinel
#

ive gotta be blind

wintry quarry
#

we can't help you without seeing

radiant sentinel
wintry quarry
radiant sentinel
#

this is just how its come installed

wintry quarry
#

press the ~ key in scene view and Turn on "View options", and most of the other ones

real thunder
#

there are even non alloc versions, now making a buffer...

wintry quarry
radiant sentinel
#

elite thats a bigg difference

wintry quarry
#

I recommend similar

pastel cave
#

does "Connecting" a project from the hub check it out from the unity version control system? I'm confused by this interface. I'd simply like to work on the same project on multiple devices

radiant sentinel
#

thanks so much ill give that a go now

pastel cave
#

that's what I was afraid of

wintry quarry
#

Wait what do you mean by "connecting"?

#

Do you mean "adding"?

queen vale
wintry quarry
pastel cave
wintry quarry
#

What menu is that 🤔

pastel cave
#

it appears when you press on the project name field in the create project menu

#

er, "new project" menu

wintry quarry
#

Are you trying to pull an existing VCS repo?

#

Or are you trying to create one?

pastel cave
#

as I have said, I'm trying to pull from an existing one

radiant sentinel
#

huzzah has been vanquished thanks so much guys

wintry quarry
pastel cave
#

ahhh, thank you

undone axle
#

I have only ever done WebGL builds of my current project. If i build and then deploy to my website, then I open the link on a macbook laptop in chrome, everything works as expected. But if I open the same URL on chrome on a windows laptop, one single feature does not work! There is a floating platform that moves back and forth and once hit, it plays a sound and dissapears along with teleporting the player. On the windows machien the platform does not dissapear (it does lose its ability to interact with the player). Also the sounds do not play but the user is teleported. Any ideas?

worn atlas
#

Is there anything in the log?

#

Why I don't see colliders of the terrain when I turn on physics debugger?

queen vale
worn atlas
#

I wanted to see if the collision is working, I have no issues now. Just asking

final ferry
#

could anyone show me an example of ParticleSystem.Particle.GetCurrentColor in use? I'm trying to fetch the current color of a particle to get its alpha as it changes over lifetime but it keeps returning (0,0,0,0)

I have a particle system paused mid playback, with a single white particle going from 255 to 0 alpha, and I'm calling the method outside runtime, with an editor button. just trying to grab the color and put into that variable to show it on inspector and see if it works.

code is literally just:

wintry quarry
# final ferry

you appear to be reading the color of an uninitialized Particle struct here

#

you just made an array of empty particles of the appropriate size, but never initialized them

final ferry
#

but ParticleSystem.GetParticles returns an int

#

I assumed it was just used for the size

wintry quarry
#

yes

#

look closer

#

what's the parameter?

#

It's the array you want to populate

final ferry
#

ah right

wintry quarry
#

Returns

int The number of particles written to the input particle array (the number of particles currently alive).

final ferry
#

lemme try again

queen vale
final ferry
#

thanks

worn atlas
queen vale
worn atlas
#

no, it has a mesh collider

queen vale
#

Oh, my bad. I misunderstood. If this is the desired effect you'll want to make sure 'Collision Geometry' is selected.

queen vale
#

Man, I'm just wrong in every way today.

worn atlas
#

Hmm, I checked collision geometry, but I still don't see any lines

wintry quarry
#

Looks like you're maybe using Unity Physics for DOTS?

worn atlas
#

yes I'm using physics for dots

#

thanks, that's what I needed

faint agate
#

hey guys, I figured a couple things out but could use some help.
So I have a orb im trying to right click hold and drag only on the x and y axis.
Its 3D first person, the orb doesnt have rigidbody, the script to drag the orb is on a weapon on the player.
The problem is when I drag on the X axis it bounces left and right really fast but is smooth dragging on the Y axis(I dont want it to move on the z axis).
Its not the raycast or a problem with the Y axis from testing. Ill leave the script if anyone would like to test
https://pastecode.dev/s/dy1tl7h5

faint agate
#

More testing, On cam orthographic its all smooth, but im using perspective and the x axis is bouncing left and right.

queen vale
faint agate
#

okay one sec

#

my record is randomly not working for the first time lol the timing is so bad

queen vale
#

You using OBS?

faint agate
#

no nvidia replay. I think I found a work around. ima start using obs after this

limber stone
#

Hello, I am currently dealing with an issue with particle effects, I have this 1920x1080 render texture that is supposed to only show the particles so that I can layer them on top of my cards which are always culled to be on top. I am having issues however with this render texture displaying because for some reason it displays nothing when mapped to a raw image. Please could I get some help. Thanks for reading.

#

Also, right after posting this I realized that the values were wonky on the Rect Transform, those are fixed now.

limber stone
#

I'll look into it however I doubt that I will use it. Thanks for the suggestion though!

grand snow
queen vale
# faint agate i was able to send the clip

Was playing around with the script.
You're creating a new plane each frame that you're holding the object. So I tried just using the plane created when you first grab it.

#

No jitters on my end

faint agate
queen vale
#

Almost, thats like 77% of what I did.
During the drag, where it's following your cursor you won't need to continually create planes like you had been, each time the function was called.
I'll send you the updated script, lmk if it works

faint agate
#

okay thank you

queen vale
limber stone
# grand snow It will be better than needing a large extra texture to draw particles too. Anyw...

In the end I Just made the emission small enough to completely fit in the size of the card, put the emitter in front of the card and the gave it the same layer as the card. The render texture that puts cards in front picks up both of them and puts it in front. Thanks for the help, I will certainly use the tips and tool provided in another project, I just need to finish this by Friday and I don't have the time to learn a new tool at the moment. Thanks for the future help!

queen vale
faint agate
# queen vale

definitely is smoother thank you. do you mind me askin the more smoothtime the more delay I noticed. Is there anyway to have both no delay and smooth or is there no real setup for that in my case

#

when I have the smoothtime at 0 the sphere goes crazy

queen vale
#

I'd probably recommend .lerp

queen vale
#

And yea the more with smoothtime, you're effectively telling it how long it must take to reach it's destination.
Or if you wanna do smoothtime, set it to it's lowest 0.0001 and see if you like it

faint agate
queen vale
# faint agate the orb goes crazy lol ima try the lerp

Third idea, `smoothTime of 0.015' & replace

currentObject.transform.position = newPosition;

with

if ((currentObject.transform.position - targetPosition).magnitude > 0.03f)
            currentObject.transform.position = newPosition;
wintry quarry
viral lake
#

oh shoot I dont have that channel added sorry!

queen vale
faint agate
#

yea

#

if theres anything youd like to ask about my setup feel free

grand snow
#

An improvement would be to get the component anyway and check if its null or not

#

tags are pretty useless when a component does the job better

queen vale
faint agate
#

lol its okay

faint agate
sour fulcrum
#

they didnt mention layers

grand snow
#

Well we use layers for other things like physics and controlling what a camera can see for example

queen vale
#

I think they're saying instead if comparetag, use getcomponent.
But yea, this jittering is still occurring.

sour fulcrum
#
if (finishHit.collider.TryGetComponent(out OrbDragGoal))
  isDragging = false;
  currentObject = null;
  return;

you can just use a component check as a tag check and ignore tags altogether

#

components are basicially just tags with more potential information and usage

grand snow
#

Indeedy

sour fulcrum
#

truing

queen vale
#

Welp, go back to the previous version, idk why when we switched to lerp & magnitude it went back to going haywrie.

faint agate
#

okay I switched to getcomponent and did a debug to make sure it worked

#

im still testing with lerp and damp my brain is baffled

#

it also seem to be the further I am the worse it gets

grand snow
#

how are you using lerp?

#

many people abuse lerp when better options exist such as Vector3.MoveTowards()

faint agate
#

Vector3 newPosition = Vector3.Lerp(
currentObject.transform.position,
targetPosition,
speed * Time.deltaTime
);

grand snow
#

Yea you want to use MoveTowards to keep going towards some goal

faint agate
#

got you

faint agate
#

its still movin left and right dragging down

hallow sun
#

I'm replacing some of my Singletons with Static Classes because its basically the same and skips Instantiation and its potential issues.

#

Lemme know if this is actually super bad for X or Y reason that I wouldn't know unless I read some obscure forum post about it.

swift crag
#

a static class is appropriate if you have no interest in Unity lifecycle functions, like Start, Update, or OnDestroy

hallow sun
#

👍 This is for managers that register items and do some operations so I think I'm good

grand snow
#

Config Manager that loads from say json? perfect use of a static manager

grand snow
#

Async solves that!

hallow sun
#

augh, can't run Coroutines on static, but its just a short rewrite anyways

swift crag
#

coroutines are executed by a specific unity object

grand snow
#

UniTask or Awaitable fully replace coroutines and can do more

sour fulcrum
#

But can they run coroutines

grand snow
#

Unitask can

#

I personally avoid coroutines so its no bother to me but UniTask has great features relating to coroutines

#

Awaitable is meh and half baked but functional

night raptor
#

Was there some problem with static fields not getting restarted to their default values after scene loading? Or was it just a thing with the fast playmode editor options?

hallow sun
#

I'm just using the coroutine for detecting a "pause" and waiting for that variable to turn false, easy 2 min fix.

grand snow
#

you would need code that uses editor events to reset them

sour fulcrum
#

Or logic that doesn’t require them to be reset

sour fulcrum
night raptor
#

Yeah, definitely worth knowing when considering between singleton and static class, when that's not an issue either, definitely go for a static class

grand snow
sour fulcrum
#

No as in an attribute you put on the fields

grand snow
#

Anyway soon ™️we will get super fast reloading yay

grand snow
sour fulcrum
#

Ya it’s how core clr workflow will work for reducing enter times

#

well some of it anyway

#

Just easier way to do the workflow people are already doing with reloads disabled and their own management

night raptor
#

I'm starting to get interested in that core clr stuff that I have been hearing a lot but never looked much into 🙂

grand snow
#

Ill be honest it doesnt sound great, how can sbox have incredible hot reload speed but unity cant do the same?

sour fulcrum
#

Comes out this year so not much wait

solar hill
#

Its virtually instant in a lot of cases

#

It was born entirely out of facepunch's frusturation with unity domain reload and compile times

grand snow
#

Yea its amazing so I expect unity to do the same or better. Surely they can afford a few smart devs to make it?

solar hill
#

Im expecting Unity to start considering s&box as an actual competitor,

#

which is going to be beneficial for everyone in the long run

#

s&box still has some great qol stuff unity could use, hot reload was one of them

sour fulcrum
solar hill
#

right now it cant do any platforms to be fair

#

its stuck within their own game ecosystem kinda like roblox

#

the biggest issue is licensing and valve, but they are still figuring things out

livid socket
#

is that released yet?

solar hill
#

Its been out for a couple of years now yes

grand snow
#

I miss the early days when it was basically s2 with c# shoved in there

twilit olive
#

quick question. whats the best practice now—async/await or coroutines?

#

or different cases for each

timber tide
#

does s&box even have proper licensing yet

#

can you even build on consoles with it

solar hill
#

as answered above

#

no

timber tide
#

thing just looks like unity with imgui* plastered on it

timber tide
solar hill
#

Well Valve had no reason to give them a source 2 license to begin with

#

so who knows

timber tide
#

better to see godot at the competition as you can crank out stylized games pretty easy and toss em on steam

rich adder
solar hill
#

its nice, and i like that its open source

timber tide
#

it is, but let's be serious. If you're looking for realistic lighting you're probably using unreal

solar hill
#

Not at all

sour fulcrum
#

godot and roblox are way closer competitors ye

timber tide
#

Godot's weakest is the pipeline and rendering that's for sure, but if you're not trying to create anything too artsy then it works fine. Mobile games come to mind and other minimal artistical games have been produced with it.

#

Unity is the jack of all trades. It does everything pretty easily, but since it has to support so much stuff the development is so split.

solar hill
#

what about it is split?

#

you mean the pipelines?

timber tide
#

SRP split trying to encourge higher quality games, yeah. Even DOTS id say took away from the general URP/Gameobject workflow

solar hill
#

they are doing away with the pipleline split

#

which is good

#

dots is an alternative really, its also the less popular option so i honestly wouldnt say its "splitting" anything

timber tide
#

I would been honestly fine if they did abandon gameobjects and forced dots lol

timber tide
#

Well, I'll let you know right now. DOTS have the better character controllers, it has the better networking solution

#

So many modules that are just generally better than what you get with game objects

#

They hired the dude who made the kinematic character controller

solar hill
#

If they remove gameeobjects and force DOTS, it will basically kill Unity's market presence for beginners

sour fulcrum
#

i think you severely underestimate the value of the gameobject workflow to people

#

also can dots use the canvas based ui stuff?

timber tide
#

I'm not saying the workflow is bad. I'm just talking about how the split with these modules have moved so much high quality work around

#

Unity loves to have multiples solutions to one problem

solar hill
#

Why are you saying that like its a bad thing

#

having more choice and variety in how you approach problems is a good thing

timber tide
#

I'm pretty sure more people would be happy if they developed UGUI more out instead of developing UIToolkit

solar hill
#

Imo they are better off just abandoning UGUI and getting UIToolkit perfected

timber tide
#

I agree

solar hill
#

S&box also has an entirely Razor based ui similliar to the uitoolkit and its a major plus for the engine

#

who would have thought that a markup language is good for designing UI

#

everybody

timber tide
sour fulcrum
#

UGUI being redone completely is UIToolkit(?)

timber tide
#

Yeah, but going back to my argument of multiple solutions to one problem.

zenith cypress
#

Just give me a modern imgui instead, I despise retained modes 😔 (can PanGui release soon)

solar hill
#

I dont see UGUI ever getting depreciated, but its almost certainly rearing end of life time support

sour fulcrum
timber tide
#

They actually did threaten to remove it in a previous talk, but everyone complained and they actually had quite a few updates in the previous release

sour fulcrum
#

you said people would prefer they update UGUI rather than develop uitoolkit, i don't really get that

timber tide
#

UGUI is just easier to jump into which is why I was saying more devs would be happy to use it over dealing with html/css garbo

sour fulcrum
#

i mean if ui toolkit was further developed it could be easier to jump into

#

i'm learning ui toolkit and i'm not doing any of the html and css shit

timber tide
#

Yeah that is true. The GUI itself for it does provide some help, but you end up copy/pasting templates after getting frustrated at times

#

My biggest gripe with it is the extra boilerplate when connecting properties to unity's editor

brave hound
#

hi guys, am i able to give an ml agent a timeout when going over the line in a 2v2 game?

sour fulcrum
final trellis
#

I have these 4 enums and was wondering how I could have it so that if you select the same option as another enum, the other one is set to None

( so like, if I set _attribute2 to Damage, but _attribute1 is already Damage, _attribute1 gets set to None

sour fulcrum
#

What part of this problem are you struggling with

final trellis
#

how to do that in general ( i know how to do it in runtime, but this is for the inspector )

timber tide
#

Probably want to just use OnValidate if you don't want to deal with Editor library tools

timber tide
#

I would think a bitwise enum would be fine too

#

unity has support for those to display

final trellis
timber tide
#

multiselect enum basically

final trellis
final trellis
#

is there a way to limit how many are selected?

timber tide
#

ah, actually you'd probably need to validate that too lol

final trellis
#

how would you count how many are selected?

timber tide
#

check how many bits are set

final trellis
#

that was what i was thinking, but was asking incase there was a function to do so by default

timber tide
#

so onvalidate would be if current enum bits are more than allowed then set to previous enum value

sour fulcrum
#

bit stuff is black magic just google and people will have easy solutions for that kinda stuff

final trellis
#

its just 0s and 1s, how hard could it be? /s

#

dammit i was tryna send the 'thousand yard stare' gif

#

is there a max amount of bits for a bitwise enum?

wintry quarry
final trellis
#

yeah

dapper heath
#

Probably 32 as it's integer backed right?

wintry quarry
#

you can make a long or ulong backed enum, which are 64 bits

sour fulcrum
#

but at that point might be worth considering other solutions like scriptableobjects

final trellis
#

i could always just make a 2nd enum and validate them both against eachother, but that would prob be scuffed as fuck

#

but yes anyways thanks :3

heady heart
#

I'm trying to make an easy way to create skills in my game in a way that can scale with many skills and is easy to add stats for each skill (Level scaling, requirements, etc.). I tried making a struct called Skill which can take the skills stats as an input and then created a script called SkillsHandler attached to the player which would dictate skill behavior. However, I cant add the skill prefab to skills handler, and im assuming it has something to do with the fact that the Gameobject rend is static? how do i get around that?

grand snow
#

its not a member variable so that wont work will it?

#

But you can just load a prefab via Resources or Addressables to solve this

wintry quarry
heady heart
wintry quarry
#

Also your skill type is not [Serializable] so it can't show up in the unity inspector anyway

wintry quarry
#

how about you share the actual error

heady heart
wintry quarry
#

use Awake

#
void Awake() {
  rend.prefab = rendPrefab;
}```
polar acorn
heady heart
wintry quarry
#

He means you have to do it like in my example

polar acorn
wintry quarry
#

but actually you shouldn't do either

#

you should expose it in the inspector

#

and assign it there

heady heart
#

How do I do that?

wintry quarry
#

For that to work your struct needs to have [Serializable]

heady heart
#

ok I will read the serializable documentation

#

thanks guys

wintry quarry
#

reading the documentation isn't going to help you

#

you just need to apply the attribute to the struct definition

heady heart
#

well I would like to understand what it does anyways so ill watch a yt vid or smth

grand snow
#

fun fact: programming languages have lots of documentation in text form

wintry quarry
#

Namely this part

heady heart
#

ok thanks for the help

elfin pike
#

How you protect important saved data? Example, player stats

rich adder
swift crag
#

you need to store the data on something you control

#

and you also need to ensure that the player can't submit completely ridiculous data

#

"I just killed 23 billion enemies" should not be accepted

elfin pike
#

Right now everything in json

swift crag
#

If you want to at least make it annoying to cheat your stats, encrypt the file that stores the stats.

#

The player will be able to extract this key from the game, by definition

#

The game has to be able to decrypt the stats file

grand snow
#

Yea you can make it harder but cannot prevent it

#

I did my own thing years ago to decode phasmaphobia saves, was quite easy

elfin pike
#

Nothing is safe. Question how easy it is to do it

solar hill
#

honestly for singleplayer games i see no reason to lose any sleep over it

#

if people want to cheat in your singleplayer game, let them

elfin pike
#

I know, but small encoding wouldn't hurt to prevent average Joe to finish game in seconds

sour fulcrum
#

Who cares if average joe finishes the game in seconds

solar hill
#

Do you think the "average Joe" is typically cheating in singleplayer indie games they play?

elfin pike
#

If you can go in and change number in txt, why not

solar hill
frosty hound
#

Why do you feel the need to exact control over what someone does with their time, is the real question here.

elfin pike
#

How Im going to mine bitcoin. XD joke

analog cypress
#

im having an issue with my targetlock script. originally just to test if it would work i did a private gameobject target and set it to look for gameobject with a set tag in a void start and a void update of transform.lookat(target.transform.position) and it did work centering itself to look at the entity at all times. But now i wanted to make it when the player has their mouse over the entity with the tag and presses a key it locks on. And unfortunately it hasnt worked: ive tried void OnMouseOver and just tried looking for the set tag and i even have a onmouseover debug and that works displayed a message in the console with mouse over works. Im wondering if i have to take a different approach to how im meant to write it and if anyone would be able to help me

analog cypress
sour fulcrum
#

!ide

radiant voidBOT
queen vale
#

On your player's script you could do something along the lines of raycast like swortech was mentioning.

// As opposed to OnMouseOver
private void Update()
{
  if(Physics.Raycast(...))
  {
    if(hit.collider.GetComponent<TheEnemyScript>() && Input.getkeydown(...));
        hit.collider.GetComponent<TheEnemyScript>().LookAndReactFunction();
  }
}
vapid aurora
#

@analog cypress
Excuse the English 👍

sour fulcrum
#

you need to fix your ide before anything

analog cypress
#

im not sure how to fix my ide i read it over the first time and updated to the newest version like it said and i thought that would be enough to fix it but i can go over it again if anything.

queen vale
analog cypress
queen vale
analog cypress
#

oh ok got it

#

thank you

#

and is there a way to see if my ide is fixed?

sour fulcrum
#

this wont be white

vapid aurora
analog cypress
#

yeah idk why its not working i tried the help forum that Oz sent but it didnt even give me the option for Editor Attaching and i tried to make sure that all the options were checked and it didnt make a difference when i went back to open the code i had MonoBehaviour is still white and i tried making a brand new C# script it didnt include it and when i tried making a MonoBehaviour Script it still was white. and i did hit to regenerate project files already too.

rich adder
#

!vs

radiant voidBOT
# rich adder !vs
Visual Studio guide

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

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

rich adder
#

if its connected you should see the suggestions popout when you type

#

some like this

queen vale
#

^
Also I noticed that and, I'm not sure what the poster meant. I assume an option back on Unity 2019

vapid aurora
#

What happens is that the editor is not linked to unity

lusty knot
#

anyone down to teach me coding i have 0 knowledge

sour fulcrum
#

i don't think you'll find anyone willing to do that for free

subtle mulch
bitter pine
#

this may be a stupid question but, is there a way to make a kind of properties component for a gameobject without using a script?

subtle mulch
#

no?

sour fulcrum
bitter pine
#

ah thank you

#

should i just make scripts and give them variables?

subtle mulch
#

yes

bitter pine
#

alr then

subtle mulch
#

public vars or private vars that you force serialize

real thunder
#

Now I faced a choice, do I make bullets triggers or not? 🤔

#

Is there an obvious answer?

naive pawn
#

no (there's not an obvious answer), there's also the option of raycasts

real thunder
#

in my current game player shoot raycasts and bullets just trace that, however enemies meant to shoot fast projectiles

bitter pine
#

huh

real thunder
#

is it even possible to make bullets capable of penetrating if they ain't triggers?
at least ain't triggers for enemies

queen vale
#

I am a bit confused though, why would you want to 'get' a component of a gameobject without a script?. WAIT WAIT. ye i read it wrong

bitter pine
#

i meant like assign values to a object without having to make a script

queen vale
#

I need sleep but the first thing that comes to mind would probably be a scriptableobject, but that requires scripting soo : | idk, sorry.

bitter pine
eternal needle
stuck parrot
#

Hey, Im a beginner in unity and coding and I cant figure out what causes this issue. when I move, the player "tilts" but that results in the player tilt over sometimes and just laying on the ground. There is also an issue with the wall clipping as you can se at the end. The room is build out of different tiles, each one has a box collider and the player has an rigidbody as well as an box collider (even tho a capsule sollider suits the mesh better, the player keeps falling over when i dont use a box collider there. If it helps, heres my player controller script ```csharp using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerControl : MonoBehaviour
{
// creating variables
GameInputs control;
Rigidbody rb;
Vector2 moveInput;
float speed = 5.0f;

void Awake()
{
    control = new GameInputs();
    rb = GetComponent<Rigidbody>();
}


void Update()
{
    moveInput = control.Player.Move.ReadValue<Vector2>();
}


void FixedUpdate()
{
    // Movement
    Vector3 direction = new Vector3(moveInput.x, 0f, moveInput.y);
    rb.MovePosition(rb.position + direction * speed * Time.fixedDeltaTime);
}


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


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

}```

radiant sentinel
#

Hey gang currently looking for a mentor of sorts, I have a solid game idea and have done some tutorials now to teach myself some basics and think im ready to commit myself to the project more but would like someone to help with some more experience and make sure the way of doing things im doing isnt total bs, im looking to make a 2.5D pirate single player game that follows a loose story, if anyone with experience in that sort of field is around i would love a 5 min discord chat

tawny sandal
#

im new in unity and trying to do something from learn.unity or something, wich one do i do and where do i start?

midnight plover
radiant sentinel
midnight plover
#

"New to Unity? This guided learning Pathway includes everything you need to get started."

stuck parrot
tawny sandal
#

2 weeks is a long time but its prolly worth it

radiant voidBOT
# solar hill !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

dawn patrol
#

hello guys

errant breach
#

Hey guys, quick question.
I don't understand why i can't access the "scoreManager" values. neither "test", neither "score".

` [Header("References")]
public ScoreManager scoreManager;

private void OnTriggerEnter(Collider other)
{
    if (other.gameObject.tag == "EnemyProjectile" && secretInvincibilityTime <= 0 && !isDead)

    {
        if (scoreManager.life - 1 > 0)
        {
            // If still has health
            playerMovement.isFreezed = true;
            scoreManager.life -= 1;
 ...`

Error : Member 'ScoreManager.life' cannot be accessed with an instance reference; qualify it with a type name instead
I tried looking on the web to fix the issue, without understanding...

Do someone know how to fix it please ? Thank you ! I want to access the player's life

sour fulcrum
#

static means it belongs to the "class", not a "instance" of the class

#

eg. you would want ScoreManager (the class) not scoreManager (your reference to an instance of the class)

errant breach
#

My gawd again you got me, quick, precise. Thank you ! <3

north kiln
errant breach
#

Oh thank you for telling me that !

hexed terrace
errant breach
#

Sorry for the mistake, i will !

real thunder
#

So I am trying to use Physics.ComputePenetration
how do I get access to the collider's position and rotation?

#

I guess position is techincally bounds.center

#

and rotation is... you can't rotate them right? get one from their transform?

real thunder
#

this is pretty annoying, so this is a projectile-trigger hitting a torso
how do I even get the normal of this ""collision""
I tried to trace Raycast from a projectile position
Using info from Physics.ComputePenetration, doesn't work, sometimes the projectile is too deep for a meaningful result
I tried Collider.ClosestPoint from projectile center but if it's inside it seems to return transform.position

worn veldt
#

Elo, I'm following this tutorial: https://www.youtube.com/watch?v=BleaG3md1zY&list=PLgXA5L5ma2BuXG5L_hcXKc8RU2gNVdQ6F&index=7

I have created the scriptable object like the tutorial says to, and I have created the prefab, and my prefab type is a game object, and the prefab input needs a game object, but when I select it out of the list it says "Type mismatch"

Does anyone know why this is happening/how to fix it?

Attached is a screenshot of the code, and menu and problem.

Project files are here: https://www.patreon.com/posts/creating-game-in-75523545
Accompanying article: https://blog.terresquall.com/2023/02/creating-an-underwater-survival-game-part-3/

Ever wanted to create a game like Subnautica in Unity? In Part 3 of our guide, we go through how to set up a simple Inventory System for the game.

CodeMonkey Gri...

▶ Play video
wintry quarry
worn veldt
wintry quarry
#

you're trying to assign a reference to a scene object on an asset (the SO)

#

assets cannot reference objects from inside scenes

#

The prefab is not in the scene

#

the prefab is the one that's in your assets folder

#

reference the prefab, not a copy of it from the scene

worn veldt
#

ohh I just dragged it from the folder, it works now, sorry idk why I didnt think of that, thank you :)

real thunder
#

alright, tracing from the previous frame position to the current other.ClosestPoint(transform.position) seem to work

#

so much hassle for basic projectiles smh

#

does this line make sense as a check so mobs not hit themselves?

if (victim is BaseMobAI && victim as BaseMobAI == base_mob_ai) return;
#

victim might as well be a player or stationary object so

ivory bobcat
#

More context would help

grand snow
ivory bobcat
#

!code

radiant voidBOT
grand snow
#

classes do a reference equals comparison by default

real thunder
#

I guess I ignore that?

grand snow
#

You can also do ReferenceEquals() to explicitly compare if 2 things are the same by ref

#

If one is an Interface this can often prompt such a warning

real thunder
#

yeah one is an interface

#

everything are classes except the victim

grand snow
#

A unique id is a nice and more reliable solution

real thunder
#

I haven't really thought I can use interface with structs

#

lucky I ain't doing it so I won't face issues

#

so I see in some cases that comparsion may actually break

#

alright ugh now I need someone to explain why my code works while it shouldn't

public void FixedUpdate()
    {
        previous_pos = my_collider.bounds.center;
    }

I got this bit

public void OnTriggerEnter(Collider other)
    {
        Debug.Log(previous_pos + " " + my_collider.bounds.center);
        Debug.DrawLine(previous_pos, my_collider.bounds.center);
        Debug.DrawRay(my_collider.bounds.center, Vector3.up, Color.red);
        Debug.Break();
    }

and this bit

#

according to the order of execution FixedUpdate executes before OnTriggerEnter

#

so I would expect previous_pos to be the same as my_collider.bounds.center inside OnTriggerEnter

#

however it still uses previous previous_pos and everything works

wintry quarry
#

so they would be different, no?

#

(sorry i'm jumping in with not much context)

real thunder
#

I got it now

#

so "internal physics update" means... everything does their things

#

I am surprised only now I stumbled upon that fact

#

that fixed update before that and collisions after

pallid pier
#

Hi!! I need some help. Is it possible to make my character "die" after the health bar (slider) go to 0? Like, restart or something?

subtle mulch
#

well, yes ofc

#

you just have to code it in...

pallid pier
#

That's the point... I don't know how to do it

subtle mulch
#

well, we didn't make your game

#

just reload the scene in case

pallid pier
#

Que listo eres no?

subtle mulch
#

huh?

#

pls speak english

pallid pier
subtle mulch
#

well, check when health is 0

#

then do stuff...

pallid pier
#

venga va

subtle mulch
#

huh??

#

can you pls speak english

pallid pier
#

"then do stuff"

#

I don't know what do I have to code, that's why i'm asking for help (if anyone knows) 😞

subtle mulch
#

idk what your game does or should do

#

so idk how to help

pallid pier
#

Maybe you could ask like a normal person and not being rude

#

Maybe

subtle mulch
#

i'm not being rude...

pallid pier
#

Ok

#

Can I send pictures right?

#

Wait a sec

subtle mulch
#

i'm just saying that we literally cannot help bc we don't know how the code you made works

#

or how it should behave when restarting

subtle mulch
pallid pier
#

When the lemon touch the plate, the health decreases

#

And the code, let me check rq

pallid pier
subtle mulch
#

well, in the decrease health function check when it is 0 or less

subtle mulch
pallid pier
#

Okay, I didn't know!

#

Omw

subtle mulch
#

ok well, what you don't understand first of all

#

and how should the game restart?

#

like, what needs to change?

pallid pier
#

This is the last part of the code

subtle mulch
#

well ok

pallid pier
#

My teacher sometimes sent us the code and we copy it because we didn't have enough time in class

#

So i don't really understand many things

#

I tried looking at the pdf's she sent

subtle mulch
#

well, the first step should be understanding it then

pallid pier
#

Im

#

trying

subtle mulch
#

first understand it, then try to continue

#

also right there, you have the spot where to execute death logic

pallid pier
#

"You have the spot where to execute death logic"

#

Que tío mas cuajao colega

subtle mulch
#

i don't understand your language...

#

here is the spot...

pallid pier
#

i know dude 😭 but i don't understand what can i do

#

delete //?

#

add something

subtle mulch
#

you can do everything

#

idk what the game should do

pallid pier
#

ou

subtle mulch
#

we literally cannot help

pallid pier
#

no gifs then

#

venga

#

va

#

gracias

#

payaso

subtle mulch
#

ok well, if you insult me, then i def won't help

#

i do understand something, ok?

#

bc it's similar to my language

real hatch
#

//Death

#

What does that do?

subtle mulch
#

<@&502884371011731486> you prob wanna look into him

subtle mulch
#

he is asking help for that afaik

elfin pike
#

Could it be that code is generated and bot placed comment there

subtle mulch
#

and they copy paste it

#

so that may be the reason why the comment is there

frosty hound
# pallid pier venga

It's already been mentioned that this is an English only server. If you're also going to throw a tantrum, then please leave.

subtle mulch
#

you can translate it to verify

frosty hound
#

Hence the tantrum part. But they left anyway

subtle mulch
#

oh they left?

#

lol

elfin pike
subtle mulch
#

but he didn't know what the game needed to do on death

#

so he was basically asking us to help him understand what death had to do...

elfin pike
#

Simple version is to reset scene,
harder would be to reset health (also update UI) and move player to location you need

subtle mulch
#

Yeah, i basically said it at the start

#

Tho i don't know what the game had to do on death

#

If there was any requirement

elfin pike
#

Don't bother, he got banned or left

subtle mulch
lone ruin
#

Does somebody know whether Awake will be called in such a circumstances?

var spawned = Instantiate(prefab, inactiveParent);
// Is Awake called if spawned.enabled = true, spawned.gameObject.activeSelf = true but spawned.gameObject.activeInHierarhy = false
silver gyro
#

Hello! Is ok to ask questions about concepts here? Or is this mainly a bug help type channel?

lone ruin
silver gyro
#

Oh w

wintry quarry
#

so if activeSelf is true, then activeInHierarchy will also be true

#

I believe if it's not active in hierarchy when spawned, e.g. if you did Instantiate(prefab, someDeactivatedObject) then no I don't think Awake runs, but this is pretty trivial to test for yourself

lone ruin
lone ruin
frail hawk
#

what are you trying to achive actually?

wintry quarry
#

Generally it's pretty easy to avoid instntiating anything as deactivated though

lone ruin
wintry quarry
#

i mean probably yes but there are probably cleaner ways to do it

lone ruin
lone ruin
queen adder
#

Can Harmony patches replace/disable an entire class, or is it only the methods?

queen adder
#

Oh sorry ok

lone ruin
#

@wintry quarry good cat by the way

wintry quarry
#

Not really, I literally just had to remove him from jumping on my computer

silver gyro
#

ok so question, Im trying to make a perk system for my game, I was going to implement it like a inventory system so I was learning about different ways of going about it. I was looking at using hash tables or lists, and it might sound like a dumb question but why would you ever use a list over a hash table?

wintry quarry
#

hash tables are not

#

They also tend to use less storage, since you don't need to separately store a key

#

I guess you mean - in the context of an inventory?

silver gyro
#

yeah

wintry quarry
#

You would use a list when you plan to access the inventory via numerical index

#

HashTable makes sense only if you plan to access it by some key

#

basically it depends what you are doing with the inventory and your planned access patterns

silver gyro
#

that makes a lot more sense thxs for the explanation

wintry quarry
#

For example if you are using "stacks" of items in your inventory and you expect to frequently be accessing the inventory by adding or removing from existing stacks, it could be faster to use a HashMap. For example if you use hashtable and want to add one apple to the list, it's O(1) to find existing apple stack and add to it.But for a list it's O(n) to find an existing apple stack

#

if there are no stacks and you always add a new item to the end, you can just use a list

#

You may need both - stacks and ordering, in which case you might use a list anyway, or some combination of both - a list as the canonical data with a hashtable for optimized lookups

pine garden
#

Question: i create instance of gameobject based by a scriptable object and i would like to when i instantiate them, changing their value or add prefix/subfix by random. What the structure would look like?

wintry quarry
pine garden
#

Ok
I have a item scriptableobject who have value such as damage,fire rate, level and rarity.

Like in PoE or diablo. The weapon can have additional bonus as prefix and suffix (+dmg,+crit rate,elemental dmg,etc).

Logically, the weapon will scale (in damage) with the level of the item

When i instantiate item now, it only pick the base value of the item.

wintry quarry
#

and select one at random

#

You can use a weighted random selection algorithm if you want some to be rarer than others. (google it)

#

You can use ScriptableObjects to define the prefixes too

#

like maybe the "Heavy" prefix applies additional 10% damage, or whatever

#

the overall system you're discussing can be pretty complex, so this is just a small simplified piece

frail hawk
#

instead of changing the values at run time ( which you shouldn´t) you could replace the items with a new Scriptable object

#

so you would have different scripable objects for one item

wintry quarry
#

oh sure - certainly don't change the SOs at runtime. Usually you want an SO and then a runtime data model which the SO can create

sleek pelican
#

hi guys how are you, this channel is for people who wants help for his own game?

frail hawk
#

yes

sleek pelican
#

oh good can I tell my problem/issue/bug

solar hill
#

just ask

naive pawn
radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

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

-# For more posting guidelines, go to #🌱┃start-here

naive pawn
radiant voidBOT
sleek pelican
solar hill
#

the point of the bot command is for you to read it, you dont have to actually do it

#

read what the bot message says

sleek pelican
#

oh ok wait

#

so I cant ask

solar hill
livid socket
solar hill
#

this whole place is a support server

#

you can ask

#

the point of the bot message is that there is typically steps to take before asking here

sleek pelican
#

now I understand

frail hawk
#

so are you going to ask your question finally

sleek pelican
#

I'm making a horror game, and I'm stuck on a part where I have a doll/monster that's watching over me, and when I look at it, it disappears. But I've found a bug. When I look at the closed door and then in the direction of the monster, it disappears, and I don't want that. I want the player to see it in more detail; there's an event in the room where the lights start flickering, indicating that the player has to do something.

wintry quarry
sleek pelican
#

I have a code

wintry quarry
#

I would imagine so

#

!code

radiant voidBOT
wintry quarry
#

Please don't share code as images

sleek pelican
#
using UnityEngine;
using System.Collections;

public class ControleSusto : MonoBehaviour
{
    [Header("Configurações do Evento")]
    public GameObject monstro;      
    public Light luzSala;           
    public GameObject porta;        
    public AudioSource somSusto;    

    [Header("Configuração de Layer")]
    public string nomeDaLayerMonstro = "Bicho"; 

    private bool eventoAtivo = false;
    private bool jaSustou = false;

    public void IniciarEvento()
    {
        if (jaSustou || eventoAtivo) return;

        eventoAtivo = true;
        monstro.SetActive(true); 
        StartCoroutine(SequenciaDeLuzes());
    }

    IEnumerator SequenciaDeLuzes()
    {
        while (eventoAtivo)
        {
            luzSala.enabled = !luzSala.enabled;
            yield return new WaitForSeconds(Random.Range(0.1f, 0.25f));

            if (VerificarSeJogadorOlhou())
            {
                FinalizarSusto();
                yield break; 
            }
        }
    }
#
bool VerificarSeJogadorOlhou()
    {
        // 1. Verifica se o monstro está visível pela câmera
        Vector3 screenPoint = Camera.main.WorldToViewportPoint(monstro.transform.position);
        bool noEcra = screenPoint.z > 0 && screenPoint.x > 0.3f && screenPoint.x < 0.7f && screenPoint.y > 0.2f && screenPoint.y < 0.8f;

        if (noEcra)
        {
            // 2. Lançamos um SphereCast (um raio grosso) para facilitar a detecção
            int layerMask = LayerMask.GetMask(nomeDaLayerMonstro);
            Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
            RaycastHit hit;

            // Se o centro da tela (ponto branco) passar perto do bicho, ele deteta
            if (Physics.SphereCast(ray, 0.5f, out hit, 15f, layerMask))
            {
                return true;
            }
        }
        return false;
    }

    void FinalizarSusto()
    {
        eventoAtivo = false;
        jaSustou = true;
        luzSala.enabled = true;

        if (somSusto != null) somSusto.Play();
        monstro.SetActive(false);

        // Garante que a porta continua a funcionar
        var doorScript = porta.GetComponent<MonoBehaviour>();
        if (doorScript != null) doorScript.enabled = true;

        // Fecha a porta na posição correta
        porta.transform.localRotation = Quaternion.Euler(0, -45f, 0);

        Debug.Log("Toy Chica desapareceu com sucesso!");
    }
}
sleek pelican
#

Im new

#

Im really sorry

wintry quarry
sleek pelican
#

Layer Monster is Monstro and Layer of Door is Default

wintry quarry
#

Also because I don't speak the language I'm not sure if this code is supposed to be for hiding the monster or showing it

sleek pelican
#

wait I will translate

wintry quarry
#

nah it's ok - I got enough

wintry quarry
#

that means it will pass right through the door

#

and it will see the monster through the door

#

What you need to do is a raycast that hits the walls and the doors also

#

So like:

int mask = LayerMask.GetMask("Default", nomeDaLayerMonstro);
// Do your raycast here...
if (Physics.SphereCast(..., out hit, 15f, mask) && hit.collider.gameObject.layer == LayerMask.NameToLayer(nomeDaLayerMonstro)) {
  // We hit the monster
}```
#

This way if we hit the door that is blocking the monster, we don't treat it like we hit the monster

sleek pelican
#

Ok Im gonna try

#

He gives me a error on ...

#

Sequence of caracteres not allowed "..."

wintry quarry
#

I was showing an example

#

you have to write the real code

sleek pelican
#

oh ok

#

I was thinking in another thing maybe the capsule collider is not high enough

#

Because its very very small as you can is in the foot

wintry quarry
#

you definitely want to fix that

sleek pelican
#

What I need to do I dont know nothing about configure capsule collider I just put

cosmic quail
elfin pike
#

Want to make branched level unlocking with requirements.

Abstract requirement class with check function.
List nodes with object id's and requirements array. When I'm going check and save levels, there will be unlocked levels and next levels to unlock.

How does it sound?

grand snow
#

If you need to override requirement checking yes, otherwise it could just all be data and done the same for all

#

but this is hardly a beginner topic

solar hill
#

!code

radiant voidBOT
solar hill
#

please send the code properly

#

use a pasting site ideally

spice roost
#

okay

#

does anyone understand why the enemy just freezes in place?

wintry quarry
spice roost
#

have you read the entire code?

wintry quarry
#

yes

solar hill
#

also your direction Random.range(-1f, 1f); is probably returning very small values

#

if this is a 2d game i see no reason why you shouldnt use ints here, to define either left or right

#

you dont have partially left or partially right

wintry quarry
#

that too

spice roost
#

yes it causes pretty odd movement but that isn't the cause

solar hill
#

also slightly unrelated but whats the point of setting movement speed as a serialized field when youre overriding it in fixedupdate with hardcoded values?

solar hill
spice roost
#

not updated code

#

it was relevant earlier

wintry quarry
#

Have you actually done any debugging? Seems like the most obvious culprit is the line setting the speed to 0

solar hill
#

if you completely remove that line does your enemy move?

#

if so then its almost certainly your burstActive state.

wintry quarry
#

the logic in the BulletSpawner is pretty confusing/overcomplicated

#

so I wouldn't be too surprised if burstActive is getting stuck on

#

especially since you're essentially setting it to true every time you fire

spice roost
#

he does move yes but the point of burstActive is to enable movement when it's false and restrict movement when it's true

wintry quarry
#

and it never gets set false except in a coroutine that doesn't run until theere are 1000 bullets

spice roost
#

yeah

wintry quarry
#

do some debugging

#

it's really not worth speculating when we can just debug the code

spice roost
#

once bullet count reaches 1000, the enemy stop sending bullets and a coroutine sets isBurst to false, in which case movementSpeed should be 0.5f but it doesnt

#

okay sure

#

I am not super comfortable with debugging but I guess I gotta learn to do that

wintry quarry
#

it can just mean printing logs

#

you can just log whenever you set burstActive to true or false

#

and when you set movement speed to 0

spice roost
#

right I'll try that

#

figured it out

#

I assumed Unity would know what BulletSpawner was in MonsterMovement.cs

#

but apparently I had to drop the gameobject in there too

solar hill
#

you didnt assign it anywhere in your code

spice roost
#

because BulletSpawner is a public class and I'm calling it in MonsterMovement

#

public BulletSpawner bulletSpawner;

#

line 11

solar hill
#

youre not calling it

#

youre just creating a field

#

youre basically saying "ok if i had a bulletspawner, this is where it goes" but you never put it there, not in the inspector not in your code

feral mango
#

yo can i get some help

solar hill
#

ask away

sour fulcrum
#

(what if you had two bulletspawners, which one would it magically pick?)

spice roost
#

aaah I'd have to do = new BulletSpawner you mean?

#

to create an instance?

sour fulcrum
#

in c# yes but in unity the drag in drop is ideal

spice roost
#

aah okay

solar hill
#

yeah especially if you just need a reference to the prefab, not the specific instance in the scene

spice roost
#

I have never touched c# in Unity and I'm not great at c# outside of Unity either, my apologies haha

subtle mulch
feral mango
#

basically im making a mechic where a player picks up a shell and adds to a ammo counter a player can then shoot, problem is when i touch the shell ammo appears, i can shoot to clear ammo but a raycast wont appear until i actually input the amount of ammo in the inspector

spice roost
#

but thanks for the help guys, I appreciate it!

subtle mulch
#

can you record a short vid?

#

to explain

feral mango
#

yea hold on

solar hill
#

i think i understand... Their ammo counter is visually updating, but the weapon itself isnt

#

so they have to use the inspector to actually increase the ammo amount for it to be able to shoot

subtle mulch
#

if that's the case, then he prob is just incrementing the ammo counter and not the gun projectile counter

feral mango
#

bro i broke the shell pickup system trying to fix it holdon i gotta recode ds

pine garden
#

i have this bug in my inventoryGrid where if i pick an item and i put it over another item to swap, it instead overlap and make the other item unpickable, try to pinpoint the issue
https://pastebin.com/LWViHidG
the PickUpItem is called normally,but when i pick and swap with another item it doesn't call twice

pine garden
#

sorry, i change it to public

wintry quarry
#

the context here isn't that clear

#

Are these two PickupItem methods on two different classes?

pine garden
#

do you want the entire classes?

#

because theres ItemGrid and InventoryController

wintry quarry
pine garden
#

my inventoryController do the input and check if the item is place in a equipementslot or somewhere in the grid, it also check if you're out of bound or overlapped a item

#

the overlap check does work because it return true, so its cleary after the check

#

i was thinking that my CleanReferenceGrid method causing issue

#

thats where im having trouble, i can't find why my items are still overlapping

wintry quarry
pine garden
#

if i place item over an item, they should swap, but instead it overlap and the on-top item remain pickable while the other become unpickable

#

the unpickable item lost its heigh and width gridSize

grand snow
#

Generally when doing a grid inventory UI you want containers and a generic display that can show item information inside those
When you drag/drop you can either "swap" the views or just update the data and refresh the views

#

e.g. 0,0 -> 2,2
swap the item positions in inventory data then refresh both ui views to show new data

spice roost
#

Might be a silly question but if I have a script for a bullet spawner behaviour that acts a certain way, duplicate a bullet spawner that holds that script and then want to make modifications to the bulletscript for that new spawner, do I have to duplicate the bullet spawner script and make the changes or is there another way?

feral mango
#

there we go

solar hill
pine garden
#

in the mouse select

feral mango
wintry quarry
feral mango
#

mb look at it when yall ready

solar hill
#

if its entirely just values

#

you can use basic composition

grand snow
#

@pine garden

solar hill
#

but if the logic is actually different, you would probably need some base "projectile" class that your other ones inherit from

spice roost
#

I'm not sure what Monobehaviour does in this case

solar hill
#

if scriptb inherits from scriptA

sour fulcrum
#

and how MonoBehaviour already works 😄

solar hill
#

and scriptA inherits from Monobehaviour

#

that means that scriptb also inherits from it as well

#

As for what Monobehaviour does, its a bit complicated, but to boil it down it basically tells unity "I can be attached as a component"

spice roost
#

aah okay, so a base class for all spawners to inherit from and then modifications in the methods of the inheriting classes for different behaviours

sour fulcrum
#

MonoBehaviour inheritence is

object : Object
Object : Component
Behaviour : Component
MonoBehaviour : Behaviour

grand snow
#

Its the shit name unity picked for user made components that they cant change anymore

solar hill
#

the benefit over just duplicating Bullet and making Bullet2, is that if they share functionality, you now have to do double the work to update it everytime you have to

spice roost
#

aaah right

solar hill
#

So if theres some bug with the Move() method, and all individual Bullet copies have it, you have to fix it in every single one

#

thats no good

spice roost
#

I'm 6 months into my studies in software development and we went through the basics of C# the first 2 months and have covered so much since then that I've basically forgotten all the basics 😭 It's partially why I've started with Unity

solar hill
spice roost
#

Oh yes a lot more

rich adder
solar hill
#

i was just demonstrating inheritance

sour fulcrum
#

too much time being a family sitcom star

grand snow
solar hill
#

Well yeah isnt the Mono of Monobehaviour just "it uses c#"

spice roost
#

it's a high pace course so we also cover JS, frameworks, databases.. I have not held onto the basics well

solar hill
#

mono means 1
and behaviour means rail

grand snow
#

soon we will be free of mono but yea its legacy will be around for many years

spice roost
#

but I'm hoping coding in Unity somewhat translates a little

grand snow
#

I still remember MonoDevelop

#

Why not? C# is C#

rich adder
#

nothing about C# changes

spice roost
#

yes but it's also very different to say coding a back end in ASP.NET so idk how much it offers other than solidifying basics

grand snow
#

Its an OO language so that is the same

rich adder
elfin pike
grand snow
#

okay?

#

no idea what you mean im just saying how I would implement UI to reflect inventory/character data

spice roost
rich adder
#

I've used both SQL based and Object /NonSQL

grand snow
#

sqlite is an option too

spice roost
#

yeah that was the first thing we learned

#

then MSSQL

grand snow
#

micro slop sql

spice roost
#

hahaha

rich adder
#

ya sqlite is great tbh.
we cannot use Microslop SQL Server on mac anyway xD

spice roost
#

with docker no?

swift crag
elfin pike
rich adder
swift crag
#

one big thing I used to believe was that destroyed objects actaully disappeared from C#-land

grand snow
spice roost
#

MSSQL feels extra in comparison

rich adder
#

havent touched a raw SQL line in a while.. Entity framework spoiled me :x

spice roost
#

haven't used it yet but I know it's standard

rich adder
#

though I find object based sometimes more what I need anyway, like mongodb or amazons dynamodb

feral mango
#

Ummm can i get some help now

sour fulcrum
#

fuck standards i converted a google sheet link into json

rich adder
stoic pond
#

when i try and open my scripts in unity it just says select an app to open with (im brand spankin new)

radiant voidBOT
grand snow
#

choose your starter!

rich adder
#

choose pokeball moment from professor oak

feral mango
rich adder
feral mango
#

basically im making a mechic where a player picks up a shell and adds to a ammo counter a player can then shoot, problem is when i touch the shell ammo ui wont change, i can shoot to clear ammo but a raycast wont appear until i actually input the amount of ammo in the inspector

rich adder
solar hill
#

I already made an assumption about this

#

if the ammo counter is visually changing, but you cant fire

wintry quarry
#

my guess is the ammo in the pickup script or whatever is doing the picking up has nothing to do with teh shotgun ammo counter

solar hill
#

yeah this

rich adder
#

was thinking the same

solar hill
#

maybe the visual ammo counter is disconnected from the actual one for whatever reason

#

and the pickup script only updates that one

feral mango
#

no ive rechecked it

solar hill
#

can you just share the code please

#

the code for the pick up

wintry quarry
feral mango
#

sure

#

pastebin?

solar hill
#

and your ammo/weapon logic

wintry quarry
#

share all the code

solar hill
wintry quarry
#

the pickup and the shotgun and the ui

solar hill
#

yeah ui too

rich adder
#

!code

radiant voidBOT
rich adder
#

pastebin is full of weird adware

solar hill
#

Oh wait you changed the description of the issue

#

the ui isnt changing either'

#

then its almost certainly an issue with the ammo pick up

feral mango
#

but look at the debug log

#

thats what im thinking too

solar hill
#

the debug log almost certainly confirms that the shell never gets added to your ammo count

feral mango
#

3 files, shotgun, pickup, and ui

solar hill
#

check that last link for me 5

#

but "Debug.Log("Shell picked up!");" is being called 🧐

#

that means that gun isnt null

rich adder
#

oh wait nvm its on the Player itself.. I see what they doin

solar hill
#

it might be the AddAmmo function then

#

@feral mangosend us the script of whatever has the AddAmmo function

rich adder
#

maybe there is a Copy of Shotgun in the scene and its picking up the wrong one since its FindObjectByType

feral mango
#

the only thing that has the add ammo is the shell

rich adder
solar hill
#

no where is the AddAmmo function defined?

#

we need that script

feral mango
#

i guess it isnt lol

#

ihh shotgun script

solar hill
#

what

solar hill
feral mango
#

this the shotgun script

feral mango
solar hill
#

when did i say that

solar hill
#

"no***,*** where?"

rich adder
feral mango
#

thats embarrasing

#

its on the player too

rich adder
#

lol had a feeling FindObjectByType was doing some like that

feral mango
#

literally been stuck on this for 2 days im sooo mad

#

thanks man

rich adder
#

I would replace

  if (other.CompareTag("Player"))
        {
            Shotgun gun = FindFirstObjectByType<Shotgun>();```
with 

if (other.CompareTag("Player"))
{
Shotgun gun = other.GetComponentInChildren<Shotgun>();```

#

delete the copy first ofc

feral mango
#

will do

#

appreciate everyone that helped

rich adder
golden canopy
#

what do you guys think of this

#

i made a function that checks if the player has a ledge infront of him, scans the length of the surface above the ledge and returns an edge and checks if player could stand or vault over it

wintry quarry
#

Sounds like a thing

elfin pike
waxen adder
swift crag
golden canopy
#

yiss exactly i hae that

golden canopy
barren osprey
#

!ide

radiant voidBOT
nocturne parcel
#

Is there a way to recompile scripts?

#

Ctrl+r does nothing for me

slender nymph
#

ctrl+r just refreshes unity to import any changes, which means it will compile if there are changes to code. is there a reason you need to recompile? surely your changes to the code were compiled when you either saved them or when you used ctrl+r (if auto refresh is disabled)

nocturne parcel
#

I'm using a serialized dictionary, but changes seem to only take effect after compiling

#

Which makes them kinda useless lol

sour fulcrum
#

That doesn’t sound right

inland pecan
#

Hello!
I’m a unity learner and I’m pretty really new to unity, and I’m curious about some things

How would I know where to put scripts and when to use them in their right contexts? Do I need to look at other open source projects?

Also, I’m not really a YouTube learner, so I just mostly depend on unity documentation and Google searches. Thanks in advance!
(By the way I know how to code in c# so it’s not the greatest worry of mine, I just hope I’m not using scripts in their wrong ways)

echo ruin
rich adder
inland pecan
#

Sounds good, I was just having a hard time with it since I've moved from Roblox studio, and scripts there and scripts in unity are so different in terms of where to put them and stuff

short gust
#

when I have a regular spherecast against flat PLANE mesh collider for ground check - I have wrong gibberish normal all the time on X and Z, but Y is right, but when I change the collider to BOX - I've got the "right normal" without this random values in X an Z axis.
I just want to know - why it does that or is this "normal behavior" in general for stuff like that?

echo ruin
north kiln
short gust
inland pecan
north kiln
inland pecan
short gust
north kiln
#

it's likely -6.76....e-16, i.e. approximately 0

#

(i.e. 0.000000000000000067...)

#

and you will always have this with floats, there's inaccuracy in calculations, and most values can't be represented perfectly at all

echo ruin
# inland pecan like I would have a module for player crouching and a module for player sprintin...

You don’t really need to initialize anything in Unity in the same way.
You can make prefabs, which are objects that you can “initialize”/spawn at runtime.
But the thing you’re refering to, I think, wouldn’t be necessary in Unity. Instead, you would just have to make sure your script is present on an object in the hiearchy.

If you have written a script to handle player movement, just be sure that it’s present somewhere in the hiearchy (preferibly on the player object).

If you have written a TimeManager script, for example, that isn’t necessarily pary of any object, you can just create an empty object and shove it in there.

The key is just that the script is present in the scene/hiearchy.

inland pecan
short gust
# north kiln it's likely `-6.76....e-16`, i.e. approximately 0

okay, didn't think about that, lol. I've stretched a lot my editor a lot and it is indeed like that. sorry for that poor screenshot and my blindness.

but I still don't get the inaccuracy in plane mesh collider and not on box one. like, why does only mesh gives those error while it's pure flat and perpendicular and box collider is fine no matter what? or it's just whatever the engine gods do

north kiln
#

You can't rely on the box collider being accurate either, but it's certainly simpler to find the normal of a box than it is a mesh, and the simpler calculations will result in more accuracy

short gust
#

ah, oki. thanks for the info!

runic urchin
#

hey so im pretty new to coding and i have been following tutorials and such on youtube to learn while piecing together my first project but with some things that are outdated or dont have a lot of people talking about in various forums i have been using AI to help make the scripts. I have been making sure i go through and understand the code it creates and such but i wanted to see if this is an ok way to learn or not. i just really dont want to stunt my growth with coding so advice here would be greatly appreciated

frail hawk
#

i would not recommend using ai as a beginner

#

learn coding without the use of ai, it is something completely different

runic urchin
#

alright, so what would be a good way to learn how to do stuff? i feel like i can picture the process of what i want to do with everything but i cant put it in the C# language. like I'm trying to tell someone how to do a job but they speak a completely different language.

frail hawk
#

if you are not able to put it in c# language that means you have to experiment and learn more. just learn the basics of programming without the use of c# in unity

runic urchin
#

ok i see, i appreciate you answering my questions!

frail hawk
#

you are welcome

elfin pike
#

Want to make branched level unlocking with requirements.

Abstract requirement class with check function.
List nodes with object id's and requirements array. When I'm going check and save levels, there will be unlocked levels and next levels to unlock.

How does it sound?

distant saddle
#

Hello guys , beginner in Unity , is there a way to "cap" the falling speed of some objects ? i'm making a 2D platformer where the gimmick is that you have to go down a lot but at some point , you fall so quickly that it's unplayable (and you clip thought floors)

keen dew
#

Depends what mechanism it uses for falling. If it's a rigidbody, check if the velocity is larger than max speed and set it to max speed if it is

distant saddle
#

i will try i guess .

keen dew
#

Every fixedupdate, yes

tiny bloom
#

should I switch to vulkan? im on linux
ik it doesn't affect the output, just wondering if it's better during development

elfin pike
stuck parrot
#

does anyone have a simple 3rd person setup that can put on a capsule object and the movement just works including the camera? im trying to make a reliable player controller for 2 or 3 weeks and I just cant do it

frail hawk
#

you should have searched the asset store earlier

stuck parrot
#

Any tips on how to make a 3rd person controller setup? moving WASD, rotating camera with mouse, not having trouble with weird colisions, wall clipping or other physics problems?

frail hawk
stuck parrot
inland pecan
#
    void Update()
    {
        float ZAngle = gameObject.transform.rotation.eulerAngles.z;
        float TargetZAngle = Mathf.Lerp(ZAngle, -50, 0.1f);
        gameObject.transform.rotation = quaternion.Euler(new Vector3(0, 0, TargetZAngle));

        if (Input.GetMouseButtonDown(0))
        {
            rigidBody.linearVelocity = new Vector2(0, PlayerInfo.JumpPower);
            gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 10));
        }
    }

why is the rotation acting crazy?

frail hawk
#

only when you press the button or?

inland pecan
#

always

#

its just rotating uncontrollably

frail hawk
#

is the code even compiling, you have typos there

#

quaternion.Euler // this line

inland pecan
#

it is

#

it might be because i used quaternion and not Quaternion? idk

#

im gonna try

#

nvm still rotating uncontrollably

grand snow
#

Btw you can access transform directly, you do not need to do gameObject.transform

inland pecan
#

oh interesting

naive pawn
#

it's from separate package and it has an implicit conversion to Quaternion

frail hawk
#

ok

elfin pike
#

i hope somebody atleast answer on this question, if other ones get ignored.
GetInstanceId on scriptableObjects change between builds or playing sessions?

naive pawn
#

...what's your question?

naive pawn
# frail hawk ok

(to be clear, it's likely an issue, but wouldn't be a compiler error)

naive pawn
#

the instance id is in the file

#

you can view it directly

elfin pike
#

because editor instanceid and build instanceid are not same. Also asked chat bot about getinstanceid and didnt advice for me to use it, because id can change

elfin pike
hexed terrace
#

probably read it as that it COULD change / is not GAURANTEED to be the same all the time.

elfin pike
#

i shouldnt use it or i have to make my own and store in field

grand snow
#

If you need unique ids then use your own or in editor grab the guid and store it

#

I dont actually know if we can get an asset guid without AssetDatabase

fresh wadi
#

hello ive been picking up unity/game devlepment again after years of not doing it

strong wren
fresh wadi
#

ive done coding alot before but just a little bit rusty but its starting to click abit for me

inland pecan
# inland pecan ```csharp void Update() { float ZAngle = gameObject.transform.ro...

ok so this branched out to a less annoying bug..

    void Start()
    {
        rigidBody = GetComponent<Rigidbody2D>();
        ZAngle = transform.rotation.eulerAngles.z;
    }

    // Update is called once per frame
    void Update()
    {
        ZAngle = ZAngle - 0.1f;
        ZAngle = Mathf.Clamp(ZAngle, ZAngle, -50);

        transform.rotation = Quaternion.Euler(new Vector3(0, 0, ZAngle));
        ZAngle = transform.rotation.eulerAngles.z;

        if (Input.GetMouseButtonDown(0))
        {
            rigidBody.linearVelocity = new Vector2(0, PlayerInfo.JumpPower);
            transform.rotation = Quaternion.Euler(new Vector3(0, 0, 25));

            ZAngle = 25;
        }
    }```
for some reason now, it only lerps once(reaches -50) and is stuck at -50 no matter what i set the rotation to after that.
naive pawn
#

don't read back eulerangles, they may not be consistent

#

also what's with that clamp lol

#

you've set the max to -50

#

so it's going to stay at -50 once it reaches that

inland pecan
naive pawn
#

would probably be clearer if you use Mathf.Min instead of the Clamp

inland pecan
#

so i instead would just clamp it

#

alright ill try

naive pawn
#

that wouldn't change anything, it just makes the problem more obvious

naive pawn
naive pawn
inland pecan
naive pawn
#

maintain your own variable and only assign into euler angles

#

just remove the ZAngle = transform.rotation.eulerAngles.z;

inland pecan
#

mhm

naive pawn
#

you don't need the transform.rotation = inside the if either, just move the other one to be at the end of Update

#

what's the goal here exactly?

inland pecan
#

something like flappy bird's bird

#

when it falls it rotates to the side

#

and when it jumps its rotation gets set to something like 25 degrees

#

i think i figured out something