#💻┃code-beginner

1 messages · Page 580 of 1

cosmic quail
#

finish your game? that's gonna take a while 😆

polar acorn
#

Instantiation is the method by which you create a GameObject

fossil tree
#

not spawn it

void thicket
#

What are you going to do with the instance?

polar acorn
naive pawn
polar acorn
#

Or, if you want an existing game object to become an enemy, you could use AddComponent instead

fossil tree
cosmic quail
eternal falconBOT
#

:teacher: Unity Learn ↗

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

fossil tree
polar acorn
eternal falconBOT
naive pawn
# fossil tree yes i wanna tell it to unity

we've told you quite a few times, if you want to instantiate a gameobject with Enemy, you can do so via Instantiate, or you can add Enemy to an existing gameobject via AddComponent
you can't instantiate Enemy on its own

naive pawn
fossil tree
#

here the ennemy script

#

and here what i try to do on my dummy script

polar acorn
void thicket
naive pawn
#

i don't think messing with quaternions quite counts as "beginner", you might want to try #archived-code-general

polar acorn
#

The first case will add the enemy component to the game object currently running this script.

The second one is illegal

fossil tree
polar acorn
fossil tree
#

i try to do this Enemy trainingDummy = gameObject.AddComponent<Enemy>(); trainingDummy.SetPv(10); Console.WriteLine(trainingDummy.GetPv());
and that dont write it

naive pawn
#

unity does not use Console.WriteLine

#

you would use Debug.Log to log stuff in the editor console

fossil tree
#

oh i'm so dumb

#

i miss this

naive pawn
#

this is why we told you to go over unity essentials

fossil tree
#

i just forget it

#

but i know that

naive pawn
#

go over the essentials

void thicket
#

Vector3.right (normal you projecting to) is world space. If your camera yaw is rotated it will not behave same.

#

Your player uses Vector3.up which works because your player always stands upward

final kestrel
ornate aurora
#

Yes. After fixing all of the cache stuff I got the GC alloc down to 54kb from 129 previously (I couldn't cache some stuff because I'm saving those in a dict). And now the performance changed very drastically. With deep profiling the results were pretty much the same, around 15fps, but without it the fps shot up to 120 minimum. Is performance really THAT sensitive to GC?

void thicket
final kestrel
#

Yeah it gets rotated with player but nothing changes considering the Y axis atleast on my Camera.

#

Thats its local yaw I believe no?

#

The one that doesnt change.

void thicket
#

Because Vector3.right is worldspace

final kestrel
#

So do I have to minus the yaw from my camera somehow to be able to calculate correctly?

tender breach
#

How do you change variables across functions in c#?

naive pawn
#

sounds like you're asking about scoping?

tender breach
#

Scoping?

naive pawn
#

wdym by "across functions", exactly?

tender breach
#

If had a variable in one function, how do I change it in another?

naive pawn
#

what's the relationship between those functions?

#

is one called by the other?

#

or are they just unrelated?

#

are they in the same class?

void thicket
naive pawn
#

in general, you just don't do that
there is 1 pattern where you would, but considering you're asking about it i don't think it's the right solution for you
it sounds like you may have an https://xyproblem.info, but i can't be sure since you've given very little information

tender breach
final kestrel
#

Thanks

hybrid prairie
#

pro builder window not showing? anyone could help me out?

naive pawn
tender breach
#

I'm using visual studio.

naive pawn
#

so what variable and methods are you talking about exactly

rocky canyon
#

and ull see a new tab on the left above ur toolbar

hybrid prairie
#

i see, i figured they changed it thank you

naive pawn
tender breach
naive pawn
#

..do you want it to be one?

tender breach
#

Yes

void thicket
naive pawn
#

you wanted this to be accessible across different functions, right?

tender breach
#

Yes

naive pawn
#

a local variable isn't going to be accessible across different functions

tender breach
#

Then no.

naive pawn
#

seems like your code already does what you want it to

final kestrel
naive pawn
#

but uh yeah.. the entire class is..not great

#

this class is doing way too much

rocky canyon
naive pawn
hybrid prairie
rocky canyon
#

the rest of the meter is cut-off until it actually hits 1 meter

#

b/c probuilder does auto uv's and tiling pretty well last i used

naive pawn
#

i did not notice that, thanks for pointing that out

rocky canyon
#

np 🙂

#

had to make sure they didnt break it w/ the new update

#

lol

naive pawn
#

i think you were moving too fast for me to notice since im not familiar with it lol

rocky canyon
#

ya, i work too fast for my own good sometimes 🤣

faint agate
#

hello, im trying to access this softness in script so I can turn it from 0 to 100 over x amount of time. the only problem im having at the moment is accessing it in script. I looked around but couldnt find help if anyone has advice

rocky canyon
tender breach
naive pawn
#
  1. what is the issue?
  2. this class is doing too much work, and getting overly complex and cluttered. seems like you should modularize it
faint agate
rocky canyon
#

might need to make a copy of the material to apply a new instance of it (after changing it) to that text and only that text..

faint agate
languid spire
warm field
#

so i got an error called CS0106: The modifier 'private' is not valid for this item

#

how do i fix it?

languid spire
#

remove the word private ?

rich adder
#

which would be invalid

warm field
#

hold on gonna send code i wrote according to unity learn

rich adder
#

local method definitions cannot have access modifiers

warm field
#
using StarterAssets;
using UnityEngine;

public class Collectible : MonoBehaviour
{


    public float rotationSpeed;
    public GameObject onCollectEffect;
    public float jumpForce = 5.0f;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {

    }

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


        transform.Rotate(0, rotationSpeed, 0);

        if (Input.GetButtonDown("Jump"))
        {
            rb.AddForce(Vector3.up * jumpForce, ForceMode.VelocityChange);
        }


        private void OnTriggerEnter(Collider other)
        {
            if (other.CompareTag("Player"))
            {
                // Destroy collectible
                Destroy(gameObject);

                // Insantiate particle
                Instantiate(onCollectEffect, transform.position, transform.rotation);
            }


        }
    }
}
rich adder
#

yup.

#

You defined a method inside a method

warm field
#

asi in i defined a void in a void?

rich adder
#

they are called functions/methods

languid spire
#

no, void is a return type. A method is a method

rich adder
#

void is just a return type for a method (means return nothing)

warm field
#

so i just remove the 'private'?

rich adder
#

no

#

close the Update method

naive pawn
#

you have a method inside a method
that's bad
you have to move the method inside to not be inside

