#💻┃code-beginner

1 messages · Page 191 of 1

summer stump
#

Do you have the c# dev kit?

carmine sierra
#

yeah

summer stump
#

Regenerating project files is unfortunately not part of the guide. But that is a big one

carmine sierra
#

so restart unity?

rich adder
#

show you selected VSCode in external tools

slender nymph
#

if you did not have the .net sdk before installing the c# dev kit then you need to restart your computer as well

carmine sierra
#

how do i know if i have .net sdk

#

ayy it shows the version now

slender nymph
#

if you are unsure whether you had the .net sdk installed before you installed the dev kit then restart your computer anyway

carmine sierra
#

i had the dev kit not unity extension though

#

yeahh it works now

#

yeah this is easy now

rich adder
carmine sierra
#

here lol

#

but i am actually confused why it's saying unnecessary assignment

#

is it only because I haven't used it yet since i haven't finished the code

summer stump
carmine sierra
#

also can I have a collider which does not actually touch other objects, just to use as a click detector for it's onmouseodnw

summer stump
#

If you haven't used it, the compiler won't know you WILL use it

carmine sierra
#

ohh okay

carmine sierra
#

event trigger?

elder osprey
#

How can I get a reference to the player objects normal value? I am trying to implement sliding with the built in character controller but I cant seem to find how to get the players normal to compare the two.

arctic ibex
#

Okay so I'm trying to get a distance joint compenent from the Player object, distanceJoint is set as a public DistanceJoint2D in the references, but this isn't working. What i sthe code supposed to look like?

carmine sierra
arctic ibex
rich adder
arctic ibex
carmine sierra
#

()

arctic ibex
rich adder
#

they finally fixed the code snippet

#

sweet

summer stump
# carmine sierra is it event trigger, or something else

A message will be sent when there are collisions to a OnTriggerEnter / Stay / Exit method on the objects involved, but you can ignore it. However, there would be no physical collision. The mouse click would work with it still

And/or you can use the layer matrix to prevent any other layers from colliding with colliders on a layer

carmine sierra
summer stump
carmine sierra
#

so basically it is solely a trigger if you tick istrigger

rich adder
carmine sierra
#

what category does is trigger, used by effector and such fall under

carmine sierra
#

nah like is it a function or idk

#

i need to know for my coursework

rich adder
#

isTrigger is a Property

carmine sierra
#

don't wanna waffle the terminology

#

okay thanks

summer stump
#

Properties are actually a kind of function behind the scenes, but look like variables

#

Most unity "variables" are implemented as properties

rich adder
#

Unity loves camelCase for properties 🥲

summer stump
#

Like .transform .gameObject .mass etc etc

carmine sierra
#

so is the x coord a variable or property

summer stump
carmine sierra
#

yeah what is that camelCase thing i've just been using it cause apparently it's standard

rich adder
#

generally you dont want anything that is Public to just be a field (variable)

#

so they should be props

#

Unity just likes to use camelCase for some f reason (they should be PascalCase)

summer stump
#

But it just comes down to consistency. The MS schema is not the only one

ivory bobcat
rich adder
#

m_Follow from cinemachine is a Public Var for example cause it can be Assigned

summer stump
#

I really hate snake_case but that is convention for rust, and clippy yells at me when I don't 😢

rich adder
#

I do use snake case for classes sometimes to prefix

#

im still on the fence for that

#

public class UI_GameManager

#

public class UI_Player

summer stump
carmine sierra
#

is the only way to change an object's position to subtract or add to it's current position

#

or can I make it snap to the same coords as another object

rich adder
summer stump
carmine sierra
ivory bobcat
summer stump
#

transform.position = otherObject.transform.position

carmine sierra
#

oh okay cool

elder osprey
#

I am currently trying to implement sliding for my game, but I am having trouble and cant figure out what the problem is, the player just isn't sliding at all, instead they stick and cant move up or down the slope. Plus whenever they walk down the slope they do this weird bounce thing. Here is my script: https://hastebin.com/share/wopodevona.csharp. Here is a video of my issue: https://streamable.com/fixz0q.

rich adder
timid quartz
#

What's the safest way to fill a 2d array with a single, specific value? From googling around Array.Fill only works in 1d. Should I just iterate over it and set the value and call it a day or is there something clever I'm missing?

carmine sierra
#

what data type would I save the rigidbody of another gameobject as?

#

I tried bool and turning it false but that didn't work

rich adder
carmine sierra
#

to turn it off

rich adder
#

you can't disable a rigidbody

carmine sierra
#

so i guess enabled won't work

#

can you not untick it through code?

rich adder
#

either make it Kinematic temporarily

rich adder
carmine sierra
#

so i need to change a property because I want to keep it floating in place until the interaction takes place

#

so i should make the mass 0?

carmine sierra
#

just completely still

elder osprey
rich adder
# carmine sierra

also Rigidbody is not same as Rigidbody2D hence ur underlined error in awake there

carmine sierra
#

ohh okay

elder osprey
#

is it CharacterController.velocity?

rich adder
# elder osprey what is the input `velocity` for that function?

here is my whole function

//Update
cc.Move((moveInput.y * currentMovementSpeed * Time.deltaTime) * Move(transform.forward) +( playerVelocity * Time.deltaTime));

private Vector3 Move(Vector3 velocity)
{
    if(Physics.Raycast(transform.position, Vector3.down, out var hitInfo, 1.5f, groundedLayers))
    {
        var slopeRotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal);
        var adjustVel = slopeRotation * velocity;

        if(adjustVel.y < 0)
        {
            return adjustVel;
        }
    }
    return velocity;
}
#

could be cleaned but made it on the spot during video recording
and yes a function named Move inside cc.Move is confusing af , i realize that lol

carmine sierra
#

it says i can't convert float to rigidbody2d??

elder osprey
#

angle = Vector3.Angle(Vector3.up, hit.normal);

rich adder
#

Im still new to trig so I dunno for sure

#

I just know FromToRotation worked great from what i've read around forums so i did that

elder osprey
#

Its basically the same thing but shorter

rich adder
storm imp
#

wow it's been busy for a long time

rich adder
#

float into a Rigidbody2D, no such conversion exists

#

computer is always right

elder osprey
rich adder
carmine sierra
storm imp
#

WOW!!!

rich adder
#

so how do you think you should save it as

carmine sierra
#

4am time

#

mass = 0 is not working

#

though

rich adder
#

btw making local variable means only lives in that function

carmine sierra
#

ohh okay

carmine sierra
summer stump
# carmine sierra got this issue solved then

