#๐Ÿ–ผ๏ธโ”ƒ2d-tools

1 messages ยท Page 58 of 1

olive mesa
#

And use a vector3 instead of a quaternion

nova bear
#

ty

olive mesa
#

Np

nova bear
#

sometimes my gameobject's spriterenderer counts color by 255f and sometimes by 1f. What determines this?

olive mesa
#

Idk tbh

#

We've got Color and Color32

#

Afaik they are both the same except Color32 uses 255 while Color uses 1

nova bear
#

ohh

#

i just use new Vector4 when setting render.color

olive mesa
#

I've never seen that done before

nova bear
#

really?

olive mesa
#

Yeah

#

Just use new Color(r, g, b, a);

nova bear
#

ok

olive mesa
#

Interesting

winged marlin
# nova bear

Please never post code in an image itโ€™s a pain to read. Please put it in a Pastebin / hastebin

nova bear
#

ok

olive mesa
#

I've never found it a pain to read

#

Also, is this source code or something?

#

I've never seen code written this way for a game

#

Oh wait

#

It's like a custom transform

nova bear
#

oh

#

basically I make functions for every common task that are easy to use, like basic commands

#

which makes the main code easier to read

olive mesa
#

That's cool

#

It's like combining the Transform and the SpriteRenderer into one component

#

I might try that tomorrow

nova bear
#

nice

olive mesa
#

Anyway, gtg

#

Cya

nova bear
#

cya

#

What are the elements in Color data types respectively?

#

i used to come across a problem where a data type for colors was ordered b g r a instead of r g b a

#

and my sprite turned the wrong color

#

i searched it up and its correctly ordered

desert cargo
#

It's standard RGBA color representation.

#

What do you mean by "ordered"? You shouldn't really need to know the memory order unless you're working in unsafe mode for some reason.

dusky wagon
#

Thanks, just one question what does the Force!pde2D.Impulse dp?

olive mesa
#

It just tells the rigidbody how to apply the force

#

Using impulse makes it start fast and then slow down

dusky wagon
#

Ah okay

olive mesa
#

Using force just adds to the velocity, nothing cool about that one

dusky wagon
#

And if I make the bounciness of an object high, will that affect things that collider with it if the object itself cant move?

olive mesa
#

Any object that has the physics material should be affected as long as it's rigidbody is not set to kinematic or static

dusky wagon
#

Alright thanks I will try both of these ways out

olive mesa
#

Np, hope they work

dusky wagon
#

But I think I will stick with the second one, as in my experience its not good to purely rely on unityโ€™s physics

olive mesa
#

Yeah

#

I don't trust Unity's physics lmao

#

I usually find it to be inconsistent and somewhat glitchy

dusky wagon
#

Yep I tried making things that entirely use unity physics a couple of times, but always ended up writing a script to do it

craggy briar
olive mesa
#

Aghh corners

#

I've tried to make platformers so many times, but the player gets stuck every other block I pass

#

Cuz of the collision

craggy briar
#

Me: "I'll make a simple arkanoid clone using physics! Should be really straight forward!"
Unity: "Hahahaha. No."

olive mesa
#

I recently discovered that the composite collider 2d is a good fix

olive mesa
#

3D physics is fine

#

2D though...

#

That's not very fine

odd comet
#

Hi, I have a problem with changing scenes, when my player sprite doesnยดt show in game. Layers order should be ok, because in the main scene its alright. Where could be problem?

dusky wagon
odd comet
#

zero

#

Changed it but nothing happened

forest cave
#

And the camera?

odd comet
#

z=-1,4659

dusky wagon
#

that is probably what it didnt catch it, because the camera was behind the player

#

I would set both to 0

odd comet
#

ok, for some reason now, when i change z to 0 on player, he appears, but I am only able to change the z position in game mode, bcs the player is teleported to the second scene. Is there a way to set it properly?

dusky wagon
odd comet
#

via empty object with 2d collider and script

dusky wagon
#

So you are setting the transform of the player to match the transform of another object?

odd comet
dusky wagon
#

And is the player already in that scene?

odd comet
#

no

dusky wagon
#

Then how do you teleport it into the scene?

odd comet
#

ehm i dont know

#

ok, I fixxed it (changed cameras position values in second scene to match with the camera in first scene)
thank you for help

#

but I have another issue
When I teleport, it duplicates my player, so in that scene, there are two players (both move the same)

frail halo
#

So how do i move a Rigidbody2d without interfering with the vertical velocity? Everything i tried either pinned it in place or made it fall slower

compact knoll
#

if you're modifying the velocity directly, you can do rb2d.velocity = new Vector2(velocityChangeX, rb2d.velocity.y). Or you can use AddForce and just not add any force on the y axis

worthy stump
#

Hey folks, I have a question regarding 2D cameras and pixel/sprite art.

I've been working with the above for some time, and understand the issues regarding the rotation of sprites, how (and why) they alias, and also issues with sub-pixel rendering and how that can create "doubling" of individual pixels when a sprite is not clamped to the pixel grid.

I have managed to alleviate these issues to an "acceptable" level, however I would like to make further improvements. Specifically, I noticed that the Editor viewport camera does not suffer from any of the above issues. I am able to zoom/scale, rotate, translate my sprites by more or less any factor (no matter how large or small) and the result in the viewport will be a (near) perfectly positioned/rotated view of my original sprite. (Although the view in the game will never be as high-quality)

Howeverm I have not been able to find out why the editor camera is able to do this, so I was wondering if anyone had the answer? And also, would be possible to replicate that same behavior with a game view camera? If it were possible, it would be a huge benefit to my game!

Thanks ๐Ÿ™‚

nova bear
#

when a projectile is launched, I made it so that it only depletes hp from an enemy. However, when it passes through obstacles it jumps over them or below them as though the obstacle should affect the projectile's single y position attack.

I thought while writing this that the projectile's rigidbody is affected by the obstacle's collider. If this is true, how can I prevent it?

nova bear
worthy stump
#

Well, may be related to the sampling/import settings of an art asset but it falls under the programming spectrum more than asset creation

nova bear
#

i mean they might know more about rendering stuff, which will help getting reached out to sooner

worthy stump
#

Oh I see what you mean

#

Well, if nobody is able to answer it here I'll post it over there. Im in no hurry at the moment, at my day-job anyway haha

nova bear
#

yes

winter bridge
#