rich adder
#
//valid
void Method1(){
void Method2(){
}}
//not valid
void Method1(){
private void Method2(){
}}```
#

thats called Local Function ^ but 98% of the time you wont ever need local functions

#

aside from that OnTriggerEnter is a Unity callback / event invoked by Unity so you don't directly call this method, especially if its inside another method Unity won't see it.

warm field
#

huh weird, it worked before

rich adder
#

it worked probably because it was outside of Update as it properly should be

warm field
#

does it have to do with me accidentally removing and readding a }?

rich adder
#

well yea

#

} closes a code block

#

if you open Update() {

} closes it

warm field
#

i completely broke the script i think

languid spire
rich adder
warm field
#

i have visual studio

rich adder
#

doesn't answer the question

#

configured and having the app are two different actions

warm field
#

probably not then

rich adder
#

if your didn't get that CS error in the Visual Studio console or underlines in red , its likely not

#

⬇️

eternal falconBOT
warm field
#

according to message above it seems it is configured

rich adder
#

hmm I'm confused..

#

looks configured but why is your theme like that..

languid spire
#

you very obviously have not put the } back where it belongs

warm field
#

that is very much possible, but i already cut and repasted the code to readd the {} correctly

rich adder
#

also that Jump would need Impulse forcemode

languid spire
#

that is why I asked if you could count

naive pawn
rich adder
naive pawn
#

yeah

rich adder
#

those colors are bugging me lol why aren't methods Yellow and classes are white..

naive pawn
rich adder
#

ahh ok.. wasn't there an Image somewhere here used to go around?

naive pawn
#

yes, i have no idea where it's from

rich adder
#

ah found it

#

rip #UnityTips

naive pawn
#

(impulse is aka momentum, p = mv)

warm field
#

found my mistake i think

rich adder
warm field
#

it was closed

rich adder
#

no it wasnt

warm field
#

i just placed the private void in the update void

rich adder
#

yes it was closed but not properly

#

should've been closed on line 27

warm field
#

huh, it is still giving error

#

rb does not exist in the current context

rich adder
warm field
#

thats the jump function

rich adder
#

its giving you basic syntax error but not missing component

rich adder
#

that should be underlined red.

#

You need to close VS go into unity and try regen project files

warm field
#

weird thing is, my visual studio isnt showing any errors

rich adder
#

because its stuck into some weird state

#

it should be underlining more, even if it says Assembly-CSharp which is correct, its like halfway

warm field
#
void Update()
{
    transform.Rotate(0, rotationSpeed, 0);

    if (Input.GetButtonDown("Jump"))
    {
        rb.AddForce(Vector3.up * jumpForce, ForceMode.VelocityChange);
    }



}
rich adder
#

yes yes no need to show me this, the error is already clear

warm field
#

so i just reboot vs

#

also ill change my language to english while im at it

rich adder
# warm field so i just reboot vs

I never said reboot. I said close VS go into unity go to External Tools in Preference and do Regen Project files, then open script again from unity

warm field
#

oh

rich adder
warm field
#

nice, it underlined the rb now

rich adder
#

ok good

#

the other things White turn into Green/Yellow?

warm field
rich adder
#

ok good good

#

now you're coding properly

#

it was like "stuck" or something , Anyway. To fix this error should be pretty clear, you have to define something before you use it

warm field
#

as in public void rb?

#

well not void but

rich adder
languid spire
#

please go and learn some c# basics

rich adder
#

yes you need basic c#

warm field
rich adder
#

check out the Unity Pathways like Essentials and Junior, they will teach you

warm field
#

i am in essentials rn

rich adder
#

oh okay, so they certinly showed you how to make a reference and use its functions

#

look carefully

warm field
#

i just realised im stupid, i put the code in the wrong script

#

yep it compiled correctly now

rich adder
#

this is a code channel

hybrid prairie
#

where would i put this issue in?

hybrid prairie
#

thank you

rich adder
# hybrid prairie thank you

also it looks like you don't even have grid snapping on, something you should probably be using. I keep all my pivots at the corners so they are easier to align

hybrid prairie
#

I see thank you for the help

tender breach
#
  1. I don't understand how to do it.
naive pawn
#

I want to make the variables change across the voids.
that's not an issue, that's what you're trying to do. and you're already doing that
also, those are methods returning void, not voids

tender breach
naive pawn
sage peak
#

Hey guys! Whats this error?

#

How do I fix it

astral falcon
daring crescent
#
public ParticleSystem runParticles;
if(stateIsActive && isGrounded)
{
    runParticles.Play();
    runParticles.emission.enabled = true;
}

Could someone tell me why the runParticles.emission.enabled = true; throws an error?

#

Here is the scripting reference

astral falcon
#

And also the error would be good to know...

daring crescent
#

yeah my visual studio is in german and i need to change it first because these errors are weird to translate 😄 I should change the language instantly. But as you said it works now. Could you try to explain, why i have to store it first?

swift crag
#

When did this come up? After installing a new package?

sage peak
#

Nope, it just randomly came up

rich adder
swift crag
#

Unity (or some other program) is using that file in a way that's preventing it from being opened

#

(the executable)

daring crescent
#

Would this be same in a c# Console App or is that unity specific?

rich adder
swift crag
#

I'd quit the editor and reopen it. If the problem persists, delete the Library folder to make Unity reimport everything.

This will take a while, and it'll dump you into an empty scene on startup

swift crag
#

Structs are value types. They are always copied. You don't "share" a struct

#

Therefore, doing something like this is, normally, pointless

rich adder
daring crescent
swift crag
#
transform.position.x = 3;

You'd be modifying the Vector3 copy returned by transform.position, which is a property

#

so, reading transform.position is like calling a method that returns a Vector3

#

Now, on the other hand, the particle system does something very interesting

swift crag
#

All of its modules are structs -- but they have properties that wind up calling into native code

hot laurel
rich adder
#

yeah PS its weird because some you can directly change
It still confuses me sometimes

swift crag
#

So even though ps.main is a struct, changing its properties affects the particle system it came from

sage peak
astral falcon
#

in the end you access a valuetype (struct) when accessing directly, that would just copy it and not reference it, so you are changing the modules fields, but only the modules copy when doing particlesystem.emission directly

swift crag
#

You get a unique copy of the main module struct, but it points back to the original particle system

#

So, in theory, it would make sense to do ps.main.whatever = 123;

#

But the compiler refuses to let you do this.

daring crescent
daring crescent
tender breach
#

Why do variables in different methods change in unity but not visual studio?

astral falcon
daring crescent
#

I will grab a book or read some articles about structs, i should get it then 😄

sage peak
tender breach
swift crag
astral falcon
rich adder
#

are you talking about a breakpoint ? what is a "circle in visual studio"

swift crag
tender breach
rich adder
#

this is a !cs question

eternal falconBOT
rich adder
#

also learn how arrays work jesus

#

and loop

tender breach
#

What do those have to do with anything?

rich adder
#

you should never have variables a1,a2,a3,a4 etc.

rich adder
tender breach
#

Nothing

astral falcon
#

especially the circle nto showing when hitting the button. This explanation is so random for someone not in your project

tender breach
#

So I should just pair program at this point?

astral falcon
#

Try to give it some thought and ccome back with something anyone can understand apart from you

rich adder
#

again this isn't a unity question

frosty hound
#

@tender breach This is the Unity server, and this isn't the first time you've been told non Unity questions don't belong here. Next will be moderated.

naive pawn
#

that explains a lot

tender breach
#

You know what? I'm leaving this server since people are being mean to me for no reason!

frosty hound
#

See ya!

naive pawn
#

do you even have unity installed

tender breach
rich adder
#

are you a child

tender breach
#

I have autism.

astral falcon
#

I think we can all calm down now.

naive pawn
# tender breach Yes

out of curiosity... was the thing you were asking about, related to unity at all

astral falcon
#

Osteel has already taken care of it and anthony knows where to go to ask.

final kestrel
#

Do you all try to avoid playing with single euler angles? If so can you please explain why?

tender breach
#

I'm about to leave.

final kestrel
rich adder
final kestrel
#

Oh you were asking why would it be something to avoid my bad.

rich adder
#

at most, dont ever directly modify euler angles or use them for calculations

#

always use Euler -> Quaternion and vice versa

final kestrel
#

the arrow means convert them, change whatever you want then convert back to Quaternions?

rich adder
#

yeah like if you want to change euler of x, dont do transform.rotation.eulerangles.x =

swift crag
rich adder
#

do Quaterion.Euler (myval

naive pawn
#

consider quaternions to be the "canonical" representation of rotations

swift crag
#

the most obvious one is gimbal lock, where changing two different axes produce the same rotation

astral falcon
#

Modifying euler angles will most likely run you into issues like gimbal lock and so on. thats why you should let quaternions take over the calcuations and then you can access the euler angles again if needed

swift crag
#

slight rotations can cause your euler angles to change dramatically, too

final kestrel
#

Aa so its fine to convert Quaternions to eulers, play with them and back to Quaternions for calculations?

swift crag
#

No.

#

Unity would turn the euler angles back into a Quaternion anyway.

#

You should, instead, use the Quaternion methods to manipulate rotations

final kestrel
#

Oh okay. I see

swift crag
#

If you want to spin a rotation around an axis, use Quaternion.AngleAxis(angle, axis) * oldRotation

#

the * operator combines two rotations

#

actually, I have that one backwards, don't I

#

lhs * rhs gives you the result of applying the lhs rotation, followed by the rhs rotation

astral falcon
#

There are very spare situations where it makes it "clearer" in code when working with eulerangles, but only if you really know, that you dont hit the limits. But as Fen said, get used to quaternion operations in unity would be the profound way

swift crag
#

Quaternion multiplication is associative, but not commutative

final kestrel
#

Ah. Makes sense. I think it was you the other day too Fen. Who taught me about Vector3 methods so I could avoid this?

swift crag
#

(A * B) * C = A * (B * C)
A * B /= B * A

swift crag
daring crescent
swift crag
#

Vertx did a great job with it.

#

I refer people to the physics section all the time.

swift crag
astral falcon
#

vertx ftw

final kestrel
#

Yeah I am studying them still. Thanks. I'm still trying to make my player's camera to look up or down at my lookTarget

#

but I managed to turn my player object to face my target today woho!

rich adder
#

rotations are still bane of my existence, grateful for those quaternion functions

final kestrel
#

Having below average iq doesnt help. I'm struggling real bad without progress

balmy charm
#

hey would someone help me with a* pathfinding project package that i installed but cant get to work perfectly

rich adder
balmy charm
#

sure i was going to send a video

faint agate
balmy charm
#

the character cuts out so much path from where it shouldnt go

rich adder
#

my guess is one of those distances you have set are too large

craggy lake
#

can anyone help me fix this thing where i cant see a list pop up

rich adder
#

the distance between points n such

eternal falconBOT
craggy lake
#

alr, ty

rich adder
#

might be too large

final kestrel
#

Wow. I just learned about that site UnityHow. What a great site!

balmy charm
rich adder
#

if you want a Ranged enemy, you have to do a distance check(eg Vector2.Distance) then stop / resume the A* pathing from there

balmy charm
#

thanks i understood now!

#

btw what do you think is the best way to sort layer orders in top downs ?

#

i painted my tile map with specific layer orders

#

and sorted by Y axis

rich adder
#

like rendering layers?

balmy charm
#

yes

rich adder
#

yeah thats usually the best way

#

so you don't have to shift the Z pos

#

I don't do much 2D so I can't really give you much advice there 😅

balmy charm
#

thanks for the next waypoint distance advice saved me a lot of time

#

have a great day

craggy lake
# rich adder !ide

i updated the editor through package manager and checked for other updates, but i still dont think it works properly

#

any idea what im doing wrong?

rich adder
#

make sure you diligently check the other steps

craggy lake
#

need to do all of these then?

rich adder
#

and which ide you got

craggy lake
#

(installed via unity hub)

astral falcon
#

maybe check the troubleshoot page

craggy lake
rich adder
queen adder
#

Hello

craggy lake
astral falcon
#

Open by file extension, nope. select visual studio there

rich adder
astral falcon
#

Like the first step coming up when oepning the link and you skipped it 😄

craggy lake
#

so far i think i did the steps on getting started

#

didnt see this side bar at first

astral falcon
#

you click the link and it deep links you directly to that dropdown...

craggy lake
#

OHHHHHHHH

#

i mustve been looking to the wrong area...

rich adder
#

yes the content is in the middle lol

#

you can skip the one under it obv "Add a version of Visual Studio that isn't listed"

faint agate
west radish
rocky canyon
# faint agate Helo, is the bottom two go in Start cause thats where I put it. I did some testi...

when building this mechanic i would probably consider making a drastic change first and make sure ur interacting w/ the correct object/material/etc all that jazz.. it may help to make different materials and feed that material straight into the inspector using a public or [SerializeField] private variable for the material itself.. or u can create one dynamically / a copy

but run debug logs to make sure the values are correctly changing.. and then figure out whats changing.. where rather..

west radish
#

google is pretty unhelpful searching "UnityHow" because it just gives a million results of people asking questions 🤣

west radish
#

Sweet!

rocky canyon
#

im only changing the face color.. but its similar code.. what do u have?

faint agate
#

when I change the number in game, I can see it change in log but nothing really happens

rocky canyon
#

and since TMPro is basically a mesh.. (i think).. if u do anything to the other stuff like outline width, underlay etc.. then u need to call
UpdateMeshPadding() * see // below

#

check the tmpro element's material

rocky canyon
#

or.. let me fix a mistake of mine.. we're not actually doing a copy
but getting a reference to the material instance already being used by that specific TMP element

#

you could however create a copy and apply it back but thats kinda pointless imo. maybe for specific reasons..

rocky canyon
# faint agate

hmm yea, now that i have a project open i can get the font-face color to work.. but not the softness

#

doesnt seem to have a FaceSoftness

faint agate
#

its okay if not

#

ill do like a fade out instead if anything

#

i appreciate the time and help

rocky canyon
#

i mean its there.. i just cant figure out how to access it myself.. lol

gloomy cosmos
#

Hello, I created an assembly definition and get this error:
The type or namespace name 'BurstCompatible'
I added Unity.Burst to the .asmdef... Is there something else that has to be done?

lean basin
ocean loom
#
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Portals : MonoBehaviour
{
    public HashSet<GameObject> portalObjects = new HashSet<GameObject>();

    [SerializeField] private Transform destination;
    [SerializeField] private Transform Entry;
    private float cooldown = 5f;
    public Vector2 velo;
     

    private void OnTriggerEnter2D(Collider2D collision)
    {
      

        velo = collision.GetComponent<Rigidbody2D>().velocity;
    
        if (portalObjects.Contains(collision.gameObject)) 
        {
            return;
        }

        if (destination.TryGetComponent(out Portals destinationPortal))
        {
            destinationPortal.portalObjects.Add(collision.gameObject);
            
        }

        collision.transform.position = destination.position;
        collision.GetComponent<Rigidbody2D>().velocity = -velo;
        
    }

    private void OnTriggerExit2D(Collider2D collision) 
    {
        StartCoroutine(Cooldown());
        portalObjects.Remove(collision.gameObject);
    }
    private IEnumerator Cooldown()
    {
        yield return new WaitForSeconds(cooldown);
    }
    
}

how do i make this so the portal, shoots out the object entering it, in the direction its facing.

cosmic gorge
#

anybody know why my player is showing up behind my background tilemap??

#

i know it has something to do with layers but i cant figure it out

gloomy cosmos
#

increase the sorting index on the sprite renderer

ocean loom
#

change the order in layer to 1

rich adder
gloomy cosmos
rich adder
#

no

cosmic gorge
#

ok tysm

rich adder
#

unity is still a 3d engine

willow iron
#

yo, want to make a save system. i need to store relatively simple data: what level you have unlocked. coins, inventory, ect. anyone got anytips? needs to work when i upload my game as a browser game to itch.io
i would also enjoy if you could link a coherent tutorial along with it. ive found lots of documentation on but nothing that explains how to put all of the code together into a working save system

obsidian plaza
#

assuming its singleplayer its pretty easy

#

forgot words wait

obsidian plaza
obsidian plaza
#

you can also serialize it with json or binary and save with playerprefs

rocky canyon
obsidian plaza
#

i couldnt get json to work when i tried initially for some reason so i did binary but apparently its less safe so if it was a multiplayer game itd prob be a bad idea

rocky canyon
#

for simple stuff json.. and the jsonutility been great for me

obsidian plaza
# rocky canyon

would this work for a browser game tho? would u have access to their files? or would u save with playerprefs so that it goes in the browser's storage

rocky canyon
#

i can use pretty print and get nice lookin structs i can read in any notepad / markdown editor

rocky canyon
#

most ppl i hear using playerprefs

#

id think browser limitations will get ya more than what u chose to use tho

#

im not web-savvy when it comes to that

willow iron
#

err, ok i think im getting it... so if playerpref works out of the gate then something like this should just work?

edgy tangle
#

IIRC for web your json file needs to be in StreamingAssets… something to do with security preventing you from getting the data externally. PlayerPrefs does work for web tho I know that much.

earnest wind
#

public List<object> OldValue;
public List<object> NewValue;
why would this not show in the editor?

edgy tangle
#

I don’t think you can show C# objects in the Inspector

#

You might want to instead be using Unity Objects

earnest wind
#

im making a undo and redo system

#

with different types of data, like vectors, and more sooner

grand snow
#

lets not save loads of json in player prefs 😐

edgy tangle
#

What’s the best practice for web builds then?

#

The only other way I know you can read from json (and I assume write to it also) is to have the file in StreamingAssets.

earnest wind
grand snow
#

Oh if its for web i presume it goes to local storage? may not be soo bad in that case

earnest wind
#

or should i just make my own inspector for debugging

#

i already have my own inspector i guess

rich adder
edgy tangle
silk aspen
#

Hey guys. I'm not sure why, but when i try to rename a blend tree and press enter it changes the text in the number "60" for some reason... Do you experience the same issue? Version: ''6000.0.34f1''

earnest wind
edgy tangle
#

And then pass the type for the Inspector to draw

earnest wind
#

would probably take a lot of time to write

queen adder
#

x and xdone is being called in build btw

#

just the light doesnt turn on

queen adder
#

that's more of graphic place tho

#

the problem is with light2d component

astral falcon
#

yeh, and I do not think, your code magically changes due to build time, so your code might still be fine in build.

#

But as you want to look at the code, could you show the full code and not just parts of it?

queen adder
#

that's what im worrying about

astral falcon
teal viper
astral falcon
queen adder
#

let me check quality

astral falcon
# queen adder let me check quality

"Project settings> Player> Other settings> shader precision model> use full sampler precision by default…" from some forum entry. Worth a shot

#

And now I gotta get some sleep, best of luck to you

queen adder
#

I guess this is what's actually happening, since we all added the lights as component via code

lean cipher
#

Why am I not getting proper syntax highlighting in vscode with unity?

queen adder
#

!ide

eternal falconBOT
queen adder
#

click the vscode one

lean cipher
#

thank you 🙏

red mason
#

does anyone know about pixel art websites where you can download as a pdf because for my game i made a character and a spike on a website called pixilart but it downloaded as a ".pixil" and i cant drag it into the sprite renderer

rocky canyon
#

use a PNG instead

red mason
#

tyyy

queen adder
#

it was actually that... reflection being the only possible solution sucks tho

#

or I could just not add lights via code

normal glacier
#

I want to learn how to make my own sprites sometime

red mason
#

also how do i make my floor a solid object that the player lands on? the player has a rigid body 2d and the floor has a box collider 2d but it still isnt solid

normal glacier
daring crescent
#
if(GameManager.Instance.State != GameManager.GameState.Active)
{
GameManager.Instance.ChangeGameState(GameManager.GameState.Active);
}

Is there some syntactic sugar i could use for that if statement?

normal glacier
red mason
normal glacier
#

It may happen

#

Try it

swift crag
#

The player also needs a collider.

#

A Rigidbody2D doesn't have any physical shape on its own.

#

It just causes an object to be influenced by the physics system

red mason
red mason
rocky canyon
# red mason it didi

ofc it did 😄 unless u untick Simulated or change gravity scale to 0..
but ur floor doesn't really need a rigidbody anyway unless its doing some crazy acrobatic stuff

red mason
#

yeah like the clouds in celeste

#

or idk if thats smth else

rocky canyon
#

the only reason i could see to have a rb on a floor is if its a moving platform/ elevator..

#

but even then it all comes down to the type of character controller u have trying to interact w/ it

late burrow
#

ok best way to do very specific math is strap bunch of action events to the character

red mason
rich ice
#

means that the object hasn't been set (usually in the inspector)

#

looks like in your case. yeah, you haven't put the rigidbody into the script in the inspector

vague sequoia
eternal falconBOT
willow iron
#

im asking here because i dont know how to word this for google. For an array with only one value, you would use the .length function to check how long it is. But in this example, my array contains two items. I want the length of only the item on the right, the left is not important. how would i find that?

rich ice
#

.length - (however many items from the right you want to ignore)

west radish
#

I think it's .length(1)

#

I'm on my phone so I can't double check

rich ice
willow iron
west radish
#

I mean you can select the thing inside the array

#

.length(0) to select the item left of the comma, .length(1) to select the item right of the comma

rich ice
#

are you sure that's c#?

west radish
#

yes

cosmic dagger
#

I believe it's GetLength(1) to get the length of the 2nd dimension . . .

west radish
#

Ooh yeah that's the one

rich ice
#

oh right, forgot GetLength exists. never actually needed it before

west radish
#

I've never needed to make use of such a thing before, but I knew I've seen something to this effect before a number of times

rich ice
#

dont crosspost

late burrow
#

how i do indexer by string?

#

if i want access by test["stuff"]

#

other than dictionary, i want that functionality for class itself

teal elk
#

Hey everyone!

I'm currently working on a speed buff in my Unity project, and I'm running into an issue where the buff isn’t expiring after the intended duration. The speed seems to keep multiplying and then never revert's, and never being reset after 3 seconds. Here’s a brief overview of my setup:

I have a Buff script that applies a Speed buff to the player when they enter a trigger zone.

The speed is supposed to increase by a multiplier and then revert to its original value after a specified duration using a coroutine.

However, the coroutine appears to start, but the speed reset doesn't seem to work as expected.

Here's the key part of my code:

void ApplyBuff()
{
    switch (_buffType)
    {
        case BuffType.Speed:
            playerController.Speed *= _speedMultiplier;
            StartCoroutine(RemoveBuffAfterDuration(_durationSpeed));
            Debug.Log("Speed buff applied");
            break;
        case BuffType.TimeAdd:
            break;
    }
}

void RemoveBuff()
{
    switch (_buffType)
    {
        case BuffType.Speed:
            playerController.Speed /= _speedMultiplier;
            Debug.Log("Speed buff removed, current speed: " + playerController.Speed);
            break;
        case BuffType.TimeAdd:
            break;
    }
}

IEnumerator RemoveBuffAfterDuration(float duration)
{
    yield return new WaitForSeconds(duration);
    RemoveBuff();
}

Buff. cs - https://pastecode.io/s/s5o0dufr - full buff script
PlayerController.cs -

using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{

    [SerializeField]
    private float _speed = 50.0f;

    private float _movementY;
    private float _movementX;

    public float Speed
    {
        get => _speed;
        set => _speed = value;
    }


    private Rigidbody rb;
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }


    void OnMove(InputValue value)
    {
        Vector2 inputVector = value.Get<Vector2>();
        _movementX = inputVector.x;
        _movementY = inputVector.y;


    }


    private void FixedUpdate()
    {
        Vector3 movement = new Vector3(_movementX, 0, _movementY);
        Vector3 newVelocity = movement * Speed * Time.deltaTime;
        newVelocity.y = rb.linearVelocity.y;
        rb.linearVelocity = newVelocity;
        Debug.Log(Speed);   
    }
}
timber tide
#

or if you want to make a multiplier then -> Boosted speed = normal_speed * 2

scarlet shuttle
#

Could be completely wrong but the coroutines probably stop running when you set the game object inactive so it never removes the speed

cosmic dagger
cosmic dagger
fluid ridge
#

Hello,I just started learning Unity and recently completed a basic 2D and 3D course. I want to create a motion capture or computer vision project. Where should I start? What tools should I use? Do you have any recommendations for beginners, online courses, or YouTube tutorials

verbal dome
astral falcon
#

A bit ambitious for the first project, but hey, you do you

latent zinc
ashen harness
#

Hypothetically speaking, for the mouse movement script right, could I make the head slightly move forward when looking down? As funny as eating your own neck might look it's not quite the feature I'll want lmfao

verbal dome
#

Of course you can. Bones are just transforms and you can move/rotate them however you want

ashen harness
#

even if i just use the neck as the parent for the mouse movement then the neck would be the issue coming out of the body at the bottom of it lmao

verbal dome
#

If you have animations, you need to do the head rotation in LateUpdate

#

Or use thte animation rigging package or other tools

verbal dome
#

Could rotate the neck a bit and the head a bit, or maybe only the head

#

I don't think humans rotate the "neck bone" as much as "head bone" when we look up/down

ashen harness
#

trying to just simply move the head forward by X amount when looking down via code or vise versa for looking up

verbal dome
#

Well if you want the head to move then yeah you need to rotate the neck

#

What type of game is it?

#

Well, mainly what perspective does it have

ashen harness
#

Honestly I'm just making a mini dungeon type game, nothing fancy but its more so directed towards learning wouldn't really have a set directive but more of a silly vibe in a way i guess you could say

#

think of mucks style its just gonna be simple like that in a sense

verbal dome
#

With perspective I mean is it first person or 3rd person or what

ashen harness
#

fps

#

The main objective to just slightly moving the head forward or backwards slightly is just so I dont just look inside my body without limiting the abillity to look up and down by too much

#

obviously still need to clamp it but I don't wanna just give it like a 20 degree angle and call it a day 🤣 cause that honestly wouldn't be fun lmao

verbal dome
#

Since it's just for the first person view, you could just make the head invisible and rotate the camera around the neck/chest

#

Or use a "viewmodel" with only the arms and don't render the rest of your body at all

#

True first person body is kind of a pain

ashen harness
#

using a full body model in order to get a more accurate hitbox if i can lmao

verbal dome
#

That's not the reason people use full body FPS models

#

The hitboxes (colliders) can still exist in the correct places even if you aren't rendering the skinned mesh

ashen harness
#

also wanna see the legs slightly when looking down and moving

charred spoke
#

Every fps full body model does not have a head

verbal dome
charred spoke
#

Well they do but just for shadow casting reflections it does not render in the main camera

verbal dome
#

Yeah

verbal dome
ashen harness
#

i guess all you really see is your torso and down anyway so really don't need a neck or head lmao

#

yeah i suppose that makes sense

charred spoke
#

For example in arkham asylum, a tps game, for the fps segments they twist the entire head 180 inside the body

verbal dome
#

Brutal

#

But efficient

#

A couple of other ways of doing it are scaling the head down or having it as a separate mesh and making it invisible

charred spoke
#

I guess the fps segments came later in production and seperating the mesh was not a option

charred spoke
verbal dome
#

The spheres are volumes that ensure certain vertices are includen in certain submeshes

#

The rest relies on bone weights

#

(Don't mind the topology lol, it's a decimated LOD mesh)

timber tide
#

dont make fun of my topology :(

verbal dome
#

This makes it a lot easier to iterate on the character models without having to use separate meshes in blender

ashen harness
#

now it should in theory keep my parent setup from blender right? it was a simple method to make animations easier since its a low poly model basically everything is indirectly parented to the torso, fingers>hand>forearm>Upper Arm & Shoulder>torso

#

it seems like a weird way but it works so that way i can rotate the upper arm which rotates the rest of the arm and then move my way down the hierarchy setup till i get something i like

timber tide
#

I just toss on rigify and call it a day

buoyant finch
#

hello everyone so I basically made a 2d character with the walking cycle but there is a problem like I want it so that when the animation starts and no key is pressed after it it should stay on that state like if in the walking animation I stop pressing the key the animation shouldn't play from the starting but the state it was in. I made that and it works fine for the first 2 frames but the 3rd and 4th frame are sped up and appear at the same time to reach the 1st frame

echo ruin
buoyant finch
#

yes

buoyant finch
ashen harness
charred spoke
timber tide
#

that + automatic weights can really pump stuff out quickly

ashen harness
timber tide
#

check the docs

echo ruin
buoyant finch
#
using System.Collections;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    public float moveSpeed;

    private bool isMoving;
    private Vector2 input;

    private Animator animator;

    private void Awake()
    {
        animator = GetComponent<Animator>();
    }

    private void Update()
    {
        if (!isMoving)
        {
            input.x = Input.GetAxisRaw("Horizontal");
            input.y = Input.GetAxisRaw("Vertical");

            if (input.x != 0) input.y = 0; // Prioritize horizontal movement

            if (input != Vector2.zero)
            {
                // Set movement direction for animation
                animator.SetFloat("moveX", input.x);
                animator.SetFloat("moveY", input.y);

                // Resume animation
                animator.speed = 1;

                // Calculate target position and start movement
                var targetPos = transform.position;
                targetPos.x += input.x;
                targetPos.y += input.y;

                StartCoroutine(Move(targetPos));
            }
            else
            {
                // Stop animation, freeze at current frame
                animator.speed = 0;
            }
        }

        animator.SetBool("isMoving", isMoving);
    }

    IEnumerator Move(Vector3 targetPos)
    {
        isMoving = true;

        while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon)
        {
            transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
            yield return null;
        }

        transform.position = targetPos;
        isMoving = false;

        // Freeze animation at current frame after moving
        animator.speed = 0;
    }
}

Here is the script

ashen harness
buoyant finch
timber tide
#

that's pretty much how animations work ;p

ashen harness
#

and actually now that i think about it this isnt the right channel anymore since the convo branched off into animations lmao

echo ruin
#

0.1 and -0.1?

buoyant finch
timber tide
#

rigify does provide IKs for you so that's sorta different

echo ruin
#

Let me get on my pc

spiral glen
#
{
    if (collision.gameObject.tag == "Platform")
    {
        Destroy(collision.gameObject);
    }
}```
am I going insane or shouldn't this check for a tag with anything it collides with and if it has the "Platform" tag it should delete it, no?
languid spire
spiral glen
#

