#💻┃code-beginner

1 messages · Page 10 of 1

swift crag
#

the editor would grind to a halt over time outside of play mode

rich adder
#

2022.3.3f works for me
but anything above .7f and I get Pink fonts

swift crag
#

interesting

rich adder
#

i was hoping new .10f would fix it

#

but nope

summer stump
rich adder
weary crystal
#

God, how do I run Unity as a standard user? It runs it as an administrator every time, I haven't checked "Run this program as an administrator" In Unity or Unity Hub's properties.

rich adder
#

you're not the first..

swift crag
weary crystal
#

If I click "Run Unity as the standard user" it just prompts it again and again and... Yeah keeps prompting it.

rich adder
#

something to do with your Windows I think running you as "Eleveted" admin user instead of regular user with admin rights

#

saw it on unity forums somewhere, fuzzy on details rn

weary crystal
rich adder
#

Unity says there will be, I'm not certain ..
I never had this issue.

swift crag
#

Your PC should have two accounts by default: a user account and the Administrator account

#

As the user, you can still elevate to do things that require admin privileges

weary crystal
swift crag
#

well, there's the problem!

#

"Run as Administrator" means that, if you aren't currently an admin, the program will elevate to gain admin privileges

#

(probably including that UAC popup)

#

but if you are the admin already, that doesn't matter

rich adder
weary crystal
#

So if I run normally but in an Admnistrator account, it will run the Unity as an Admin, no matter what we do, right?

swift crag
swift crag
weary crystal
rich adder
#

its not a fix

#

read the thread

#

It's been many months using Unity and it always opens as administrator even though I didn't mark it to be. I have crashes even in the LTS version, which cause almost all applications on my PC to stop working, I thought it was related to RAM, but I have 32 GB and it happens even with a very small scene open in the background.

weary crystal
swift crag
#

it means to gain more privileges

#

when you run an installer, and you get that UAC prompt, it's elevating

#

