#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 765 of 1

placid jewel
#

Nice, it sounds like you have the right idea to me

#

In that case best of luck!

fluid ether
#

Deprecated ? Intellisense can't find anything about LightUnitUtils
I'm genuinely lost on this man

midnight plover
#

Ahh, okay, well at least thats some information you can work with.

fluid ether
#

Regardless, that's really not helpful for me anyway, my issue isn't unit conversion ๐Ÿ™

midnight plover
#

I was just wondering, if your light somehow is in a different mode than your RP or something and therefore converts the lumen values weirdly

midnight plover
fluid ether
#

I think the whole HDAdditionalLightData thing has been deprecated maybe was used during the whole HDRP merge thing or idk

placid jewel
#

Does that break in some way when you try?

midnight plover
placid jewel
#

Documentation for HDAdditionalLightData:

#

But HDRP says

#

Someone forgot to update the docs

fluid ether
#

Yeah that just resolves back to Light.intensity, which is what flashlight.intensity is doing in my code.

fluid ether
placid jewel
midnight plover
#

So this seem to work on my side. on HDRP. It has to be something on your settings

fluid ether
fluid ether
midnight plover
#

can you paste it quickly somewhere or tag it?

fluid ether
midnight plover
#

Now I am hooked and want to test it ๐Ÿ˜„

fluid ether
# midnight plover can you paste it quickly somewhere or tag it?

sure, here

{
    flashlightObj = new GameObject("Flashlight");
    // Fallback to attaching the flashlight GameObject to the parent if playerCamera can't be obtained.
    if (playerCamera == null)
    {
        flashlightObj.transform.parent = transform;
        Debug.LogWarning($"{this.name} tried to attach {flashlightObj.name} to the playerCamera but it was null." +
            $"Used fallback attachment to parent transform." +
            $"This will likely cause unintended behaviors and should be fixed.");
    }
    else 
    { 
        flashlightObj.transform.parent = playerCamera.transform;
        Debug.Log($"{this.name} attached {flashlightObj.name} to {playerCamera.name}");
    }
    flashlightObj.transform.localPosition = Vector3.zero;
    flashlightObj.transform.localRotation = Quaternion.identity;

    // Set up flashlight component.
    flashlight = flashlightObj.AddComponent<Light>();
    flashlight.enabled = true;
    flashlight.type = LightType.Spot;
    flashlight.lightUnit = UnityEngine.Rendering.LightUnit.Lumen;
    flashlight.intensity = 5000f;
    flashlight.spotAngle = 80f;
    flashlight.colorTemperature = 4000f;
}```
placid jewel
#

!code

radiant voidBOT
midnight plover
#

Haha, nvm, copilot ai just created it for me UnityChanLOL

fluid ether
#

oh my bad

midnight plover
fluid ether
#

no way, let me try

#

what the hell

#

why

midnight plover
#

I guess, because HDRP is recalculating all lights all the time. And therefore trying to ease out all lighting to fit PBR realistic lighting

#

if you just set it in update for example, it will eventually reach the lumen

fluid ether
#

i set it on the ToggleFlashlight call and it does work but this isn't something i'd expect

twin pivot
#

would the StopCoroutine on line 28 stop the coroutine started in line 20?

midnight plover
fluid ether
fluid ether
midnight plover
midnight plover
twin pivot
midnight plover
twin pivot
midnight plover
#

the example code does exactly what I suggested. assign to the field coroutine and later StopCoroutine(coroutine);

#

this way you guarantee to stop the one you started

twin pivot
#

oh i see thank you for your help

naive pawn
twin pivot
naive pawn
#

didn't see anyone actually directly answer the question, so i answered it

boreal violet
#

Why when i click to any points, i got something like this in console:
Point 1 UV=(0.21, 0.54), click UV=(0.79, 0.46), distance=0,5789823

Activation Radius = 0.006, mesh sizes 0.1(X,Y,Z)

Points activating when i click to opposite side of plane.

Plane lies in XZ

radiant voidBOT
naive pawn
#

what are you expecting to get exactly? what's the issue?

boreal violet
#

I want create script, that should create polygons by points on mesh UV and translate it to RenderTexture, that using for overlay texture 1 to texture 2 by lerp, like
LerpA - Texture1
LerpB - Texture2
LerpT - Render texture

#

And if 95% of all points is activated i send OnBlue bool to material for changing texture

naive pawn
#

ok, and what's the issue?

#

(also, share your code appropriately as described in the "large code blocks" section above please)

boreal violet
naive pawn
#

are you getting any errors/warnings? have you debugged to see what point in execution is reached? etc

placid jewel
boreal violet
#

It's debug log

naive pawn
#

hm so basically opposite sides, i'm noticing they're like, 1-x of each other

#

sounds like something was set up inverted?

boreal violet
# naive pawn sounds like something was set up inverted?

Points are pass through this code:

    private Vector3 UVToWorld(Vector2 uv)
    {
        float x = (uv.x - 0.5f) * meshSize.x + meshCenter.x;
        float z = (uv.y - 0.5f) * meshSize.z + meshCenter.z;

        Vector3 localPos = new Vector3(x, 0f, z);
        Vector3 worldPos = transform.TransformPoint(localPos);
        return worldPos;
    }
#

After, i get coordinates of click point and compare with each point

#

like distance between them <= activationRadius

naive pawn
#

btw, gizmos are editor only

boreal violet
#

Wdym?

naive pawn
#

once you build the game/project, gizmos won't show up. they're for debugging in the editor

boreal violet
#

I knowthinksmart

placid jewel
boreal violet
placid jewel
#

It is a mesh right?

naive pawn
#

are the gizmos in the expected place?

boreal violet
boreal violet
boreal violet
#

And then polygon

placid jewel
#

Yeah that's what I'm trying to help with

#

You say the points work if you click on the opposite side of the plane?

boreal violet
#

Yeah, like if i change activationRadius for 1, when i click it's all get activation true

placid jewel
#

If the triangles are wound the wrong way (*or some other mesh issue) the mesh will be upside down, which could explain why the mesh is working from the wrong way

#

How have you set up the mesh? Via code or via mesh object?

boreal violet
#

Just mesh object with collider

#

Idk what do u mean, can u explain some better your answer?

placid jewel
#

Looking at that it does seem like the mesh is the right way round so that won't be the issue

#

In your code, can you explain why on line 208:

private Vector3 UVToWorld(Vector2 uv)
    {
        float x = (uv.x - 0.5f) * meshSize.x + meshCenter.x;
        float z = (uv.y - 0.5f) * meshSize.z + meshCenter.z;

        Vector3 localPos = new Vector3(x, 0f, z);
        Vector3 worldPos = transform.TransformPoint(localPos);
        return worldPos;
    }```