I'll give it a try

#

Didn't change anything, does activating "Used by effector" on the platform cause any other side affects?

verbal dome
echo ruin
#

animator.SetBool("isMoving", isMoving);

languid spire
echo ruin
#

Try putting animator.SetBool("isMoving", true); in if and animator.SetBool("isMoving", false); in else

spiral glen
buoyant finch
echo ruin
#

Also you're only setting the bool at the end of Move(), remember to also set animator.SetBool("isMoving", false);

languid spire
buoyant finch
# echo ruin Also you're only setting the bool at the end of `Move()`, remember to also set `...
using System.Collections;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    public float moveSpeed;

    private bool isMoving;
    private Vector2 input;

    private Animator animator;

    private void Awake()
    {
        animator = GetComponent<Animator>();
    }

    private void Update()
    {
        if (!isMoving)
        {
            input.x = Input.GetAxisRaw("Horizontal");
            input.y = Input.GetAxisRaw("Vertical");

            if (input.x != 0) input.y = 0; // Prioritize horizontal movement

            if (input != Vector2.zero)
            {
                // Set movement direction for animation
                animator.SetFloat("moveX", input.x);
                animator.SetFloat("moveY", input.y);

                // Set isMoving to true in animator
                animator.SetBool("isMoving", true);

                // Calculate target position and start movement
                var targetPos = transform.position;
                targetPos.x += input.x;
                targetPos.y += input.y;

                StartCoroutine(Move(targetPos));
            }
            else
            {
                // Stop animation, freeze at current frame
                animator.SetBool("isMoving", false);
                animator.speed = 0;
            }
        }
    }

    IEnumerator Move(Vector3 targetPos)
    {
        isMoving = true;

        while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon)
        {
            transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
            yield return null;
        }

        transform.position = targetPos;
        isMoving = false;

        // Set isMoving to false in animator
        animator.SetBool("isMoving", false);

        // Freeze animation at the current frame after moving
        animator.speed = 0;
    }
}