Hi! I'm trying to make it so it loads a new scene when it collides with a certain object. I have made it known in build settings and applied the script to the box + I have turned off mesh rendering and on for is trigger. Hope yall can help!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneSwitch1 : MonoBehaviour
{
    private void OnTriggerEnter(Collider other)
    {
        SceneManager.LoadScene(0);
    }
}
turbid heart
winter bridge
#

aahh! sorry, im just going right through it

sly palm
#

did you build the scene?

winter bridge
#

how would one do that?

#

ahh, just seen it, trying now

#

still doesnt seem to be working

winter bridge
#

I managed to work it out, i didnt do ontriggerenter2d!

#

thanks for your help!

nova bear
#

how can I make every element of a List<bool> true without iterating?

#

actually I change my mind

#

how do I check the length of a List?

worthy stump
compact knoll
#

list.Count

nova bear
#

List<bool>

#

so List<bool>.Count?

worthy stump
#

list<bool> mylist
mylist.count

compact knoll
#

^ that but capital C and L

nova bear
#

yeah

#

also i realized in my code there was a way to do it without count

#

but thx still

stoic moon
#

I have an enemy ai script here:https://pastebin.com/0ZPTrg2H that moves the enemy towards the player only on the x axis. How would i make it so that the enemy rotates either 0 or 180 degrees depending on where the player is?

#

E.g if the player is to it's right face right

compact knoll
#

an extremely simple implementation of that would be something like:
if player.transform.position.x < enemy.transform.position.x: rotate enemy to the left
if player.transform.position.x > enemy.transform.position.x: rotate enemy to the right

stoic moon
#

thanks i'll implement that

#

should be able to go from there pretty easily

compact knoll
#

Tilemap colliders exist

#

It's a component you attach to a tilemap object like any other collider

#

It will give everything on that tilemap a collider. So if you only want collision with certain tiles, move those tiles to a new tilemap and put the collider on that

snow willow
#

you can give any sprite a custom physics shape in the sprite editor

#

TileMap collider will respect that

#

Anything that's part of a tilemap is a sprite

#

yep - go edit the various sprite(s) custom physics shape in the sprite editor

#

or do that

#

AFAIK there's only one sprite

#

the tile palette thing is not a sprite

#

it's a tile

#

I think it probably just edits the same sprite?

#

ยฏ_(ใƒ„)_/ยฏ LMK - I didn't realize the Tile had a sprite editor button on it

#

check his position

#

maybe he's just behind the tiles

compact knoll
#

Is it on a tilemap layer that has a tilemap collider on it?

#

Do you see the colliders for the tiles? Select the grid in the hierarchy and you should be able to see the collider outlines

#

Alright, you should probably make a new tilemap that all the collision tiles will be on. Also do you have your player and the tilemap on separate collision layers? Because your player should be forced out of the collider if they are able to collide

#

It's the right drop down menu under the object name. You can also change what layers collide in Project Settings > Physics 2D

#

Layer: Default

#

The drop down menu on the right directly under the box to enter the object's name

#

Well they should be colliding then. Is the player able to move at all with how you have it set up now?

#

Oh wait, does your player have a RigidBody2D on it?

#

You can turn gravity scale to 0

#

Give it a RigidBody2D, set its gravity scale to 0, then press play and let me know if the player flies away

#

Did you turn off collision for the default layer for itself? Check in Project Settings > Physics 2D. Scroll all the way down until you see the matrix with all the checkboxes. Make sure the one that is on the Default row and column is checked.

#

Can you screenshot the inspector with the player selected to show the collider and rigidbody settings

#

Yes, that's what I suggested earlier.

#

For collisions to work as expected because I just realized you are probably changing the transform to move your player which entirely ignores physics/collisions

#

Yeah you should be using the rigidbody to move the player instead of the transform. You can use rb2d.MovePosition(), or set the rb2d.velocity for easy movement

limpid drift
#

could someone explain this to me

#
private IEnumerator AutoFire()
    {
        while (true)
        {
            FireBullet();
            yield return new WaitForSeconds(FireRate);
        }
       
    }