#

Oops

placid jewel
#

Why do you take uv.y into world space z coordinate exactly? I'm having trouble understanding the code itself

boreal violet
#

It's because initially mesh was in XY plane

boreal violet
placid jewel
#

Are you not already getting mouse click in UV? With

private bool GetMouseUV(out Vector2 uv)
    {
        uv = Vector2.zero;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out RaycastHit hit))
        {
            Debug.Log($"Raycast hit: {hit.collider.name}");
            if (hit.collider.gameObject != gameObject)
            {
                Debug.Log("Hit object is not this plane");
                return false;
            }


            hitPoint = hit.point;

            uv = hit.textureCoord;
            uv.y = 1f - uv.y;
            return true;
        }

        Debug.Log("Raycast did not hit anything");
        return false;
    }
boreal violet
placid jewel
#

Hold on

#

Wait never mind I thought I had spotted something but I misread it

#

So when you click it calculates the distance between the texture coordinate of the click position and the ContourPoints.UV value which is a Vector2

boreal violet
#

Yeah

placid jewel
#

The ContourPoints.UV value is also a texture coordinate right?

#

Not a world position?

#

I'm assuming you've manually defined each of the contourPoints[] values in the editor, with one for each point

boreal violet
# placid jewel Not a world position?
    private Vector3 UVToWorld(Vector2 uv)
    {
        float x = (uv.x - 0.5f) * meshSize.x + meshCenter.x;
        float z = (uv.y - 0.5f) * meshSize.z + meshCenter.z;

        Vector3 localPos = new Vector3(x, 0f, z);
        Vector3 worldPos = transform.TransformPoint(localPos);
        return worldPos;
    }

I think it's world position

placid jewel
#

If uv is a world position and clickUV is a texture coordinate (i.e. vector2 with values from 0 to 1 representing the position on a texture associated with that point) then that might be an issue?

misty marten
#

yo i just started whit unity only thing i know is control.Writiline("hi"); does anione have any tips?

boreal violet
#

It is i think

radiant voidBOT
misty marten
slow mantle
boreal violet
slow mantle
#

PFF.

#

I need to go to sleep.

boreal violet
#

XD

placid jewel
boreal violet
#

I think it's an issue

hollow cliff
#

uhh can anyone help me w this one thing

so when a player walks into a portal and presses a button, the player turns 90 degrees towards the wall and all the gravity thing is shifted accordingly so that the player can walk on the wall as if its ground, whats the simplest way to do this?

slow mantle
# boreal violet XD

I literally struggled long enough that I felt the need to ask a question here instead of normally figuring it out myself, oh no.

boreal violet
#

'Couze i thought it should be in one type of coords

radiant voidBOT
misty marten
#

or google it up im new so idk yet

placid jewel
boreal violet
hollow cliff
misty marten
placid jewel
# misty marten !learn

No, that command is for formless questions like "How do I learn?" Any specific questions like how do I approach this we can try to help people with. If you don't know how to answer don't answer.

hollow cliff
#

i actually joined the server for this one thing so i need some help ๐Ÿ˜ญ

placid jewel
#

Waht

hollow cliff
#

yessir 2d

boreal violet
placid jewel
hollow cliff
#

ohlmaoo

placid jewel
#

What stage are you at so far? Do you have a character controller?

frosty hound
#