Just to clarify, every time you declare a type (float, string, Camera, Rigidbody, etc) you are making a new variable. You only declare the type ONE time

So as nav pointed out, and you saw, writing float made a new separate variable that only existed in that method.

carmine sierra
#

if a gameobject is disabled can you get a component from it

#

because I am trying to get it's mass but I have it disabled initially

teal viper
#

Is mass a component on your GameObject?

arctic ibex
#

How do I say "This does not equal this or this"? eg. if (buildindex != 0 or1){what ever I want to happen} I mean, I know I can just say buildindex twice but it feels like there should be a less clunky way of doing it

feral crane
arctic ibex
elder osprey
# rich adder well yeah it gives me a rotation from the slope..its in the name

I'm not sure why but for some reason what you suggested didnt work and instead what worked was me attempting to implement sliding. Looks like the reason the player was going down slopes wonky was because of an issue with my variables, and determining if the player is on a ramp seems to have fixed that. But now I cant jump if I'm on a ramp.

rich adder
rich adder
arctic ibex
feral crane
arctic ibex
rich adder
arctic ibex
#

sorry I didn't mean for that to sound so passive agressive over writing

feral crane
rich adder
rich adder
fierce geode
#

This is gonna sound stupid, but can you change this part in an Editor script?

feral crane
rich adder
#

the class you created PlayerData holds your data to save. Just keep it in sync with that Score value before save

icy grotto
#

I'm just wondering what will happen if I keep on making local variables? is it going to affect the performance greatly or no?

rich adder
#

and not something you should worry at all

icy grotto
#

okay thanks!

feral crane
#

Oh jeez I gotta go, this thing is itching my brain XD

rich adder
feral crane
#

I am just going to look for a new method I guess, thank you for the help though

#

no

rich adder
#

you followed exactly ? It should work 100%

hybrid sundial
#

I made a program with a plane and obstacles , they both have colliders yet if my plane moves at the obstacle at a decent speed it phases through it

#

It glitches though

unreal imp
#

Guys, is there a way to make my bullet come out of the gun and go to the center where the player's crosshair is pointing? I did it with this code but it is not very clear where the bullet comes from (it is generated in a corner to the right of the screen) ``` Ray ray = fpsCam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0) );
RaycastHit hit;

    Vector3 targetPoint;
    if (Physics.Raycast(ray, out hit))
        targetPoint = hit.point;
    else
        targetPoint = ray.GetPoint(1000);
    var bullet1 = Instantiate(bullet, bulletSpawn.position, gunHolder.rotation);
    bullet1.GetComponent<Rigidbody>().velocity = (targetPoint - bulletSpawn.transform.position).normalized * shootForce;```
ivory bobcat
#

Your initial position would be bullet spawn position

arctic ibex
#

Is there any way to check if a sprite is hidden by another sprite? Like, it's still there, but it's hidden form the camera by another sprite

#

Cause my game involves paralax creating obstacles and things, and I don't want to give everyone of my paralax layers a trigger collider (espeically since it need to be decently specific for it to work properly, so i cant just use circles or squares)

vale karma
keen dew
#

Because you haven't assigned anything to playerMovement

vale karma
#

i thought it was using the value from the base movement script i have? i cant just pull from it?

keen dew
#

Show the base movement script

vale karma
keen dew
#

That's just a normal component. You need a reference to it like you always do with components

vale karma
#

how so?

keen dew
#

What do you mean how so

kindred swallow
#
```help
keen dew
#

that's how Unity works

#

You're getting reference to all the other components in PlayerMovement too, why would it be any different here?

vale karma
#

i think the different layout of how state machines work compared to monobehavior is tripping me out. ive done this a few times where i felt stumped over things i do without thinking about in a regular script

summer stump
teal viper
#

You can use both without a problem.

#

I said many times already: state machine is a programming pattern. It's an abstract thing without actual form, until you implement it in one way or another. MonoBehaviour on the other hand is a physically existing type.

vale karma
#

yea im gettin there, little by little. And yea i know most of what you guys are talking about, i just dont have the vocabulary or dont know how to say things. i meant im used to only using Monobehavior scripts, so it looking different makes things different even though theyre unrelated

#

i get most of what your talkin about, it might just be my IQ or bc im newer but using words like references, functions vs methods, all those words kind of dont mean anything to me yet. It mainly just confuses me unless Im used to using it in code. So when easy concepts come up in a more compicated topic all the easy stuff flies out the window lol

#

it took me until recently to understand wtf return and void meant fully

charred spoke
#

Functions and methods are the same thing

teal viper
vale karma
#

okay, just kuz i know what somethin is doesnt mean i know how its used

charred spoke
#

Honestly learning to code via gamedev might possibly be the worst choice

teal viper
#

And a good way to learn is asking. Even better: explain how you think you understand it and ask whether it's correct and how it relates to the issue or topic at hand.

#

That is assuming you went through the learning resources and still don't understand.
If you just ask about things that are written all over the place, no one is gonna repeat it.

vale karma
#

lol this is gettin off topic. If i have rb = GetComponent<Rigidbody>(); in the start method of the movement script then why would I have to do it again? also i added GetComponent with a few different types and it didnt work

teal viper
#

Imho it's not off topic. Knowing how to learn correctly is probably the most relevant topic for this channel. Perhaps even more than concrete code questions.

teal viper
#

Also assuming it actually found the rb.

vale karma
#

thats what i was tryin to say, i already have it there

teal viper
#

Have it where?

vale karma
#

in the start function of the movement script

teal viper
#

Does it run? Does it actually find the component? Did you confirm that?

vale karma
#

NullReferenceException: Object reference not set to an instance of an object" yea i dont think it does

keen dew
teal viper
#

Here's another important tip: understand the issue properly before moving on to debugging. How is it that you're talking about the rb when the issue appears to be something else?

vale karma
#

not sure dude

teal viper
#

Did you solve the issue?

native seal
#

how can I change a scriptable object reference at runtime? for example, i want to change the ItemWeapon to currently equipped weapon

keen dew
#

The same way you change anything else, with the = operator

vague dirge
#

Hi quick question, for debugging purposes is there a way to visualise vector3 ? Like the 'VisualPhysics' package for example, but draws arrows for vectors.

vague dirge
#

Thank you !

earnest atlas
#

Why visual studio is telling me this?

       InputSystem = new StarterAssetsInputs();
pallid verge
#

i have an empty gameobject with some images and text as children, is it possible to decrease the alpha value of everything and once or do i have to do it for every image individually (through code)

