#💻┃code-beginner

1 messages · Page 616 of 1

queen adder
#

But that's not a good way to handle particles, its better to keep the particle system not directly on the player object

azure wraith
#

Huh?

queen adder
#

Go to the particle object, and just drag the particle system component itself on the player object (in the hierarchy, not the scene)

#

its gonna automatically transfer it

rich adder
#

then what is it ?

queen adder
#

However, having the particle system on the player directly is bad, keep it on a child object

azure wraith
#

Okay,
The system is a gameobject, the parent is the Player
I don't want this, I want it as a component to the player
but I don't know how to convert it

azure wraith
queen adder
azure wraith
#

so its fine if its parented to player?

queen adder
#

Yes, its supposed to be like that

#

Having the particle system be directly a part of the player as a component is a bad practice

azure wraith
#

oh so I'm lucky

queen adder
#

Do you understand how components and prefabs work?

azure wraith
#

then how am I supposed to make the particle position to the player? unless it automatically positions

#

idk what a prefab is but I know what a component is

queen adder
#

You have to learn more of the basics before doing anything complex

azure wraith
#

Emitting dust particles upon hitting the ground is not complex

queen adder
#

When youre a beginner it is

#

Not the hardest in the world, but its better to spend that time learning the foundation

polar acorn
wicked pulsar
#

An object's position is actually defined as the sum of the transforms of all its parents in the hierarchy.

calm badge
#

Hey guys have you tried importing a 3D object to Android using Google's Sceneform?

safe root
timber tide
keen dew
#

well you literally have a function speedControl that limits the player speed

#

you'll have to not call it for the duration of the dash

cosmic dagger
safe root
#

I didn't think it affected since it did work before

timber tide
#

Even if the velocity is set, seems strange to just teleport like that

keen dew
#

The "teleport" is because they've had to crank up the dash speed to do anything so it gets massive speed for one frame before the speed control function kicks in

cosmic dagger
#

I think the teleport "effect" comes from setting the velocity when they attempt to add the dash . . .

safe root
#

I see, well what would be the best way to disable that for that moment?

cosmic dagger
cosmic dagger
keen dew
#

Make a boolean variable isDashing and set it to true when the dashing starts, then use a timer or a coroutine to set it to false after a few seconds. If the variable is true then don't call SpeedControl or return early

#

actually you could probably use the dash cooldown you already have

safe root
cosmic dagger
#

And I would use coroutines instead of the Invoke method to reset your jump and dash . . .

timber tide
#

Ah, yeah that is quite a large dash amount. Also, throwing SpeedControl into the fixed update is an idea too since it wouldn't take affect till the fixed frame anyway

calm badge
#

Hey guys have you tried importing a 3D object to Android using Google's Sceneform?

short fjord
#

Hey can anyone tell me what to look up so I can study how to make a render distance and load things in and out based on distance( I want to start making some bigger projects and figured this is a good place to start)

keen dew
#

LOD

dapper mirage
#

Hey all, I just had a quick question. How could I change a simple boolean variable in my playerControls script from a different script attached to a trigger that the player touches?

#

I want the trigger to detect that the player has touched it and change a value in the playerControl script accordingly

timber tide
#

DifferentScript should have a reference to PlayerControls