``` why cant i add a "while (false)" inside of this?
#

because right now i have inside my ontriggerenter2D StartCoroutine

#

but i want on exittrigger2D to StopCoroutine and wait a set amount of seconds

#

so how can i make it wait

#

because right now this happends

compact knoll
#

You can use while loops that aren't only while(true).

limpid drift
#

everytime i reenter the trigger it starts up again but i want it to suppend 3 seconds or so after ontriggerexit

compact knoll
#

Well if they expected to interact with physics then they are doing it wrong

wide lagoon
#

Anyone have an idea how I can check the tile depth of a tilemap inside a shader?

#

I can check x and y coordinates using the vertex position, but it seems all layers are at z=0

limpid drift
#

wont it loop when i put StopCoroutine inside ontriggerexit?

elder minnow
#

No

snow willow
#

wdym

elder minnow
#

Physics objects interact with colliders but projects with only colliders dont use physics

#

You need to elaborate a little

snow willow
#

You can use physics with only colliders. Colliders interact with all Physics queries like Raycasts, OverlapXXX, CheckXXX, etc..

#

but simulating newtonian physics with colliders? You need a rigidbody.

#

If you want your character to collide with those colliders, the easiest way by far to achieve that is with a Rigidbody

elder minnow
#

You don't need a rigidbody, but if you want to detect collisions you need to either use raycasts, overlaps or implement your own collision system

snow willow
#

that's what it's made for

#

but yes there are other ways - querying the colliders via raycasts etc..

#

It's also a good idea in general to used a fixed timestep for your character movement to ensure it behaves the same regardless of framerate

#

If it's a platformer kinda game

#

that will ensure the player always gets the same jump heights etc.

elder minnow
#

I use my own collision system, it's just a bunch of overlap checks

#

and then resolve the position based on extents

#

You need a composite collider

#

It will merge colliders together

#

That is because you gave a rigidbody to your collider

#

Only your player really needs one, yeah

#

Then it is part of the composite (I don't really remember), if you remove it, you might be able to remove your rb

#

Ah yeah, if you mark it as static or kinematic you will solve that

#

If you mark your tilemap rb as static it will solve it

#

yes

#

Just try it

#

No, the rigidbody in your tilemap

#

it has an option called body type

#

Did you make sure the composite is working?

#

Does it merge your colliders into big chunks?

#

I think you need to mark the colliders with "used by effector"

#

in your walls

#

Not the composite collider, but the actual colliders

#

Not that I am aware of

#

You probably could with editor scripts but that is a bit advanced for this topic

#

If you wanna see if they are single or in chunk you can just turn off the 2d grid

#

It should

#

You might not be checking the "used by effector" box on the actual colliders

#

Oh it's used by composite not effector, I'm sorry

#

Yes

nova bear
#

how do I delete all the children objects of a parent gameobject?

turbid heart
#

Googleable

nova bear
#

thx

#

can I do it without using loops?

#

loops scare me

elder minnow
#

physics material 2d @still tendon

nova bear
#

loops froze unity once

elder minnow
#

it's not a loop @nova bear

#

you will use a foreach statement

nova bear
#

what does foreach do?

#

it sees each object in something?

#

it gets each transform that the current transform contains?

#

i like that

elder minnow
#

in this case, each transform would be the children

nova bear
#

yeah\

#

also I have a List<GameObject> of all the objects

#

can I iterate through that instead?

elder minnow
#

it's easier if you name 'em like this:

foreach(Transform child in parent)
{
    Destroy(child.gameObject);
}
nova bear
#

thank you for your help

elder minnow
#

No idea, I haven't used physics material in awhile

nova bear
#

pprojectiles is my List<GameObject>

elder minnow
#

that works too if you want to delete each object of the list and not its child

nova bear
#

each object in the list is the child

elder minnow
#

Then that works

nova bear
#

works like a charm

#

next I have to get rid of lag in my attack

elder minnow
#

By lag do you mean it freezes when you shoot? It could be that you are instantiating new objects every time you do it, which can be resource intensive

#

If that is the case, look into object pooling, it will be a big performance boost

nova bear
#

actually, i built an fps tracker and discovered something

#

my fps is amazing, and the real issue is that my movement scripts are highly-dependent on frames

#

they change at tiny amounts, so if I lose about 30 frames, it looks like I'm getting severe lag

#

I create objects on level start and destroy them on level over

#

I'll try to use timers instead of changing a set value per frame

ancient path
nova bear
#

whats fixedupdate

#

oh like fixed fps?

ancient path
#

Update

#

but with physics

#

call

nova bear
#

confused

#

i'll just use time

#

but thank you for the option

#

i'll look into it later

ancient path
ancient path
#

because you are already using time

#

and with Time.scale =0 it pauses fixedupdate

nova bear
#

I have updated all of my movement scripts and made them time-oriented

#

everything moves at a set speed ๐Ÿ™‚

#

i made it 210fps based

#

so if the game is running at 210fps it's going to move at the amount that the script says

snow willow
nova bear
#

thats what i did

snow willow
#

so what do you mean by "210fps based"

nova bear
#

i meant by the 210fps based that

#

lol

#

that if its running lower than 210fps it's gonna look a bit chunkier but it's going to move at the same speed

#

so if its running at 200fps its going to be a tiny difference of chunkiness

snow willow
#

Most people don't have monitors that can even draw more frequently than 144 or 60 times per second

nova bear
#

or 60fps is gonna suck a bit

#

oh

#

but my game runs at around 200-300fps

#

so it renders about every 3 frames?

snow willow
#

on your hardware it might, but your monitor can most likely not even draw that many frames

nova bear
#

yeah that

#

well it's still smooth

snow willow
#

I don't doubt it

nova bear
#

i guess it's because I use small numbers

#

idk

#

even if I made it 60fps based it would render the same

#

well i guess its nice if the game runs faster than 60fps

snow willow
#

I don't even understand what you mean by that

#

ยฏ_(ใƒ„)_/ยฏ

meager mural
#

210fps based, 60fps based? What does that mean

nova bear
#

basically if the game runs at 210fps exactly the amount my object would move per frame would be exactly the amount I put it to, the same amount that is multiplied by Time.deltaTime

#

example:

#

oh i meant the amount divided by 210

#

so 31.5f / 210 * (speed / 75f) is how much the y position would change here per frame if it was running at 210fps constantly

#

if it runs at, say, 30fps the movement would be a lot chunkier but would move the same speed

#

basically 210fps-based is a term meaning I have to change up the numbers in every movement script I make so that it fits that level of smoothness

#

i can always make a script that goes on 100fps but that depends on me

snow willow
#

Then you just do speed * Time.deltaTime

nova bear
#

yeah

snow willow
#

and no magic numbers required

nova bear
#

what are magic numbers

snow willow
#

31.5 and 75 in your screenshot

nova bear
#

oh those

#

i cant make a new variable because right next to this are other ones that go by 10.5f * (speed / 75f) and stuff

#

also (speed / 75f) is used because my speed will either be 75f or 25f in this game

#

if its 25f I want this movement script to catch it and move 3x slower

#

and I use the same speed variable so I don't have to make new variables like velocity = (1/3) to represent 3x slower

frigid minnow
#

Heeey, so I have a Box Collider 2D component set to trigger, but it doesn't actually seem to detect anything at all

#

Anyone have any ideas?

#

Intersecting object has a rigidbody, and is on the same layer

#

Woops, figured it out.

#

Was supposed to be OnTriggerEnter2D rather than OnTriggerEnter

#

๐Ÿ˜Œ

nova bear
#

He made a prefab, which is an object that's easy to make copies of and quickly alter. Or if it's an animation, he made a .anim file, which can easily be done by dragging a bunch of images to hierarchy

#

which can also be easily be used as a variable

meager mural
#

you make things in the scene

#

and to save that thing, you prefab it

#

Yes

#

Well one way. theres probably more. like generating prefabs via editor scripts

#

But thats more advanced. the way he did it is the normal way

#

What do you mean

#

instantiate them as a child

nova bear
#

i'd just make a bomb gameobject, add a public Sprite[] array, add them in the inspector window's script component, and iterate through them in the script

meager mural
#

i don't know what you're actually doing. Childed objects inherit the transform animations of the parent

frigid minnow
#

@still tendon Are you having trouble doing what he's doing?

#

Basically what he's doing is making the explosion a different prefab

#

That way he can have the bomb create the explosion

#

This is helpful for a few reasons

#

First: you don't have to tell the bomb how the explosion actually works

#

And second: you can have the explosion spawned by other things, like explosive barrels or something

#

I have to watch the video to understand exactly

#

What do you want the bombs to do?

#

Like, what is the animation?

#

Is that in the video?

#

Oh okay

#

You can animate the bomb, you just need to have an animator component and everything

#

On the prefab

#

Yeah

#

Let me know if you need help, animator can be tricky if you don't know what you're working with

#

:]

frigid minnow
#

A question for ya guys

#

How would you generally do hurtboxes?

#

Do you turn the trigger collider on and off?

#

Or do you do something else?

#

I have a collider I'm trying to use as a hurtbox by turning it off and on at will, but it only detects OnTriggerEnter the first time it's enabled

#

If the thing is enabled, then disabled, then enabled again, it only calls OnTriggerEnter once

nova bear
frigid minnow
#

Nope!

#

So the problem would be that you can't really hit a stationary object

#

Which is annoying

nova bear
#

if you also call OnTriggerStay, it will run more

#

until it leaves

#

and if it leaves, you can also can OnTriggerExit

#

also, if you turn off the Trigger option, you can also use the functions:
OnCollisionEnter
OnCollisionStay
OnCollisionExit

snow willow
frigid minnow
#

Actually no

#

Okay did that

#

:]

dusky wagon
#

If you have a rule tile which generates a gameobject wherever you place it, and you destroy the game object in the middle of the game, does it delete that tile as well?

compact knoll
#

no, but the game object will (obviously) no longer be attached to the tile

dusky wagon
#

Hm okay

dusky wagon
compact knoll
#

a kinda hacky way that i use is to just put the sprites onto the game object and turn off the tilemap renderer for the layer that the rule tiles are one. Then the tiles won't show, but the objects attached to them appear to be the tile. That way if you destroy one, it doesn't look like it is still there even

#

That does of course mean that those tiles will need to be on a separate tilemap layer for it to work as expected

dusky wagon
#

Hm Im not sure if I want to do that. Its already annoying with two tilemaps as somehow the pallet always manages to draw on the tilemap I dont want to draw on at that point and I imagine it would be even worse with three tilemaps

dusky wagon
tepid drum
#

How can i AddVelocity to object that doesnt care about direction it will just the player to that direction

#

What is actually happening: it wont launch up it will launch to opposite or other direction

abstract olive
tepid drum
#

did it not working

abstract olive
#

That's so vague to the point I think you're just saying that to claim you tried.

dusky wagon
#

@tepid drum show what you tried, the concept itself will work

tepid drum
#

I tried to remake dani game called balls

dusky wagon
dusky wagon
#

@tepid drum if you want help, you have to provide this information

#

What does the second line in here work? I am having some problems as it sets the x velocity to a set amount each frame, but I want to change it.

            Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y);

m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing);
hot fog
#

hi so im currently making a cutscene and i want the material of my scene to change half way through how would i do something like that

snow willow
#

should be able to keyframe that material in either of those I think?

snow willow
#

maybe share your code?

#

none of this code rotates anything

#

you said your problem is your character is looking up

#

so I was looking for code that rotates the character

#

So sounds like your problem is in your animator I guess

fickle crypt
#

hello! im following some different tutorials and im trying to make a simple 2d game and at the player controller part im kinda stuck my character doesnt jump and idk if the grouncheck that i placed is good or not or if the code is badly done

hot fog
crisp narwhal
#

Hi, i need 2 box colliders on my sprite (one at the feet, and one for the body) but how can i reference these both in the script as GetComponant<BoxCollider2D>() doesnt specify which one

snow willow
#

it's also a bit more manageable if you put the colliders on two separate child GameObjects

#

Or use GetComponents<BoxCollider2D>() which returns an array of all of them

crisp narwhal
#

hm okay

#

i managed to get it working with an edge collider at the feet and box collider on body so that i cant wall jump when hugging the wall

#

but now if i clip from the underside of the box collider i cant jump or fall down

crisp narwhal
#

unless if i moved the side points of the edge collider to be like .1 inwards from the sides of the box collider making it an almost impossible occurance of the box collider being collided with from undernearth

#

but that seems a very cheated way to fix

nova bear
#

I have a boxcollider and it was previously set to a small sprite, but when I changed it to a larger sprite the boxcollider didn't change. I don't even remember changing it to that specific sprite. Is there a way to update my boxcollider?

grand coral
nova bear
#

oh i just realized

#

i made a formula to calculate boxcollider's extents using size

#

nvm i accidentally accessed boxcollider

grand coral
#

ah i see

#

well glad you solved the problem

nova bear
#

thank you for replying

#

i was taking a break but because of you I got back to focus and solved the problem

nova bear
#

im paranoid of c# not doing order of operations

#

should I just trust that it does

late viper
#

yes

dapper nova
#

You can add 2 params for the last x and y input

flint lagoon
#

Hi, I'm having trouble with scaling with screen sizes (in a 2D game). I would like to have the whole screen (not just the canvas) match the width/height of the screen (whichever is smaller), and the height/width to scale accordingly. I'm hoping this will cause the dimensions to be exact, which is important as it is a puzzle game. Is there any way to program this, or otherwise change a setting? Thank you in advance!

hollow talon
#

idk if this is a stupid question but how do u go about connecting animations like in my case qb throws ball reciever catches it

opal socket
hollow talon
#

so like make seperate animation with him catching then add ball

#

that feels like how u get ball teleporting

opal socket
#

You just deactivate gameobject (ball) when itโ€™s close enough

#

I donโ€™t know what game youโ€™re making and if itโ€™s a good a solution for you

#

But it is a solution

hollow talon
#

its an american football game

#

thats 2d

snow willow
#

You can use IK in 2D with Unity's 2D animation stuff

nova bear
#

is this what you mean? If not, reply to this message to specify the details of your issue.

#

If you want camera to display more, you can adjust its orthographicSize variable in inspector or in your code. The orthographicSize of a camera is half its height, and the size of the width depends on your screen display settings as shown above.

hollow talon
snow willow
#

Inverse kinematics

lusty belfry
#

I canโ€™t create new palette in tilemap. Click create but nothing changes?

outer wagon
abstract olive
hot fog
#

hi so my code works but it also doesn't because i want my player to walk into the trigger collider to enable the textbox but then when they press space it disappears however if they walk back again i dont want the text box to reappear but i dont know where else to put the if statement other than the update function

compact knoll
hot fog
#

how do i do that

dusky wagon
#

I have this code in my player movement script:

            Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y);

m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing);

And the problem is, that it sets the velocity every time it gets executed to a certain value. I want the player to move with another platforms, if he is standing on it. Since the velocity gets set to a certain value every fixed update, the way I would normally do it, by setting the player to be a child object of the platform, doesnt work. I tried adding the velocity of the platform to the velocity of the player each fixed update, but for some reason that makes the player always have an a lot higher velocity. Does anyone know why?

hot fog
#

@compact knoll

compact knoll
#

just getcomponent then set enabled to false for whichever component you want to disable

dusky wagon
#

This is how you disable a game object.

compact knoll
dusky wagon
#

Oh wait are we talking about a component here? My bad, sorry

compact knoll
dusky wagon
#

With velocity

#

If I move it with Vector2.MoveTowards, everything works fine

hot fog
compact knoll
#

I mean if that works, why not use it? or does the platform actually need correct physics for something?

compact knoll
dusky wagon
#

It does need physics, as I want the player to be pushed of if the platform goes under a wall, and that looks relatively with setting the position

compact knoll
#

your platform doesn't needs physics for the player to be pushed off, just the player needs physics for that

dusky wagon
#

Hm but the player seems to always be pushed into the ground a bit since the platform directly sets the position and then the physics push it out again

compact knoll
dusky wagon
#

Does it say anything about the player movement code anywere, or do I just go to the point called "the hard way"?

hot fog
compact knoll
compact knoll
dusky wagon
#

Hm looking at it, the first code block shown under that point is exactly what I tried to resolve my error, but it resulted into the error of the player always having a higher velocity than the platform, even when he isnt moving at all

hot fog
dusky wagon
#

boxCollider is a game object, not a component

hot fog
#

soooooo

compact knoll
# hot fog

if you are attempting to disable a Box Collider component, then your boxCollider needs to be of type BoxCollider2D not GameObject

hot fog
#

im very new to c# so idk what u mean

compact knoll
hot fog
#

dw i got it

#

i think

#

ayyyyy

#

thanks guys

dusky wagon
compact knoll
#

prevents the player object from sliding too much. whoever wrote the guide i linked said a friction value of 7 did the trick for them

#

i haven't actually tested it myself though so i can't confirm

dusky wagon
#

Yeah I guess I have to try that. I just thought that it wouldnt slide if it has the same velocity as the platform

hot fog
#

wait also how would i make a public string be able to use more than one line in unity

hot fog
#

ok nice that works thanks

#

no how would i disable a whole script

#

wait no

#

how would i disable one script in another script

abstract olive
#

Get a reference to the script, and set it as enabled = false;

#

Though, scripts should rarely have the authority to control other scripts in that manner.

drifting dock
#

hi anyone knows how to make this? i want to make a top down player that follows mouse , with something like Vector2.MoveTowards , the problem is i want it to be smooth like lets say if there is a wall on top of the player and the mouse clicking on the topside as well i want it to check the collision on top and if there is a wall there , then just ignore the Y input of the mouse and only do the X input , so it should not get stuck on the wall

#

i tried ray casting but it somehow doesn't work with this type of movement and get stuck on the wall

hot fog
ancient path
#

I mean itโ€™s what you tried

#

But A* project

#

Can work

drifting dock
#

(ignore that i forgot to change the last 4 playerX to playerY)

#

the only problem is i don't know how to write this function called place_free to find if the position is free (no collision)

hot fog
#

hi so im using brackeys topdown movement and animation system and when a text box appears i dont want to be able to move so i disable the movement script but when that happens my guy will carry on doing the running animation

hot fog
#

i still need help

turbid heart
#

show some code, you're in a code channel @hot fog We cant help if we dont know what you're doing

hot fog
#

bear in mind that the animator is on a different gameobject to the script

abstract olive
#

Do you not see the red errors in your script?

hot fog
#

Yeah

#

Doesnt mean ik how to fix them

abstract olive
#

Just curious why your initial question wasn't regarding them. When something doesn't work, it usually means you have bad code, so that's usually what you ask about.

#

First off, you need to provide a type to your variable. Notice how all your variables have three parts but your animator one only has two.

dusky wagon
dusky wagon
#

I got this error while trying out stuff, what does it mean?

nova bear
#

can I change the layer of a gameobject during runtime?

nova bear
#

amazing

#

i was getting nervous

snow willow
#

why lol

nova bear
#

there are some times I want an object to collide with it, and sometimes I want it to pass through

snow willow
nova bear
#

tyvm!

#

does this work?

flat imp
#

im just trying to have something move

#

i justw ant to move the objectt

#

why is this so hard

#

i tried using sprite
BoxCollider2D

none of them have a way to actually move their position i dont understand

#

this doesnt work either

snow willow
snow willow
# flat imp

Perhaps look at the error message and think about why it's giving you the error

snow willow
flat imp
#

ive done them before
im just doing it thhe same way i was taught

snow willow
#

There's a lot wrong with your script. Better to follow a tutorial

flat imp
#

i feel like crying

snow willow
#
  • Can't have public variables inside a method
  • BoxCollider2Ds don't have velocity
  • Even if they did you need a reference to an actual instance to use its methods/properties
flat imp
#

ive done tutorials before i dont know what is happening

snow willow
#

go back

#

do more

#

you didn't learn

#

try to understand what's happening in the tutorials as you do them

#

don't just blindly copy

flat imp
#

I HAVE BEEN TRYING TO UNDERSTAND

#

slow down

#

what is the object that the script is attatched to CALLED

#

i want to change its position

#

thats all im trying to do

#

i called the object goomba

#

but that doesnt seem to work either

snow willow
#

it doesn't matter what the name of the obejct is

flat imp
#

what is the thing that has a position for me to change

snow willow
#

you can access the GameObject that your script is attached to simply with gameObject

#

or its Transform simply with transform

snow willow
flat imp
#

gameobject doesnt have a transform

#

it doesnt have anything useful

late viper
#

small t

snow willow
#

no GameObject.

#

No capital T

#

and if you want to change the position you need to do transform.position = something;

late viper
#

(gameObject should work, but its redundant)

snow willow
#

because the Transform keeps track of position, rotation, and scale and other things too

hot fog
flat imp
#

its not helping

#

nothign is HERE

snow willow
# flat imp

that's correct, but it seems like you have other errors too

#

calm down a bit

#

go through the errors one by one

flat imp
#

the errors only help if i know what im doing

#

which i dont

#

which is why im asking for help

#

because the tutorials didnt teach me anything

snow willow
#

you're a bit scattershot is all

#

go through errors one by one

#

if you don't understand them

#

feel free to ask

flat imp
#

its not teling me what options i have within transform.position

#

do i need to ()

#

or .

snow willow
#

just cs transform.position = transform.position + Vector3.right * Time.deltaTime; for example

#

or transform.position = new Vector3(1, 2, 3);

#

ยฏ_(ใƒ„)_/ยฏ

#

you can assign it to anything you want

flat imp
#

im not allowed to access movespeed from update but it freaks out when i make the float public

nova bear
#

would this work?

snow willow
#

it will work, it's pretty weird though

nova bear
#

ok

#

i dont like making too many big variables like gameobject variables

#

or variables i wont use that much

snow willow
#

Find is super expensive

#

just fyi

nova bear
nova bear
snow willow
nova bear
#

or is there a way to go from script to parent of script?

flat imp
#

dont you initialize variables when the object is created though? why cant you do it in start??

snow willow
nova bear
#

you don't

#

start is just stuff you do before the game runs fr

snow willow
flat imp
#

well what do i do if i want it to be set once and not set again unless i change it

snow willow
#
public float MoveSpeed;

void Start() {
  MoveSpeed = 0.3f;
}```
#