(I am also not an experienced windows sysadmin, so i'm probably butchering the terms a bit)

rich adder
#

is your UAC off ? @weary crystal

weary crystal
#

Ohh, well I didn't got an UAC prompt.

swift crag
#

Because you are an admin already.

#

You don't have to do anything if you are already the admin.

#

you don't have to unlock the door if you're already home

weary crystal
rich adder
#

well that explains it..

#

probably messed with UAC

#

or turned it off

#

which causes these issues

swift crag
#

This would have absolutely nothing to do with "gaming performance", btw

weary crystal
#

It's called Tiny11, I never had issues with something else though, I installed Python and used it for a while and many other dev things I don't remember.

swift crag
#

a lot of "windows optimization" and "windows debloating" is like throwing a live hand grenade in your car's engine bay

rich adder
#

maybe it was back in Windows 7 that these "minified" version mattered

#

or XP

#

I remember i had windows xp "black gaming edition"

swift crag
#

if you have just one user, and that user is an Administrator, then unity is always going to be launched with admin permissions

#

because...how couldn't it?

weary crystal
rich adder
#

at all

#

thats like saying " I installed PHP with no issues"

weary crystal
#

I know but, isn't it one of dev things?

swift crag
weary crystal
#

They both are "dev stuff" after all.

rich adder
#

python just a language, unity is an engine

swift crag
#

Make a new user account. Install Unity Hub as that user, install Unity, and you should be good.

#

You will always get this warning if your only account is an administrator.

weary crystal
rich adder
swift crag
#

they just happen to not complain if they're run with admin privileges

#

unity is mostly complaining for your own sake

#

a game engine runs a ton of random code, including a lot of code you didn't write

weary crystal
swift crag
#

if you are married to Tiny11 and you don't want to make a new user account, then you'll just need to click through the warning

rich adder
#

use a legitamate windows

#

lol

weary crystal
rich adder
#

I feel like those "tiny" versions are just placebo for your PC

#

it doesn't change the hardware

swift crag
#

they might disable some system services

rich adder
#

yeah maybe 0.4% gains , who knows what the real life numbers are

weary crystal
rich adder
#

"I'm gonna remove my car seats to make my car faster" sure it works.. but doesn't change the engine being crappy

weary crystal
rich adder
#

are u not able to make a regular user account and try that?

weary crystal
#

I "kind of" know how to make games but I don't know where to start, what type of games I make and all that.

buoyant knot
#

then you probably need to start with something very small

rich adder
#

the usual suspects : Pong ,Breakout

#

Physics? Flappy Bird / Angry Birds

buoyant knot
#

i would look at what type of game you want to end on, pick the engine that would be best for that particular game, then start with a very basic game in that engine

rich adder
#

this^
just dont make your first game Call of Duty or something llike that lol

buoyant knot
#

like if you want to make a game that is best with Godot, start by making flappy bird in godot following a tutorial

rich adder
#

Godot ?

buoyant knot
#

godot is another engine

#

good for 2D

rich adder
#

I know what godot is just found it odd mentioning it to someone who just started unity lol

#

and godot is not easier than unity Imo

weary crystal
buoyant knot
#

i’m saying: look at dream game, find out which engine is best, start learning that engine with basic game

weary crystal
#

Is there any modeler to make an SMG better than mine?

buoyant knot
#

some people start with the very wrong engine, and get started down a very wrong path

#

one guy tried to make mario maker with kirby using python’s pygames. Very wrong decision

#

he was fucked before he started

rich adder
#

true grit : you can make any game using any engine

#

the tool can be important but the toolmaster can open all doors

buoyant knot
#

you can cut a 2x4 with a kitchen knife, but it’d be foolish not to use a saw

rich adder
#

yeah like 2D in unreal

buoyant knot
#

start in the right workshop

weary crystal
#

Damn true, bro's speaking facts.

solid timber
#

Hey guys, a Z-fighting question.

I have two flattened cubes in unity, that are on the exact same table at similar position (as in picture), and since they are told not to collide, they instead start Z fighting. Which is not unexpected.
But since my game will have this scenario happening all the time (cubes overlapping each other), I need to solve how to make sure one is always infront (even if there are 4 or 5 overlapping cubes.

Is there a reasonable tutorial or way to make an hiearchy on what should be shown ontop? And avoid Z fighting.

rich adder
#

Godot is good but has a few years before it can catchup to unity's 2D

#

lets not even mention 3D as its very...very early..

weary crystal
#

I made this, what's next, coding and I'm fucked.

rich adder
#

eg. Raycasts, Inventories, AI etc.

weary crystal
rich adder
eager maple
#

Hey I finally found a place to ask this question!
So I'm making a game where you can look at the side to rotate your camera, well the rotating works fine, but if you go to the side/boundary you can no longer turn back which is really annoying...

I decided to post the code in here:
https://mystb.in/ParticipantFundedImplementing

thick goblet
#

I attached my BlueBallCollision script to my player and I assigned the BlueBall tag to the Blueball gameobject and prefab which gets instantiated. However the problem is that the player doesn't turn blue like I want him to when he gets hit for a period of 5 seconds and afterwards he's supposed to return to normal. The slowed movement doesn't work either ever since I changed the blueballcollision script from being on the player instead of the ball. Any ideas? https://gdl.space/ubasenedom.cpp

rich adder
#

doesnt seem code related

rich adder
solid timber
thick goblet
rich adder
rich adder
#

make sure that thats running

solid timber
rich adder
thick goblet
#

I need to debug.log more often looks like

rich adder
#

alr so we know its not the coroutine

rich adder
eager maple
thick goblet
#

isTrigger is checked for the ball gameobject tho

rich adder
#

if Debug.Log("Blue ball hit!"); is printing

#

its not the trigger

#

either player is null

solid timber
thick goblet
#

ah

rich adder
#

or isHit

#

and not both

thick goblet
#

One sec

#

This is the error that returns once the balls falls on the player

rich adder
#

expand ur errors

thick goblet
#

oh brings me to this line

eager maple
rich adder
#

player is null

#

removing the if statement made it worrse

thick goblet
#

Oh damn it

rich adder
weary crystal
#

I want to learn coding all by myself, I don't want to watch YouTube tutorials or stuff, is there anyways I can learn C# that will make me enough to make indie games, at least like Flappy Bird without YouTube tutorials?

rich adder
#

Unity is just an API

weary crystal
rich adder
#

if you can learn how to read API you can use any program with c#

rich adder
#

there is no Unity c#

#

its an API for the engine which is written in c++

#

if you have c# knowledge this comes with ease, you jus need to learn what each function does

weary crystal
#

Ohh, the thing is I learnt English so easily, I just wish C# were easy to learn too, it's a language after all.

rich adder
#

so you didn't learn English in a day right?

#

it ranges from easy stuff and then progresses into harder stuff

#

easy stuff : what are variables? what are function ? what is the correct syntax

#

etc.

#

you said you know most of this stuff from other coding you did

thick goblet
#

Navarone do you know what could be causing the error I can't figure it out

rich adder
eager maple
weary crystal
#

Yeah you're right bro, I'll try not to get bored and start playing games while learning C#, thanks, really appreciate your help man.

thick goblet
#

Wait so if I called lets say PlayerController player = collision.gameObject.GetComponent<PlayerController>(); and the rest outside of the OnTriggerEnter then it wouldn't need to be attached to the ball script

#

its the fact that its in the ontrigger

#

hm

weary crystal
#

navarone, one more question, what you think about Brackey's C# tutorial? I know it's old but I can learn from him easily.

summer stump
rich adder
summer stump
weary crystal
thick goblet
#

Alright Navarone it turns blue once I attach the script thanks so much

#

just need to make it slow now

summer stump
rich adder
eager maple
#

that's why im here

weary crystal
rich adder
#

those are good

summer stump
rich adder
#

im bad with rotations tho maybe someone else will chime

#

lol

slow thunder
#

what's the best way to make scripts be able to access data for different guns like their fire rate, recoil, name and stuff?

slow thunder
rich adder
#

sorry I think its called Mediator

rich adder
eager maple
#

ehm, what do you mean

weary crystal
#

Off to a good start I guess.

rich adder
eager maple
#

you know fnaf?

#

like that

rich adder
#

Five nights?

eager maple
#

ye

thick goblet
#

Navarone this completely fixed everything I just want to make sure I understood correctly tho. Does this instead get the PlayerController of the object which this script is attached to while the commented line got the PlayerController of the collision gameobject which didn't exist?

#

Yeah I think that's it actually

rich adder
thick goblet
#

yeahhh

#

thank you

rich adder
# thick goblet thank you

np. but you better off just putting a field in the inspector next time whenever you need a component on the same object as script

#

I thought you were looking for PlayerController on the other object since this one was named Ball or w/e lol

thick goblet
#

Yeah that would be easier lmfao

#

But sometimes I'm scared to do that because my prefabs were referencing incorrectly

#

last project

#

yeah my namings can be shit as well

rich adder
rich adder
thick goblet
#

Yes that was the mistake I made it confused me badly

#

I need to ask more often here because the way you guys deduce the solution is great

#

teaches a ton

rocky canyon
#

repetition is the key

weary crystal
#

navarone, I do think why am I doing this, is this even useful in game dev??

wintry quarry
#

definitely useful yes

rich adder
#

of course

eternal needle
weary crystal
#

Umm okay.

rich adder
#

its always a slow burn in the beginning and may feel like a chore maybe

weary crystal
#

I'm asking cuz in game dev, we play with Physics, Rigidbody and all that stuff, not this.

rocky canyon
#

you also use this stuff alot

#

and it can help debug the physics rigidbody and all that

weary crystal
#

hm, well I agree.

rich adder
weary crystal
#

Well I know some Python and C# is kinda same, so...

rich adder
#

not really the same

weary crystal
#

Numbers are hehehe

zealous oxide
#

a few days ago i had my important variables showing as textmesh pro on my games gui. it would work instantly, all the variables would be set on start and the game would immediately show the corresponding figures (eg 5% crit) on launch on the screen. however now this doesnt happen and I dont know what i've done wrong. for the record, the only one that works is "timePassed" because its also sitting in the **update **bit of the script, but I dont know what is best practise here, having all of these variables just continuously updated via the Update (method?)

wintry quarry
#

because you're printing c twice

weary crystal
#

oh nvm

summer stump
#

For things like max jump, start should be fine, right? Unless that changes

zealous oxide
summer stump
#

Current health, though, will never update in start

summer stump
zealous oxide
#

yeah so as you can see in the first pic, private void start, i set the critchance, max health and current health, and up until about yesterday when i launched the game it would instantly show those variables

#

now when i launch it doesnt for some reason

#

the only thing thats updating is timepassed because its in UPDATE

weary crystal
#

Um I have no idea what is this, can someone help me?

weary crystal
#

Did it divide d by a and gave me the reminder?

weary crystal
summer stump
wintry quarry
#

% is literally called the remainder operator in C#

#

it returns the remainder of the division operation

#

that's all

swift crag
#

which is an important distinction

#

-1 mod 5 is 4; -1 rem 5 is -1

#

where's my damn modulo operator, Microsoft

summer stump
zealous oxide
#

whats wierd is the crit chance one seems to completely omiss the first 5% crit i give the player inherently, so when i get the power up, rather than going from 5% to 15% (10% inc as intended), it goes from 0% to 10%

#

this was working up until like today

wintry quarry
#

And checked that there are no errors in the console?

swift crag
#

yes, you should always reach for that when things aren't adding up

#

"is this code even running?"

zealous oxide
#

best way to do this? Debug.Log( maxHealth = 50;) or?

summer stump
wintry quarry
queen adder
wintry quarry
#

printing data will be helpful but that's the next step

swift crag
#

bonus points

#

Debug.Log("Hi", gameObject);

#

assuming this is in a MonoBehaviour

#

clicking that log will take you to the game object

summer stump
zealous oxide
queen adder
zealous oxide
#

thank you

#

i thought i had done something stupid somewhere as all the variables etc were working yday

summer stump
eternal falconBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

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

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

queen adder
#

while I am here
can I check if a specific point in space is intersecting geometry

#

like a raycast but checking a single point

swift crag
#

the best I know of is a small-radius sphere overlap query

queen adder
#

works, i suppose

wintry quarry
queen adder
#

like Physics.CheckSphere(randomPoint, 0,_layerMask);?

summer stump
rich adder
#

overlap is better because it gives you specific colliders as results

zealous oxide
queen adder
rich adder
swift crag
#

it's better if you need the colliders

#

but you may not

#

I used to use Overlap queries to check if the ceiling was too low

#

but that's a clear case for a Check query

queen adder
#

just need to know if the point in space has any solid colission (doing a sort of scanner effect)

rich adder
#

I usually use checks if i need to know if a spawn is blocked by anything solid, doesn't matter which

queen adder
#

sorry not quite sure how to do this haha

swift crag
#

if you just care if something exists there, you don't care about the colliders you hit

#

you already know what the position is (it's randomPoint)

#

Do you want a point on the surface of a collider?

#

OverlapSphere would not be appropriate. You would need a raycast.

#

(or some other cast)

queen adder
#

oh so if h.Length > 0 then something IS there

swift crag
#

Correct.

queen adder
#

and that's all we care about

#

duh

#

silly ourple

swift crag
#

or you can just use CheckSphere, which returns a bool

queen adder
#

that's even realer

swift crag
#

hang on the cat just came in and is screaming

swift crag
#

he does this constantly

queen adder
buoyant knot
#

there’s a method to get the closest point on a collider to a given point in space

swift crag
queen adder
#

so I guess I should use OverlapSphere

buoyant knot
#

.ClosestPoint

swift crag
#

If not, then you'll need to iterate over all of the colliders and check their tags

summer stump
#

But annoying boilerplate needed

buoyant knot
#

oh, you need to know if a given point in space has any collision with anything?

#

are u in 2D or 3D?

queen adder
#

3D

swift crag
#

and thus we come full circle :p

buoyant knot
#

Check a sphere centered at the point in space, and the radius is the contact length that your physics system checks

#

layer mask to only look for relevant things

queen adder
#

up to no good i think

buoyant knot
#

i’m just going back to the initial question to figure out wtf he wants to do

queen adder
#

(it worked)

buoyant knot
#

gg

#

sometimes you just need to know the right method

queen adder
buoyant knot
#

i would definitely not loop through all colliders in the world. I think that will be slow as shit because of the complexity

queen adder
swift crag
#

well, using Physics.OverlapSphere

#

i don't think anyone was suggesting to just iterate over every collider

languid spire
#

and wtf do you think that actually does?

swift crag
buoyant knot
#

🤷‍♂️

#

without being able to dig into the source code, I have no idea how unity’s physics system doesn’t normally have colliders^2 time

languid spire
#

this is just damn stupid, Unity are bound by the same rules as the rest of us, there is no magic, you want to find something you loop over all available object. end of line

buoyant knot
#

unity can keep things under the hood that we don’t know about

swift crag
buoyant knot
#

like, during physics calculation, it could realistically separate things to avoid calculations between colliders that are too far

swift crag
#

hence these settings

languid spire
buoyant knot
#

i don’t think you understand

#

without being able to see the source code, we can’t know wtf unity is up to

#

we don’t know its implementation

#

we don’t know how it is optimized

#

we don’t know how shit is stored

swift crag
#

this is a multi-level miscommunication about my remark about iterating over colliders returned by a physics query

languid spire
#

of course we can, the fact that you cannot does not mean that we who know what we are doing cannot

buoyant knot
#

you can do experiments to discern, but you need source code to really see what it is doing, or need a good enough explanation of it, which I do not see

swift crag
#

this is a given. it would be ridiculous if it wasn't the case.

languid spire
buoyant knot
#

for example, when I tried to see what 2D effectors actually do (and how they work), I just hit a brick wall. Code is injected from closed off C++. The most I could get are a few snippets from forum posts

short hazel
#

steve moment!

buoyant knot
#

got blocked lmao

swift crag
#

I do not think we can extract any more value from this topic.

short hazel
#

Log in, see this, made my evening

dawn sparrow
#

I can't drag this prefabs transform into my scriptable objects transform fields, anyone know why?

swift crag
#

You can only reference the asset itself (so, the top-level object in the hierarchy)

buoyant knot
#

it looks like the query is operating on something like a tree or heap, with the details unknown

#

to avoid N^2 complexity

#

so more like N log N, which is much nicer

swift crag
rare dust
#

Pretty stupid question - how do you make grounded checks for character controller or gravity.

The problem is, on the "corner" on the collider it lays on the edge of the ramp. so the raycast detect it is grounded. but it does not slide down.

Here is the code:


        private void CheckIfCharacterIsGrounded()
        {
            // Check if the character is grounded.
            IsGrounded = Physics.Raycast(transform.position, Vector3.down, out RaycastHit hit, groundCheckDistance);
        }


        private void ApplyGravity()
        {
            // Apply gravity to the character controller if it is not grounded.
            if (IsGrounded)
            {
                return;
            }

            characterController.Move(gravity * Time.deltaTime * Vector3.down);
        }

        private void SetSlopeSlideVelocity()
        {
            // Check if the character is on a slope and apply sliding velocity if necessary.
            if (Physics.Raycast(transform.position, Vector3.down, out RaycastHit hit, 5))
            {
                // Calculate the slope angle.
                float slopeAngle = Vector3.Angle(hit.normal, Vector3.up);

                if (slopeAngle >= characterController.slopeLimit)
                {
                    // The character is sliding on a slope.
                    IsSliding = true;

                    // Calculate the slide direction based on the slope normal.
                    Vector3 slideDirection = Vector3.ProjectOnPlane(transform.position - hit.point, hit.normal).normalized;

                    // Apply the slide velocity to the character controller.
                    characterController.Move(slopeSlideSpeed * Time.deltaTime * slideDirection);
                }
                else
                {
                    // The character is not sliding.
                    IsSliding = false;
                }
            }
swift crag
#

Now that I think about it, it would be nice if you could do that...

eternal falconBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

dawn sparrow
#

Hmm, well here's what I'm trying to do:

ItemData will hold all information pertaining to a type of item. If the item can be equipped, there is equipment mapping data to map the different parts of the equipment to different parts of the player/character model

When I create a physical prefab with this item data, I want the data to have references to all the correct parts of the equipment, but I'm having a hard time figuring out how I do that

swift crag
#

prefab children feel like they should be roughly as "first class" as the prefab parent

buoyant knot
#

I have like 3 different ways to check for ground

swift crag
dawn sparrow
#

Yeah that makes sense, I'll try doing that

swift crag
#

You can reference that component just fine

buoyant knot
#

the main way I check ground on the player (because for player it’s really fucking important) is to cast down every frame a fixed distance

#

expensive, but for just one guy it’s fine

dawn sparrow
#

Actually that's what I had originally, but I wanted to have all item data including the mapping contained in item data itself

#

But I suppose this doesn't exactly qualify as item data, it qualifies as item prefab data, so It makes most sense to put that under the prefab

buoyant knot
#

where is mr plants?

swift crag
#

Yeah. I think it makes more sense to be on the item prefab.

dawn sparrow
#

So I'll continue on with this

swift crag
#

I guess your litmus test is "if I replace the prefab, do I have to replace every single one of these fields?"

#

if so, move the fields onto the prefab

buoyant knot
#

another way to check for ground is OnCollisionEnter/Stay. But this information is basically always 1 frame old, so it should only really supplement other information

dawn sparrow
rare dust
swift crag
#

So for things like "Armor value", that test fails: you might have various qualities of armor with the same model

rare dust
#

so it is just that "corner" case - word joke

buoyant knot
#

my player uses OnCollisionEnter/Stay. I use this to check for specific types of ground (ie ice, jumpable ground, spikes, etc). Then the next fixed update, if I am not grounded (and should not disconnect due to a jump request etc), then cast my collider down a fixed distance

#

do NOT use a square box to check for ground. Some people do that. It will get you in trouble with edges and corners

#

raycasts also struggle with checking the whole bottom

buoyant knot
#

i’m just saying some people do

rare dust
buoyant knot
#

do you have friction?

rare dust
#

so it gets basically stuck on the edge

calm moss
#

hey, So I have a parent and 3 children. the 3rd child is a trigger. How can I use the onTriggerEnter method with one of the child GameObject colliders?

rare dust
#

good question

buoyant knot
#

in that situation, should he be on ground, or should he be falling

swift crag
rare dust
buoyant knot
#

if he SHOULD be falling, you probably have a friction issue

swift crag
#

For example, I use this anywhere I need to sense an entity:

using UnityEngine;

public class EntitySensor : MonoBehaviour
{
    public Entity owner;

    void OnTriggerStay(Collider other)
    {
        if (other.gameObject.layer == LayerMasks.entityLayer)
            if (other.TryGetComponent(out Entity entity))
                if (entity != owner)
                    OnHit?.Invoke(entity);
    }

    public event System.Action<Entity> OnHit;
}
buoyant knot
#

i don’t use capsule colliders because I do 2D. I use box colliders with an edge radius.

#

so if you fall, I can make it look convincing

swift crag
#

LayerMasks.entityLayer is just a precomputed mask for the entity layer; it's equivalent to LayerMask.GetMask("Entity")

rare dust
calm moss
buoyant knot
#

mr plants: first thing; make sure you set the player’s material to something with no friction

#

sure. Also remember you may need platform effectors for your world. Just something to keep in mind

#

also removing friction may make your slopes wacky, depending on if you have dynamic/kinematic RB for character controller

rare dust
#

thanks 🙂

#

yeah i just didnt thought about the friktion 🙂

#

thanks for the brain push 😄

buoyant knot
#

is your character dynamic?

#

or kinematic

rare dust
#

it is not a "rigidbody"

#

it is the character controller

buoyant knot
#

gotcha. idk if friction affects that

#

character controller is like a weird mix of dynamic and kinematic

#

for 3D, there is a common kinematic character controller package you might be interested in. If you forsee having a lot more issues in future, it might be worth swapping now

rich adder
#

ie your collider is bigger than your ground check

rare dust
rich adder
rare dust
rich adder
#

this aint gizmos

rare dust
#

i know wrong image 😄

rich adder
#

what kind of ground check do you have on this

#

also your Mesh has 0 to do with collisions / grounding

#

its based on collider

rare dust
#
        private void CheckIfCharacterIsGrounded()
        {
            // Check if the character is grounded.
            IsGrounded = Physics.Raycast(transform.position, Vector3.down, out RaycastHit hit, groundCheckDistance);
        }
rich adder
#

there you go

#

one single line shooting down

#

according to the raycast ur mid-air

#

and its causing animator to set to not grounded

rare dust
#

but that is not the problem

rich adder
#

if you say so

rare dust
#

the problem is that i get stuck there

#

so it does not slide downwards

rich adder
#

so you're not talking about that it switches to not-grounded ?

rare dust
#

even with adding gravity


        private void ApplyGravity()
        {
            // Apply gravity to the character controller if it is not grounded.
            if (IsGrounded)
            {
                return;
            }

            characterController.Move(gravity * Time.deltaTime * Vector3.down);
        }

        private void SetSlopeSlideVelocity()
        {
            // Check if the character is on a slope and apply sliding velocity if necessary.
            if (Physics.Raycast(transform.position, Vector3.down, out RaycastHit hit, 5))
            {
                // Calculate the slope angle.
                float slopeAngle = Vector3.Angle(hit.normal, Vector3.up);

                if (slopeAngle >= characterController.slopeLimit)
                {
                    // The character is sliding on a slope.
                    IsSliding = true;

                    // Calculate the slide direction based on the slope normal.
                    Vector3 slideDirection = Vector3.ProjectOnPlane(transform.position - hit.point, hit.normal).normalized;

                    // Apply the slide velocity to the character controller.
                    characterController.Move(slopeSlideSpeed * Time.deltaTime * slideDirection);
                }
                else
                {
                    // The character is not sliding.
                    IsSliding = false;
                }
            }
rich adder
#

and thinks ur mid-air

rare dust
ashen ferry
#

I think he wants to slip of the ledge in that situation idk

rich adder
#

ur still checking for wrong spot for slope

rich adder
#

but you're technically not on a slope

ashen ferry
#

tho idk how to do that without bunch of complexity lmfao

rich adder
#

simple, switch the raycast to be an overlap

#

then you can better determine you're on a slope when on corner

buoyant knot
#

did removing friction fix the sticking issue?

rich adder
#

private void ApplyGravity()
{
// Apply gravity to the character controller if it is not grounded.
if (IsGrounded)
{
return;
}

        characterController.Move(gravity * Time.deltaTime * Vector3.down);
    }
buoyant knot
#

alternatively platform effectors, which have a mode to remove side frictkon

rich adder
#

its probably trying to push you down

#

because ur not grounded

rare dust
#

ah i see what you mean

weary crystal
#

I think it's enough for today, I mean better than playing 8 hours a day, isn't it?

queen adder
#

uhhhh
how am I supposed to debug random lag spikes

polar acorn
#

Profiler

queen adder
#

Profiler?

rich adder
#

Profiler.

polar acorn
#

Profiler.

queen adder
#

Profiler.

polar acorn
#

Profiler!

queen adder
#

Where is profiler haha

#

I found statistics but not profiler

polar acorn
rich adder
queen adder
#

what Does this Meanb

rich adder
#

Time to find youtube

swift crag
#

The timeline shows what methods ran in what order

#

Children appear below their parents

#

So, you are spending 14.14ms per frame in SoundOrbLogic.FixedUpdate

#

these are probably individual queries

#

I presume this is because you're doing all those OverlapSphere queries

queen adder
#

yeah it seems the mass OverlapSpheres calls is

#

yeash

#

hmm

swift crag
#

This will be useful for you.

#

It lets you perform a very large number of queries in one big go

#

Even if you don't manage to get any parallelism out of it, you'll still be saving time compared to doing many individual queries

#

The ideal scenario would be to start it early in the frame, then read it later in the frame (or even in the next frame)

#

note that physics commands are forcibly completed before the physics world gets messed with

#

I couldn't get RaycastCommands to run between two frames because of that, for example

#

But I still got a significant boost

queen adder
#

this is some arcane shit

swift crag
#

you just make a really big blob of commands

#

and a big array to store results in

queen adder
#

i made some improvements actually

#

simply increasing the inital radius spread, decreasing points, reducing points as range increases and making the scan more coarse did wonders

swift crag
#

You can also make the updates less frequent

queen adder
#

did that too

swift crag
#

Reducing points as range increases will be a big help.

queen adder
#

reduced scans per frame

swift crag
#

You can also cull points you can't see

queen adder
#

all in all it looks about the same but now doesn't spike

#

oh shit good point

swift crag
#

(strictly based on view direction)

#

not even thinking about occlusion culling here

#

you COULD also bake occlusion culling, and then...not quite sure what I'd do with that information, actually

#

I think you can ask "is this thing visible?"

#

but I've done very little with occlusion culling

queen adder
#

will ponder this!

hazy quiver
#

Really new to unity, trad dev playing around with game dev for fun.

Trying to get a grasp of rendering/meshes/colliding/etc

Imported a random env and trying to figure out the ground prefabs

For some reason it renders in scene but when i hit play, my player controller falls on the "Concrete" (if i move in either direction a bit i fall) however i can't actually see it when i look down, it's invisible. What am i doing wrong?

swift crag
#

is it still invisible if you disable the LOD Group component?

#

that's my first suspicion

#

Also, to sanity check: add a new cube (GameObject > 3D > Cube). Can you see the cube?

#

If you can't see the cube in the Game view, then your camera is messed up

wary sable
#

So im having a silly little problem with Behavior Designer where transitioning from one of its built in nav mesh nodes to my own the character just freezes. The node still runs, and properly updates the agent destination, but it just stis there. No errors or anything

#

Ive been looking to see if their scripts change any agent settings that could screw with the movement, but I'm kind of at a loss for this one.

rancid cypress
#

im trying to code (ish) im making a simple game any ideao why this isnt working im sure its an easy fix but alas

swift crag
#

Ah, right, that's the transition.

#

Are you setting the destination every frame? I've seen problems where you never get a path if it doesn't actually manage to finish finding a path before you ask it to change destination again

#

But that shouldn't really be a problem for such a direct path (I saw that when asking for an unreachable destination)

wintry quarry
swift crag
wintry quarry
#

(the second one)

rancid cypress
swift crag
#

But, nah, if that was false, you'd see the agent cylinder moving towards the player, leaving the model behind

#

so that isn't going to be the issue

#

maybe isStopped is becoming true?

wary sable
queen adder
swift crag
#

afterward, you'd tell the points whether or not they hit anything

queen adder
#

oh, so make a big list of the random points, run them through the command, and it outputs only the ones that hit?

wary sable
#

thats stupid

swift crag
#

it'd make sense that it stops when exiting the state

#

so that it doesn't keep moving

#

although I usually just set the destination to the current position to do that

#

close enough

wary sable
swift crag
#

np!

queen adder
#

fen i think a lot of people really appreciate how much time you spend just helping newbies

sly wasp
#

Hey how do I reference a public void function from another script?
I tried script.publicvoidfunction(): but it didn’t work

buoyant knot
#

If I want to make a glowy transparent circle. What is the best tool for that?

sly wasp
buoyant knot
#

should I be using the particle effects package

buoyant knot
sly wasp
buoyant knot
#

public class MyClass {
public void MyFunction() {}
}

I cannot call MyClass.MyFunction(). But I CAN call:
MyClass instance;
instance.MyFunction();

summer stump
#

Just DON'T include those words

#

Public is a scope modifier, and void is the return value

summer stump
sly wasp
summer stump
wary sable
#

do they share a namespace?

buoyant knot
#

did you read my comment?

sly wasp
#

Oh I didn’t see it

summer stump
# sly wasp Oh I didn’t see it

you could show the code if you still have issues, so we can give more concrete suggestions.

But in essence, after declaring the class, you don't use public or void

sly wasp
summer stump
#

It isn't implicit

#

That was just an example they showed

buoyant knot
#

yeah, the instance isn't initialized

summer stump
sly wasp
summer stump
# sly wasp .

Yeah, that is incorrect. It will help. No offense.

If it doesn't explain what part is confusing. We can help more

sly wasp
#

I just looked at it

#

I saw nothing like loup and soup said

buoyant knot
#

think of it this way. The class defines a circle, and you wrote a function to get the area. You cannot get the area of the idea of a circle, because that's not actually a circle. But once you have a specific circle, you can ask to get its area

summer stump
#

There are a lot of links to follow. You need to spend time on it

But like I said, show actual code

polar acorn
buoyant knot
#

if I make a circle of radius 2 at (3,5), then I can call thatCircle.GetArea(), and it should give me 4pi.

#

but I can also have a separate circle of radius 1 at (6,9).

#

I need to have a reference to the specific circle whose area I want

#

does this make sense?

sly wasp
#

Im still a bit confused. Just in case I confused any of you, im wantting to call this from the script to here in another script. I looked at the page again but im still confused

polar acorn
buoyant knot
#
  private float radius;

  // This is a constructor to make a new circle
  public Circle(float newRadius) {
    radius = newRadius;
  }

  // Get the area of a SPECIFIC circle
  public float GetArea() { return 3.14 * radius;}
}```
then in other code, I could do something like:
```Circle circleOne = new Circle(5f);
Circle circleTwo = new Circle(1f);
Debug.Log("Circle #1 has an area of 25pi: " + circleOne.GetArea());
Debug.Log("And circle #2 has an area of pi: " + circleTwo.GetArea());```
sly wasp
polar acorn
buoyant knot
#

You should read my comment, fishy

summer stump
# sly wasp the character show one?

That link shows all the ways to reference a script. I promise you, it is very helpful. If you can, you want a serialized reference (drag and drop)

We can't really help without more info though

Do both scripts exist in the scene before play? Are either instantiated?

sly wasp
#

the current one

summer stump
polar acorn
#

What object do you want to call that function on

buoyant knot
wary sable
#

A class needs to be tied to an object for methods to be called on it. When you are calling a method you can't refrence the class, you must refrence an object derived from that class.

In plain c#;
you can make your class:

  //vars

  public void doLemonStuff(){
  }
}```

Create an object from that class
```public class program{
  public static void Main(string[]args){ -- ignore these few lines, they are just there to show that this is in a new class that is running code.
    public Lemon myLemon = new Lemon(); -- The class must be made into an object before its methods can be used just like this
    myLemon.doLemonStuff() -- Now I can do lemon stuff
  }
}```
modest dust
#

public Lemon lemon = ...

#

it needs a name biauch

wintry quarry
wary sable
#

this isnt exactly what it looks like in unity, but this is to give you an idea of why you cant just call Lemon.doLemonStuff()

wary sable
wary sable
#

and that could be a solution to the problem depending on what their particular script does, but that hasnt been disclosed

modest dust
#

Either way, the best explanation would be presented in a book/course when learning C#

#

Not when trying to do something in Unity with little C# knowledge

wary sable
#

yeah, thats one thing that a lot of people stuggle to comprehend when going into this is that you need to know c#

#

at least the basics

modest dust
#

Or use Unreal and blueprints UnityChanOops

rancid tinsel
#

am i allowed to ask about code unrelated to unity (for example C# console application in VS)?

eternal falconBOT
rancid tinsel
ashen ferry
#

doesnt even error brb gonna code in editor

wet trench
#

How do you work with the input system presented in the FirstPersonCore template from Unity 2021? I'm struggling to figure out how to use it. I'm trying to make a basic weapon

StarterAssets.GunController.MainInteraction () (at Assets/Scripts/GunInfo/GunController.cs:23)
StarterAssets.GunController.Update () (at Assets/Scripts/GunInfo/GunController.cs:19)```

this seems like a simple error, but how exactly do you fix this?

```cs
using UnityEngine;
#if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED
using UnityEngine.InputSystem;
#endif

namespace StarterAssets {
    [RequireComponent(typeof(AudioSource))]
#if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED
    [RequireComponent(typeof(PlayerInput))]
#endif
    public class GunController : MonoBehaviour {
        public AudioSource gunSound;
        private StarterAssetsInputs _input;
        private void Start() {

        }

        private void Update() {
            MainInteraction();
        }

        private void MainInteraction() {
            if (!_input.mainInteraction) { //error line
                return; 
            }
            gunSound.PlayScheduled(0);
            Debug.Log("Gun shoot");
        }

    }
}```
swift crag
#

Visual Studio IntelliCode is an experimental set of AI-assisted development capabilities for next-generation developer productivity.

#

it mostly just suggests useless names

#

I am surprised that [SerializeField] can be applied to a method at all

#

I guess it doesn't declare any restrictions

#

so you can stick it on whatever you want

#

attributes don't do anything by themselves

ashen ferry
#

would be lit if text box appears in editor

#

and u can type into it like notepad or smthn

radiant thunder
#

quick question: why does doing musicSource.clip = Resources.Load<AudioClip>(songPath); not work while musicSource.clip = Resources.Load<AudioClip>("Songs/testsong"); does??? even though songPath is literally the same as Songs/testsong?

ashen ferry
#

bro thats same piece of code

#

double check what u got in songPath ig

radiant thunder
#

not exactly the same but vierually the same

swift crag
#

then songPath doesn't contain what you think it does

radiant thunder
swift crag
#

is this the correct component? is there more than one copy of it in the scene?

#

also, ensure that there isn't a space at the end or anything like that

summer stump
#

And ensure you don't overwrite that variable anywhere in code

swift crag
#

you can prove that it's got the right value by logging the value of songPath before using it

radiant thunder
#

yeah i am

#

could it be the newline character?

#

songPath = lines[3];

swift crag
#

Sure looks like it.

#

Strip the whitespace off.

radiant thunder
#

omg it was the newline character 🤦

radiant thunder
timid quartz
#

I am trying to load a scene in additive mode but it looks like that async load never gets to the isDone state.

`AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(scene, LoadSceneMode.Additive);

    // Wait until the asynchronous scene fully loads
    while (!asyncLoad.isDone)
    {
        print("loading");
        yield return new WaitForSeconds(10f);
    }

    print("loaded");`

Am I missing something with scene loading?

#

oh, wait, I'm unloading the previous scene, which probably dumps the coroutine

ashen ferry
#

I think u can just do yield return new WaitUntil(() => asyncLoad.isDone); inside coroutine

timid quartz
#

I wanted the text so I could see how long it was spending loading

swift crag
#

that would still die if the MonoBehaviour your coroutine was running on got destroyed

timid quartz
#

ya my problem is that my scene switcher was getting culled

ashen ferry
#

yea its just weird

#

to wait 10 secs

swift crag
#

you could do this in a DontDestroyOnLoad'd object so that it's never unloaded

ashen ferry
#

when scene is gonna load in one lol

timid quartz
#

to each their own. for me it was equally as helpful as something printing every 1 second.

#

I just wanted to know if it was still in the while loop or something downstream

#

yanno?

#

anyway problem solved, scene switcher moved to the meta scene that I didn't want to unload (hence the additive scene load and manual unload)

#

thanks!

ashen ferry
#

u print and start 10 seconds wait just put that print before WaitUntil I sent and its the same thing

swift crag
swift crag
#

that's where the StartCoroutine method comes from in the first place -- it's a member of MonoBehaviour (rather than being a static method or something)

ashen ferry
#

hes not printing it in intervals well the code does that but its not gonna print again scene will be loaded ages ago

timid quartz
swift crag
#

Deactivating a MonoBehaviour's game object also kills all of its coroutines.

swift crag
#

You will need to do something to give _input a value.

wet trench
#

Ye, i pretty much copied it from FirstPersonController.cs

swift crag
#

It's going to be null by default

wet trench
#

It just leaves _input like that

swift crag
#

show me FirstPersonController.cs, then

#

use a paste site

#

!code

eternal falconBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

wet trench
#

Yessir. Give me a sec

upper spire
#

is there any way i can modify a single direction of a vector3 without doing the following?

whatevervalue = new Vector3(ogvector.x, 0, ogvector.y);
summer stump
upper spire
summer stump
#

Vector3 newVector = new Vector(oldVector.x, oldVector.y, oldVector.z);

Replace any of those three with the new value you want

upper spire
#

yeah thats what ive been doing, im wondering if theres a faster way or a shorthand or smth

summer stump
#

You could do, like:
Vector3 oldVector = transform.position;
Then do what I wrote above

upper spire
#

hmm alr, thanks

summer stump
upper spire
#

👍

swift crag
#

Not too much nicer.

#

It does let you "zero out" any direction, not just a cardinal one, though!

upper spire
#

ah, that shoul be of some use- thanks!

ashen ferry
#

public static Vector3 ChangeX(Vector3 v, float x) => new(x, v.y, v.z) lol then maybe u can do transform.position = ChangeX(transform.position, 50);

swift crag
#

so you might do

#
Vector3 horizMove = Vector3.ProjectOnPlane(velocity, gravityVector);
#

that would give you the velocity perpendicular to gravityVector

#

useful for something like Super Mario Galaxy

wet trench
swift crag
#

see line 94

#

_input = GetComponent<StarterAssetsInputs>();

#

StartedAssetsInputs is a component you need to attach.

wet trench
#

gahh. thanks

unreal imp
#

doesn't anyone have a video tutorial in which I teach you how to create objects on fire in rigidbodies?

meager ermine
#

how do i turn VS code trust mode on all the time? every time i open a script it opens and says that its in restricted mode. I dont want that. I never want that. every time i open a file I set it to trust mode. even if i open a file ive set it to trust before it still opens in restricted mode. how do i stop this?

wintry quarry
unreal imp
#

It means that the fire moves in the position of the object when it is moved (be careful, it does not change its rotation when the object rotates)

autumn schooner
#

why isnt this working? its the lego microgame

wintry quarry
unreal imp
#

yeah thats easy

#

but the particle instantiate is difficult

swift crag
swift crag
#

go to File -> Open Folder, then navigate to your project directory

#

(not the Assets folder -- the folder your entire project is in, one level up from Assets)

autumn schooner
meager ermine
swift crag
#

in VSCode.

meager ermine
#

ok nothing shows up when i do that

swift crag
#

clicking "Open Folder" will bring up the file picker

#

i am unclear what "nothing shows up" means

#

do you mean no files are open?

#

that is expected.

meager ermine
#

i mean like no files show up at all

swift crag
#

it will only display folders

#

you are in some random folder (probably in your project)

#

navigate to the root directory of your project and select that.

meager ermine
#

ok

#

ok so i did that and when it reloaded it asked if i trust the authors of the files i hit yes

swift crag
#

now double click a script asset

#

also, if you have not already done this, you should set up your code editor

#

!ide

eternal falconBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

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

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

swift crag
#

follow the instructions for VS Code.

meager ermine
#

that did nothing my vsc still doesnt suggest code and stuff

#

oh wait hold on this just appaeared

unreal imp
# wintry quarry make the fire a child of the object?

here is the code but its doesnt works for me 😦 if (isInFire) { particleInstance = Instantiate(fireParticles, transform.position, Quaternion.identity, transform); var v = particleInstance.GetComponent<DestroyInRandomTime>(); if (!v.isActiveAndEnabled) { hitsReceived = maximalHitsToDestroy; } }

wintry quarry
swift crag
meager ermine
supple wasp
#

I have a problem with this code

'GUIText' is deprecated: 'GUIText has been removed. Use UI.Text instead.'

wet trench
#

how should you handle input contexts? like say a player equips a weapon, and now the context changes

queen adder
#

this is pretty simple issue, so i'll ask here
i want to spawn a bunch of Shruiken particles at specific points, just for temporary visuals (they fade quickly.) is the best way to do this seriously to move a an empty Gameobject with a ParticleSystem attatched to each point, burst 1 particle, and then move it again until it's spawned particles at every single point?

ashen ferry
#

what do u want to reference

supple wasp
ashen ferry
#

yea

teal viper
supple wasp
summer stump
# supple wasp

What is the issue? Change it to Text, as it says in the error

#

Unless you're using Text Mesh Pro

ashen ferry
#

I mean in the scene

#

tho yeah bet my balls u wanted TextMeshProUGUI here but idk where u got GUIText from

supple wasp
summer stump
#

Show what component are you using

supple wasp
#

I wanted to make a car controller but I get this and I downloaded it in the asset store

ashen ferry
polar acorn
summer stump
queen adder
ashen ferry
#

its as cheap as u can get prolly

queen adder
#

will give it a shot :)

tropic crown
#

im making a flashlight for my game and I have an issue where its automatically toggled when I start the game. I have it untoggled in the unity editor and Im not sure why its turning on automatically?

unreal imp
supple wasp
#

What is passing the file name is fine and it won't let me put the script where I want it.

supple wasp
wintry quarry
supple wasp
swift crag
supple wasp
wintry quarry
#

Yeah I'd guess you have compile errors then

swift crag
#

GUIText is extremely old

#

I've never even heard of it

#

If you do not have a very good reason to not use TextMeshPro, you should use TextMeshPro.

supple wasp
#

and what do I put

swift crag
#

using TMPro; up top. TMP_Text for the type

summer stump
#

For future reference, those red exclamations are compile errors, and should ALWAYS be handled before moving on

swift crag
supple wasp
summer stump
#

No worries though. Just a learning opportunity

supple wasp
summer stump
#

You should show the object in the scene like we kept asking, or just do that 👆 and hope that's the right type. Tmpro is what you SHOULD use, but maybe you used legacy?

honest saddle
#

I have a very stupid question to ask but i just dont understand. Why is the Pos Y of a rectTransform in my inspect different to the position when I run the game? I have tried localPosition and just Position but still doesnt come out right.

honest saddle
#

@young warren yes thanks I knew it was going to be something simple

summer stump
#

I'll take that to mean it worked haha. Nice

queen adder
#

thus making the write calls in SoundOrbLogic extremely slow

supple wasp
queen adder
#

and when it generated a new VisualEffect object the lag stopped

#

i simply turned down the size of the Texture2D and voila

supple wasp
#

How can I make the R joystick control the car so that it goes left and right?

#

and that the LB and RB buttons go forward and backward and that the A button makes it brake

charred prairie
#

waht do I do here?

#

I can't click the recording mode button

crisp token
#

is there a place where I can specifically see what would cause RaycastHit.triangleIndex to return -1?

charred prairie
#

Help.
I created a new scene and double clicked it

#

now everything is gone

#

how do I go back to where everything is?

queen adder
charred prairie
queen adder
#

Bro

#

The thing called Level 1

charred prairie
#

yes

#

level 1 is the one I made

#

after realising everything's gone

queen adder
#

Then click on Start Screen

charred prairie
#

start screen is what you're seeing right now

eternal needle
queen adder
crisp token
charred prairie
#

I dont think I've made a scene in the beginning

#

YOOOO

queen adder
# charred prairie no

Welp I don't know how to help you then, just try searching for other scenes with the unity icon

charred prairie
#

a friend just

#

told me how to fix it

queen adder
#

Good for you

eternal needle
north kiln
crisp token
north kiln
#

A browser extension that adds a comment section to documentation

crisp token
#

oh wow, thats awesome, thanks so much

#

thanks for telling me about it too @eternal needle

jovial orbit
#

!code

eternal falconBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

tiny terrace
#

Hello, I want my game object to randomly change it's position within a certain radius from it's initial position. How do i start to do that?

crisp token
#

so like, if I have non convex mesh colliders then do I need to add a kinematic rigidbody to each mesh? And also, can you have multiple rigidbodies in one prefab?

eternal needle
crisp token
tiny terrace
jovial orbit
#

private void MouseClick()
{
Vector2 mousePosition = mouseInput.Mouse.MousePosition.ReadValue<Vector2>();
//error Object Reference not set to instance of an Object
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
Vector3Int gridPosition = map.WorldToCell(mousePosition);
if(map.HasTile(gridPosition))
{
destination = mousePosition;
} Does anyone know why the code here might be producing the commented error?

keen dew
#

Is the error on the line above or below the comment?

jovial orbit
#

below

keen dew
#

You don't have a camera that's tagged as main camera

jovial orbit
keen dew
#

Fix the camera first

light moss
#

I have a tilemap set of Terrain. Each tile is 16x16. When I put the Tiles in the Editor, they come out as blurry. How can I fix that?

eternal needle
jovial orbit
#

I did

rich adder
light moss
light ivy
#

weird question, does anyone know how to rid of this box cursor, Its just annoying to use cause i cant adjust small lines between code and it deletes everything around it. this is visual studio 2022 btw

light ivy
#

oml ty

light moss
#

I want to rename a sliced Sprite. How can I do that?

river roost
light moss
#

Thank you

tiny terrace
#

how do I check if a gameobject is within my camera view?

solar tide
#

I created a scriptable Object that has a sprite image container.
And when I put the image in and wanted to display it on screen as a tooltip I just realized.
There is no way to link UI image or a UI rawimage to a tooltip object that recieves only sprites. UI Image is considered an image and rawimage is a rawimage so if I change the code in my Tooltip object to make it recieve rawimages or image, then I can't seem to modify my own 2D sprites into images.

#

I did fix this issue in the past but I forgot how to do it!

teal viper
eternal needle
thick goblet
#

My player turns red like I want him to in the IEnumerator. But he doesn't turn back to normal the Debug.Log(Timer Over!) doesn't work.

burnt vapor
thick goblet
#

Ah

#

Would this be a bad way to reference it?

#

the spriteRenderer of player

silent valley
#

how can I change this so it doesnt keep adding until +1 each time i press interact until i pick up the battery itself? I can see my mistake just cant find a solution to fix it. (this script is on my battery itself)

main flame
#

Hey, is there a way I can make only the edges of my box act as a collider? ie an empty box?

supple wasp
#

How can I make the R joystick move the character and the other L joystick move the camera?

ivory bobcat
ivory bobcat
silent valley
ivory bobcat
uneven parcel
ivory bobcat
silent valley
#

or shall i create a thread. as i have a few questions regarding raycast

ivory bobcat
#

You're able to do any of the above, yes.

silent valley
#

Raycasting

final kestrel
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerPhysicsController : MonoBehaviour
{
    Rigidbody _rb;
    [SerializeField] private float _jumpForce;
    [SerializeField] private float _moveSpeed;
    private bool canJump;


    // Start is called before the first frame update
    void Start()
    {
        _rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {
            canJump = true;
        }
    }

    private void FixedUpdate()
    {
        if(canJump)
        {
            MoveForward();
            Jump();
        }
    }

    private void Jump()
    {   if(canJump)
        {
            _rb.AddForce(Vector3.up * _jumpForce, ForceMode.Impulse);
            canJump = false;
        }

    }

    private void MoveForward()
    {
        _rb.AddForce(transform.forward * _moveSpeed);
    }
}

Why does my character only move after I jump? I want it to move in a constant speed without user input.

#

I got a physics material with 0 friction on both the ground and on player.

ivory bobcat
#

With your current code, no locomotion is started till jump is pressed at least once.

final kestrel
#

Ohh

#

my bad my bad. I forgot move forward inside canJump condition

#

thanks.

#

Add force continously adds force right? Is there any way to set it so that I start and move along with the same speed?

keen dew
#

Add an impulse force once in Start

final kestrel
#

It would be too fast though no?

#

I use impulse on jump

keen dew
#

It would be as fast as the force you apply to it

final kestrel
#

It moves too fast even though I set my moveSpeed to .1

#

I am happy with the movespeed I just want it to stay consistent

keen dew
#

well you obviously have to remove the MoveForward call from FixedUpdate too

final kestrel
#

Oh? Why? I thought physics based stuff went into fixed update

keen dew
#

that's the part that keeps adding more speed to it

#

If you add force once in Start then it keeps moving at that speed if you have friction and drag at 0

final kestrel
#

Ahhh

keen dew
#

The other option is to keep what you have and set drag instead

#

And the third option is to set the forward velocity manually

final kestrel
#

you mean directly setting rigidbody velocity?

keen dew
#

yes

final kestrel
#

All right I will give it a try. Thanks!

ivory bobcat
final kestrel
#

Yes I have no friction

timber tide
#

Just a preference question. When equipping items, do you pass in the player's reference into its equipping function, or do you assign the reference of the player immediately when picking up the item?

queen adder
#

Can I add a component via string? Like I want to add a Stunned : Monobehaviour component to a class via "Stunned" string

timber tide
#

Kinda odd how a lot of my stuff has no ownership binding and I only pass in the references

queen adder
#

I have a list of component type names and i wanna add them in a GO

queen adder
#

how blushie

burnt vapor
#

With reflection you get the component

queen adder
#

oh yea refleksi thingi

burnt vapor
#

But reflection is bad, and especially in Unity

#

You should see about code generation to prevent it, or just make a dictionary

queen adder
#

I dont mind reflection, it's just a save system thingy

timber tide
#

Yeah do a dict

burnt vapor
#

A dictionary would only work if you know the types at compile time though

#

That's why you're best off with code generation if you know how to do that

timber tide
#

You trying to save status inflictions to persist on loading?

#

could just do IDs on them effects and apply them when you restart

burnt vapor
#

Just deserialize your data and have a handler set every component manually.

queen adder
#

AYE, THANKS, IMMA GONNA DO DICTIONARY :>

#

.ToLower()

#

How can dictionary work though? I can do a switch(string) and add the component per case, but a dictionary? How?

#

what are the kvp to use?

#

Dict<string, Monobehaviour>?

burnt vapor
#

Actually, that's not true. You want to add the component and add the data through some sort of method I assume? Then I would suggest an interface

#

It really depends on the functionality

ashen ferry
#

u can assume different components needs different data to save/load how does interface solve that? Just curious cause im using switch since I couldnt figure that out without making generic poco and interpreting that per component

sand condor
#

Here is a simple code block that gives weird results... I have a 2d-grid of cells, that want to know how many neighbours they have and who they are. I thought the quickest way to test that is to disable their own collider, OverlapBoxAll at the cells position and then reenable the collider. But for some reason some cells have really overblown results (25 neighbors) event though 9 should be the possible maximum. I really have no idea why, can anybody help?

for(int i = 0; i < _Cells.Length; i++)
  {
    _Cells[i].EnableBoxCollider(false);
    Collider2D[] colliders = Physics2D.OverlapBoxAll(_CellTransforms[i].position, Vector2.one * 1.5f, 0f);
    _Cells[i].SetNeighbours(colliders);
    _Cells[i].EnableBoxCollider(true);
  }
eternal falconBOT
#

You can format your multiline code block with C# highlighting! Just add cs to the start of it. Highlighting example below!

class Fluffs : FluffyCat
{
    public void PetCat ()
    {
        Debug.Log ("Petting Cat.")
    }
}
sand condor
#

(Unity2020.3.34f1)

ashen ferry
#

the obvious one is ur overlap box might be too big also how can there be 9 neighbours max or result 25 your iteration cell is counted in as well prolly

slender nymph
#

also if an object has more than one collider it is possible for each of those colliders to be in the array

sand condor
#

Each cell has only one collider, and no two cells are in one spot. The box is also not too big, as only 3 instances have ridiculous high neighbor numbers. Some cells get it right, some miss neighbors or get wrong neighbors.

slender nymph
#

well you are using a different array to get the position for your boxcast. is there a particular reason for that instead of just using the _Cells array?

sand condor
#

The result is the same if I do _Cells[i].transform.position, I just though calling .transform performs a GetComponent<> each time so I cached them at the start.

#

Dumb question: OverlapBoxAll is in the xy-plane, right? Because all my cells are in xy with z = 0.

slender nymph
#

yes, 2D physics is only on the X and Y axes

#

also you are unlikely to see much performance benefit from caching the transforms. it's not really going to make much of a difference. but if you choose to keep using separate arrays you also need to be sure that your arrays are absolutely the same order or else you'll see issues where some cells have the wrong neighbors

sand condor
#

Ok thanks I'll keep that in mind, but as I said it doesn't make a difference which array I get the position from.

slender nymph
#

okay and what debugging steps have you taken to ensure only the correct objects are being detected by the overlapbox?

idle orbit
#

A quick question, I have a script from the asset store that I would like to verify regarding collisions, right now I'm getting the intended results for moving left and right with it but jumping doesn't seem to properly detect grounding (and resultingly ends with a stuck pose). So I was wondering as to what I should look for to figure out what is happening.

sand condor
#

I have checked if there are overlaps in the cells (like two cells in one position) - this is not the case. I also wrote this to check which cells are causeing problems

if(colliders.Length >= 10)
  {
    Debug.LogWarning("Too many neighbours");
    for(int j = 0; j < colliders.Length; j++)
    {
      Debug.Log(colliders[j].gameObject.name + ": " + colliders[j].transform.position);
    }
  }

But I am have really no idea what to debug because to me it seems as if BoxOverlapAll does not produce the results it should. :/

#

I mean I could rewrite it to manually check all 8 neighbors with OverlapPoint but that seems to be the dumbest solution 😄

slender nymph
#

have you drawn the boxes for the overlap box to ensure they are positioned where you expect them to be?

sand condor
#

And I dont know if that matters: All objects are instantiated, positioned, checking for neighbors etc in the same frame.

#

Might this cause problems?

slender nymph
#

it depends entirely on the order of operations

sand condor
#

Ok then this should not be a problem

slender nymph
#

also what is the actual use case for this? because it seems like you could probably just have a 2d array where each cell can just access said array to look up its neighbors on the fly

ashen ferry
#

how do u draw a box is it 4 Debug.DrawLine or smthn

#

actually i shoulda just googled

#

first time I see Gizmos class lol

slender nymph
#

i personally just use vertx's debugging package so i don't have to do any of it manually and so that it is built right into the query

wintry quarry
#

Unity also has physics query visualizations built in to the physics debugger now

slender nymph
#

that's 3d only though

wintry quarry
#

Ah yes.

sand condor
slender nymph
#

yeah just use a 2d array then. no need for physics queries if this is just for game of life. don't even need colliders at all tbh

sand condor
#
_Cells[i].SetDebugRect((Vector2)_Cells[i].transform.position - Vector2.one, Vector2.one * 2f);
private void OnDrawGizmosSelected()
    {
        Gizmos.color = Color.red;

        Vector3 bottomLeft = _debugRect.min;
        Vector3 bottomRight = _debugRect.min + Vector2.right * _debugRect.width;
        Vector3 TopLeft = _debugRect.max - Vector2.right * _debugRect.width;
        Vector3 TopRight = _debugRect.max;

        Gizmos.DrawLine(bottomLeft, bottomRight);
        Gizmos.DrawLine(bottomRight, TopRight);
        Gizmos.DrawLine(TopRight, TopLeft);
        Gizmos.DrawLine(TopLeft, bottomLeft);
    }
#

Well I kind of do because I don't want to fill a 2d-array with all slots

#

Each level has a unique shape made of grid - and some overlap, have holes in them etc.