#
public class DifferentScript
{
  [SerializeField] private PlayerControls playerControls;
}```
dapper mirage
#

Okay thanks :)

#

so here I can just drag the gameObject that contains my playerControls script and now the trigger can reference it?

timber tide
#

yep, as long as it's part of the same prefab/scene

dapper mirage
#

Perfect, Thank you

fleet venture
#

Is it possible to change the global scale of an object. Basically if i rotate my object 45 degrees i want it to scale down and not into the rotated direction which is what currently happens. If this isnt possible its fine but i did see lossyscale which says its global but its read only

topaz mortar
#

Is MonoBehaviour.OnMouseOver() the proper way to handle hover events?
Is this extendable to other input devices like touch, controller, ...?

#

Hmm I probably need IPointerEnterHandler since it's UI

#

Same question though

fleet venture
#

uh what the fuck? how is comparing to null expensive, if i cant even do a nullcheck what am i supposed to do

topaz mortar
fleet venture
#

oh

topaz mortar
#

maybe transforms just can be null?

fleet venture
#

my IDE suggests this

#

ill try that ig

#

apparently its overloaded

#

that should check if the object still exists which is what i want to achieve

timber tide
#

What IDE is that? Rider?

wicked pulsar
#

@safe root Further to what others have said, your movement code breaks some conventions regarding time measurement. Generally, you want the amount of movement in your code to reflect some amount of change over time (in real time measurements, like seconds) and then multiply the final amount of movement by the amount of time that has passed since the last time the code was run. For Update, you would multiply your motion by Time.deltaTime and for FixedUpdate, you multiply by Time.fixedDeltaTime. This would be a good habit to get into.

If your fixed update loop runs 50 times per second, this would mean increasing your movement forces and velocities by 50x and then multiplying your numbers by Time.fixedDeltaTime before feeding them back to your rigidbody. This creates parity between how much stuff moves in FixedUpdate and Update.

Not directly related to your problem, and a bit of a nitpick, but something to think about. You should know that those precomputed values exist so you can structure your values around them.

sour fulcrum
fleet venture
sour fulcrum
#

Logic wise might be worth going down that line of thinking and having that code directly attatched to that object but i don't know the context so i'm sure you know best on that 👍

hot harbor
#

Is it possible to use C#'s reflection magic to avoid having to do this for every single editor I'd like to redraw/customize? As in avoid having to findPropertyByName and type out everything

fleet venture
sour fulcrum
#

at the very least if you wanna avoid spelling mistakes you could use nameof

#

eg. FindProperty(nameof(MyClassName._canEnterCombat)) etc.

hot harbor
#

any tips on learning more about editor extensions other than the official docs or is that hte best place

sour fulcrum
#

that thread, offical docs and just various tutorials/articles on places like medium, git and reddit have helped me a ton. a lot of the time it just comes down to knowing what you have to play with so code snippets can go a long way

lethal smelt
#

hi guys, does anyone know how to sync hierachy between clients when using Photon to do multiplayer, I have pickUp function that used SetParent() but the parent happen only on player thats doing the pickup side and yes i did add both Photon View and Photon Transform view the only problem is with the parenting

#

from what AI told me there is no Photon specific function to do parenting but it did give me this code ```public class NetworkParenting : MonoBehaviour
{
public void SetParent(GameObject child, Transform parent)
{
PhotonView childView = child.GetComponent<PhotonView>();
PhotonView parentView = parent.GetComponent<PhotonView>();

    if (childView != null && parentView != null)
    {
        Debug.Log("99999");
        // Call the RPC to set parent on all clients
        //childView.RPC("RPC_SetParent", RpcTarget.AllBuffered, childView.ViewID, parentView.ViewID);
        childView.transform.SetParent(parentView.transform);
    }
}

}```

sour fulcrum
#

dont post AI stuff here

#

no one is gonna help you with it

lethal smelt
#

well

sour fulcrum
#

if you don't understand your own code no one is going to be bothered

lethal smelt
#

ai was my last resort

sour fulcrum
#

if you came here after using the AI it was in fact not your last resort

lethal smelt
#

its not a problem that i dont undertand the code

#

just that parenting isnt workng in photon

quick fractal
#

Nearly everything in my Utils file is flagged as expensive, even simple stuff that just has a single nested loop

fleet venture
#

Ok

quick fractal
#

The redundancy stuff is really nice, but I don't think performance analysis is worth it to most people

naive pawn
naive pawn
#

keyword relatively

naive pawn
quick fractal
naive pawn
#

true, but i think that'd be pretty hard to make

quick fractal
#

Especially if I'm running a method once, before the player can even move loopymeow

quick fractal
naive pawn
#

in general for this kind of stuff, false positives are better than false negatives, so yeah, expect to find false positives

naive pawn
#

it isn't magic

quick fractal
naive pawn
#

!ide

eternal falconBOT
naive pawn
#

Install the bundled Unity Support plugin in Rider
yeah so this is the part where rider is informed about unity methods

#

and also about unity null checks being expensive, most likely

quick fractal
#

-# Yeah, It'd be nice if Unity also told rider that calling something in Start is less expensive. Stare

naive pawn
#

well that's just not really true?

quick fractal
#

I'm not saying it should be perfect lol, I'm saying some more accurate context would be nice

naive pawn
#

context goes beyond what method it's in though

quick fractal
naive pawn
#

something in start being "expensive" could still be problematic if you instantiate that object frequently

quick fractal
#

Does rider not pick up on things being called frequently?

naive pawn
#

it'd be impossible to pick up on that scenario

#

it'd see Instantiate being called frequently, but there wouldn't be any link to any other method, since that link goes through unity serialization

quick fractal
#

I don't feel like performance analysis is a useful enough feature to warrant being more accurate than it is, but it's not as if it couldn't be done.

naive pawn
#

it's impossible to get "right" for everyone's definition of "right", though

quick fractal
#

Well, yeah, that's where customisation comes in

naive pawn
#

so, compromising middle ground is best you'll get, unfortunately

naive pawn
quick fractal
stray cosmos
#

Just quick, I wanna use this function. Is it possible to put a sort of logical test in each parameter like "A=1", "B=1", "C=1"?

#

I feel like this is a thing but idk what it's called

quick fractal
#

I feel like we'd need a bit more context

naive pawn
#

you can't put logic directly on parameters, no

#

what are you trying to achieve, exactly?

cosmic dagger
#

Unless you want default values for the parameters?

stray cosmos
#

Actually I guess I could just assign the logic to a new boolean and put that as the parameter

naive pawn
#

yeah no clue what you're talking about at this point

stray cosmos
#

I apologise I may have brainfarted

naive pawn
#

you can put, uh, conditions, as arguments

#
void Method(bool x);

Method(0 == 1);
#

if that's what you're talking about?

stray cosmos
#

Ok so that function takes in three values which are used for a save system. I bunched them together because they're supposed to be saved all at once at this one point. I essentially only want any one of those to be true if the corresponding save data for each is equal to 1

#

This is the function

naive pawn
#

ok and what's your intended usage of the method?

stray cosmos
#

To save the data to a json file?

naive pawn
#

i mean, how do you want to call it

quick fractal
naive pawn
#

im so confused what you're asking

quick fractal
#

It looks like a "level complete" sort of thing? sus

stray cosmos
#

Ideally here. I collected the values I want to test, labelled as A, B and C

quick fractal
#

Oh, you've already got an enum for it, this is confusing

naive pawn
#

what is your actual question?

stray cosmos
#

Well I just wanted to know if there was some sort of way to call the function and put something like A==1 in the first argument

naive pawn
#

yeah you can do that

#

by.. calling the function and putting A == 1 in the first argument

stray cosmos
#

Huhhh so you can

naive pawn
#

that's why i asked what your intended usage was lol

quick fractal
naive pawn
#

because if you just said SubmitNewPatternUnlocked(A == 1, B == 1, C == 1) i couldve just told you to tryitandsee

stray cosmos
#

Idk I got confused

quick fractal
#

That's the one thing I just can't remember the name of lmao

naive pawn
#

you can just call it a conditional operator

stray cosmos
#

Idk why I was so sure it wouldn't allow that

naive pawn
#

because that's what it does

#

ternary just describes how many operands it takes

#

the others are unary/binary operators

stray cosmos
#

Ah well, thanks anyways, we got there in the end 😅

naive pawn
#

(you generally wouldn't use a ternary to get a bool though. you would just take/negate the condition)

#

@stray cosmos though, regarding design;

  • if A/B/C are 0/1, why not just use bools there?
  • if the 3 cases are mutually exclusive, you could just use the enum you have
stray cosmos
#

Because A, B and C aren't binary. They are how many times an attack pattern has been played, passed or perfected respectively. I'm only interested in this bool being for if any of those things happen for the first recorded time (in other words, when they're equal to 1)

#

I suppose I could have used that enum though lol

naive pawn
#

i feel like i understand less about what you're trying to do lmao

stray cosmos
#

I have that effect on people

#

It's a pretty complicated system with a lot of stuff going into it but I just tested and this does indeed do what I wanted it to do

#

This stuff is for stat collecting that the player can browse in their records

fleet venture
#

but it never helped

#

it WAS the transform

#

of the object itself

#

it says i should check if its null

steady oar
#

can someone tell me how to create 2d games in unity?

#

i need general advices and how to create games?

stark prawn
#

when i change a script in unity and my friend changes it too when i get his update it gives error why?

grand snow
grand snow
stark prawn
#

idk its name but we used organization

eternal falconBOT
#

:teacher: Unity Learn ↗

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

grand snow
stark prawn
#

ok ty

grand snow
# stark prawn ok ty

btw if you both change files you can get merge conflicts when you pull in their changes. consult google for how these work and how to resolve em

grand snow
#

why?

stark prawn
#

it gives error

grand snow
#

😐 then share it

stark prawn
#

wdym

kindred iron
grand snow
stark prawn
#

ok

naive pawn
#

we can't help you solve an error if we don't know what the error actually is lmao

grand snow
#

ill guess anyway, you are probably trying to pull changes that conflict with your current file changes, so it will just cancel the pull.
You need to stash or commit your current changes to pull in the new changes (which may then result in a merge conflict)

naive pawn
#

could you be more specific with "i can't update"? what are you trying to do exactly, pull changes?

#

(also what rob is saying also applies to using git)

stark prawn
#

so i deleted the script both of us changed and get it from the update

#

but now i cant see his changes

grand snow
#

er usually you want to just discard the changes you have, if you delete it that wont solve it.

#

a deletion is also a "change"

stark prawn
#

what should i do to fix

#

i cant use ctrl z

grand snow
#

I have never used unity vc but I would guess there is a UI you can use to see your changes? If so see if you can discard it.

gleaming bridge
#

Hello guys, Would anyone mind helping me here, Im trying to instantiate a prefab from a scriptable object but when it does instantiate it, it loses certian game objects which are in the scene. Do i need to create a prefab for every game object i got in the scene for it to work?

#

For context this is how it should look

echo kite
#

how do i make peeking around the walls

thorn holly
#

Can you show a video

thorn holly
gleaming bridge
#

its very hard to explain on a video for me

polar acorn
thorn holly
#

oh i misunderstood the question

polar acorn
#

You could have whatever object spawns in the prefab set your variables after creating it

kindred iron
#

Guys how can i disable the lights icon?

#

I tried already gizmos from right up and deselected it but it still does show me

grand snow
#

click its icon in that list

#

then the icon should go away in scene views

kindred iron
#

oh yeah it worked ty

#

what does gizmo then?

grand snow
#

its the other things that get drawn in the scene view, the icons arent that

#

e.g. the camera frustum

kindred iron
#

oh got it

#

ty

echo kite
#

idk what rainbow 6 siege looks like

polar acorn
#

I don't know what either of those look like but if it's anything like Time Crisis, you just apply some Z rotation to the player, which your camera is probably a child of

red igloo
echo kite
#

it does that in call of duty and i liked it very much

gleaming bridge
#

public class PlayerCamera : MonoBehaviour
{
    [SerializeField] private Transform character;
    public float sensitivity = 2;
    public float smoothing = 1.5f;

    private Vector2 velocity;
    private Vector2 frameVelocity;

    [SerializeField] private GameObject inventoryPanel; // Assign your inventory UI panel in the Inspector

    void Reset()
    {
        // Get the character from the PlayerController in parents.
        character = GetComponentInParent<PlayerController>().transform;
    }

    void Start()
    {
        // Lock the mouse cursor to the game screen.
        Cursor.lockState = CursorLockMode.Locked;
    }

    void Update()
    {
        // Check if inventory is active
        if (inventoryPanel.activeSelf)
        {
            Cursor.lockState = CursorLockMode.None; // Unlock cursor when inventory is open
            Cursor.visible = true;
            frameVelocity = Vector2.zero;
            return;
        }
        else
        {
            Cursor.lockState = CursorLockMode.Locked; // Lock cursor when inventory is closed
            Cursor.visible = false;
        }

        // Get smooth velocity.
        Vector2 mouseDelta = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
        Vector2 rawFrameVelocity = Vector2.Scale(mouseDelta, Vector2.one * sensitivity);
        frameVelocity = Vector2.Lerp(frameVelocity, rawFrameVelocity, 1 / smoothing);
        velocity += frameVelocity;
        velocity.y = Mathf.Clamp(velocity.y, -90, 90);

        // Rotate camera up-down and controller left-right from velocity.
        transform.localRotation = Quaternion.AngleAxis(-velocity.y, Vector3.right);
        character.localRotation = Quaternion.AngleAxis(velocity.x, Vector3.up);
    }
}
#

Weird issue im having, if i collide with an object and open my inventory, my camera starts spinning in a singular direction, would anyone be able to give a hint on what the issue could be, because if when the inventory shows, it disable camera movement from my point of view

#

And once you exit, it returns back to the original position

rocky canyon
#

or.. if its a rigidbody it might be external forces causing it to rotate..

#

because the rotation is momentarily paused when the menu is open..

#

may want to freeze rotations while u have the inventory open.. or maybe use isKinematic

#

or.. get the current rotation when u open inventory.. and keep it clamped there until u close it again

urban marsh
#

this activated a single instance of "movement"

#

so one press sends my character (its just a ball atm) forward a set distance

#

how do I get a continuous forward/sideways input

#

whats the "word" for that

#

in the code

#

or am I missing a line of code that makes it check for "holding" a button?

slender nymph
#

look into using GetAxis instead of polling the keys individually

urban marsh
#

sure

#

will do

rich ice
# urban marsh

btw, == ture is pretty useless. the value you're checking is already a bool

urban marsh
#

oh

#

thank you

#

starting out sucksss

#

cause you dont even know what you dont know

#

so you just follow videos blindly until it makes sense

slender nymph
#

instead of following videos blindly, you should instead start by learning the language and then the engine. there are beginner c# courses pinned in this channel and the pathways on the unity !learn site are a good next step to learn the engine

eternal falconBOT
#

:teacher: Unity Learn ↗

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

willow breach
#

hey, I'm trying to use Discord SDK, I followed their instructions for Unity and it works fine but when I try to build they I get:

Assets/Plugins/x86/discord_game_sdk.dll would be copied to <PluginPath>/discord_game_sdk.dll
Assets/Plugins/x86_64/discord_game_sdk.dll would be copied to <PluginPath>/discord_game_sdk.dll
Please fix plugin settings and try again.
after deleing all the lib files```
and when click the inspector on those files i can only choose `Any CPU` or `x64` (on the dll i could select `None` and tick the `x86` checkbox so i resolved the duplicate issue for the dll)
https://discord.com/developers/docs/developer-tools/game-sdk#step-1-get-the-sdk
Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