for example

flat imp
#

OH

#

okie

nova bear
#

the object whose layer I'm changing is the one with the script changing it. Can I access the parent gameobject from the script without doing something like GameObject.Find();

flat imp
#

see where im from
if you set a variable that doesnt exist, that is declaring it

snow willow
#

or transform.parent.gameObject.layer = whatever; for the parent

snow willow
#

you have to declare your variables

flat imp
#

god if moving is going to be this complicated id hate to think how much harder this is going to get

nova bear
#

I have an object called object1, object1 has a script called script1
script1 tries to change object1's layer but has to access it using GameObject.Find();
script1 wants a cleaner, more lightweight way to access its parent object. How can script1 do this?

abstract olive
#

Movement is probably one of the hardest aspects of a game, to get it to feel good and work well with your design.

abstract olive
#

So if you can nail that down, you're in a good spot.

nova bear
#

one of my many scripts

flat imp
snow willow
#

Once you are familiar, it's a breeze

nova bear
#

^

#

once you get the basics down, you'll be able to tackle more complicated concepts in unity

#

and make your game richer

flat imp
#

alright it works

but i want to add this stuff to the position rather than setting it

but "+=" isnt allowed

nova bear
snow willow
#

you're replying to the code of how to do that

late viper
flat imp
#

it doesnt let me