earnest atlas
#

you can get all Image components

#

and just iterate through them

north kiln
grand forge
#

!IDE

eternal falconBOT
violet falcon
pallid verge
earnest atlas
#
       foreach (var image in images)
       {
           
       }```
#

Text also has color probably

pallid verge
violet falcon
earnest atlas
#

Also you want components from same object or children

#

If same object remove Children

pallid verge
earnest atlas
#

Then the line I have given

pallid verge
#

alright ty

violet falcon
pallid verge
violet falcon
earnest atlas
#
var r = _pRenderer.color.r;
var g = _pRenderer.color.g;
var b = _pRenderer.color.b; // Cleaner representation of RGB

for (var i = 0; i < flickerCount; i++)
{
    // Alfa value logic
    _pRenderer.material.color = _pRenderer.material.color.a switch
    {
        1f => new Color(r, g, b, 0.3f),
        0.3f => new Color(r, g, b, 0.6f),
        0.6f => new Color(r, g, b, 0.3f),
        _ => _pRenderer.material.color
    };
    yield return new WaitForSeconds(flickerDuration);
}```

This is somewhat similar to what you want. Its dealing with different thing so you will need to rewrite this. 

Its Corutine code
#

Just noticed a kekw

#

by rgb was more of rrr

pallid verge
violet falcon
pallid verge
#

so when you play the game in the editor the player isnt stuck?

fierce geode
#

Hey, this is gonna sound stupid but I have a music volume slider that goes from -80 to 0. But it doesn't really lower half way when the slider is half way down; I think this is because the decimal is a logarithmic system of measurement. So I'd have to convert the slider value into a logarimthmic scale, I think? But I'm not sure

violet falcon
violet falcon
#

player its good on preview

#

and thats the grid

noble summit
#

how can i share my project with others

pallid verge
noble summit
pallid verge
noble summit
violet falcon
rare basin
#

use git+github for example

rare basin
pallid verge
pallid verge
rare basin
#

terrible idea to work together on one project

#

version control systems exist

#

for a reason

west sonnet
#

Could someone please help me understand why this isn't working?

rare basin
#

== for comparisions

west sonnet
#

Thanks

pallid verge
#

it could be a million things, just start testing and see what fixes it

violet falcon
pallid verge
violet falcon
#

i have beta testers

pallid verge
#

no i mean testing what the problem could be

#

not the game itself

violet falcon
#

i tried to fix with scripts and clear player prefs

#

but nothing

pallid verge
#

well try other things then

violet falcon
#

idk what to try

pallid verge
#

try removing some box colliders, some rigidbodies

rare basin
#

anyway, this is code related channel

pallid verge
#

well the problem could also be in a script

rare basin
#

then share the code

violet falcon
earnest atlas
#

Anyone has any idea how this works? Its not getting call anywhere and this is working.

#

It came with unity starter assets

rare basin
#

!code

eternal falconBOT
earnest atlas
#

OnReload and OnShoot I added

pallid verge
earnest atlas
#

I have no idea

#

This is unity input system that came with Unity Starter assets player

#

Last time I delt with it I autogenerated a class

#

Here its doing something else

pallid verge
#

its bad when you dont know what your code is doing

earnest atlas
#

Its not mine code Im tempted to rewrite it all

pallid verge
#

if you have the time then do it

#

imo

earnest atlas
#

I think I will because atm I have no idea how its accessing inputs

pallid verge
#

and make sure to understand what youre doing not just copy paste things

earnest atlas
#

this code is not mine

#

I got told to import this

pallid verge
#

who told you

earnest atlas
#

Teacher

#

And atm Im hitting my head against how is it accessing anything

pallid verge
#

well if your teacher wants you to work with that code then you should probably try to understand it

earnest atlas
#

Im not sure he wants us to work with it

west sonnet
#

I've got this method that is called whenever the player presses the Space key and when a bool is enabled determining if the pick up has been picked up by the player. It chooses a random integer and then plays a sound based on that integer. But for some reason, I can't hear anything else in my game anymore, but when I pick up the pickup, the sound comes on

earnest atlas
#

And autogenerated code looks like nothing

west sonnet
#

I can't figure out why. Can anyone offer any help?

wintry quarry
#

Why not use an array

earnest atlas
#

yeah that works too

#

what is audio controller?

west sonnet
#

I have an Empty in my game which has an Audio source attached to it

rare basin
#

!code

eternal falconBOT
west sonnet
#

I'm getting this error, and it's taking me to this bit of code but I don't get it? How is the statement empty?

silent valley
#

I'm trying to teleport my player but they just do not teleport. There are no errors

earnest atlas
west sonnet
#

Is it not about line 27?

earnest atlas
#

Ah I though u shown us line 7

west sonnet
#

When I double click it, it takes me to that line

#

Oh my bad, I cropped it badly

pallid verge
#

maybe you could show us the method

glossy eagle
rare basin
west sonnet
rare basin
#

what if you have 20 sounds?

earnest atlas
#

you would need 1 line isntead of all of that

rare basin
#

20 switch cases

#

AudioManager.PlayOneShot(fartSounds[Random.Range(0, farSounds.Length)]

west sonnet
#

Oooh, I see

earnest atlas
#

AudioController.PlayOneShot(soundsArray[UnityEngine.Random.Range(1-n)],soundVolume)

west sonnet
#

Even once the method is called, I don't see any Debug logs

earnest atlas
#

Well I tend to name everything Controllers

rare basin
#

entire formatting of that line is wrong

#

idc how you name your controllers

earnest atlas
#

Its perfect

rare basin
#

you passed 2 parameters

#

into the []

#

they array takes a index into the []

earnest atlas
#

I know that

rare basin
#

and why is there 1-n that doesnt make any sense

#

(0, array.Length)

#

is the proper way

#

1-n wont even compile

#

it needs 2 parameters into the Random.Range function

earnest atlas
#

Its just a representation of values from range

rare basin
#

if you write code, then write it properly, not a representation of your thinking lol

#

it should also start from 0, not from 1

earnest atlas
#

It.Doesnt.matter:)

rare basin
#

it does tf

pallid verge
#

i should be making a dialogue system rn but im watching u argue

earnest atlas
#

Xaxup just cant

rare basin
#

you would skip first element

#

in the array

earnest atlas
#

not argue

rare basin
#

if you start from "1" xd

#

but ye it doesnt matter 😄

#

if you want to help someone, then do it properly, instead of make someone guessing mate

earnest atlas
#

Its others guy job implementing it