dapper mirage
#

Hey all, just need a little help with the HUD in my game.
I want to display a timer and what level the player is on in my game, but the text remains the default on the TextMeshPro gameobjects. I have them under one parent HUD gameobject that contains the script and has references to both text gameObjects

    public TMPro.TMP_Text slopeNumber;

    private Scene currentScene;

    private float elapsedTime;
    private bool timerRunning = true;

    void Update()
    {
        if (timerRunning)
        {
            // Set elapsedTime to current delta time and increment/add to it every second
            elapsedTime += Time.deltaTime;

            // Set minutes to an absolute integer
            int minutes = Mathf.FloorToInt(elapsedTime / 60f);

            // Set seconds to an absolute integer
            int seconds = Mathf.FloorToInt(elapsedTime % 60f);

            // Set formattedTime to a string using the minutes and seconds integers
            string formattedTime = string.Format(" TIME {0:00}:{1:00}", minutes, seconds);
            timerText.text = formattedTime; // Set Timer UI text to the formattedTime string (text)
        }


        int sceneIndex = currentScene.buildIndex;
        string slope = "SLOPE " + sceneIndex.ToString();
        slopeNumber.text = slope;
    }```
sour fulcrum
#

You might want TextMeshProUGUI rather than TMPText

#

The latter is the base version of that class

naive pawn
#

that's perfectly fine

cosmic quail
naive pawn
dapper mirage
#

those lines are being hit but they arent doing anything

obtuse ether
#

Made the enemy follow the player if its in range of its detection trigger

#

but when it follows the player across a gap it just kinda falls off pathetically lol

#

is there any way for me to check if it should be jumping across a gap?

queen adder
ivory bobcat
naive pawn
# obtuse ether Made the enemy follow the player if its in range of its detection trigger

Follow Isadora's Edge on Kickstarter: https://www.kickstarter.com/projects/inboundshovel/isadoras-edge
Wishlist Isadora's Edge on Steam: https://store.steampowered.com/app/3125320/Isadoras_Edge/

The game that I'm developing as an indie game dev is called Isadora's Edge! A 2D Pixel Art platformer game, that I'm developing in the Godot Game Engin...

▶ Play video
obtuse ether
#

alright ty

ember gate
#

how can I fix this, my character when it falls from jumping he gets dragged faster by using a downward key but for some reason he goes through the collider under it

wintry quarry
ember gate
#

via physics only u mean without using rigidbody?

wintry quarry
#

I mean only via the Rigidbody

ember gate
#

this is my script for the movement

burnt torrent
#

Do any of you guys know how to get an array of the positions of every tile on a tile map?

ember gate
#

oh nice that seems to work

#

thanks

burnt torrent
#

Because that would not be good

wintry quarry
#

You have to use both of these

burnt torrent
#

alright i'll try it

burnt torrent
fleet venture
#

Is it possible to give a single object in my canvas a different sorting layer than the canvas itself? or should i put that object in a separate second canvas

wintry quarry
fleet venture
#

i really dont understand where these are coming from

burnt torrent
burnt torrent
#

alright i'll try it

burnt torrent
wintry quarry
#

If you requested from (10,10,10) to (20,20,20) the first array element in the result corresponds to 10,10,10

devout shore
#

where can i find the camera clear flags? following a tutorial on how to make a main menu but i want to change the background color

wintry quarry
#

For URP you want to look at the background setting on the base camera

devout shore
#

oh i just selected an empty 2d template cause i didn't know what any of that meant

#

so am i just out of luck?

wintry quarry
#

Wdym by being out of luck

wintry quarry
#

Either way you need to look at the inspector of your camera

devout shore
wintry quarry
#

Show a screenshot

devout shore
#

that was my q mb

wintry quarry
#

Forget which

burnt torrent
devout shore
#

ohh i found it

#

it was under environment

#

thx

burnt torrent
#

i prolly should have figured

devout shore
#

another thing though: my buttons/text appear normally in the game, but not in the editor. how can i fix that?

#

on this tutorial everything works fine but for some reason it doesnt for me

wintry quarry
#

Double click any object in the hierarchy to center it in scene view

#

Or click it once and press F

devout shore
#

oh whattt

muted helm
#

does anybody know if unity has a contact email for career inquiry

#

i cant find one anywhere

devout shore
#

i was just extremely zoomed in for some reason without even realizing

#

that's one i'm gonna write down thank you so much 🙏

#

should be able to go on now

slender nymph
#

the canvas is just huge because it is typically 1 pixel per unit

#

see the documentation pinned in #📲┃ui-ux to learn how the canvas works

rancid tinsel
#

guys what is this text file that my game generated?

slender nymph
#

that is the log file

rancid tinsel
#

i have no idea where this came from and wasnt there before

#

oh is that because i ran the actual built version?

slender nymph
#

the editor should generate the same player log file

rancid tinsel
#

it definitely didnt before

eternal needle
rancid tinsel
#

but the editor definitely didnt make one

#

im 100% sure because thats where i create my text files and i was testing them yesterday

devout shore
#

i'm using a custom font which i've imported and it works great, but unfortunately when i change the outline color it changes it for all elements that use that font

#

i want to only change the outline for the buttons but keep the title as-is

timid quartz
#

Is there a way to set up a volume to control a skybox material? The docs are telling me to add an 'override' but skybox doesn't appear to be an option

slender nymph
#

this is a code channel

timid quartz
#

what is the appropriate channel to ask for this kind of help, then?

slender nymph
tribal fulcrum
#

hello i need help with coding a flappy bird game

pseudo pagoda
#

Hi

#

I need some help

#

My character keeps falling down

#

Can i send a vid in here?

tribal fulcrum
#

is it bc u gave it physics

pseudo pagoda
#

Idk

tribal fulcrum
#

send a screenshot of your unity screen let me see

pseudo pagoda
slender nymph
pseudo pagoda
tribal fulcrum
pseudo pagoda
#

It worked

tribal fulcrum
#

well thats splendid

#

now i need help with my code

slender nymph
#

!ask

eternal falconBOT
tribal fulcrum
#

im watching a tutorial video and it has these lines of codes

#

but on my end its an error

#

it might be because the video is from 2 years ago but im not sure

slender nymph
#

compare what you have with what they have very carefully

tribal fulcrum
#

the only difference is the velocity and linearvelocityY

slender nymph
#

but also since you're using unity 6 you really only need to assign to the one axis so just remove the Vector2.up multiplication there

slender nymph
tribal fulcrum
#

dang you saved me

#

thanks

#

theres no error anymore

burnt torrent
# wintry quarry Math

Ok, it took me a long while but I finally figured out the math behind this formula and it is successfully accounting for all the grid spaces on which I placed tiles so thank you so much for that /gen.

But there is one more thing, there is some tiles in which I have not placed that it is still accounting for, is there a way to check if the cell of a given position actually has something placed on it?

narrow pulsar
#

im extremely new to unity and im not sure what this error means

azure wraith
#

let me see the script

narrow pulsar
#

alr

#

following a tutorial and every time i press jump the game crashes

azure wraith
#

for the jump section
Try linearvelocity = Vector2.up jumpspeed;

narrow pulsar
#

oh thats a really useful link

#

does it just tell you whats wrong with every single error

slender nymph
#

not every error, but it does have a lot of useful info. the site is maintained by one of the mods here

azure wraith
#

Wait a minute

#

I think I understand that error

#

find your script in unity

#

hmmmmmm how do I say this

#

show me a picture of your script in unity

narrow pulsar
azure wraith
#

is the script in inspector

#

like is it a component

narrow pulsar
slender nymph
# azure wraith like is it a component

instead of guessing since you clearly barely know what to do, just let them go through the incredibly useful link that takes them through everything they need to check.

azure wraith
#

yeah on the right side where it says all the code go up until you see boxes with soundcontroller and stuff like that

slender nymph
#

well you're pointing them in the wrong direction anyway so good luck with that

azure wraith
#

Nice assumption

narrow pulsar
#

im gonna be using both regardless

#

whatever works

azure wraith
#

thanks for being open

slender nymph
# azure wraith Nice assumption

it's not an assumption, it's a fact. you're about to have them drag a reference into the default reference slot, but that won't necessarily work, especially if they object they want to reference is in the scene

azure wraith
#

well lets see

narrow pulsar
#

so you want me to just show the components on the player?

azure wraith
#

In the playerscript yes

slender nymph
azure wraith
#

Uhm... that was literally what I was dragging him into

#

the assumptions go crazy

narrow pulsar
#

this is the entire player

#

death script works and i know its trying to access jump in order to play a sound every time i jump

slender nymph
#

notice how The Sound Controller says "None"

azure wraith
#

Boom

#

exactly

narrow pulsar
#

it plays it on entering the scene but doesnt actually play it on jumping

slender nymph
azure wraith
#

thanks for proving what I was gonna lead him to boxfriend

slender nymph
azure wraith
#

huh?

#

I don't understand what you are trying to point here

slender nymph
#

i linked to your message where you were directing them to where they can drag in a default reference, not a reference on the instance of the component

#

those are two different things and what you were originally directing them to was wrong

azure wraith
slender nymph
#

and, again, instead of just guessing, just let them use the resource that was already provided to them that very helpfully walks through each step and explains what they need to do

#

wanting to be helpful is great! unless you don't actually know wtf you're doing and you lead people in the wrong direction.

azure wraith
#

So the error means nothing was defined right?

slender nymph
#

no, it means nothing was assigned to the reference type variable

azure wraith
#

Are you talking about the empty sound controller box?

slender nymph
#

yes. the variable theSoundController was defined in the code, but it had nothing assigned to it

azure wraith
#

Oh okay so I did know what I was talking about
I can finally sleep at night knowing I wasn't an idiot

kindred iron
#

Can someone explain me please that why a interface is a compenent?

IInteractable interactableObj;

if (hit.collider.TryGetComponent(out interactableObj))
teal viper
kindred iron
#

oh, ty bro

azure wraith
#

I'm making jump particles whenever the player jumps, the player is a circle (intended)
whenever the circle rolls, for example, 180 degrees, the jump particles will emit on top, not on the floor, I'm trying to make the particles only appear on the bottom of the player, not the local bottom of the player

#

Is there any efficient way to do this?

wintry quarry
burnt torrent
#

i can try looking back at my code again and seeing if I did anything wrong

wintry quarry
burnt torrent
#

their positions are still existent in the array

#

im gonna check back in my code to see if i did smthn wrong though

wintry quarry
#

the array will be a continuous rectangle

frosty cargo
#

im trying to follow a tutorial, but ive run into an issue, and the auto fix is just going in a loop that wont fix

wintry quarry
#

because you didn't

frosty cargo
#

ohh

#

im so confused

#

😭

wintry quarry
#

what are you confused about

frosty cargo
#

i dunno how to copy the correct code properly and put it in the right spot

wintry quarry
#

put it exactly how they have it in the tutorial

#

don't change anything

#

that's all

#

copy

frosty cargo
#

thats what im doing

wintry quarry
#

You didn't do it correctly

#

double check it and try again

wintry quarry
frosty cargo
#

exactly the same thing i wrote

wintry quarry
#

This is your code

frosty cargo
#

oh yeah the second public void is the result of the auto fix

wintry quarry
#

auto fix of what? Copy the code as it is written and there will be nothing to auto fix

frosty cargo
#

this is what it looks like rn

#

not the old one

wintry quarry
burnt torrent
wintry quarry
burnt torrent
#

ah

wintry quarry
#

You cut off the error message in your screenshot @frosty cargo

#

mouse over it to read it

#

That's a lot of typing to just copy the error here

frosty cargo
#

The type 'Gun' cannot be used as type parameter 'T' in the generic type or method 'Object.Instantiate<T>(T)'. There is no implicit reference conversion from 'Gun' tp 'UnityEngine.Object'.

wintry quarry
frosty cargo
wintry quarry
#

and look at it

#

and compare it to the tutorial

#

and copy it properly

frosty cargo
#

the tutorial hasnt done anything with the gun script yet

wintry quarry
#

then keep watching the tutorial

#

until they do

frosty cargo
#

okay

wintry quarry
#

but why was it created as a plain class here

#

seems the tutorial created the script

#

and they probably created it from Unity as a MonoBehaviour, which you did not

frosty cargo
azure wraith
wintry quarry
azure wraith
#

huh???

#

let me check then

wintry quarry
tribal fulcrum
wintry quarry
#

looks like it's a Sprite

#

A sprite is just an art asset

tribal fulcrum
#

ok

wintry quarry
#

You're probably meant to be dragging a prefab into there

#

are you following a tutorial?

tribal fulcrum
#

yeah i am

wintry quarry
#

The tutorial should be covering this

tribal fulcrum
#

and youre right im trying to do a prefab

wintry quarry
#

to make a prefab you can drag that sprite into the scene, which will create a GameObject with a SpriteRenderer attached

#

then drag that object from the scene into the project folder

#

that will create the prfab

#

then you can delete the one in the scene

#

and use the prefab

azure wraith
azure wraith
wintry quarry
#

isn't that another setting?

tribal fulcrum
wintry quarry
#

presumably.. you didn't share your code but that's what it looks like

tribal fulcrum
#

yeah i know its like that

#

i should probably clarify im following a tutorial by every single thing of code

wintry quarry
#

Yeah the tutorial does exactly the same

#

and has tons of pipes spawning too

#

did you listen to what the tutorial person said?

tribal fulcrum
#

i feel like i am but our obstacles are spawning differently

wintry quarry
#

you didn't set up your prefab the same way

#

or you didn't put your spawner in the same place

tribal fulcrum
#

ohhh i rewatched it and i realize i didnt do it correctly

#

thanks for pointing it out i didnt prefab right

vagrant pendant
#

if you wanted to re-create the Stardew Valley fishing "minigame" would you use UI elements or regular 2D game objects?

https://forum.makecode.com/t/fishing-mini-game-ui-like-stardew-valley/8258 (GIF of what the minigame looks like is in this link)

swift elbow
#

i would use UI

wintry quarry
#

maybe the latter but then rendered in UI via RawImage?

#

eh, probably just UI yeah

swift elbow
#

UI just feels like the simplest apporach

vagrant pendant
#

any reason for one vs the other? I got a similar mini game created using UI Elements (Images in particular)

#

yeah it was fairy simple to get going

wintry quarry
#

Ui elements are easier to lay out in terms of screen position, size, and distances from screen edges etc, as well as within itself

#

it's made for relative layouts.

Whereas with sprite renderers you basically... need to build that whole system yourself

silent vault
#

Hello, I have an issue with Unity where when I activate a mesh which was already in the scene from the start, Unity creates instance of all its materials instead of using the sharedmaterials

#

I would need to use the sharedMaterials directly in the inspector (this is to allow me to quickly change original materials in the project)

#

Currently, I have to drag and drop all the original materials back in the materials array of the inspector to be able to edit the original materials easily.

#

Is there no way to modify the original materials in the inspector at runtime ?

hot harbor
#

Is hot reload work in a similar way as assembly definitions do? Where they define that only the scripts changed will be recompiled or something

chilly vigil
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyAI : MonoBehaviour
{

private Pathfinding1 pathfinding;
private Vector3 startingPosition;
private Vector3 roamPosition;

private void Awake()
{
    pathfinding = GetComponent<Pathfinding1>();
}

private void Start()
{
    startingPosition = transform.position;
    roamPosition = GetRoamingPosition();
}

private void Update()
{
    pathfinding.MoveTo(roamPosition);

    float reachedPositionDistance = 1f;
    if (Vector3.Distance(transform.position, roamPosition) < reachedPositionDistance) {

        roamPosition = GetRoamingPosition();
    }
}

private Vector3 GetRoamingPosition()
{
    return startingPosition + Pathfinding1.GetRandomDir() * Random.Range(10f, 70f);
}

}
is this right for an bad ai c#

sour fulcrum
#

Don’t post ai here

#

if you can’t write it and can’t proofread it no one is gonna be interested in assisting you

eternal falconBOT
chilly vigil
wintry quarry
chilly vigil
# wintry quarry ok what's your question

NullReferenceException: Object reference not set to an instance of an object
EnemyAI.Update () (at Assets/Scripts/EnemyAI.cs:24)
is what i get plus the npc not roaming around randomly althought the video makes me prefab the enemy

wintry quarry
#

which means this: pathfinding = GetComponent<Pathfinding1>(); returned null - which means you don't have that script attached to the same GameObject as this one.

solid helm
#

Guys I have this code "https://paste.mod.gg/anttbeeivfwk/0" and already tried everything watching tutorials and codes of there more I just can't unlock my player client, the player host usually works but the player client does not leave the place, it even activates the animations but simply does not leave the place

teal viper
#

And to tell you the truth, networking is not a beginner topic.

solid helm
#

oh sorry, thanks

wintry dew
#

Hello, i would like to ask if it's better to use a character controller or regular rigid body and stuff for parkour physics

teal viper
wintry dew
#

Yeah and with that i can even change up the hit box with custom colliders

#

Rather than the capsule

neon forum
#

trying to 2d raycast and hit an obj in the game but it's not doing anything

#
        if (hit.collider != null)
        {
            Debug.Log("Target Position: " + hit.collider.gameObject.transform.position);
        }```