snow willow
#

what happens

nova bear
snow willow
flat imp
snow willow
snow willow
#

doens't matter

flat imp
#

why doesnt it matter

snow willow
#

everything in Unity is 3d

flat imp
#

this is important

snow willow
#

there are no 2d games in Unity

nova bear
#

wait

snow willow
#

only 3d games with an orthographic camera and a side-on camera angle

flat imp
#

is vector 3 is required, why does vectore 2 EXIST

snow willow
nova bear
#

aren't transform and layer on the same level?

snow willow
nova bear
#

gameObject.transform and gameObject.layer

snow willow
#

if you really want to use those

late viper
#

vector3 isn't required, there just are various uses for Vector2/Vector3

snow willow
#

but I wouldn't

nova bear
#

I like using it to get my boxcollider's x and y extents

#

or for seeing how far a gameobject is from the other

snow willow
# flat imp is vector 3 is required, why does vectore 2 EXIST

the reason you're getting an error is because your code is essentially adding a Vector2 and a Vector3 and it doesn't know if it should convert the Vector3 to a Vector2 and then add, or if it should convert the Vector2 to a Vector3 and then add them

#

it's not about Vector2 "not being allowed"

#

so it's easier to just resolve the confusion by only using Vector3 in this case

flat imp
#

and why is this information made clear