#

Also. Im. TRYING. TO.WRITE 1 LINE OF CODE

#

Silence

rare basin
#

🤡 😄

silent valley
earnest atlas
#

what u have there

#

What is Island.gameObject

rare basin
#

show the entire class

earnest atlas
#

What is TP.Teleport

#

Where rest of class

rare basin
#

that code wont even compile if thats the entire class, is your IDE configured?

earnest atlas
#

Also I think class teleported ends on 3rd bracket

#

Its all wrong

silent valley
earnest atlas
#

that is not correct way to destroy something

silent valley
earnest atlas
#

but in that class you have nothing that accesses those things

silent valley
pallid verge
earnest atlas
#

That entire class is broken

#

Let me just underline all things that are wrong

stuck cliff
#

Does anyone know if there is a C# script for a 2d game, basically I want to create a mechanic, that after the knife cuts the bread (goes through all the bread collision) changes the sprite

carmine sierra
earnest atlas
rare basin
#

just configure your IDE

#

@silent valley

pallid verge
earnest atlas
#

when knife reaches it it should be cut

stuck cliff
#

alr

earnest atlas
#

Im not sure what u want to make, beware if you set all logic on hitting that last trigger if someone just goes for the bottom trigger it will cut the bread

earnest atlas
stuck cliff
#

yeah i will try to avoid that somehow

silent valley
#

I'd like to point out that the space in the middle is 2 different scripts. I have the teleporting class and another class with the IEnumerator in it

#

I'll post both scripts. 1 sec. sorry. i was at the shop

west sonnet
#

I'm changing the orthographic size of my 2D camera, so that it zooms out, when something is triggered. This is my code at the moment:

When the trigger is activated:
Cam.m_Lens.OrthographicSize = 15;

And when the trigger is deactivated:
Cam.m_Lens.OrthographicSize = 10;

My only issue is that it does a quick snap to the different values and it looks ugly. Does anyone know how I could make it more of a smooth transition?

#

Would Lerp work?

wintry quarry
silent valley
wintry quarry
#

Mathf.MoveTowards in Update is the most straightforward

carmine sierra
#

is this how I can save the mass value

silent valley
earnest atlas
#

I would say do it with corutine by using Mathf.Lerp

silent valley
#

I'm aware code is bad. This was my first project. I'vce improved it a lot

earnest atlas
#

Its not that its bad it just wont worl

west sonnet
earnest atlas
#

Why move towards?

carmine sierra
# earnest atlas yeah

how can I change the masses value it if I've already initiated outside the methods

earnest atlas
#

Its to omve

wintry quarry
#

Yes that's what it's for

earnest atlas
wintry quarry
#

It "moves" a number

earnest atlas
#

It does?

wintry quarry
#

There's nothing here that changes the mass

carmine sierra
earnest atlas
#

Also if you save mass into BulletMass or whatever and change it

#

it wont save bullet mass only variable

carmine sierra
carmine sierra
#

so it saved the number not the reference

earnest atlas
#

yeah

carmine sierra
#

how do I call the reference again then

earnest atlas
#

Same way as before

wintry quarry
# carmine sierra

This just changes your variable. If you want to change the Rigidbody mass you do myRb.mass = 0;

wintry quarry
carmine sierra
#

so that should work

earnest atlas
#

yes

carmine sierra
#

didn't think id just be able to write a dot and access the property

silent valley
rare basin
earnest atlas
#

You class even ends after 3rd bracket

#

I want to serialize a player object, but issue if I serialize it from the scene on next scene it will commit complamo in my DDOL object.

#

Should I just find it?

west sonnet
silent valley
#

I would of thought when calling on the Teleport method. My players position will = the target position

earnest atlas
#

Yeah that sets the position

silent valley
#

So my player should end up on point B?

earnest atlas
#

Yes if you have transform of the object

silent valley
earnest atlas
#

On the scene object not prefab

#

Looks like there is position

#

So what happens now?

silent valley
#

nothing at all. I'll debug.log it RQ

west sonnet
wintry quarry
#

The current value goes in the first parameter

#

And duration doesn't go in the last parameter

#

It should be speed * Time.deltaTime

silent valley
earnest atlas
#

Where is it even calling debug

#

Post ENTIRE class

#

I cant guess

west sonnet
silent valley
wintry quarry
#

Times speed

#

Which is correct

west sonnet
#

Ooooh

arctic ibex
#

Is there any way to check if a sprite is hidden by another sprite? Like, it's still there, but it's hidden form the camera by another sprite. Cause my game involves paralax creating obstacles and things, and I don't want to give everyone of my paralax layers a trigger collider (espeically since it need to be decently specific for it to work properly, so i cant just use circles or squares)

west sonnet
wintry quarry
#

Use the correct parameters

wintry quarry
west sonnet
#

The current value is my first parameter.
The second is my target value.
Third is the durration * time.deltatime

west sonnet
wintry quarry
#

This is not correct

#

First parameter is wrong

#

The current value would be the camera orthographic size

#

Not "RegularSize"

west sonnet
#

Ooo

#

Ooooh

#

I think I get what you mean

wintry quarry
#

Also is this code running in Update?

jolly quarry
#

Hi Although an experienced programmer I am new to Unity (Really helping my daughter).
She have a project that uses a Playmaker asset bundle that I import into a new project.
Here original project works on her college computer.

At home the trouble is it always shows the following compilation error

Assets\PlayMaker\Actions\VideoPlayer\VideoPlayerSetTimeSource.cs(21,22): error CS0246: The type or namespace name 'VideoTimeUpdateMode' could not be found (are you missing a using directive or an assembly reference?)

Now I see VideoPlayerSetTimeSource is part of the Unity scripting API. Why can it not find the assembly reference ?

Where in Unity can I see what references it has ? I assume assemblies have to be in Unity itself and not the global .Net install.

Thanks for any guidence.

west sonnet
wintry quarry
wintry quarry
west sonnet
#

Should I assign the value at the top of my Script or in Start()?

#

Or at the beginning of the method?

wintry quarry
#

You need a "targetSize" variable

#

Which you will move towards in Update

earnest atlas
#

Do I need to get component or I can just pass "this"?

carmine sierra
#

why does the object fall when it is spawned despite having the mass set to 0?

hybrid sundial
#

I’m trying to use the new input system to add movement and jumping to a capsule is there any good tutorial, that shows good code, and explains

wintry quarry
earnest atlas
#

Im just not sure what is considered component

wintry quarry
wintry quarry
west sonnet
wintry quarry
#