The "simplest" (it's not simple) is to have custom gravity that you apply to your CC. Moving through a portal simply updates the direction that gravity points.

placid jewel
misty marten
#

yo @placid jewel what version of unity shoud i download?

frosty hound
#

Your CC will rotate so its feet is always pointed in the direction of the gravity vector.

placid jewel
# hollow cliff ohlmaoo

But the bad news about that is that you have to make a custom character controller in order to do custom gravity usually

slow mantle
hollow cliff
frosty hound
#

Why not?

hollow cliff
#

ahh okay thankss

placid jewel
boreal violet
frosty hound
#

It's custom gravity, you can update it whenever and however you want.

frosty hound
#

You can even make your character walk around a sphere at that point, updating the gravity to always point towards the center of it.

twin pivot
boreal violet
#

like bajaBlast[] = { 10, 20, 100};

placid jewel
# hollow cliff ahh okay thankss

So long as you're familiar with how velocity and acceleration work even in a vague conceptual state, then you can mess around with applying gravity in whatever direction you want

slow mantle
#

I literally have done that for one of the variables I have.

boreal violet
slow mantle
#

I can't believe my eyes.

#

What the hell.

rich adder
slow mantle
#

Thanks.

boreal violet
naive pawn
#

you put it next to the variable name

boreal violet
#

Oh

naive pawn
rich adder
#

yea lol

boreal violet
#

It's sooo different

placid jewel
naive pawn
#

ive done too much cpp recently, ive started writing them in the wrong place lmao

naive pawn
boreal violet
naive pawn
#

meanwhile java accepting both...

slow mantle
placid jewel
#

Ahhhhh

slow mantle
#

Only one of them deserved to be arrays.

placid jewel
#

I see now

naive pawn
#

also this is for declaring, not initialization

vital fractal
hollow cliff
boreal violet
vital fractal
rich adder
boreal violet
#

I tried dart

naive pawn
boreal violet
placid jewel
vital fractal
#

oh no wait

boreal violet
#

XD

vital fractal
#

was it go

naive pawn
naive pawn
vital fractal
#

dang im even messing them up now

naive pawn
#

var <name> <type>, so var a [2]string

vital fractal
#

ah yeah

boreal violet
#

Guys, who to do it?

naive pawn
#

primes := [6]int{2, 3, 5, 7, 11, 13}
what is thattttt

placid jewel
boreal violet
placid jewel
#

Wait no they do

vital fractal
vital fractal
naive pawn
placid jewel
boreal violet
#

Damn, what is it...

vital fractal
vital fractal
#

classic

boreal violet
placid jewel
naive pawn
vital fractal
boreal violet
placid jewel
vital fractal
naive pawn
#

damn this got off track real quick, whoops

vital fractal
#

oops

#

i mean

placid jewel
#

Real

vital fractal
#

we are talking about code languages

#

so on topic

naive pawn
#

(that wouldn't make it on topic)

boreal violet
#

So, @placid jewel
I should change this

    private Vector3 UVToWorld(Vector2 uv)
    {
        float x = (uv.x - 0.5f) * meshSize.x + meshCenter.x;
        float z = (uv.y - 0.5f) * meshSize.z + meshCenter.z;

        Vector3 localPos = new Vector3(x, 0f, z);
        Vector3 worldPos = transform.TransformPoint(localPos);
        return worldPos;
    }

to this for example?

private Vector2 WorldToUV(Vector3 worldPos)
{
    Vector3 localPos = transform.InverseTransformPoint(worldPos);

    float u = (localPos.x - (meshCenter.x - meshSize.x * 0.5f)) / meshSize.x;
    float v = (localPos.z - (meshCenter.z - meshSize.z * 0.5f)) / meshSize.z;

    return new Vector2(u, v);
}
#

Oh no

placid jewel
#

No I don't think so

#

You use UVToWorld somewhere else

boreal violet
#

To this...?

private Vector2 ToUV(Vector2 localPoint)
{
    float u = (localPoint.x - (meshCenter.x - meshSize.x * 0.5f)) / meshSize.x;
    float v = (localPoint.y - (meshCenter.z - meshSize.z * 0.5f)) / meshSize.z;
    return new Vector2(u, v);
}
boreal violet
placid jewel
#

You only use it in OnDrawGizmos I think?

boreal violet
#

For now

placid jewel
boreal violet
#

If i got u, i should change UVToWorld to Vector2 in texture coords

rich adder
# placid jewel

?. doesn't work reliably on components btw
(unityengine.Object to be exact) @boreal violet

#

unity overrides the == operator

placid jewel
#

Yeah so since you're using it somewhere it might be best to make a new function for WorldToUv and use that in Start to convert your List<ContourPoint> contourPoints into a List of texture coordinates that you use in update instead of the original list

#

That's what I'd do

#

I see no reason to change UVToWorld at all since I don't think it's related

boreal violet
placid jewel
#

What do you mean?

boreal violet
#

Like they was at letter 'e', after Start method they go to a corner for example

placid jewel
#

Wait what have you done

boreal violet
#

Nothing for now

boreal violet
#

No

placid jewel
#

Or UVToWorld I meant but I think you assumed that

#

So wait

#

How does UVToWorld even work

boreal violet
#

No changes

#

I think what i should do now

placid jewel
#

It takes the values from contourPoints.UV and multiplies them out by the mesh size, which would imply that contourPoints.UV were already texture coordinates

#

Wait tell me

#

How big is your mesh

boreal violet
#

.1 on each XYZ

placid jewel
#

.1? Hmm

boreal violet
#

.006 on activation Radius

placid jewel
#

I feel like the issue is from using a mixture of texture coordinates and world coordinates, and since all the world coordinates are possible texture coordinates (i.e. between 0 and 1) there are no errors thrown

#

But I don't know for sure

#

contourPoint.uv is the world coordinate of that point

boreal violet
#

Yes

#

Wait no

placid jewel
#

If you convert it to the texture coordinate of that point and then check the distance of it from mouse click texture coord that should work no?

placid jewel
boreal violet
#

My code on mesh, that i use

#

So it's local positions?

placid jewel
#

What do you mean

boreal violet
placid jewel
#

What I want to know is what values are put in contourPoints.uv

boreal violet
placid jewel
#

And can you send a screenshot that shows the points on the mesh? (like your initial one)

boreal violet
placid jewel
#

Ok

#

Those look like texture coords to me

#

Since they're larger than the actual mesh size

#

In that case

#

Could the issue not be that the mosue has to click extremely close to the point in order to actually hit it?

boreal violet
placid jewel
#

Wait what do you mean

#

Oh

#

I think that still works for texture coords since the mesh is square

boreal violet
#

Yeah

#

So, maybe compare directly point.uv?

placid jewel
#

You are doing that right?

#

Wait

#

I do think tht if the activation radius is 0.006f it's hard to get that precision

#

This is how close the detection range is

#

(The purple circle around the green dot)

#

You mentioned before something about if you increased the activation range to 1 it worked

#

What happens if you say increase it to 0.02?

boreal violet
#

In debug, it's actual size of activationRadius

placid jewel
#

Is it possible to click from the right side then?
(These are questions I ought to have really asked earlier lol)

boreal violet
#

If i change to .02:

placid jewel
#

If you click them, do they activate at that radius?

boreal violet
#

No ๐Ÿ˜›

placid jewel
#

But they do at radius 1

boreal violet
placid jewel
#

So one of the coordinates is translated incorrectly still

#

Real

boreal violet
#

It's if i change to radius 1

placid jewel
#

Can you send a screenshot of the outputs of this line (with normal radius or not, it shouldnt affect)

#

You gave some example values before but I'd like to see at least a few of the full values

#

If you know where point 1 is, can you try to click next to that one specifically and show the output for that one?

#

Or any index point

boreal violet
#

I clicked to point 1

#

Wait

#

What if

placid jewel
#

Point 1 being the one labelled Index 1

boreal violet
#

What if i just add 1 - mousePos

#

It'll invert my click position

placid jewel
#

It looks like the mouse pos is 1 - the uv coord yeah

#

Also, could you create a small gameobject at position (0.02, 0.054) and show me where that is?

placid jewel
#

Odd request but it's to check that the uv values actually line up with world values

placid jewel
#

Wait what position is your mesh actually at

boreal violet
#

if i change to 0 0 0

placid jewel
#

That's the mesh at 0, 0, 0?

#

Still with scale of .1, .1, .1

boreal violet
#

Yeah

#

Wait

#

XD

placid jewel
#

What?

boreal violet
#

Vector2 clickUV = new Vector2(1 - hit.textureCoord.x, 1 - hit.textureCoord.y);
I added this

#

Points get activating when i click on them

placid jewel
#

That's great

#

However

boreal violet
#

But new issue

#

No, it's 2 issues

placid jewel
#

There's a possibility it's the uv coordinates that should be 1-x and not the mouse pos (though that is mostly irrelevant and just a code cleanliness issue)

placid jewel
boreal violet
#

I clicked at point with black lineup, but activated with blue too

placid jewel
#

That seems like it would be an issue with the detection radius

boreal violet
#

Also here is no polygon that should lerp two textures...

placid jewel
#

Could you move the Debug.Log($"Point {i} UV={pt.uv}, click UV={clickUV}, distance={dist}"); to inside the if (!pt.activated && dist <= activationRadius) and show me which ones activate when you click the same object?

#

Like this

boreal violet
#

Oh

#

It's not issue

#

Well not quite

placid jewel
#

Yeah?

boreal violet
#

The logic is that I kind of flash it and when I make a large polygon, the points that are inside the polygon are activated, forming it fully, but for some reason it doesnโ€™t take into account neigbourhoodRadius

placid jewel
#

You only use it once (apart from declaration)

grand snow
#

Ideally you use your IDE correctly and do "find all references" for the symbol

boreal violet
#

Oh...

grand snow
#

a simple text find is not reliable

#

it looks like your vs code isnt setup correctly anyway

#

!ide

radiant voidBOT
boreal violet
#

For what is it?

grand snow
#

I can tell by the lack of syntax highlighting your vs code is not fully configured for use with unity projects

placid jewel
#

That's not VSCode

grand snow
#

ah my bad, still same issue

boreal violet
#

XD

placid jewel
#

It's not my code I'm just searching through what was shared with me

grand snow
#

thats new

#

ah i got confused who was "helping" and who needed help

boreal violet
hushed fable
#

why cant i export it to VRM? exporting it to VSF works, but when i load the VSF file into VSeeFace its not working. I have been doing this for like 5hrs ๐Ÿ˜‚ ๐Ÿ’€.. I have the (.glb) 3D slime object, i just wanted to use it as an avatar where it floats.

boreal violet
radiant voidBOT
placid jewel
#

I'm not exactly sure how the polygon part works but you definitely aren't using the neighbor radius value in it

grand snow
#

Whats the issue? I cant locate the original message

#

Finding the closest vertex to some position?

boreal violet
#

XD

boreal violet
#

Points didn't activate when i click on it

grand snow
#

How do you detect which one is clicked and how is the state reflected in the gizmos?

boreal violet
#
    private void OnDrawGizmos()
    {
        if (contourPoints == null || contourPoints.Count == 0) return;

        planeMesh = GetComponent<MeshFilter>()?.sharedMesh;
        if (planeMesh != null)
        {
            meshCenter = planeMesh.bounds.center;
            meshSize = planeMesh.bounds.size;
        }

        foreach (var pt in contourPoints)
        {
            Vector3 pos = UVToWorld(pt.uv);
            Gizmos.color = pt.activated ? Color.green : Color.red;
            Gizmos.DrawSphere(pos, activationRadius);
        }

        foreach(var pt in contourPoints)
        {
            Vector3 pos = UVToWorld(pt.uv);
            Gizmos.color = Color.yellow;
            Gizmos.DrawWireSphere(pos, neighborRadius);
        }
    }
grand snow
#

uv to world wut?

boreal violet
#

Idk what is 'Wut'... :p

grand snow
#

uv doesnt naturally translate to a vertex

#

I would expect a world to local position conversion for the input position, then you use local positions only (local to the mesh/Transform)

placid jewel
#

This case uses a mesh that's just a flat square with a certain size, so UVToWorld just converts the point local to that plane to a point local to the world I think

#

But I do agree it's better to work all in local positions

placid jewel
#

Yeah I don't know why I forgot the word for "plane" and went to "flat square" lol

#

I suppose it's technically accurate

grand snow
#

you just assume then that a uv pos and vertex pos are the same but that is just an assumption

placid jewel
grand snow
#

anyway wheres the other code that changes activated

placid jewel
boreal violet
placid jewel
#

Or that one

placid jewel
#

That's updated right?

#

Yeah

boreal violet
#

Go sleep hero

placid jewel
#

Thank you ๐Ÿ˜ฉ And best of luck

boreal violet
grand snow
#

This is a bad idea Vector2 clickUV = hit.textureCoord;
You should just convert the hit position to local for the object and then find the closest.
Then you can just use the methods on Transform to convert

boreal violet
#

It just started work catcrymic

grand snow
#

What I already said but you don't seem to care

boreal violet
#

I mean

#

texture coord it's not local for the object?

grand snow
#

A UV position can't be translated back to a local object position reliably

#

A mesh may happen to have vertex positions match up with uvs and that's just luck or a presumption

boreal violet
#

So, this is why my code doesn't generate polygon for RT?

grand snow
#

Don't know but using uvs is flawed

cedar peak
#

my charecter is phasing through edges when moving and using a jump pad im using a tilemap with comopsite collider 2d
my charecter has a sqare collider 2d

unreal imp
#

ExponentialDecay is an example or it was replaced by smth else?

polar acorn
#

It's in the link

boreal violet
#

I got this

minor goblet
#

havent used unity in like 2 years did they change scripting fully?

#

Apparently cant even use do manual character movement script

#

gotta use a feature or something

slender nymph
#

presumably you are doing something wrong then

minor goblet
#

otherwise it doesnt let you use it

slender nymph
#

that's not a change in scripting, nor is it an issue with "manual character movement"
this is just you not reading your errors

minor goblet
#

i did read and fix it

#

thats why i asked if they changed it

slender nymph
#

nothing about scripting was changed in that regard. the new input system is just the default input handler now as of 6.1

minor goblet
#

And for velocity apparently i have to use linearVelocity or something

#

changes every single time i type it

slender nymph
#

yes because the name of that property has changed

minor goblet
#

gotcha

#

But nothign else changed right

slender nymph
#

there may be other small changes that your IDE will tell you about if you try to use something that has been deprecated. so just trust your tools

#

and for future reference, instead of asking a vague question like "has scripting changed" you should ask about your actual issue

minor goblet
slender nymph
#

i am not saying you cannot ask questions. i am just saying your initial question's actual premise wasn't even what you were asking about

minor goblet
#

it was more like a discuss other than a issue

cedar peak
#

is there a way to chage between 3 sprite
im tryna make a mute unmute button
rn its
unmuted + click = muted can convert it back to unmuted icon
its a toggle btw

slender nymph
#

an if statement and assigning to the .sprite property

cedar peak
#

any code less way ?

slender nymph
#

this is a code channel mate

cedar peak
#

fair enough

slender nymph
cedar peak
#

okay

unreal imp
#

Not a feature XD

cedar peak
#

my chrecter is behaving as if its collideing with something even though theres nothin there

slender nymph
#

you're gonna need to provide more info, like relevant code and info about the scene setup

cedar peak
#

1min

slender nymph
#

not related to the actual issue, but is this not your code, or is there some specific reason you have this part in it?

#if UNITY_2023_1_OR_NEWER
        uiManager = FindFirstObjectByType<UiManager>();
#else
        uiManager = FindObjectOfType<UiManager>();
#endif
cedar peak
#

same i have no clue why its there i havent added it i figured unity auto added it so i didnt remove it

slender nymph
#

unity would not have automatically added preprocessor directives

cedar peak
#

i do use ai occasionllay that my be the source aswell

valid violet
#

This statement works only for assets

slender nymph
valid violet
#

I mean assets from asset store

cedar peak
slender nymph
#

version control does not modify your code in any way

#

that was likely something added by the AI you use

cedar peak
#

okay if you say so

rocky canyon
#

if its only happening in that one vertical shaft area.. perhaps test out in the open.. to confirm
if the same code works fine in one area but doesn't in a specific area... then odds are its something in that specific area.. and not in the code

cedar peak
#

it also happes on top

rocky canyon
#

check those areas.. โ˜๏ธ make sure theres nothing in the way..

  • one thing we see is people will destroy or disable a gameobject (a coin pickup, or maybe a door) and they'll somehow forget to remove the collider that represents that object..
  • (removing the graphics but leaving the collider)...
    ** this could be the cause or something
cedar peak
#

also when i stick to the right wall in the shaft area it lets me go up

#

what do expanded colliders mean

#

if i go to the render button and make it wireframe it shows all colliders ?

rocky canyon
#

gotta confirm is nothing actually in the scene (thats blocking) and then you can move to the next likely thing.. (which i have no idea what may be..) might be ur jump logic.. /something in ur movement.. idk.. but the first guess is just something is in the way..

    // on the the rigidbody gameobject
    void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log(collision.gameObject.name);
    }

if you use the https://docs.unity3d.com/6000.2/Documentation/ScriptReference/MonoBehaviour.OnCollisionEnter2D.html method you can Log everything it touches in the console...

just peep ๐Ÿ‘€ the console when that happens.. and make sure its not colliding with anything...

rocky canyon
cedar peak
tender mirage
#

i want to put my collider mode on continous but when i do that, my onCollisionEnter2D stops working

i noticed continous completely prevents tile clipping from happening which would be really nice.

private void OnCollisionEnter2D(Collision2D collision)
{

    Vector2 contactPos = collision.GetContact(0).normal;


    //If velocityY is relatively high
    if (recordedMagnitude >= dangerMagnitude || recordedMagnitude <= -dangerMagnitude)
    {

        //Only hurt if hit from above or below
        if (contactPos == Vector2.down || contactPos == Vector2.up)
        {

            int damageAmount = Mathf.RoundToInt(recordedMagnitude) / 2;

            print(damageAmount);

            TakeDamage(damageAmount);


        }


    }

}
#

Does anyone know why continuous just stops it from functioning?

slender nymph
#

Continuous Collision Detection wouldn't stop OnCollisionEnter2D from working, in fact that mode makes the rigidbody do more/complex checks to ensure collisions happen more reliably. If OnCollisionEnter2D is not working at all then something else is likely wrong

polar acorn
#

For example, continuous collision detection could potentially be causing you to collide with a different object than you were expecting to

slender nymph
#

should absolutely add some logs outside of those if statements to figure out what is actually happening

tender mirage
#

I added a simple print at the top. which never printed out

#

it should've especially if something else collided.

slender nymph
#

show both colliders involved in the collision

tender mirage
#

Oh right that's relevant. tilemap collider can always be abit indifferent.

#

This is my tilemap collider.

barren lantern
slender nymph
#

which part was it

timber tide
forest cosmos
#

Hey, got a question about Animation Trigger in code

#

why does this trigger not reset by itself when the condition gets set to false?

#

I go from jump to fall but isJumping still is active in animator.

polar acorn
#

A trigger will un-set itself once it's used for a transition.

forest cosmos
#

it goes from Jump to fall, i can see falling animation running

#

it has that bar below it in animator

polar acorn
#

What is the transition condition from jump to fall

slender nymph
#

presumably you are setting the trigger multiple times, including after it was used for the transition and automatically reset

forest cosmos
forest cosmos
slender nymph
#

you want to only set the trigger one time to enter the Jump animation then not again until you want to enter the animation again

forest cosmos
#

ah i see,

#

btw any tutorials/assignments on net i can do to improve my animator logic?

#

I get stuck in it alot

polar acorn
#

Yeah, so, looks like it's set, which causes the animator to enter Jump, then there is at least one frame where the velocity is still above 0.1f, which sets it again.

#

Then, once the velocity becomes negative, it goes into Falling

forest cosmos
#

yes, looks like its triggering multiple times

slender nymph
#

yes, every frame for pretty much the entire duration of your Jump animation

forest cosmos
#

man this animator is confusing.

#

gets messed up so fast

#

made one earlier and it has like 8-9 parameters

slender nymph
#

rather than checking every frame if the velocity is above a specific threshold, why not trigger the animation when you actually add force/change velocity to perform the jump

#

that way you aren't setting the trigger every frame

forest cosmos
#

when i press jump

#

cuz arnt we suppose to keep stuff seperate?

#

I currently have a UpdateAnimation funciton running in Update

slender nymph
#

there are plenty of ways you can handle this. but it all stems from that initial jump input detection which is what you want this trigger to respond to

forest cosmos
#

can you please suggest me a way to do it as a beginner theres so many ways it gets super confusing

slender nymph
#

i just did

forest cosmos
#

ah yes

#

thanks

mortal jasper
#

Hello i am new to C# and im here to learn more to flex to teacher and get 10 int technology class hehe

misty marten
#

yo im looking for somone to make a game whit me for now i wanan just to make a map but the idea is cool its a vr game (like gorilla tag) so if u wnat dm me

mortal jasper
#

How can i animate stuff in unity?

#

!Ide

radiant voidBOT
mortal jasper
#

I already did this

cosmic quail
misty marten
#

daum๐Ÿซก

civic gust
#

Hello. I have a problem using TMP and some fonts with layout groups.

I'm using two objects, parent have vertical layout + content size fitter with preferred horizontal fit, child is just a centred text. When text have some symbol combinations it breaks in to two lines.

#

Okay, I think I can fix that by settings text to "No wrap" mode, but I'm still curious why is this happening

rocky canyon
#

yea that wat i was going to mention.. it appears to be the default wrapping..

#

the symbol part is a bit confusing tho

#

Use a non-breaking hyphen which is Unicode \u2011.
The normal hyphen is defined as a line breaking characters whereas the non-breaking hyphen is not.
- Stephan_B (Unity Staff)

-# ๐Ÿ”Ž Line Breaking Characters

slow mantle
#

Hello. I tried making something on my own until realizing I am woefully underprepared.
I am trying to make an idle game where the production upgrades create an item, and that item is the thing that generates the main currency.

Kind of like > Arbitrary Building creates an Arbitrary Item and that Arbitrary item makes Arbitrary points.

I could do it one by one, which I would have probably succeeded in already, but I tried doing using lists and arrays and... Yeah, I'm lost. I'm not sure what to do.

#

I'm trying to screenshot this code but I don't even know what to show. Hm.

slow fossil
#

You can paste your code using the ``

cosmic dagger
slow fossil
#

Do you think this is a reasonable layout for a tower in a tower defence game?

Since status effects could be a big thing, I'm thinking of putting a separate script just for status effects

#

Blue means functions

glad shore
#

how can i make it so particles are affected by lighting

polar acorn
#

Give them a lit material

teal elk
#
private void OnValidate()
  {
         ValidateAtrributes();
  }

  public bool ValidateAtrributes()
  {
      if (DoesRequiredAttributes)
      {
          foreach (var attr in itemAttributes)
          {
              if (attr.Attribute != ItemAttribute.None || attr.BaseAttributeValue! > 0)
              {
                  return true;
              }
          }

          Debug.LogError("All attributes set to none Or Value is set to zero, atleast one attribute must be set to Str,Dex,Int");
          return false;
      }
      return true;
  }

I am trying to throw error if my item require attributes but the attributes in the array are not set properly , then I will get an error do I can fix it ,but currently despite some scriptable objects having the requirement for me to get an error, i dont get an error

polar acorn
#

Try logging something in the true cases. Log the attribute before the first one, and log that the object doesn't require one in the second. See which true its hitting when you don't expect it to be

#

Probably include the name as well

teal elk
eternal needle
meager siren
#

I'm trying to think of a way to make smooth movement and overall I am lost and Don't want to spend my entire day trying to code this :p

fast relic
#

smooth movement like one that feels good to play?

meager siren
#

yeah

fast relic
#

well there isn't really one way to do that

#

but there are a bunch of techniques you can search for

meager siren
#

yeah ik

#

I just

#

wanna try and figure this out myself ngl

#

I just want some help :p

#

I'm getting somewhere, but I, well. yk?

fast relic
#

you can check out some videos from gmtk like theo ne about celeste, which covers what you can actually implement to make it feel better (but not actual code itself)

๐Ÿ”ด Get bonus content by supporting Game Makerโ€™s Toolkit - https://gamemakerstoolkit.com/support/ ๐Ÿ”ด

Celeste is one of the most satisfying platformers released in recent memory. And a big part of that is due to the tight and responsive controls of the gameโ€™s main character: Madeline. In this video, letโ€™s look at how designers Maddy Tho...

โ–ถ Play video
meager siren
#

I'm doing the 3d tho :p

#

oh

#

you just meant techniques

#

ah

fast relic
#

the techniques still apply to 3d, it's just an extra dimension

meager siren
#

yeah

fast relic
meager siren
#

whilst actually using the rigidbody

fast relic
#

use the rigidbody's linearVelocity

meager siren
#

lmao idk

meager siren
#

xyz with rb

#

whoops

fast relic
#

wdym? a vector?

meager siren
#

wait

#

how do I use the linearvelocity

fast relic
#

you just set it

meager siren
#

I know velocity is the speed of a vector

#

oh

fast relic
#

(also, you probably wanna be doing this in fixed update to make physics more consistent)

meager siren
#

facking

#

alright

#

wait im so screwed lmao

#

do I have to use *=

#

or just *

#

*=

#

idk why I didnt test it before asking

fast relic
#

just =

meager siren
#

oh

fast relic
#

it's just a property

meager siren
#

should my input vector be vector3?

#

I think so for the z direction right?

#

input = move.action.ReadValue<Vector2>();

fast relic
#

i mean you don't wanna move vertically with wasd do you

#

you just wanna move on x and z

meager siren
#

yeah

#

so Vector3

fast relic
#

yeah

#

but the y of the input is the z of the velocity

meager siren
#

whaaa

#

makes no sense but alright

fast relic
#

well your input is a vector2

meager siren
#

rb.linearVelocity = input.z * forwardDirection * speed * Time.fixedDeltaTime;

#

I changed it to vector 3

fast relic
#

you want its x component (a and d) to move you on the x axis and its y component (w and s) to move you on the z axis

sour fulcrum
fast relic
meager siren
#

whaaaa

fast relic
#

you only have 2 dimensions you can move in

#

w & s and a & d

#

w & s is the y component and a & d is the x component

meager siren
#

alright

#

it works

#

wth is wrong with unitys moderation

#

i cant even say some words

#

anyways, its rotating not actually moving

slender nymph
meager siren
#

or ":p"

slender nymph
#

and again, read the bot message next time

meager siren
#

IM SORRRYRYY

#

my fault

#

this is what I currently have, its just rotating rn

#

I have now paused all constraints

#

so thats that

#

but now it just doesnt move :p

fast relic
#

it probably does move, just very little

#

linear velocity shouldn't be multiplied by delta time, the engine does that automatically

meager siren
#

oh

#

yoo it works

#

the x is the same thing correct?

#

but then I've just gotta make it all even

fast relic
#

well you'd multiply it by the right direction

meager siren
#

yeah

slender nymph
#

ideally you wouldn't do multiple multiplications and would instead create a vector3 from your input and transform the direction of that

#

also just fyi, but transform.TransformDirection(Vector3.forward) is equivalent to transform.forward

placid jewel
meager siren
#

heres this btw, I dont move forward. But I guess its overriding it correct?

slender nymph
#

and yes, don't multiply your velocity by deltaTime. just use an appropriate speed value as velocity is already expressed in units per second

fast relic
placid jewel
#

yeah you are saying "Velocity is a certain vector in the forward direction" then immediately saying "forget that, velocity is a certain vector in the right direction"

meager siren
#

put them both in the same syntax?

#

but just add together

placid jewel
#

What do you mean by that

meager siren
#

same line

fast relic
#

straight up just add them together

placid jewel
#

but not necessarily

#

Just add them together in as many lines as you want

fast relic
#

(input.y * forwardDirection + input.x * rightDirection) * speed

meager siren
#

I'll make it cookies

#

since that seems better tbh

#

but it works

#

now time for camera

#

im guessing camera is weird

fast relic
#

rotation is weird in general

#

but it shouldn't be too hard

meager siren
#

do i use the quaternion.lookTorward or whatever its called

fast relic
#

i usually just do it with euler angles directly

placid jewel
fast relic
#

a bit unnecessary

meager siren
#

WAIT

#

no

#

nvm

#

you can just put the variable in there, myfault

devout dock
#

Hi all. This is probably a stupid question, but what should I do if my tileset is too complicated for a Rule Tile? For example, I have some tiles that can have tiles in 8 directions, but in some directions, it has to be a specific subset of tiles

placid jewel
fast relic
#

if you want it to be more readable, i'd do

Vector3 forwardInput = input.y * forwardDirection;
Vector3 rightInput = input.x * rightDirection;
Vector3 input = forwardInput + rightInput;
rb.linearVelocity = input * speed;
meager siren
#

you can

placid jewel
meager siren
fast relic
#

well you wanna rotate the camera based on the mouse movement

placid jewel
meager siren
#

I have this but yk. Im a slow dumbass ngl

fast relic
meager siren
#

Oh

#

alright

fast relic
#

but if you don't want to you don't have to

meager siren
#

I mean like

#

you have the best profile in this server hands down

#

and your really helpful

fast relic
placid jewel
meager siren
#

Ive never used them before

fast relic
meager siren
#

yeah

#

so like

#

how do I use it yk?

#

im thinking that

#

I get Vector 2 of look InputAction

fast relic
#

well you want your camera to rotate around the x axis (which would be up and down) whenever you move your mouse vertically

meager siren
#

then assign it through there whilst using angles

fast relic
#

and around the y axis when you move it horizontally

placid jewel
#

Also, do you want your mouse/crosshair to stay in the center of your screen? (Like in most 3d games)

meager siren
#

this is the one thing I remember how to do

#

๐Ÿ˜ญ

placid jewel
meager siren
#

should I grab the Quaternion of the cameraholder?

#

I think so

#

or do I use transform.rotation or smth

fast relic
#

no, we're gonna be using euler angles

meager siren
#

aaaaaah

fast relic
#

(transform.rotation is the quaternion)

meager siren
#

is it just

#

aaaah

#

how do I bring up the eulerangles

placid jewel
#

transform.eulerangles right?

fast relic
#

well, because converting quaternions to euler angles can be a little inconsistent, you'd wanna make your own variable for the angle

meager siren
#

yeah

#

transform.eulerAngles

placid jewel
#

Also make sure you know whether to use eulerAngles or localEulerAngles based on how the objects are set up

meager siren
fast relic
#

you'd wanna keep track of them yourself

#

and you initialize it to transform.eulerAngles only at the start

meager siren
#

i hate rotations

fast relic
#

everybody does but it's just something you have to put up with

#

just make a vector3 variable

placid jewel
meager siren
#

I make a vector3 variable to grab eulerangles correct?

fast relic
meager siren
#

can this leave me alone

fast relic
#

no because unity is stubborn and wants their own vectors

meager siren
#

aaah

fast relic
#

you want UnityEngine.Vector3 not System.Numerics.Vector3

meager siren
#

yeah dw I know

#

do I add the Vector3 variable to the transform.eulerangles?

#

then the input and what not or smth

#

or is it more complicated

placid jewel
#

Don't think so

fast relic
#

you just set transform.eulerAngles to that variable

meager siren
#

OH

#

oh alright

fast relic
#

now, you'd wanna add your vertical mouse movement to its x component and your horizontal mouse movement to its y component

#

i know it's a bit confusing, but it's because x rotation is rotating around the x axis

meager siren
#

coding is confusing lmao

#

I'll get used to it tho

fast relic
#

here it's just rotations that are confusing haha

meager siren
#

it a bit broken

fast relic
#

how?

meager siren
#

did I do something wrong

fast relic
#

i said, you want to add your mouse's horizontal movement (the x component) to your rotation around the y axis, and your horizontal to your rotation around the x axis

meager siren
#

oh

fast relic
#

also, you shouldn't be adding your angle to eulerAngles - you should just set it directly

meager siren
#

oh

#

I see

fast relic
#

since transform.eulerAngles converts from and to quaternions when accessed and set, it can be inconsistent and confusing to work with directly

placid jewel
#

you want to essentially:
-read the euler angles to a variable at the start
-update your variable with whatever logic/math you need to get the right rotation
-then set euler angles to the variable

fast relic
#

yeah

placid jewel
#

It's like taking a copy to work on, since you don't want to mess up the original

fast relic
#

well no, it's like working on your own copy and then occasionally updating the target

placid jewel
#

True

#

It's like using github

meager siren
#

hey

fast relic
#

git

meager siren
#

if I look up, I kinda fly

fast relic
#

yeah, because you need to set your input's y component to 0

meager siren
#

its kinda funny tbh

placid jewel
#

wait

#

is your movement script based on the camera's forward direction?

meager siren
#

yeah

fast relic
#

like here

Vector3 forwardInput = input.y * forwardDirection;
Vector3 rightInput = input.x * rightDirection;
Vector3 input = forwardInput + rightInput;

// set it to 0 because you can look up
input.y = 0;
rb.linearVelocity = input.normalized * speed; // needs to be normalized, because you don't want to move slower when looking up
placid jewel
# meager siren yeah

it might be better to base it on the player object's transform.forward direction and then rotate the player according to the mouse movement

meager siren
#

but like

fast relic
#

and might be more confusing

placid jewel
#

And then normalize forwardDirection (I assume)

fast relic
#

not justforwardDirection

placid jewel
#

doesn't right direction not have a upwards component though?

#

since it's perpendicular to the forward direction

#

it should be only along x and z no?

fast relic
#

well no?

#

or i might be getting confused myself

#

but i'd just set the sum's y to 0

#

and then normalize it

meager siren
#

also how di I clamp it properly

#

ive done this

#

which isn't working ofc

fast relic
#

well you're clamping your movement, not the final angle

meager siren
#

oh

#

like how do I clamp it then

fast relic
#

well, you clamp the x angle, not the y input

meager siren
#

well yeah

#

but im guessing no need to assign a variable to it

fast relic
#

wdym

#

you first subtract input.y from it, then you clamp the angle.x

meager siren
#

doesnt matter im a dumbass

#

double checking the angle.x is the y axis? because i am so confused with which is what now

fast relic
#

no, you're clamping the input.y

#

Mathf.Clamp() returns the value you passed in, but it can't go below the min or above the max

#

you're passing in the input.y, which is what you're clamping

#

buyt you don't wanna limit the rotation speed, rather the target rotation

meager siren
#

im lost

#

what do I do here then?

fast relic
#

okay, do you know what returning a value from a function is?

meager siren
#

I think

fast relic
#

let's say i want you to write a function that takes a number, multiplies it by 2 and then returns it

meager siren
#

is the 'return' thing or something else

fast relic
#

how would you do that?

meager siren
#

well

#

function, inside function number multiply, next line 'return'

fast relic
#
public int Double(int value) {
  // what do you put here? 
}
meager siren
#

something like that

#

honestly, this is like school lmao

placid jewel
# fast relic or i might be getting confused myself

It's not really important but I want to make sure I'm not going crazy myself lol

These are the two angles of rotation of the camera (the black arrows) and the corresponding rotation (blue arrows) of the right vector (green), I don't see how it's possible to rotate the camera in a way that the right vector doesn't stay horizontal

fast relic
meager siren
#

I dont entirely understand how to use functions

meager siren
meager siren
fast relic
fast relic
meager siren
#

I said 'Basis' not Basics

#

I know how its used I just dunno how to use it

fast relic
#

that's a linear algebra term

meager siren
#

yk?

fast relic
#

well a function is just a piece of code you can reuse

meager siren
#

yeah

#

I know that

#

its callable through your script

fast relic
#

they can take arguments and return values

meager siren
#

I know you use return to return values from memory

fast relic
#

yeah

#

or you can use just return; to exit a function that doesn't return any value early

meager siren
#

buuut,
the "int" and "value" in the thing you sent I dunno if you meant multiplay the value

#

I just remembered what the int part is lmao

fast relic
#

the int is the return type and the value is one of the parameters

meager siren
#

yeah

fast relic
#
public int /* <- return type */ Double(int value /* <- parameter */) {

}
meager siren
#
public int Double(int value) {
  value *= 2;
  return value;
}

Forgot if it was *= or just *

#

*=

#

or *

#

wait

fast relic
#

* just gives you the value multiplied by 2, but you aren't doing anything with it

#

while *= sets it to that

#

doing value *= 2 is the same as doing value = value * 2

#

it's just a shorthand

meager siren
#

I forgot if you do return and then value

meager siren
meager siren
#

this

#

that I mean

fast relic
meager siren
#

oh

#

alright

fast relic
#

so return "Hello world"; makes the function output "Hello world"

radiant glen
#

Working on movement for my game and really want this to feel polished, the character does not move well, at all, I want the model to move with the camera smoothly, I am using a premade movement pack from the unity asset store, trying to get a VR feel from a pc game

fast relic
meager siren
fast relic
#

outside of the function

meager siren
#

ouside of the function

#

yeah

fast relic
#

how do you use a function that returns something

meager siren
#

I forgot to add that

fast relic
#
int myInt = 4;
int doubledInt = // how do you use the Double() function we wrote earlier here?
fast relic
meager siren
#
int myInt = 4;
int doubledInt = Double(value);
#

something like that

fast relic
#

almost

#

you don't have a value declared anywhere, that value we had in the function was simply the name of the parameter

#

which is what you use in the actual function

#

but you need to double myInt

meager siren
#

oh

#

ohhh

#

lmao

#

hold on

#

I forgot how to be smart lmao

int myInt = 4;
int doubledInt = Double(value = myInt);
#

something like that

fast relic
#

well, it'd be value: myInt

meager siren
#

ah

#

right

fast relic
#

but you can just do Double(myInt) - you don't need to explicitly name the arguments if you pass them in the same order

radiant glen
meager siren
#

close enough lmao

fast relic
#

now, let's look at a more complex example - writing your own clamp function

public int Clamp(int value, int min, int max) {
  // (...)
}
meager siren
#

oh

#

im screwed

fast relic
#

nah you should be fine

#

how would you do something like this?

eternal needle
#

you should really make a thread if you plan to just tutor someone

meager siren
#

lmao

fierce shuttle
meager siren
fast relic
#

well, if your value is less than the min, you want it to return the min, and if it's greater than the max you want it to return the max

#

and otherwise the value itself

meager siren
#

right

radiant glen
meager siren
#

I can use if statements

fast relic
#

yeah

fast relic
#

shouldn't be that hard

radiant glen
#

Okay, that makes sense, when typing it sounds silly

radiant glen
fierce shuttle
meager siren
#
public int Clamp(int value, int min, int max) {
  if (value > max)
  {
    value = max;
  }
  else if (value < min)
  {
    value = min;
  }
  return value;
}

Something like this

fast relic
#

yeah (you got the greater than sign the wrong way round tho in the second statement)

#

but you still need to return the value

meager siren
#

I was contemplating it ngl

meager siren
placid jewel
meager siren
#

I forget things fast alright

placid jewel
#

Don't worry

fast relic
#

okay, now how do you use our fancy not-exactly-new clamp function?

placid jewel
#

Probably should make a thread by the way, it feels like this discussion is going to go on for a while longer

fast relic
#

yeah sure

ashen trail
#

why cant i move my character??

placid jewel
#

What is moveSpeed set to?

worthy forum
#

just do velocity

meager siren
#

even I know why

#

I think anyways

worthy forum
#

and make sure speed is set in the inspector

meager siren
#

nevermind, but it is probably speed

placid jewel
ashen trail
#

speed is set

placid jewel
#

Wait

#

OnMove is never called no?

#

It's not a built in function

meager siren
#

yeah

ashen trail
#

ohh

worthy forum
#

oh yea don't know how i didn't catch that lol

ashen trail
#

so i should just call it in fixedUpdate then?

placid jewel
#

Yeah

worthy forum
#

are you you using the playerInput?

placid jewel
#

But it might be a good idea to move line 17 (velocity update) into your movement function

worthy forum
#

and is it set to event, sendmessage or broadcastMessage

ashen trail
#

okay

ashen trail
worthy forum
#

usually i just go for the "C# events" for the new input system. and i just access the InputAction directly for movement input

#

if you are using the new input system either you have to use the PlayerInput or manually setup the C# events

fast relic
#

(or reference the input action)

worthy forum
#

yup

#

but with playerInput you can reference a global and easy to edit InputMap/actionMap

#

you can just add the playerInput component to your object

ashen trail
#

i dont really know how input works or anything really

so i just went with this

#

ohh and then set playerinput to 1

and it should work

#

or am I tweaking?

fast relic
#

playerinput is a component

worthy forum
#

no need to set playerInput to 1. its a component

cloud fox
#
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;
using Unity.VisualScripting;
using Unity.VisualScripting.Dependencies.NCalc;
using UnityEngine;

public class playerController : MonoBehaviour
{
    public float playerSpeed = 5f;
    public int playerJump = 10;
    private Rigidbody2D rb;
    private Vector2 moveVel;
    private Transform grounded;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        grounded = GetComponentInChildren<Transform>();
    }

    // Update is called once per frame
    void Update()
    {
        moveVel = Vector2.zero;
        handleInput(KeyCode);
        moveVel = moveVel.normalized * playerSpeed;
    }
    void FixedUpdate()
    {
        rb.MovePosition(rb.position + moveVel * Time.fixedDeltaTime);
    }
    void handleInput(KeyCode key)
    {
        switch (key)
        {
            case KeyCode.A:
                moveVel = new Vector2(1 * playerSpeed, 0);
                break;
            case KeyCode.W:
                moveVel = new Vector2(-1 * playerSpeed, 0);
                break;
        }
    }
}

how do I feed my key inputs into this? I'm not even sure a switch case is necessary here either. (Also before anyone says to use getaxis I don't want to because I'd rather have more finite control over which keys are moves

ashen trail
fast relic
worthy forum
#

new input system is quite nice. has a learning curve but it has flexibility

cloud fox
meager siren
#

btw is there an inputaction reference for sprinting or smth? or should I just use the Keycode

cloud fox
fast relic
#

you just make a sprinting action and reference that

meager siren
#

oh

fast relic
meager siren
#

I should probably use my own input action map

#

ngl

fast relic
#

you can edit the default input actions

meager siren
#

oh

#

ok

worthy forum
#

iirc in unity 6 and up it by default gives you a input action map

cloud fox
fast relic
placid jewel
cloud fox