something like this?

languid spire
buoyant finch
# echo ruin Yeah

now the animation is just stuck at the idle poses and no walking ones are shown

echo ruin
#

In all directions?

buoyant finch
echo ruin
#

How have you set up your blend trees?

#

Or rather, your animations

buoyant finch
craggy lake
#

does anyone know how i can fix the issue by the place where ive commented

buoyant finch
buoyant finch
craggy lake
#

i get the issues below it

#

and nothing happens

#

when i follow the instructions

buoyant finch
#

but does the red error go away?

craggy lake
#

it wont let me do anything when i follow the steps

#

the yellow bit just shows up below the error

echo ruin
# buoyant finch

What about the animations themselves? You said the first couple of frames works fine. Can you show the timeline of one of the animations?

verbal dome
#

Likely a Unity UI bug

craggy lake
echo ruin
#

So naturally it wouln't resume updating the animation

buoyant finch
#

thank you for pointing it out

buoyant finch
buoyant finch
echo ruin
#

Oh.. Like it speeds up the longer you hold it down?

buoyant finch
echo ruin
#

You did set them to loop?

buoyant finch
echo ruin
#

It might not be the issue but it's worth giving a try

buoyant finch
#

ok lemme try

buoyant finch
sterile path
#

hell yeah i got the book thing working, and it barley took 30 mins of my own time