Components are all the things attached to GameObjects in the inspector

wintry quarry
#

You seem to have gotten confused

west sonnet
#

I was getting the value of the orthographic size and assigning it to RegularOrthoSize

wintry quarry
#

Why

west sonnet
#

Should I just assign it to 10?

wintry quarry
#

That' doesn't make any sense

carmine sierra
west sonnet
wintry quarry
carmine sierra
#

but what is the science behind that?

#

I swear without mass it will stay still

wintry quarry
#

Or the other one

carmine sierra
#

cause you multiply the gravity scale by the mass right

wintry quarry
carmine sierra
#

fair lol

#

but if it were to exist in a game why not

west sonnet
carmine sierra
#

0*9.8 is 0

rare basin
carmine sierra
wintry quarry
carmine sierra
#

fair enough

wintry quarry
#

Probably because it makes things simpler to code as you don't need to special case anything

wintry quarry
#

Buff and Regular are basically constants

#

In fact you can make them constants

#

You need a third variable to keep track of the current target value

#

And in Update you can just do cam.OrthoSize = Mathf.MoveTowards(cam.OrthoSize, targetSize, speed * deltaTime)

#

So then all you do in the trigger code is change the target value to whatever you want

west sonnet
#

Oooh okay, I think I finally get what you mean

#

Thank you so much!

earnest atlas
#

10f of jump force is a lot or not?

velvet tide
#

I have a bit of an issue I'm to dumb to figure out. Im testing out Netcode for GameObjects, I get everything to move properly, x players with one host or one server everything on that front works. But my issue is my animator, everything animates correctly on the host/server, but on the clients it doesn't change to my "move" layer when I'm moving. The character is moving, its idling in the correct direction, it just doesn't want to activate the "move" layer so it animates its legs while moving, instead of just hoovering about. Could anyone of you help me out? Why is it capable of getting the direction its moving in, but it doesnt understand that it is moving?

using UnityEngine;
using Unity.Netcode;
using UnityEngine.InputSystem;

public class PlayerNetwork : NetworkBehaviour {
    private readonly float MyBaseSpeed = 1f;
    private Vector3 MyDirection;
    protected Animator myAnimator;
    public override void OnNetworkSpawn() {
        if (!IsOwner) gameObject.GetComponent<PlayerInput>().enabled = false;
        myAnimator = GetComponent<Animator>();
    }

    void Update() {
        transform.position += MyBaseSpeed * Time.deltaTime * MyDirection;
        
        if (MyDirection.x != 0 || MyDirection.y != 0)
        {
            ActivateLayer("Walk");
            myAnimator.SetFloat("x", MyDirection.x);
            myAnimator.SetFloat("y", MyDirection.y);
        }
        else
        {
            ActivateLayer("Idle");
        }
    }

    public void ActivateLayer(string layerName)
    {
        for (int i = 0 ; i < myAnimator.layerCount; i++)
        {
            myAnimator.SetLayerWeight(i, 0);
        }
        myAnimator.SetLayerWeight(myAnimator.GetLayerIndex(layerName), 1);
    }
    
    public void OnMove(InputAction.CallbackContext callback)
    {
        SendMovementToServerRpc(callback.ReadValue<Vector2>());
    }

    [ServerRpc]
    private void SendMovementToServerRpc(Vector2 movement) {
        MyDirection = movement;
    }
}
west sonnet
#

When it's triggered, the ortho size is increased. I then have a method that is called, using Invoke, after a few seconds that changes the target value back to the RegularOrthoSize

#

But nothing's happening

#

and the MathF.MoveTowards is in Update()

wintry quarry
#

Show the code

earnest atlas
#

Should I move object with RigidBody or with transform in 3d?

wintry quarry
#

Depends on your game and the object

earnest atlas
#

I got told its better to move with RB

wintry quarry
#

it depends on your game and the requirements of the object in question

#

A decorative blimp floating in the sky? Move it via the Transform.

An object that needs to have physics interactions? Use a Rigidbody

earnest atlas
#

I mean player

west sonnet
#

And here's the OnTriggerEnter2D. The ortho value changes are in the 2 methods below

wintry quarry
west sonnet
wintry quarry
#

Add more logs. Check in update that the target is correct

west sonnet
#

When DeactiveBuff() is called. I can see in the Inspector that the camera's Orthographic size has changed back to 10, but the game still looks the same

wintry quarry
#

What object is this code on? I see you're deactivating this object

#

That means update isn't going to run anymore

#

So the zoom won't happen

west sonnet
#

Oooooooh shit, you're right 🤦🏻‍♂️

#

Can't believe I missed that, Thank you

lost anvil
#

not sure whats going on here im new to unity

wintry quarry
earnest atlas
#

I have a suspition this is not how I imagined player moving

wintry quarry
#

Second, you put a semicolon where it doesn't belong

lost anvil
wintry quarry
eternal falconBOT
wintry quarry
#

^ you're not getting error highlighting and autocomplete

lost anvil
wintry quarry
#

OnCollisionEnter

trail fox
#

im trying to aim in with my weapon but the weapon doesnt go exactly to the anchor so its offset from the anchor which means the gun isnt where its supposed to ive checked it is because of the headBob without the headbob it goes where its supposed to why is this that the headbob is changing the aim in positions whenever i aim in https://gdl.space/exuwikariw.cs

#

nvm i just fixed it

bold nova
#

Hi, I'm trying to implement logic, where player cliks on some spot on the screen in 2d game and on that spot should be created a game object (or in this case set active) but for some reason the objects get -10 value on z axis and are rendered outside of the camera frustrum. Any idea why?

private void CheckPlayerInput()
{
   if (Input.GetMouseButtonDown(0))
   {
       Vector3 mousePosition = CalculatePosition();
       CreateWindForce(mousePosition);
   }
}
private Vector3 CalculatePosition()
{
   Vector3 position = Input.mousePosition;
   return camera.ScreenToWorldPoint(position);
}
private void CreateWindForce(Vector3 position)
{
   var windForce = ObjectPooler.Instance.GetWindForce();
   windForce.transform.position = position;
   windForce.gameObject.SetActive(true);
}
faint sluice
#

So camera.screentoworldpoint
Returns x, y value on where you touched it, and z value for where camera is

spiral narwhal
#

Do I have to check for OnMouseHover and then for the right mouse input to detect a right click on a Sprite, or is there a method like OnMouseRightClick?

faint sluice
#

Or something like that

spiral narwhal
#

But that triggers anywhere no?

#

No matter if the sprite is hovered or not?