timber tide
#

Debug the mouse position and world point to see if it's getting any values

#

Ah, what could be happening too is the ray's origin is probably spawning inside of the collider plane so maybe add a unit or two in the up direction to the origin

neon forum
#

so a flat +2?

timber tide
neon forum
#

zero vector direction does nothing

timber tide
#

The thread has a few other considerations so worthwhile to go over it

neon forum
#

ok

wintry quarry
#

Not Raycast

slender sundial
#

im trying to make a scene where after reaching a certain y-cord and staying at it for 3/4 of a second, an animation plays. I've made the code and animator controller work (I can send proof of it if you need) but when the trigger happens and it goes to the state that the animation clip is in the animation just doesn't play. does anyone know what's wrong?

neon forum
#

ok I'll try that

sour fulcrum
hot harbor
#

Does the generic T type not support getting the fields on the instance of said type? But the "Type" type can do this?

neon forum
wintry quarry
neon forum
#

oh right lol

wintry quarry
neon forum
#

just a different declaration

hot harbor
# wintry quarry Example of what doesn't work?

the screenshot is someone talking about being able to use reflection to copy fields of a scriptable object to a copied instance of it, and he mentioned how specifically casting

Type type = Base.GetType();

was needed

wintry quarry
#

that's calling GEtType()