#

Now let’s say I wanted a GUI to pop out of the object whenever it’s on its “open state”

#

like let’s say whenever the book was opened, a picture of a page would pop up, and there’d be a “next” and “back” button to go through the pages

echo ruin
#

See what it does when you hold down a button

buoyant finch
#

ok lemme see

sterile path
#

especially with the “next page” and “go back” button, would i need an array with a bunch of PNGS?

sterile path
# echo ruin That's one way to do it

i thought of having it work like this, i insert a page or text onto the open book model and you’d press a button that’d take u to the next/previous pages but idk if that’d look weird

echo ruin
#

That's very interesting

verbal dome
eternal falconBOT
verbal dome
#

Also do you mind stating again what is the issue

echo ruin
# buoyant finch looks fine to me

I'm curious as to why you'd want idle states when you want the character "idle" state to be a walk animation frame?
Also, can you show the transition conditions?

verbal dome
#

You are using animator.speed which I assume will affect the speed of the transitions too

#

So setting it to 0 would not let a transition progress

buoyant finch
verbal dome
#

And when you walk again it continues from the same point in the walk anim?

buoyant finch
echo ruin
buoyant finch
#

o let's go Melton was right the idle is unnecessary

#

now the game works as I wished thank you very much to both of you for taking your valuable time out for me