faint sluice
#

Ohh wait yeah

faint sluice
spiral narwhal
#

I thought of using OnMouseEnter to flag a bool and OnMouseExit to unflag it, and in Update check for the right mouse button and if the flag is active. But maybe that's bad practise?

faint sluice
#

No clue tbh, depends on use case i guess?

rare basin
#

and ExitHandler

spiral narwhal
#

I thought that only works for UI elements

rare basin
#

nope

#

works for 2d/3d objects aswell

#

just needs physics raycaster on the camera

vague dirge
#

Hi, I have a really strange issue. I have this statement : if (isonground && Vector3.Dot(gvelocity.normalized, groundnormal) == -1)The thing is that on start, the conditions are passed and all is fine, but on input I can change the two vectors, and when it's done the statement is not validated : with debugs, I checked and the two conditions really are true, so I don't understand why the condition is not passed.

faint sluice
vague dirge
#

I think

faint sluice
#

Did you debug it?

vague dirge
#

When I print it on Debug.Log() it outputs -1

faint sluice
#

Could be a floating point error

vague dirge
#

But why would it not print the whole number ?

cobalt wing
#

i dont know where to post this but

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at <5675beb25788478c930377bea67fb893>:0)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List1[T] inEdges, System.Collections.Generic.List1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <5675beb25788478c930377bea67fb893>:0)

im getting this error for some reason wasnt able to solve it, dosent interrupt anything in my game it runs just fine

upper yoke
#

Hey, coming in the middle of all conversations but is there a way to know if my controller is Xbox/PS4/other to display the right buttons (ABXY or circle/squares/etc) using the new input system?

faint sluice
swift crag
#

just restart your editor

cobalt wing
#

ty

vague dirge
faint sluice
swift crag
#

You generally don't want to test for equality after doing math

#

Especially not when your inputs might be slightly off in the first place

#

even ignoring floating point error, I'd still give a little margin to the result of Vector3.Dot

faint sluice
#

For some reason debug only looks at first few decimals of a float and if it's all 0 it be like "GOOD ENOUGH FOR ME! SEND IT!"

So if you debug a float with value 0.10000000001 it will show 0.1

But if you compare it with 0.1f it will be false

swift crag
#

That's down to how float implements ToString(), I presume

timber comet
timber comet
upper yoke
#

I'll have a look thanks

timber comet
lost anvil
#

can anybody tell me whats wrong here?

swift crag
#

what's wrong is that your !ide isn't configured

eternal falconBOT
swift crag
#

follow the instructions for the code editor you're using

#

Your IDE should be highlighting the error.

lost anvil
#

ok

swift crag
#

also, if you're using VS Code, make sure you remove the old "Visual Studio Code Editor" package

#

the instructions mention this

timber comet
swift crag
#

the syntax is very mangled, yes

#

but we should get the IDE working first

faint sluice
vague dirge
#

Also, is it possible to change the whole Cinemachine orbits ? Like instead of being world reference, it related to the player or an input, and if I click it, the orbits rotate too ? Like if I was changing referencial

swift crag
vague dirge
#

Oh sry

#

In my movement, I have somewhere cam.eulerAngles.y for my camera, what is the function to call the get the same thing but for a given vector and not y ? Thanks !

rare basin
#

what?

#

that sentence doesn't make sense, atleast I completely dont understand

vague dirge
#

I may be not clear

#

In the cam.euleurAngles.y, it returns smth depending on the y axis, so a Vector3.up. I wanted to know if we could use the same methos or smth similar, but dpeending on another given vector

meager raptor
#

hi i don't understand what to change here

slender nymph
#

what does the error say

meager raptor
#

that is the error

faint sluice
slender nymph
meager raptor
#

yeah but i've changed everything

faint sluice
meager raptor
slender nymph
#

there it is. you have two namespaces with similar names and you are likely working inside of the Units namespace so it is trying to resolve Units.Player.PlayerManager instead of Player.PlayerManager

#

use an alias or don't name your namespaces so similarly

meager raptor
#

ah okay that makes sense thanks

swift crag
#

However, introduce a new class and...

#
namespace Foo
{
    public class FooClass
    {

    }
}

namespace Bar
{
    public class BarClass
    {
        public Foo.FooClass foo;
    }

    public class Foo
    {

    }
}
#

This malfunctions.

slender nymph
#

right but they have the namespace Units which contains the nested namespace Player. they also have the namespace Player. they are working inside of the Units namespace so by trying to access something in the Player namespace it tries to resolve Units.Player because that is the closest one

swift crag
#

Ah, I see

#

I missed that being in namespace Foo would let you refer to the Foo.Bar namespace as Bar

exotic wedge
#

hello I am a beginner in C# and I am making a game where the main camera is intended to rotate around a game object (ball) with this script and there are no errors in the console but it does not work and all variables are assigned.

slender nymph
#

!code

eternal falconBOT
amber spruce
#
public void StartGame()
{
    if (Lock.activeSelf == false)
    {
        characterSelect.SetActive(false);
        StartGameServerRpc(selectedOption);
    }
}

this will check if the lock gameobject isnt active to do the stuff right

rare basin
sullen rock
#

hello, Im trying to fix my formula for finding a point inside of a collider that has the shape of an ellipse - Ive been looking at this for a while and I cannot find the mistake, could someone please help me here?
https://gdl.space/jironofuso.cs

#

or, suggest a better approach even

faint sluice
sullen rock
#

or well, it should be

#

but for some reason the method is returning points outside of the ellipse

buoyant knot
#

you should use intermediate variables so your math isn’t one line broken across 3 lines

faint sluice
buoyant knot
#

also you are using lossyScale

sullen rock
buoyant knot
#

you already got the collider bounds

#

also, this function should take a bounds as an argument

sullen rock
#

bounds returns box bounds

sour yew
#

hey guys. complete noob here. i was wondering how do people version thei unity projects? can smb help me out? thanks

faint sluice
buoyant knot
#

you are trying to get points in the ellipse defined by what would go up to the edges of the bounds?

#

there is just a lot wrong with this code tbh

sullen rock
buoyant knot
#

like, this should be a while loop, and not a recursive call

faint sluice
#

Any is fine tho

buoyant knot
#

also, you are returning a vector3 for a 2D ellipse

#

when I would expect the result to be an ellipsoid

sour yew
buoyant knot
#

the function name does not match what the function does, and there is no documentation to describe it

faint sluice
# sullen rock nope, both inside and outside

I know this isn't what you asked for but in case it helps