hot harbor
#

Ah my bad

wintry quarry
#

you have to call GetType on an object to get its type

hot harbor
#

Makes sense

#

Thanks!

slender sundial
neon forum
hot harbor
wintry quarry
#

You could do typeof(MyScriptableObject).GetFields() or typeof(T).GetFields()

wintry quarry
#

use Camera.main.ScreenPointToRay(Input.mousePosition) to create the ray

neon forum
#

got it, thank you

hot harbor
wintry quarry
#

yes...

#

GetFIelds is a method on Type

#

it's not a method on anything else

neon forum
hot harbor
wintry quarry
neon forum
# wintry quarry what are you expecting to be logged? What object are you expecting to be hit? Wh...

What I'm expecting to be logged is whatever the ray is colliding with.
The object I'm expecting to hit is a tile(game object that was spawned with a grid code).
Current code:

    {
        RaycastHit2D hit = Physics2D.GetRayIntersection(Camera.main.ScreenPointToRay(Input.mousePosition));
        Debug.Log(hit.ToString());
        if (hit.collider != null)
        {
            Debug.Log("Target Position: " + hit.collider.gameObject.transform.position);
        }```
#

the tiles DO have box colliders

wintry quarry
#

(it also probably makes sense to log the name of the object you hit)

neon forum
#

... why did it become a png

#

okay I split it

wintry quarry
#

This should be in Update

#

which object is this code on?

neon forum
#

oh

#

the object the raycast code on is on a gamecontroller object(not the tile)

wintry quarry
#

yeah OnMouseDown is only going to run if the gamecontroller itself has a collider and you click on the game controller

neon forum
#

oh duh

#

yeah that fixed it lmao

#

ty

prime chasm
#

I started trying to learn C# and Unity a little while ago and I had an idea of something I wanted to make to experiment with and I can't find any resources online about it so I wanted to ask if anyone has a suggestion of how I should go about implementing my idea. It's pretty simple, I just want to make player movement similar to that of West Of Loathing since I really like the way that game handles movement. In West Of Loathing you can move back and forth as well as left and right like a 3d game but the camera is side-scrolling and the sprites are 2d. I particularly like how the shadows of the characters and objects work but I'm not even sure if I should try to make this in a 3d project or a 2d project so if anyone would be willing to help me figure out how I can start getting the desired result I would greatly appreciate it.

wintry quarry
prime chasm
#

oh that's good to know thank you

wintry quarry
#

a quick google for that game shows it appears to be a pretty typical 2D game with sprites

#

I see it has a cute shadow thing going on in some scenes

prime chasm
#

yeah its just 'cause I was confused since in the game you can move back and forth which I thought was only possible in 3d

wintry quarry
#

not sure how they did that exactly

wintry quarry
#

but - the style of movement you're talking about has been around in 2D "beat-em-up" games since the 80s

prime chasm
#

yeah

wintry quarry
prime chasm
#

I see what you mean yeah

#

So it should be relatively simple to implement I suppose?

wintry quarry
#

yeah - the movement part

#

the shadow thing is a different story

prime chasm
#

alright thank you so much for the help

wintry quarry
#

You mean these shadows right?

#

Or something else?

snow warren
#

hey guys

#

need some help

#

is there any script for camera which mimics breathing effect

#

like when breath in camera goes up and to the right side a little bit randomly

#

and when breathe out it comes onto the normal position???

verbal dome
snow warren
#

lol

#

randomly moving camera

verbal dome
#

You can rotate your camera additively after you calculate its rotation each frame

#

You can use Mathf.Sin and/or Mathf.PerlinNoise to get some movement, for example

snow warren
#

any examples i can follow?

verbal dome
#

Well I suppose you can google "view bobbing"/"camera bobbing" or just additive camera animations in general

verbal dome
#

Show your current camera code?

#

If you modify thet camera every frame, you can do something like ```cs
void LateUpdate()
{
// Update base camera rotation and position here first

// Now apply additive rotations
float sin = Mathf.Sin(Time.time * speed);
camera.transform.Rotate(sin * angleMultiplier, 0, 0);

}```

#

This rotates it on its local X axis which makes it bob up and down

topaz mortar
#

GameObject itemGO = Instantiate(IFGameManager.Instance.itemPrefab, new Vector3(0, 0, 0), Quaternion.identity, emptySlot.transform);
Why is this instantiating my object at a completely different position (I think it's the player's position)

teal viper
topaz mortar
#

oh, it's a UI element

teal viper
#

Are you sure you're looking at it's world position and not local position?

topaz mortar
#

work perfectly like this:
GameObject itemGO = Instantiate(IFGameManager.Instance.itemPrefab, emptySlot.transform);
Guess the Quaternion messes up the position somehow

#

I'm looking at the transform in the inspector

#

It was instantiating at -1500, -1000 and the values changes as my player moved

teal viper
topaz mortar
#

dunno, it's showing 0, 0, 0 now and it doesn't change

teal viper
#

000 means that it's at the same position as the parent. And it wouldn't change even if the parent is moving.

teal rapids
#

What do you think the better naming scheme for enemy classes are:
Suffix:

  • BaseEnemy
  • SlimeEnemy
  • SpiderEnemy
    Prefix:
  • EnemyBase
  • EnemySlime
  • EnemySpider

Here's my thoughts:

  • Suffix reads better for natural-language
  • Prefix better for IDE autocomplete
  • Looking at Unity collider variants names (BoxCollider, SphereCollider, CapsuleCollider) they use suffix
topaz mortar
#

I prefer prefix, since I need to constantly find them in my code

#

you could also just go with Enemy, Slime, Spider

sour fulcrum
#

i think suffix works nicely when you do more layers of inheritence eg.

BaseEnemy
SlimeEnemy
FireSlime

teal rapids
safe root
#

Is there a way to make a OnCollisionEnter or OnTriggerEnter (Collision) and be able to set what collision that would be?

safe root
sour fulcrum
#

you have shown me a screenshot that reflects nothing about the link i sent you

safe root
eternal needle
snow warren
#

breathing effect

#

i am using lerp to interpolate from end to start position for camera

#

this is my code

#
public class CameraBreathe : MonoBehaviour
{
    [SerializeField]
    private bool isBreath = true;

    [SerializeField]
    private float MinHigh = 0.8f;

    [SerializeField]
    private float MaxHigh = 0.9f;

    [SerializeField]
    [Range(1f, 10f)]
    private float freakness = 1f;

    private float movement;
    void Update()
    {
        if(isBreath)
        {
            movement = Mathf.Lerp(movement, MaxHigh, Time.deltaTime * 1f * freakness);
            transform.localPosition = new Vector3(transform.localPosition.x, movement, transform.localPosition.z);

            if (movement >= MaxHigh - 0.01f)
            {
                isBreath = !isBreath;
            }
        }
        else
        {
            movement = Mathf.Lerp(movement, MinHigh, Time.deltaTime * 1f * freakness);
            transform.localPosition = new Vector3(transform.localPosition.x, movement, transform.localPosition.z);

            if (movement <= MaxHigh + 0.01f)
            {
                isBreath = !isBreath;
            }
        }
    }
}```
#

all it does is that once it goes to the max height

#

it stops

#

and waits for some time

scenic notch
#

Why can't i access the public variable "isAlive" from the player script?


using UnityEngine;

public class PipeScript : MonoBehaviour
{
    public LogicScript player;

    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player").GetComponent<LogicScript>();
    }


    void Update()
    {
        if (player.isAlive)
        {
            //do something
        }
    }
}
snow warren
#