snow willow
#

?

late viper
#

its clear if you are familiar with types

nova bear
#

does vector1 exist

#

lmao

snow willow
#

C#'s compiler error messages assume you are familiar with the workings of C#

snow willow
nova bear
#

ik

snow willow
#

in fact vector1 does exist in many languages, especially shader languages

nova bear
#

fr

#

weird

flat imp
snow willow
#

but the error you were just struggling with is a C# thing not a Unity thing

flat imp
#

i fixed it by this point

#

and the "scripting reference" doesnt help me find what im looking for
i need to know what im looking for in order to search for it

snow willow
#

that's what google is for ๐Ÿ˜›

#

and - you know - time and experience

flint lagoon
late viper
#

and tutorials

snow willow
#

you're not going to just know everything right away

flat imp
#

googling isnt always as magical as people say

snow willow
flint lagoon
snow willow
#

yeah

flint lagoon
#

Alright, thank you!

snow willow
#

or just check if Screen.width > screen.height

late viper
snow willow
frigid minnow
#

If I have two trigger colliders, how can I define which trigger collider is which when calling something like OnTriggerEnter2D ?

frigid minnow
#

Huh?

#

I mean if I have two trigger colliders on the same object

#

One for detecting vertical and one for detecting horizontal

#

How can I tell the script "if the horizontal trigger collider is triggered..."

late viper
snow willow
frigid minnow
#

That's what I'm doing but it seems like it's just pulling info from the other trigger collider anyways

#

Maybe I'm screwing something up

snow willow
#

if you want to detect the individual triggers

frigid minnow
#

Yeah that's what I'm doing

#

Hmmmmm

snow willow
#

if there's a script on the parent object, it will detect collider events from any child colliders

#

they should be siblings

frigid minnow
#

Right so I have a parent with two children both with their own trigger colliders and scripts

#

Oh well, guess I'll just keep looking for what the bug is

#

Haha

#

I thought it might've been that the script is pulling info from the wrong collider

#

For some reason I can't get the walls above or below to register collision

#

Something weird is happening

#

OH wait duh

#

I recoded this and forgot to take out a condition

#

Disregard

prime swift
#

I'm trying to make it so that when I enter a house trigger the roof tiles become transparent

#

I know that you can set individual tile's colors through their position, but how could I identify where all of the roof tiles are to mark them all transparent?

flat imp
#

i am already burnt out and ive been working for 3 hours
but if i dont do this again i'll forget everything

silver gust
#

any pointers on how to go about making a replay system that captures how the player dies and then save it to disk where if needed it can be viewed from the main menu?

candid bronze
#

Hello, I have tilemap and I want to simulate item drop "bounce" effect (like in stardew valley when you drop items and they bounce a bit). But the issues is how should object bounce of tilemap, it just falls right thru it... Any ideas?

nova bear
#

I have a script, it's attached to a gameobject and I want to modify that gameobject's layer without using a GameObject variable or calling GameObject.Find().gameObject.layer

#

How can I do this?

nova bear
#

wait

#

can I call gameObject.layer inside the same script that's attached?

snow willow
#

yes

nova bear
#

I can call gameObject?

#

wow

snow willow
#

that's the only place you can