I would put random spawn points manually inside the ellipse shaped spawn area. And when you want to spawn, just grab a random point from the list

That way you have more control over which spawn point you want to choose and also avoid spawning on "non spawnable areas" as randomly finding a vector might give you a result that's inside another object, which you will have to check for anyway

buoyant knot
#

i would expect a ///<summary>This function produces a random point within the ellipse/ellipsoid that makes normal contact with the edges of the input bounds.</summary>

#

and the name of the function should reflect this

sullen rock
buoyant knot
#

if someone can’t immediately tell wtf the function is supposed to do, then you need to work on your documentation

#

if this function gives a random vector3 on a plane, then I expect only 2 calls for Random, not 3.

faint sluice
#

Atleast the places I worked at used that as well, but I hear plastic is also pretty good

buoyant knot
#

does collider.Bounds not already include the effects of scale? I thought it did.

sullen rock
sullen rock
sour yew
sullen rock
#

thats the issue

buoyant knot
#

what mesh. i don’t see any mesh here

faint sluice
buoyant knot
#

you generated a random 3D point within the bounds, and then do a check on a 2D projection of this point, when compared to lossyScale. The units simply don’t make sense, as lossyScale is dimensionless, and x/y/z have units of length.

sullen rock
#

hows lossyScale dimensionless?

buoyant knot
#

lossy scale is a dimensionless quantity.

#

it is a scaling factor to make the whole thing bigger or smaller, relative to a transformation matrix = identity.

#

that inequality will never make sense

swift crag
#

scale is also dimensionless

#

if I ask you how tall you are, you don't say "My scale is 2"

#

that just tells me that you're twice as big as if your scale was 1

swift crag
#

localBounds is iin local space and thus doesn't care about your scale (or anything else), by compariosn

faint sluice
swift crag
#

so that's expected

sullen rock
#

found the issue

buoyant knot
#

there are many issues

#

and i recommend you fix them all lol

sullen rock
#

I mean, it works perfectly now

#

I will clean it up a bit

buoyant knot
#

i assume you used bounds.size to get the major and minor axes

sullen rock
#

btu Im sticking to this logic

#

nah

#

I just halved the localScale

buoyant knot
#

oh, so the numbers are just accidentally correct now

sullen rock
#

not accidentaly

buoyant knot
#

the units don’t match up, so it is wrong. So if it is right, it is purely accidental

#

and will not be correct if the collider is made a different size without changing the scale

#

you probably have collider size = 1 on each dimension, with lossy scale = 1 in each dimension

faint sluice
#

@sullen rock first think I would suggest is clean up that horrendous if statement, use local variables

float x² = ....;
float y²=.....;
float a²=.....;
float b²=.....;

If((x²/a²) + (y²/b²)) <1)

#

Sooo much cleaner to read and figure out where you went wrong

sullen rock
#

not sure if Im explaining myself well here

#

english isnt my native language

swift crag
#

But why not just do it correctly?

faint sluice
buoyant knot
#

you will immediately see it cease to work

#

also, your units are still wrong

#

therefore, it is impossible that your formula is correct

#

A collider of size 2,2,2 and scale 1,1,1 should give the same result as a collider of size 1,1,1 and scale 2,2,2. However, that is not going to happen in your code. The collider of size 2,2,2 will generate points within an area of 1,1,1

#

That is part of why this method should be a static method that solely takes a single Bounds as an input argument.

sullen rock
#

I mean, I made this for my specific use case, not for any collider I will be ever using again

swift crag
#

why do you insist on doing it incorrectly?

sullen rock
#

I dont insist on doing it incorrectly

buoyant knot
sullen rock
#

this is a correct formula for one specific use case, it is not universal, I understand your point

buoyant knot
#

the formula is only accidentally correct when a specific set of numbers line up in a certain way

#

and it is so easy to change it from the wrong variable to the correct variable

#

from lossy scale, to bounds.size

#

but you insist on using lossy scale

carmine elm
buoyant knot
#

private const int CONSTANT_NAME = 28;

faint sluice
buoyant knot
#

this is a very strange way to use a singleton pattern

carmine elm
swift crag
#

just write HEALTH if you made a variable named HEALTH

faint sluice
swift crag
#

alternatively, make the variables static if you really want to refer to them as PlayerData.HEALTH

#

but you already have a variable called HEALTH (which should really be written as health)

faint sluice
swift crag
#

ah, I missed that

swift crag
faint sluice
#

Also HEALTH and base_health should be different, keep in mind

#

One shows current health and one shows what starting health should be

carmine elm
#

Thanks'

faint sluice
#

I.e. base_health value should never be touched, so yeah make it a const too

dusty hull
#

how do u get what physics material an object is using? Like say if u bumped into something u would know what physics material that object was using

#

i mean the ones u can create

faint sluice
#

Wat

dusty hull
#

in colliders

faint sluice
#

Ohh

#

Wait my bad

#

Collider.material doesn't work?

swift crag
faint sluice
#

Something like that

swift crag
#

and the collider can give you the Physic Material

#

(Physic, not Physics!)

dusty hull
#

that was an example but thats what im doing

#

what im trying to do is when u enter a surface it checks what current physics material u are using

buoyant knot
swift crag
faint sluice
dusty hull
#

yes

#

idk

faint sluice
dusty hull
#

how would u write that in code?

#

ive been doing playerCollider.GetComponent<PhysicMaterial>();

#

but that doesnt work

faint sluice
swift crag
#

read the documentation

faint sluice
#

You don't do
Spriterenderer.getcompoment<sprite>();

#

You just spriterenderer.sprite

dusty hull
swift crag
#

yes, because you don't write collider.PhysicsMaterial

#

you also don't write collider.potato

faint sluice
swift crag
#

it's just a property on Collider. that's it

faint sluice
swift crag
#

collider.GetComponent<SomeComponent>() has the SomeComponent name because it's a generic method

#

you don't just stick the type name in when accessing a field or property

trim gulch
#

Helllo! I have a bit of a problem
I'm making a 2D topdown game, and I want my character to be able to pick up a gun. The idea is that he approaches it lying on the ground, interacts and the gun joins with the player, and now he's able to rotate it and shoot

#

What I was doing is I have a gun object, and when the player approaches and interacts, the gun destroys and instantiates itself again as a child of the player and enters "picked up state"

#

Where it does all of it's stuff

#

But the gun still isn't attached to the player and is somewhat independent with its movement

#

Is there anything I can do or should I go for another approach?

faint sluice
faint sluice
trim gulch
#