and instantly jumps to the Min Height

#

when i want it to go from Min to High and then High to Min

#

how to fix it?

scenic notch
#

fixed it

snow warren
#

here

#

how to fix it

#

i want it to go high and then come down gradually

#

but it isnt

#

Any Helps??

dusk prism
#

p8hjkew uiqn-c80 o3qs9tiyd-'0o

onyx cove
#

Hello,
I'm making a build for an AR scene, and these warnings show up. Does anyone know how I can fix them?

topaz mortar
#

rectTransform.position = new Vector3(0, 0, 0);
This doesn't set the position to 0 somehow? It's a UI element.

teal viper
topaz mortar
teal viper
topaz mortar
#

How do I set it to 0/0/0

teal viper
#

Use the properties of RectTransform

topaz mortar
#

so I just need anchoredPosition instead of position?

teal viper
topaz mortar
teal viper
#

It's not me having the problem

real thunder
#

I can of course do that manually but is there a perhaps a method to display seconds into min:sec 99:99 format?

#

nvm, TimeSpan.ToString(@"mm:ss") seem to work

covert flower
#

ignore some of the other glitchy aspects

real thunder
#

teleport the agent to the ragdoll via code

covert flower
real thunder
#

maybe NavMeshAgent.Warp I am not sure

covert flower
#

im unsure how to do that

timber tide
#

what's wrong? The agent is disjointed from the ragdoll?

#

If you're using unity's pathfinding you need to disable the agent when you use any sort of rigidbody when applying physics

covert flower
timber tide
#

a* pathfinding project is better at this stuff

#

free version may be enough if you wanted to look into it

real thunder
#

how is it better?

timber tide
#

it works out of the box with rigidbodies

real thunder
#

I got so used that nothing works out of the box with unity...

#

except rendering I guess

timber tide
#

Unity's agent controller requires a lot of custom logic since it'll always override forces

real thunder
#

yeah I was about to start making my solution where it's only used for pathfinding