nova bear
#

tysm!

snow willow
#

otherwise you need a reference

nova bear
#

my life is 100x easier now

#

if I have a OnCollisionEnter2D function, can I call it inside the script?

snow willow
#

Unity calls it for you when a collision happens

nova bear
#

i would call it if an object moves too much due to its velocity and skips over an object

#

i set it to be on top of the object, but it might not call until next frame so I'd just call it to get it over with

#

how do I determine the collision

#

like what should I put for the parameters

#

i'll just copy and paste the action

snow willow
#

it doesn't make sense to do this.

nova bear
#

ik i just like exploring possibilities

nova bear
#

I'm calling Random.Range(0, 1) but it never gives me 1. Why is that?

#

seriously, I even called it 6 times

#

doing a second test run on that

#

like six times at a time

#

wait actually the six times got called 26 times

snow willow
#

well documented too

#

0, 1 will only give you 0

nova bear
#

rip

#

(1, 2) - 1 would work though

snow willow
#

you have to do Random.Range(0, 2) if you want 0 or 1

nova bear
#

oh

#

ohhhh

#

exclusive

#

ty!

#

so (1, 21) would give numbers 1-20?

drifting escarp
nova bear
#

does HSV go by 0f-100f or 0f-1f?

snow willow
nova bear
#

oh ok thx

#

i was in the same docs

#

forgot to check parameters

#

it works! ty

elfin notch
#

Hello, I'm trying to implement a system where the player can illuminate the "closest" block to the light source, but then that block will cast shadows on ones behind it. Does anyone know how I could go about implementing this in a shader? It'd be nice to be able to pull the light level from the base, and then project it upwards.

hot fog
#

Ok so im using brackeys 2d topdown movement tutorial but the thing is if i press D to move right when i let go it will return to idle front instead of idle right

#

How do i change this

crisp narwhal
#

This is for a flat golf game (Top down i think theyre called)

#

how can i add friction within this code (Changing the velocity every frame)

chilly thorn
#

hey! so I am using a 2d mouse parallax script for some ui

#

it seems to work on scene view but it doesnt load on the game

abstract olive
#

What a weird thing to print to your console.

chilly thorn
#

O_O you didnt see that

abstract olive
#

Right.

#

Well first off, you're applying a new position to the gameobject twice, not sure why.

#

Secondly, what's the position of your camera?

crisp narwhal
chilly thorn
#

1 sec recompiling >_>

#

i just noticed tho that when i hover the bottom left colour it does appear massive on the right side

#

camera is at 0 1 0

abstract olive
#

You're setting the canvas to z:0 as well, which is exactly on the same plane as the camera.

#

Either move the camera back, or put the canvas forward a bit.

#

Or rather, use the z-value the canvas has in the editor you currently have it set to.

#

Since that seems to be the distance you want it to be, anyway.

chilly thorn
#

i tried setting it to the canvas (90) and it is the same thing

#

im trying the game object that they are currently in

abstract olive
#

It's whatever object your ParallaxUI script is on.

chilly thorn
#

it goes to -900 something

#

when played

abstract olive
#

Remove your gameObject.transform.position line all together, it's not doing anything useful.

#

Then add pz.z to the third parameter to your Vector3.

#

This won't fix it, but at the very least it'll clean up your code a bit.

#

In your above screenshot, where is your camera?

chilly thorn
#

third parameter intead of 0 correct

#

apologies if these are simple answers, im just a lowly artist haha

hot fog
#

guys im using brackeys top down 2d system but whenever i stop running it will go to idle down instead of idle the way i was running how do i change this

abstract olive
chilly thorn
#

oki

frigid minnow
#

Can a coroutine start a coroutine?

abstract olive
#

Yep

#

You can even yield to other coroutines to wait for them to finish before the code inside the previous coroutine continues.

#

Useful if you need to queue things sequentially, such as in a turn based game.

frigid minnow
#

Okie doke, cool

#

Trying to figure out why a coroutine is being called in Unity but not in the build

#

Okay the coroutine is being called

#

But the result is different

#

In Build:

#

In Unity:

snow willow
# frigid minnow

could be you have code that is framerate-dependent. In other words your game behaves differently depending on the current framerate

#

builds tend to have higher framerates because they don't have the overhead of the Unity editor itself

frigid minnow
#

Ooooh interesting, that makes sense

#

The code that raises and lowers the sprite happens on every frame

#

That's probably exactly what's going on

snow willow
#

yep

#

sounds like it

#

You can generally multiply things by Time.deltaTime to convert things that are "per frame" to be "per second" instead

#

which is the typical way to achieve framerate independence

frigid minnow
#

Yep that fixed it. :]

#

Also, how come I can't use Cursor.visible?

#

Was it changed?

snow willow
#

what happens when you try to use it

frigid minnow
late viper
frigid minnow
#

... ye

#

Haha

#

Crap

#

Alright well figured it out ๐Ÿ˜Œ

#

Literally the most helpful community I've ever come across, good stuff guys

formal smelt
#

Getting this error

snow willow
# formal smelt

seems like you're trying to access something called IsGrounded on an Animator.

#

Animator doesn't have a member called IsGrounded

#

so naturally it doesn't work

#

this is kind of like asking someone to show you the wheels on their surfboard

formal smelt
#

So I need to create an IsGrounded boolean inside of my code?

#

And wow you type fast, what wpm if I may ask?

snow willow
#

It depends on what you're actually trying to do

#

Maybe you're just trying to get IsGrounded from the wrong variable or something

formal smelt
#

I'm running this to set it to either true or false

#

I'm not really sure tbh

snow willow
formal smelt
#

Player Script

snow willow
#

that's the one that has the error

formal smelt
#

o yea that was the one I sent

#

I didn't get the number in the shot

snow willow
#

doesn't seem like it would cause the error you're seeing

formal smelt
#

weird

snow willow
#

would you mind showing some more context

#

maybe just the whole script

#

also make 100% sure you've saved any changes you've made to your script

formal smelt
#

yea

#

I've been ctrl + s a lot

snow willow
#

if you don't follow it the bot will delete your code

formal smelt
#

ohk thanks

snow willow
#

the code looks fine to me

#

do me a favor - select your script in the project window and look at the text preview that it shows in the inspector. Does the code look like it matches what you've sent me here? @formal smelt

formal smelt
#

hmm

#

i think its the same

#

U mean like vscode?

#

ok

#

this is the preivew

snow willow
formal smelt
#

wuts going on

snow willow
#