echo ruin
#

I'm glad it works 😄

neon pine
#

Guys, i have a question, struct is better than class in optimizing right? cuz its a value type, should i use it whenever i dont use inheritance ?

grand snow
#

but if you have an array of a struct you need to loop over a lot then you will benefit greatly from it being a struct (as it all gets allocated together in memory)

timber tide
#

I usually just stick to classes unless I'm doing serialization

#

or start with classes then refactor into structs for polish

gloomy cosmos
#

Hello, can RuntimeInitializeOnLoadMethod only be used on static methods? If so are there any alternatives?

timber tide
#

Any reason you can't just entry point a load scene

gloomy cosmos
timber tide
#

And you can't accomplish this by loading up some singleton and keeping it in mem throughout the runtime?

gloomy cosmos
#

(to be clear I didn't make my own List, just using it as an example)

grand snow
#

it can just be a static field instead then?

craggy lake
#

what do i need to do from the build settings menu?

timber tide
#

Add the scene as specified

craggy lake
craggy lake
#

then

timber tide
#

scene is an assest in your directory

craggy lake
#

not sure what im meant to do from here

timber tide
#

Drag it or use the "Add Open Scenes"

verbal dome
timber tide
#

^ which shouldnt be a problem with newer c# versions

#

missing a lot of goodies that structs have

craggy lake
gloomy cosmos
craggy lake
#

just comes up with this

gloomy cosmos
#

but it doesn't matter

timber tide
grand snow
#

but that is only useful to init data once for a "whole class" statically

#

if its seperate per class instance then well just use Awake or the constructor normally...

craggy lake
#

no

#

how do i make sure something counts as a scene

timber tide
#

make a new scene asset in your directory and try that

verbal dome
warm field
#

huh weird, every time i start visual studio after starting pc, it is in a "broken" state, so i always need to regenerate project files. any way to fix it?

#

also i got an error, that Getcomponent(Type) is a method not valid in given context

#

nvm i think i figured it out

rich ice
#

!ide

eternal falconBOT
neon pine
spark musk
#

guys i need help im trying to make a simple 3d movement game just a beginner friendly game i made the script by following a toutorial but its like not coected to the(Player) anyone willing to help?

candid gate
spark musk
#

idk how to do that

candid gate
#

a script need to be added as a component for it to work

candid gate
# spark musk idk how to do that

take your script in the project files, drop it onto the player game object, or with the Add COmponents button in the inspector type the name of the script and add it

candid gate
spark musk
#

it just says

candid gate
#

your class needs to inherits from MonoBehaviour

spark musk
#

i have like no idea what that means is there a toutorial that explains it?

candid gate
#

after the name (if i'm not wrong) you write class MyClassName : Monobehavior

eternal falconBOT
#

:teacher: Unity Learn ↗

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

astral falcon
#

Go through that before doing anything I suggest

candid gate
#

np

warm field
#

how can i lock my camera to normal head movement? this current code does not work(i wrote it similarly to the original code)

 void MoveCamera()
 {
     float mouseX = Input.GetAxis("Mouse X") * mouseSensivity * Time.deltaTime;
     float mouseY = Input.GetAxis("Mouse Y") * mouseSensivity * 0.1f * Time.deltaTime;

     transform.Rotate(Vector3.up * mouseX);

     verticalRotation -= mouseY;
     verticalRotation = Mathf.Clamp(verticalRotation, -90f, 90f);

     if (playerCamera != null)
     {
         playerCamera.transform.localRotation = quaternion.Euler(verticalRotation, 0f, 0f);
     }
 }
#

the 0.1f is because the vertical rotated too fast

craggy lake
#

does anyone have an idea as to why i cant see the clouds in game?

#

in the scene menu theyre over the pipes

warm field
#

probably layered wrong?

craggy lake
#

but then ingame theyre nowhere to be seen

craggy lake
#

/how to fix issues with layers for them

obsidian plaza
craggy lake
obsidian plaza
#

oh like u can look behind u

#

u want a 180 degree cone

warm field
#

yea

obsidian plaza
# craggy lake

oh they are particles?? u need to do 2 things then. Make sure they are emitting and make sure they are layered correctly

craggy lake
#

then theyre emitting prob right

obsidian plaza
#

theres a preview mode thing

#

which will show them

#

but u can change their layer under renderer in the particle thing

craggy lake
#

"order in layer: 0"

#

is 0 higher or lower priority?

obsidian plaza
#

higher is better

craggy lake
#

alr

#

ty

obsidian plaza
#

np

craggy lake
#

changed layer to 3 but its still not visible even over just the default background weirdly

obsidian plaza
warm field
#

also with adding the Y rotation, the X rotation has extremely slowed down for some reason

obsidian plaza
#

you should be able to see the outline of the particles emitting even if you cant see the actual thing

craggy lake
#

not sure how to do that...

obsidian plaza
#

so if emission is on you should be able to see it

#

are u sure ur emitting on play?

#

well if emission is on i guess it would be

#

im ass at particles smh

craggy lake
#

thats what i read atleast

#

not sure how else to set particle emitters to emitting

warm field
#

i just realised somehting

#

the vertical rotation is somehow getting counted as horizontal

obsidian plaza
craggy lake
warm field
#

and the horizontal rotation is not getting counted at all

verbal dome
verbal dome
warm field
#

oh

obsidian plaza
warm field
#

finally, it works

verbal dome
#

Nice

warm field
#

i'm gonna have to lower the sensitivity a bit since its still a bit too high, but at least movement works now

verbal dome
#

You removed * deltaTime right?

warm field
#

yeah

verbal dome
#

Yep then you need to make your sensitivity about 50x to 100x smaller

#

Because it's no longer being multiplied by delta which is a small number

#

@warm field Just curious, did you get that part of the code from a particular tutorial?

warm field
#

the original was generated by gpt, but since the movement code got quite messy over time as i was telling gpt to add more stuff(there was animated player model), and when i removed it(the model), the code was broken so i had to rewrite it manually using the original without animations, as the player is now a invisible capsule

verbal dome
#

Okay, I was just wondering where this incorrect mouse * deltaTime keeps coming from

#

I know a couple of tutorial videos did it, including Brackeys

warm field
#

it was coming from gpt(it worked but then i decided to remove the model since animations were pain)

verbal dome
#

Oh my lord.. Yeah, I just tested with GPT

obsidian plaza
#

mouse sens isnt frame dependent even in update?

warm field
#

also, should i delete deltatime here?

void Movement()
{
    float currentSpeed = Input.GetKey(KeyCode.LeftShift) ? sprintSpeed : movementSpeed;
    float moveForward = Input.GetAxis("Vertical") * currentSpeed;
    float strafe = Input.GetAxis("Horizontal") * currentSpeed;

    Vector3 move = transform.forward * moveForward + transform.right * strafe;

    if (move.magnitude > 0)
    {
        rb.MovePosition(rb.position + move * Time.deltaTime);
    }
}
obsidian plaza
#

i mean get axis

verbal dome
#

(In pixels I think?)

#

So it is already "scaled" to the frame rate

verbal dome
warm field
#

void Update()

verbal dome
#

Well, it might work in this case but it's generally good to do physics movement in FixedUpdate instead

#

Is it a 3D game? Is your rigidbody marked as kinematic? Does it need collisions?

warm field
#

yes its a 3d game, rigidbody is not marked as kinematic, do you mean like can it collide with cubes and other?

verbal dome
#

Yeah, like should the player ever be blocked by anything it hits

#

Because MovePosition is meant to be used with kinematic rigidbodies and doesn't produce good collisions AFAIK

obsidian plaza
#

yea otherwise u can just use the built in rigidbody add force and stuff

verbal dome
#

Normally you'd move a non-kinematic body with rb.velocity or rb.AddForce

warm field
#

kinematic means controls whenever physics affect the rigidbody

verbal dome
#

Pretty much

warm field
#

so its better if i enable it?

verbal dome
#

Other non-kinematic bodies can still collide with a kinematic but the kinematic body isn't stopped by other bodies

obsidian plaza
#

surprised move position was even working at all

verbal dome
#

(Although there's a physics setting to enable kinematic-on-kinematic collisions)

warm field
#

It's useful for making object completely controlled by the script and resolving collisions via scripts without using forces.
this is what i found on google

obsidian plaza
obsidian plaza
verbal dome
#

Yeah, if you use kinematic then you should do your own collision checks which gets more complex

#

Just go with non-kinematic and use AddForce/velocity

warm field
verbal dome
#

Exactly, so go with the simpler mode

#

Let the physics engine worry about collisions

warm field
#

alright, thanks for helping

tiny bloom
#

can I have multiple Class libraries or projects in the same game?

cosmic dagger
tiny bloom
#

i dont mean as a dll
i mean in my base code to seperate stuff

swift crag
#

I don't know what that would entail.

#

You can use assembly definitions to break your code into multiple assemblies. This is useful if you have some code that doesn't need to know about the rest of your game's code.

#

You can split that off into an assembly that's referenced by your game assembly

cosmic dagger
swift crag
#

If you just want to give things more distinct names, that's what namespaces are for

dark apex
#

What sort of game sud I make as my first game??🤔

languid spire
dark apex
#

Ok where can I ask that?

languid spire
#

the very first thing you should learn, before even thinking of making a game, is how to research, #🔎┃find-a-channel

craggy lake
#

if i pause while testing then go to scene view it seems fine too

swift crag
#

Turn off 2D mode

foggy wren
#

getting errors please help

languid spire
craggy lake
naive pawn
obsidian plaza
craggy lake
#

ty for all the help

obsidian plaza
#

nice

#

thanks for fen too

fringe plover
#

Can someone help? OnMouseDown/OnMouseEnter/OnMoseExit doesnt work in builds

obsidian plaza
#

try changing ur window size in unity and seeing if that moves ur ui components

swift crag
#

those methods are for MonoBehaviours attached to objects with colliders

#

if you are using those methods in UI objects, then you're doing something funky

obsidian plaza
#

o yea true

#

i never really used those

swift crag
#

same here

fringe plover
#

window is not fullscreen but it doesnt work

obsidian plaza
fringe plover
#

collider

#

in world

obsidian plaza
#

whats it tryna tell u

#

is it making a build only sometimes

#

or is that irrelevant

fringe plover
#

What

obsidian plaza
#

its saying build failed in log but also build succeeded

fringe plover
#

its always in build

swift crag
#

asa is pointing out the error in the console

fringe plover
swift crag
#

but that's just a build that didn't succeed

#

I'm not aware of anything that would get in the way of the OnMouse* methods.

#

Try setting your game view to a very high resolution, like 4K. Does the problem happen in the editor?

#

I don't know if the UI can block the OnMouse* methods, but it's certainly plausible

obsidian plaza
#

ah thats a good one too yea

#

im not sure if onmouse gets blocked by raycasts but maybe

fringe plover
#

works in editor

#

even with 4k

swift crag
fringe plover
#

i tried disabling raycasting on UI elements

swift crag
#

oh, UI raycasting

obsidian plaza
#

yea that raycast

swift crag
#

I'd try using a raycast to check what the mouse is actually hovering over

#

Maybe another collider is getting in the way, but only in the build

#

I don't know why that would happen

#

You could do something simple like this

#
void OnGUI() {
  Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  if (Physics.Raycast(ray, out var hit)) {
    GUILayout.Label("Hit: " + hit.collider.name);
  }
}
#

You'd put that on any object in your scene

#

it'll display the thing the ray hits in small text in the top left

grand snow
#

The event system inspector will state what the current hover/click object is btw if you want to tell if its UI or something else if using a physics raycaster with it.

swift crag
#

(only with the old input manager, annoyingly)

grand snow
#

Oh shit not on the new one? that sucks 😦

obsidian plaza
#

apparently ui raycasts DO block it

#

he said he disabled them and still not working

#

but still

last edge
#

say question is there a chat i can ask for help in?

#

i need a second eye haha

verbal dome
eternal falconBOT
languid spire
last edge
#

when you say title do you mean the conduct page?

last edge
rocky canyon
#

u only got 1 eye?

languid spire
#

no I mean the bit at the top of this page

rocky canyon
#

👇 this

last edge
#

o. no i did not lol

languid spire
#

why not?

rocky canyon
#

each channel has a description

#

b/c he only got 1 eye foo..

#

give the man a break

last edge
#

😅 why am i being bullied already

rocky canyon
#

😛 i just woke up.. gottta tease a little bit before the real work begins

magic mantle
#

if i was to make a player, should i use input action or just straight up code it using mono script

swift crag
rocky canyon
#

up to you.. i still use both input systems

last edge
#

so are you guys ok with me posting scripts in here?

swift crag
#

you're asking if you should buy a car or buy gas

magic mantle
swift crag
#

you need both

languid spire
magic mantle
#

alr

rocky canyon
swift crag
#

you need to define the kinds of inputs (input axes in the old system, input actions in the new system)

rocky canyon
#

here is fine.. use the Ask embed that was sent to see what u need to include to get a decent answer

swift crag
#

and then you need to use them

last edge
#

def is a code issue.

well anyway,

im trying to make an inventory manager script. my inventory itself works however i feel like im forgetting something this is my script to allow it to show up on my object.

rocky canyon
#

ur technically doing the same.. both methods

swift crag
#

"allow it to show up on my object"?

#

do you mean that you can't find it in the "Add Component" menu?

verbal dome
#

First you should configure your !ide though

eternal falconBOT
last edge
#

ehh kinda so for instance i was trying to make the script to have a field like this idk how to explain it.

my other scripts works but for some reason my current script just doesnt show the fields that i am trying to create

last edge
naive pawn
languid spire
grand snow
#

this chat is just "fix your ide" and "read what they said"

naive pawn
languid spire
grand snow
#

perhaps the unity editor could do a better job of having ides work out of the box but anyway

rocky canyon
#

go over to -general or -advanced coding and see how often u see those

verbal dome
naive pawn
#

(no-one uses rider)

languid spire
verbal dome
grand snow
#

i just mean have the packages needed install or prompt you. unitys fault for needing extra stuff for vs/vs code to work properly 🤷‍♂️

verbal dome
#

I mean majority use VS or VSC yeah

naive pawn
# verbal dome ...Wat

no-one that needs help configuring their ide uses rider lol
i haven't seen any beginners using rider at all
vs and vsc have more reach

verbal dome
#

Rider became free recently (for noncommercial purposes)

languid spire
last edge
#

damn i just fixed my ide and it looks hella different now LOL

rocky canyon
grand snow
#

id say no, unreal usually works better as they expect you to use visual studio on windows

rocky canyon
verbal dome
#

But it seems to break randomly for people, they have to keep hitting that "regen project files" button

grand snow
naive pawn
last edge
rocky canyon
#

ya. lots of ppl ignore basic things

#

and think they gunna gung-ho a RPG multiplayer game in a day or two

#

b/c they played a "gorilla tag game" or w/e

grand snow