#

let alone trying to do "local avoidance" described at A* asset

timber tide
#

local avoidance is pretty non-existent with navagents

real thunder
#

default pathfinding is sad

timber tide
#

you can do some hacky stuff making agents also obstacles to kinda get it to work but it's pretty bad

real thunder
#

not pathfinding but agents

timber tide
timber tide
#

You probably need to start a new path too after enabling the agent, assuming the agent is actually parent to the ragdoll mesh

real thunder
#

I am very hesitant to use anything made by not Unity but I guess it would be very annoying for me to do anything like that

covert flower
teal viper
# covert flower this didnt work

If you want to combine physics and navigation movement, you'll need to get rid of the agent and handle moving along the path manually.

timber tide
#

NavAgent and Rigidbody on the same parent gameobject. When you apply a force to the rigidbody -> turn off navagent. Once you decide a point where the zombie should get up, enable the navagent again and calculate a new path.

real thunder
#

he just want the agent to ragdoll and back transformation as I understand

covert flower
covert flower
#

I used the Unity ragdoll feature

timber tide
#

Sure, but the root of it all moves with it and that's what the agent should be on

covert flower
#

hold on lemme try something i might get it

timber tide
#

turn on gizmos and make sure everything is moving with each other

covert flower
#

I need to get the parents to effectively follow the ragdoll

real thunder
#

first thing I myself would try is to disable the agent on start and teleport it in the end to the main RB child

#

that's what you said, yeah...

covert flower
real thunder
#

don't make me feel bad

covert flower
#

i think you just told me how I was having it be so buggy before

#

I didnt realise ty

#

The nav mesh was causing it to glitch so much when it teleported

#

now ive forgotten what the code i Used before was TwT

real thunder
#

ok I am now confused but if you solved issues I glad

covert flower
timber tide
#

I'd feel like sticking the agent on the root of the skinmesh render would be fine, but maybe I'm mistaken how the ragdoll is moving

real thunder
#

I hope you are teleporting the agent itslef, not the gameobject
there is a difference right?

covert flower
#

should I instead put those components on the root of the ragdoll?

real thunder
#

ah right right right I figured

#

yeah I can see how it can get screwed on teleportation

covert flower
#

theres a trigger collider and another one that Also dont move as well as the nav mesh agent

real thunder
#

so mesh and agent have the same relative positions always

#

this seems more complex than I initially thought

#

and you would also need some interpolation logic I guess

#

anyway I think there are guides on youtube to do ragdoll>agent

bitter apex
#

So I have a game state manager object that persists in all scenes, and is initially created when you first load up the game. This means I can't assign something in the inspector immediately when it doesn't exist yet and will only exist in a different scene (I think?). I've been trying to get one of the buttons that are on my screen but it seems to keep saying that Object Reference is not set to a reference of an object.

#
UIButtonToggles digButtonScript = GameObject.FindWithTag("DigButton").GetComponent<UIButtonToggles>();```
#

It's the GameObject.FindWithTag("") bit that is the problem, but I have no idea how to do it otherwise

#

I've tried it with just .Find() but that hasn't worked either

#

I also just tried this cs UIButtonToggles digButtonScript = GameObject.Find("Canvas").transform.Find("DigButton").GetComponent<UIButtonToggles>();
but that didn't work either. I feel like I'm just misunderstanding how buttons work or something

visual linden
#

I feel like I'm just misunderstanding how buttons work or something
Not that, necessarily, but maybe architecturally you're approaching it in a not so ideal way

#

What exactly are you trying to do?

bitter apex
#

I apologise, yeah I think I've just been doing things in the wrong way. Turns out I was trying to find the wrong thing anyways and I managed to sort it out 🤦‍♂️

#

I'm not trying to make anything pretty I just wanted it to function and it was a logic thing, rather than a syntax thing

#

thank you

visual linden
#

Well it's less about making something pretty and more about making life easier for yourself. Setting things up "Correctly" helps reduce the chance of bugs, on top of all other benefits like better performance, faster iteration etc.

#

Glad you got your issue sorted though :)

bitter apex
#

Yeah I don't disagree, structuring my code better would definitely have helped but I'm rushing through this as I have a deadline for my game to meet soon, it's just a little project that I need to do for school. I initially realised that what I was doing now was going to become a problem so I came up with a solution, and then forgot I made that solution

covert flower
#

I have an issue where if the nav mesh is on the parent it causes 0 errors and works fine as movement. but when ive moved it to a child object it now comes uo with set destination can only be called on an active agent placed on a nav mesh

shy cairn
#

Anyone know a good way to fill in attribute values of a prefab after instantiation?

#

When I drag and drop a prefab, I get reference errors, I have a script that fills in these attributes but I still get the reference errors

hexed terrace
#

Have a component on the prefab which the spawner passes the relevant references to. Have either properties (getter/ setter) or methods which allow you to set the values from another class.
Don't spawn as a GameObject spawn as this component, so you get the reference to it straight away (no need to do getcomponent).

MyFancyComponent newlySpawnedObject = Instantiate(prefab);
newlySpawnedObject.Reference1 = someReference;
newlySpawnedObejct.Player = player;
shy cairn
#

okay thank you, im going to try it this way and see if I can solve the problem

hexed terrace
#

You'll need MyFancyComponent on the root of the prefab

ripe shard
fervent abyss
#

hey guys

so i have a vr game with hand grabbing locomotion, where you have to grab the floor in order to move, and it modifies rigidbody velocity using the hand position

but the issue is that whenever some object in the map with a collider pushes down on the player from above, the player is pushed out of the map (obviously)

how can i try to make so the player stays in the map? i thought that i should write some collider kind of thing using raycast or something?

playerRigidbody.velocity = playerRigidbody.velocity + (handLastPosition - handTransform.position) / Time.fixedDeltaTime;

fervent abyss
cosmic dagger
sage peak
#

I doubt that this is code, but can someone tell me why my colliders dont work?!

cosmic dagger
# sage peak

What do you mean by, "don't work." What is not happening that you expect to. It's best to explain what is going wrong when asking for help . . .

sage peak
#

My bad, They... dont work?????

I just clip through the object like the collider isnt there

cosmic dagger
#

Clip through which object?

sage peak
#

The table

cosmic dagger
#

How are you moving the player?

sage peak
#

First person, WASD and Arrows

hexed terrace
#

the controls aren't relevant

sage peak
#

If thats what you mean 😬

hexed terrace
#

what code moves it

shy cairn
hexed terrace
cosmic dagger
hexed terrace
shy cairn
# hexed terrace You do not want to do `[SerializeField] private GameObject myPrefab;` You want ...

Would you by any chance know why I get the error: ""UnassignedReferenceException: The variable recoilTransform of ShootMechanics has not been assigned.
You probably need to assign the recoilTransform variable of the ShootMechanics script in the inspector"" straight after instantiating the object into the scene. The fields are correctly filled out in inspector thanks to my script but for some reason I still get that error. The error only comes up once after instantiation, after unpausing the game I dont get it anymore, making me believe that the error is being thrown before I get the chance to assign the attribute values. thank you

hexed terrace
#

because you're tyring to use something before it's assigned... at a guess

#

probably in Awake or something

eternal falconBOT
shy cairn
shy cairn
# polar acorn Show !code

I just got it fixed thank you. And also uh, apologies for my behaviour yesterday, you were correct there was also an error in my script!

#

🙏

sage peak
#

Where do I ask for help with something not to do with code

naive pawn
ripe matrix
#

hello, how do i spawn a 2d ui in a canvas over the position of a 3d gameobject on the screen?

ripe matrix
ripe matrix
#

thank you

subtle hedge
#

how do i make the player move while being fixated to the surface under hit, in this case a sphere ```cs
private void Update()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");

 Ray ray = new Ray(transform.position, -transform.up);
 if (Physics.Raycast(ray, out RaycastHit hit, treeLayer))
 {
     transform.position = hit.point;
     transform.rotation = Quaternion.FromToRotation(transform.up, hit.normal) * transform.rotation;
 }

}