see wheerr it says anim.IsGrounded

formal smelt
#

yea

snow willow
#

that's what the error is about

#

and it's not in the code you sent earlier

formal smelt
#

oh

#

how come

snow willow
# formal smelt

Double click this script in the project window and see what opens up

#

I would guess you have multiple duplicate scripts by accident or something

#

idk

formal smelt
#

is this that?

snow willow
#

Press this Open button

formal smelt
#

ok

snow willow
#

and what does that open?

formal smelt
#

same code as the link

snow willow
#

can you show your console window? DO you have any other errors besides the one you shared?

#

FOr some reason Unity doesn't seem to be getting the up to date code from your file.

#

Also you can try restarting Unity.

formal smelt
snow willow
#

what's left after you clear?

formal smelt
#

o

#

only this one after clear

snow willow
#

try restarting Unity ๐Ÿค”

formal smelt
#

i did right before i sent u that

snow willow
#

also triple check that the file was saved in Visual Studio

#

Make sure there's no asterisk like this next to the filename

#

I've had bugs where ctrl+s in VS doesn't actually save the file for whatever reason

formal smelt
#

i did have that bug apparently

#

I just manually saved

#

now I can run the game but i get this error

snow willow
formal smelt
#

o

#

in the inspector?

snow willow
#

yeah

#

click on your player object

#

in the hierarchy window

#

the look at the inspector

#

you should see your script there, attached to the player

#

there are slots on it

#

you didn't drag the animator into its slot

formal smelt
#

hierarchy window?

snow willow
formal smelt
#

oo

snow willow
formal smelt
snow willow
#

scroll up

#

to your script

formal smelt
#

OOHHH

snow willow
#

also you have multiple copies of your Player Script on the player object

#

you should get rid of all but one of them

formal smelt
#

Ok i just did that now everything works

#

thank you very much kind person

potent lake
#

i have 3 objects in my game all with the same script getting sprites from a sprite atlas stored in a singleton "GameAssetManager"

Debug.Log(GameAssetManager.instance);
_sprites[0] = GameAssetManager.instance.entityAtlas.GetSprite("entities_" + spriteID);

2 of these objects find their sprites perfectly fine, but one cant seem to find the asset manager
even if I duplicate one of the working ones it cant find it
can someone please tell me what went wrong?

#

ok now i restarted unity none of them work rip

potent lake
#

sprites[0] = GameAssetManager.instance.entityAtlas.GetSprite("entities" + spriteID);

snow willow
#

Sorry it's obvious

#

ok so

#

Can you show the GameAssetManager script?

snow willow
#

dont need to show the script

#

you are running this code in Awake right?

potent lake
#

yep

snow willow
#

and in GameAssetMaanger, you're assigning instance = this in Awake()

potent lake
#

yep

snow willow
#

if one of your Animator scripts runs its Awake before GameAssetManager runs its Awake

#

instance isn't ready yet

potent lake
#

makes sense

snow willow
potent lake
#

ok

#

thank you so much lmao

wooden night
#

I am adding speed to my character with this line of code, but my character gets stuck on a flat tilemap randomly

        rigidbody2D.velocity = new Vector2(Input.GetAxis("Horizontal") * speed, rigidbody2D.velocity.y);
wooden night
#

also whole physics just stopped

#

is that normal?

dusky wagon
#

Can you show a screenshot of what you mean with the tilemap?

dusky wagon
#

Im trying to modify these two lines of code:

            Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y);

m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing);

And make it so that it doesnt take the entire x velocity of the player and changes it, but only the velocity that was added through this line.

craggy kite
dusky wagon
#

Currently when I add any velocity to the object it instantly gets damped down, but I only want this to damp the velocity that was added through this movement script

dusky wagon
craggy kite
#

You are overwriting the velocity right now. You should add it instead, I guess, if I understand correctly

wild pivot
#

Anyone have and idea on how I could find the position of the players mouse in 2d?

compact knoll
#

Camera.ScreenToWorldPoint(Input.mousePosition)

craggy kite
#

there you go

dusky wagon
#

I only want to overwrite the part of the velocity that is added by this script. tried storing the velocity in a variable, but it works until I walk against a wall, since then the velocity gets reduced

craggy kite
#

Okay, so right now your velocity is overwritten, what "part" do you want to overwrite instead of the whole velocity?

dusky wagon
#
Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y);

            m_tempVelocity = Vector3.SmoothDamp(new Vector2(lastVelocityX, m_Rigidbody2D.velocity.y), targetVelocity, ref m_Velocity, m_MovementSmoothing);
            m_Rigidbody2D.velocity = new Vector2 (m_Rigidbody2D.velocity.x - lastVelocityX + m_tempVelocity.x , m_Rigidbody2D.velocity.y);
            lastVelocityX = m_tempVelocity.x;

This is what I tried. I made a variable called lastVelocityX which always stores the velocity added by the script last time and takes that as the current velocity to damp from. It works until the player encounters anything that changes its velocity e.g.:
slopes, walls or custom abilities

#

@craggy kite do you have any idea? Ive been stuck on this for a while and I have no idea how I could do it

craggy kite
dusky wagon
#

Oh okay, of course you dont have to answer, especially when you are sick. But yes Im trying to only damp the velocity that is responsible for the movement and was added there, and not any velocity that was added through and other objects or scripts

craggy kite
dusky wagon
#
  1. Determine what part of the velocity was added through the movement script and not any other script.

  2. SmoothDamp the velocity determined in step 1.

  3. Overwrite the velocity from step 1 with the velocity of step 2 while leaving the rest of the velocity intact

#

@craggy kite

craggy kite
# dusky wagon <@144387642140655616>

Please dont mention me all the time ๐Ÿ˜‰ I come here when I got time. So what two vectors do you want to smoothdamp? The lastAdded to the new added Velocity?

hot fog
#

whenever my character moves left or right when it stops moving it will return to player idle down instead of player idle the way it was running. how do i fix this

abstract olive
#

You only have one player idle animation which the movement returns to.

hot fog
craggy kite
hot fog
#

ok now what

craggy kite
#

Im not an interactive tutorial ๐Ÿ˜„

hot fog
#

do i need to make a blend tree for them like my movement

abstract olive
#

Blend trees aren't really ideal for 2D animations.

craggy kite
#

You better check the tutorials on animator on youtube, there are dozens

hot fog
#

i have its literally a straight copy of brackeys 2d topdown movement but he leaves it like that

craggy kite
abstract olive
#

Right, 2D sprite animations. *