And if I add a rigidbody and try to sync the movement up with the player it gets it's own physics

wintry quarry
rich adder
wintry quarry
#

you could also use a completely separate object for the "gun on floor" and the "gun in player's hand".

#

There's no rule saying they need to be the same prefab or whatever

wintry quarry
#

the "gun on floor" prefab could have a reference to the "gun in hand" prefab, for example, which can be instantiated when picked up

storm imp
rare basin
#

usually pickups are different prefabs than the actual items, yes

rich adder
sterile radish
#

i want an object to follow my mouse (the light blue square) however everytime i start the game it goes into the corner and it only moves when my camera moves? this is my script

    void Update()
    {
        transform.position = cam.ScreenToWorldPoint(Input.mousePosition);
    }```
rich adder
wintry quarry
sterile radish
#

oh okay

storm imp
rich adder
storm imp
rich adder
storm imp
rich adder
rich adder
rich adder
storm imp
#

here @rich adder

rich adder
#

3 times

#

put debug.log inside here make sure index are passed on correctly

storm imp
rich adder
#

ok

storm imp
rich adder
# storm imp before or after objsite?

put log like this cs public void LoadSite(int siteNumber) { //show site objSites[siteNumber].SetActive(true); Debug.Log($"found site {objSites[siteNumber].name} with {siteNumber}"); canvasMainMenu.SetActive(true); //enable the camera isCameraMove = true; }

#

click some buttons and show logs

storm imp
#

I'll let you knew if it fixed it

rich adder
#

click all three buttons and show the prints

neon marsh
#

i dont know if this is the correct channel for my question but how does unity decide what sprite gets rendered first?

median ferry
#

Does anybody know how to make a Grid Layout Group the same for all resolutions?

wintry quarry
#

in what ways should it stay the same?

#

Generally UI must adapt to different resolutions either by scaling, rearranging, etc.

median ferry
#

I mean the spacing and stuff

neon marsh
median ferry
#

Its different depending on the resolution

wintry quarry
median ferry
#

How would i fix it?

wintry quarry
#

By changing canvas scaler settings

rich adder
sour yew
#

hey guys. when i try to import asset, i get this. can smb help me out?

rich adder
wintry quarry
sour yew
rich adder
eternal falconBOT
#

:teacher: Unity Learn ↗

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

wintry quarry
#

that runs the game

median ferry
sour yew
storm imp
rich adder
storm imp
#

unity is busy a lot and for a long time

rich adder
#

I wrote Debug.Log

#

capitalization matters..

storm imp
rich adder
#

just copy it exactly how i wrote it

south sky
#

Hey guys, im new so sorry for the dumb question but how do you reference other scripts within a script. If I wanted to access code from a different file etc

storm imp
rich adder
noble summit
#

idk if this is the right channel but how do i remove the line in the center of visual studio

rich adder
#

thats helpful

noble summit
#

its like a divider but it doesnt do anything

rich adder
noble summit
#

i would but im on my phone rn i will try to find an image on google

storm imp
rich adder
storm imp
rich adder
#

Pay attention

noble summit
rich adder
noble summit
swift crag
#

log in to discord in your web browser and send a screenshot.

noble summit
#

i cant right now

rich adder
#

see if you have this option

noble summit
#

im on a mac

rich adder
#

ooofa

noble summit
#

yeahhh

rich adder
#

Visual Studio mac or VScode?

noble summit
#

visual studio mac

swift crag
#

oh, that's nothing to do with Visual Studio on windows

noble summit
#

vscode says i dont have an .net sdk (i do)

swift crag
#

you should really just switch to VSCode, since "Visual Studio" on macOS is getting sunsetted

#

I use VSCode on my mac

#

(the "visual studio" editor also just kind of sucks)

rich adder
noble summit
#

yeah i would use vscode

late bobcat
#

guys why the hell is this not working wtf
https://hatebin.com/ryekhonufd
I just wanted to make it so when i hold down left click ,laser (which is a stupid 2d sprite square gameobject) is active, else is unactive. I'm going crazy

summer stump
rich adder
#

yeah VS for mac is going bye bye in august

rich adder
summer stump
storm imp
faint sluice
noble summit
rich adder
late bobcat
#

@faint sluice i see thanks

rich adder
#

are you using the new VSCode Unity extensions ? @noble summit

noble summit
#

like version? if so i have the latest

rich adder
noble summit
#

i think?

#

how do i know if it is new

#

i used vscode for unity before and had no problems

rich adder
noble summit
rich adder
summer stump
# storm imp

Why would you do that?
Look at what you did and think about it for a bit

rich adder
#

Nowhere did I say to put a function inside a function..

storm imp
rich adder
#

you outta make your life easier and learn some basics of c#..

rich adder
timid saffron
#

I hate to say that IM still stuck on this transform codes but It wont move can you tell me why?

#

I think i did everything right

faint sluice
rich adder
#

what is separationSpeed value in the inspector ?

#

5f seems kinda low esp with Time.deltaTime

faint sluice
#

Issue could be something else entirely, like gameobject being disabled so no update, speed value being 0, script is not attached to correct object etc

swift crag
swift crag
#

make sure that seperationSpeed is 5

sullen rock
#

and make sure the object isnt set to static

rich adder
vague dirge
#

Real quick, is there a method to calculate the distance between to points, instead or manually doing every time sqrt(x^2 + y^2)

rich adder
# storm imp

Debug.Log($"found site {objSites[siteNumber].name} with {siteNumber}");

rich adder
#

holy shit if you're fucking up a copy and paste job, you're in trouble.. @storm imp

faint sluice
#

Vector2.Distance

rare basin
#

chat gpt enjoyer?

#

that white IDE hurts my eyes

rich adder
# storm imp

finally.. and yeah you still got a line twice but doesnt matter right now, this is taking long than it should as is..

#

ok now save changes

#

as you see * means no saved

#

Save , click some buttons. Screenshot the Console window

rich adder
#

who knows tho

vague dirge
sullen rock
faint sluice
vague dirge
#

yes

#

But I whant for example transform.position.y and transform2.position.y

sullen rock
#

could you elaborate a bit please

#

you can just substract them in that case

swift crag
#

There's no Mathf.Distance method

swift crag
#

But you can just do Mathf.Abs(a - b)

vague dirge
sullen rock
#

the individual values are just floats

rich adder
#

thats what they suggested

swift crag
#

I did write a MathUtil.Distance method because I like the consistency

vague dirge
sullen rock
storm imp
#

why is unity always busy?

rich adder
night mural
#

to get to the other side!