grand snow
hexed terrace
#

do not cross post, delete from here

#

post the same thing in multiple channels.

#

You could have left one of the messages.

#

Yes, ONE of the code channels you posted in.

(all channels are help channels)

cobalt grotto
#

hello, im new to unity and im trying to make a turn based rpg could u please help me? i just made the system and works everything except that idk how to make the two characters chose their action and then the turn order kicks in instead i just made that based of whos the faster decide who act first and after selecting a move it get used instantly and its the turn of the other character and so on untill the gameover. how can i make it pokemon like or like game with multiple party member like in final fantasy where you select for each a move and then the action order its mixed btw enemy party member etc...

subtle hedge
soft creek
#

Hello, i have a block that i want to eliminate only when the player collide with it, how i can do it?

polar acorn
rich adder
soft creek
polar acorn
rich adder
soft creek
#

reference sorry

polar acorn
soft creek
#

i want to know how i can identificate the player collider and no other colliders

rich adder
#

You can also use tags, but its much easier to check for a component.

soft creek
neon ivy
#

I'm trying to create a 3d biome map texture in code and was looking at how minecraft generates their biome map, and they seem to zoom a lot
sadly I don't see any way of doing this in Unity and I believe that such a stack of tasks drawing to a texture should be done in a compute shader? (might be wrong about this) which I also don't know much about. does anyone have any ideas for how I should proceed?

polar acorn
eternal falconBOT
polar acorn
soft creek
#

i'm testing with other objects and is not working

polar acorn
#

The Three Commandments of OnTriggerEnter:

  1. Thou Shalt have a 3D Collider on each object
  2. Thou Shalt tick isTrigger on at least one of them
  3. Thou Shalt have a 3D Rigidbody on at least one of them
hardy hedge
#

can someone explain how I can limit velocity in a character controller

#

im new to unity

soft creek
polar acorn
hardy hedge
#

@polar acorn thaanks I appreciate it

wintry dew
#

Is there a better way to make a new "type" of game object rather than making a tag and setting my certain "type" of game object to that tag?

dense badge
#

anyone know how to fix this

#

this is a new project

dense badge
#

just created it

rich adder
#

this is a code channel

dense badge
#

oh sorry

west radish
polar acorn
#

Chances are a package is out of date

wintry dew
rich adder
#

Interface also could work

wintry dew
#

Hmm but how would i access them from other scripts in like different scenes

west radish
#

an interface could work, or you could do

public class Room : MonoBehaviour {}

public class CornerRoom : Room {}
public class StraightRoom : Room {}
public class TJunctionRoom : Room {}```
wintry dew
#

Would i also need to make it be singleton or sm i saw that somewhere

rich adder
#

do you know what singleton is for?

wintry dew
#

Is when you only need one script right

#

I would only need one room script ig

polar acorn
rich adder
#

kinda. its for ideally keeping 1 instance that easy to reference/access

wintry dew
#

Oh i see

polar acorn
wintry dew
#

With the same script

polar acorn
wintry dew
#

That's what I'm perplexed on

#

Oh so i would make a room prefab?

rich adder
#

Pretty much

wintry dew
#

Or every type of room prefab as well

rich adder
#

depends what you plan on adding to room that others wont have in prefab

wintry dew
#

So if i have a lot of different rooms that all share the features of a "room" its possible to get by only using the general "room" prefab?

rich adder
#

should be fine yea

wintry dew
#

Alright thanks guys

west radish
#

a quick solution could be if make a Resources folder, you can easily access objects inside that. I can write GameObject decoration = Resources.Load<GameObject>("Prefabs/Deco0"); from any script and it will load the object at the path

wintry dew
#

Ohh that's handy

rich adder
#

I'd opt for Addressables if you plan on going the load by file route

#

its the newer system

rich adder
#

Resources can get slow if you start loading up too much stuff into it

wintry dew
#

I'll have to learn that then

rich adder
# west radish oh?

Basically Resources just Packs everything into one giant file in Build key/value type deal.. so imagine the bigger resources folders get, the bigger the file, the slower the lookup

#

Addressables skirts this by you accessing the resource directly at an address

wintry dew
#

That's pretty cool then

ripe matrix
#

hello, ive been trying to make a multiplayer game. i wish to have crosshairs be displayed over and follow every gameobject with the tag "Player" in the view of the camera of each player. how would i do that?

rich adder
ripe matrix
#

the poitn of multiplayer is that players might join or leave anytime

rich adder
rich adder
ripe matrix
rich adder
#

transform.position = other.position

#

multiplayer in this case would only change that this function would run as a Server RPC o

ripe matrix
#

you're right im not sure why i mentioned multiplayer

rich adder
#

in an ideal situation the players all get spawned with the same components because they all stem from the same prefab

#

would be the same as spawning a bunch of "offline" player prefabs

ripe matrix
#

my main problem is that while instantiating the prefabs, it appears as a 3d element inside the world even though i parented it to the canvas?

rich adder
#

You never spawn something outside canvas and then parent to canvas

#

you should always spawn it as child of canvas if it needs to be a canvas object

#

this makes sure it has a rect transform properly set on spawn

ripe matrix
#
Instantiate(enemyUIPrefab, screenPos, Quaternion.identity, canvas.transform);
#

is this incorrect?

rich adder
#

looks fine

#

enemyUIPrefab should ideally contain the UI elements

#

eg not Sprite Renderers but instead Image.. etc..

ripe matrix
rich adder
#

as long its on a gameobject, it can even be blank

#

of course all Gameobjects always have a Transform component, you can't change that part
(for UI should be a RectTransform ideally)

ripe matrix
polar acorn
honest iron
#

which way is the best to hit enemies with melee attack?

ripe matrix
polar acorn
ripe matrix
#

ill try

rich adder
ripe matrix
honest iron
rich adder
ripe matrix
#

hm still doesnt seem to work

rich adder
#

what "doesnt work" mean

ripe matrix
#

the image is not appearing

rich adder
# ripe matrix the image is not appearing

not much we can go on from here..
if you intend to get any sort of help you outta show.
How you set it up, what is the expected result and whats happening instead

#

all with clear screenshots and code in context

faint osprey
#

im using a joint as a tether for my my astronaught in space and it works but the player can not see that there tethered now obviously i could just do a line renderer from start to end but how would i add like slack to the tether rope and stuff cause i dont know where to start

ripe matrix
#

i have to leave now though, ill just ask again later. thank you for your help

rich adder
#

lemme see if I can find it again

slender nymph
faint osprey
rich adder
subtle hedge
#

can i get a little help with this ? the player is standing in place and it's not moving```public float feetRadius;
public float walkigSpeed;

Vector3 movement,offset;
public LayerMask treeLayer;

private void Update()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");

Ray ray = new Ray(transform.position, -transform.up);
if (Physics.Raycast(ray, out RaycastHit hit, feetRadius))
{
    transform.position = hit.point + new Vector3(horizontal * walkigSpeed * Time.deltaTime, 0, vertical * walkigSpeed * Time.deltaTime);
    transform.rotation = Quaternion.FromToRotation(transform.up, hit.normal) * transform.rotation;
}

}```

#

i'm trying to make the player walk around a sphere

wintry quarry
honest iron
#

is there a collider that cover the gameobject and prevent other can go through it?

subtle hedge
wintry quarry
subtle hedge
#

and i want it to be fixed to the ground on the y aixs and to be able to move forward and horizontaly

wintry quarry
wintry quarry
#

Souds like you just want a MeshCollider?

#

Your question is way too vague sorry

subtle hedge
steep rose
#

I believe they want certain gameobjects to go through eachother while others do not

honest iron
wintry quarry
#

provide details

#

show what you tried

honest iron