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

1 messages ยท Page 61 of 1

uneven stream
#

im moving it manually

snow willow
#

I suspect not

#

if you're modifying transform.position that will completely ignore the physics engine

#

or using transform.Translate

uneven stream
#

1 sec

#

transform.position

#

but i will need to rewrite the code?

#

or i can use physics with transform.position

spiral swan
# uneven stream or i can use physics with transform.position

You could use rigidbody velocity to move your character. Transform.Position basically ignores everything else with the only mission to move the exact amount that you told it to, so if zed amount was large enough it would run right through the colliders

uneven stream
#

wait

#

im sorry

#

i didn't used any script in the ball

#

i confused

snow willow
uneven stream
#

but if i don't

#

use transform*

#

what can be the problem

spiral swan
#

Can you send a video

#

@uneven stream

uneven stream
#

of

#

hmm

#

is there a way of verifying unity

#

idk why my unity just crashed and it isn't starting

#

man it's late here and my unity just broke

#

i will try tomorrow

#

im very sory

left canyon
#

if (enemySpawnerTilemap.GetTile(x, y) != null) anyone know why GetTile hates this?

#

"No overload method for GetTile takes 2 arguments" but anything i try to throw in for the z doesnt work

nova remnant
#

already tried that

#

it doesnt work

#

it just zooms off into infinity

#

Nvm i got it working

#

it was moving the camera beyond the scene

#

from z = -10 to z = 0

#

solved it by using a vector 3 with a fixed Z

limpid drift
#

could anyone help me out with a bullet script right now i shoots the wrong way and i think it has to do with this line of code

#
transform.position -= new Vector3(Mathf.Sign(Player.transform.position.x - transform.position.x) * Velocity, 0f, 0f);
spiral swan
#

Just inverse it

undone gorge
#

hello

#

what can i do to make my game's code smoother ?

abstract olive
#

Use the profiler to see where the bottlenecks are.

undone gorge
#

acctualy

#

the game was running at 20 fps

#

so

#

i set the targeted framerate to 60

#

works fine

#
  • adaptive performace
undone gorge
#

how can i reduce the loding time to load a scene

craggy kite
undone gorge
#

but

#

i resolve that problem by doing some weird shit

#

but my splash screen is not showing, but unity's is showing

#

why

#

instead of my splash image

#

there is a black screeeb

craggy kite
# undone gorge ok

Please try to not spam the chat with one word posts... you did say loading time. So is your scene showing or not? If there is no scene showing, you maybe did not set any to be build in the scene overview.

undone gorge
craggy kite
#

Okay, so where and how did you setup your splashscreen? @undone gorge

undone gorge
craggy kite
#

Virtual reality

undone gorge
craggy kite
#

You gotta add it to the logos list

undone gorge
#

what ?

#

i need to add a logo there ?

#

but ma game is not vr

undone gorge
#

how i can load lots of music tracks in my scene

#

without effecting load time ?

snow willow
#

instead of all up front

undone gorge
undone gorge
mossy fossil
#

hi

#

my animator does a strange thing

#

when going fromany state

#

to some animation

#

the play_hide bar is not moving

#

it just stays there like so

#

it starts

#

it changes the sprite to hiding

#

but doesnt play the animation

#

ok fixed it

#

i need to check trigger not bool

river sail
#

Hello

#

I'm currently doing a 2D platformer game and I need one last step to finish it off. When my enemy goes below a certain Y co-ordinate I need it to trigger my EndGame scene (I already have the code for)

#

I think my method is wrong but I dont know what to use

#

(Using c#)

ancient path
#

<=

#

intead of >=

#

because ^ is more than

river sail
#

I tried both and neither worked

#

Do you know how to use a delay

#

I tried invoke

ancient path
#

what about a coroutine

#

or a timer?

river sail
#

I don't know how to do either, I'm fairly new

ancient path
#

with an if statement checking if it bigger than the desired value

river sail
#

I've heard of it but I can't say I know how to incorporate it too well

ancient path
river sail
#

This is what i've got but it doesnt quite work obviously

ancient path
#

research for coroutines

#

they are very useful

river sail
#

Is there no way I could use time delta

ancient path
rancid moss
#
using System.Collections.Generic;
using UnityEngine;

public class CharacterMovement : MonoBehaviour
{
    public float moveSpeed = 5;
    private bool walking;

    private Rigidbody2D rb;
    private Animator anim;

    private Vector2 movement;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        anim = GetComponent<Animator>();

    }


    void Update()
    {
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");

        if (movement.x != 0 || movement.y != 0)
        {
            if (!walking)
            {
                walking = true;
                anim.SetBool("walking", true);
            }

            Move();


        }
        else
        {
            if (walking)
            {
                walking = false;
                anim.SetBool("walking", false);
            }
        }
    }

    private void Move()
    {
        anim.SetFloat("X", movement.x);
        anim.SetFloat("Y", movement.y);

        rb.MovePosition(rb.position + movement * Time.fixedDeltaTime);
    }
}
#

I cant get my 2d character to move with arrow keys could someone help me fix the script?

#

MissingComponentException: There is no 'Animator' attached to the "Front" game object, but a script is trying to access it.
You probably need to add a Animator to the game object "Front". Or your script needs to check if the component is attached before using it.
UnityEngine.Animator.SetFloat (System.String name, System.Single value) (at <753965d1225041ae90af37ef632f784e>:0)
CharacterMovement.Move () (at Assets/Animations/CharacterMovement.cs:52)
CharacterMovement.Update () (at Assets/Animations/CharacterMovement.cs:36)

hollow crown
#

As the error says:

You probably need to add a Animator to the game object "Front". Or your script needs to check if the component is attached before using it.

rancid moss
#

I added the animator but it only moved the scene screen not the actual character

#

nvm got it to work

rancid moss
#

Assets\Scripts\Player\PlayerMovement.cs(18,28): error CS0117: 'Input' does not contain a definition for 'getAxisRaw'

#

need help again

ancient path
#

is GetAxisRaw

#

capitalization

rancid moss
#

oh

#

works now

#

thx

ancient path
#

np

hollow crown
strange cove
#

so ive been trying to figure this out and my dash only works when i press space and left shift at the same time, how do i fix this? ```csharp
void Update()
{
horizontalMove = Input.GetAxis("Horizontal");
transform.Translate(Vector2.right * speed * Time.deltaTime * horizontalMove);

    if (Input.GetKeyDown(KeyCode.Space) && playerJumps < maxPlayerJumps && isGrounded)
    {
        playerJumps++;
        if (playerJumps == maxPlayerJumps)
        {
            isGrounded = false;
        }
        rb.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);

        Dash();
    }
}

void Dash()
{
    if (Input.GetKey(KeyCode.LeftShift))
    {
        rb.AddForce(Vector2.right * dashForce, ForceMode2D.Impulse);
    }
} ```
hollow crown
#

That's what your logic is saying

#

If you want it to only work when you are holding shift, then move Dash(); out of the enclosing if statement

blazing mica
#

I am trying to make directional particle system works in 2d space. The particle will instantiate on point A to point B, i cant really get my head around the rotation in the Particle System.

prime musk
turbid heart
#

i'm assuming here, since it's commented as "JUMP"

prime musk
turbid heart
#

I dont think it'll make a difference? I'm assuming you want the jump animation to play when you jump. double jump or not

#

so look at your own code, and see where your jump logic is, then add that there

turbid heart
prime musk
turbid heart
#

Your question is.. bizarre. Did you copy paste this code from somewhere?

turbid heart
#

So then why can't you pinpoint where the jump logic is?

prime musk
#

ok i'll try

turbid heart
# turbid heart

I believe I found it here anyway, so why can't you set the isJumping bool of your animator there?

prime musk
#

ok thanks for your help

prisma ocean
#

I'm currently making a ship building part for my game; I want to have a screen that pops up where you can see / edit the blueprint for your ship before going back to the real ship and building it. Should I / can I implement the blueprint mechanic in a second scene that is overlaid over the first scene?

#

not sure if that was clear

abstract olive
#

Yes, you can have multiple scenes stacked.

frigid minnow
#

Howdy folks. I'm trying to rip a sprite sheet on runtime and dynamically store them as sprites to use in the assets. Can someone tell me why what I'm doing is wrong?

#
   Sprite icon = Sprite.Create(spriteSheet, new Rect(50, 3, 7, 7), centeredPivot);
   AssetDatabase.AddObjectToAsset(icon, icon.texture);
#

I don't totally understand how sprites are stored, trying to add it to the texture here, which doesn't seem to yield any results beyond this:

#

I might just try to manage without doing this

#

Just wanted to know if there's actually a way of storing the created sprites

snow willow
# frigid minnow

It looks like your image is stored in the assets folder somewhere?

#

If you're loading a sprite at runtime it would prresumably come from outside the project folder(s)

#

and if you want to save it you'd save it in Application.persistentDataPath

#

However:

AssetDatabase``` is not something you will be able to use at runtime
#

that's an editor-only thing

frigid minnow
#

Gotcha, welp! I think at this stage I've decided that saving the sprites in that manner isn't really necessary; what I'm trying to do is basically dynamically create an animation set from a sprite sheet

#

I've run into an entirely different issue with that though

#

I have no clue at all how you're supposed to set a keyframe value using a sprite.

#

Because a Keyframe can only take two float values

#

One for time, and one for the actual value of the frame

#

No clue how Unity is pulling off the witchcraft that is just slapping some sprites into an animation

#

This ain't no float

prisma ocean
#

Say the dark blue walls (tile map) and white grid (quad) were supposed to be inside the frame (the light blue box) how would I make it so that anything outside of the box didn't render?

#

Is masks what I need to look up?

frigid minnow
snow willow
strange cove
#

Is there a way to check if a collision ends im trying to make a platform that destroys after a little bit of time but i want it to only destroy if the player is on the platform so i need to know if the player isnt on the platform anymore.

magic junco
fleet knot
#

Hello Comunity, i want to ask about loop,how to call method every X time? with systematic

frigid minnow
#
private void MyMethod(){
  //Do our stuff here.
  StartCoroutine(RepeatMethod(1));
}

IEnumerator RepeatMethod(float seconds){
  yield return new WaitForSeconds(seconds);
  MyMethod();
}
#

@fleet knot This should repeat MyMethod every 1 second

coral yarrow
#

Hey guys, I have a big problem that I've tried fixing for 3 days, basically my game has a tilemap (2d platformer) and the tilemap uses a polygon collider. I have some dropdown platform that use the PlatformEffector from unity. The two colliders (tilemap and platform) are perfectly alligned at the top, but everytime my player walks from the tilemap to the platform. He glitches. I looked online for solution to maybe merge the colliders but I cannot since one of them uses the effector. Does anybody have a clue on why it's doing this?

vestal rock
#

i need a 2d unity to dm me

opal socket
#

Itโ€™s program, it may have some trouble formulating words

dusk escarp
mossy fossil
#

Hi

#

I would need to know if it is possible to do something like this

#

the two green lines being connected to the two black circles

#

and when I move one of the circles

#

the green lines to move like this

#

without changing size

#

(I want to use it for hands)

craggy briar
#

Yeah, sebastian lague just posted a video the other day on that actually

mossy fossil
#

wait really ? ๐Ÿ˜„

#

really !

#

thanks

#

in case someone would also need it

gusty oyster
#

How to I detect if a 2D particle hit my 2D player?

#

oh nvm

#

it worked

prisma ocean
#

Anything on applying masks to quads or mesh renderers?

harsh hollow
#

Guys I have a question

#

It's not about coding

#

I'm making a 2d space shooter game

#

And I'm trying to add a wall so that my spaceship cant pass through

#

I tried to add the 2D collider, but it didnt block

#

What should I do?

snow willow
harsh hollow
#

I have BoxCollider2D attached on this wall

snow willow
#

e.g. no transform.position = or transform.Translate

ancient path
#

And have the wall rigidbody static

harsh hollow
#

I have the Rigidbody2D attached to the player, with body type = dynamic

snow willow
#

you have to move the ship via the Rigidbody2D

harsh hollow
#

And a collider2D on the player

#

which is the spaceship

snow willow
#

right you have to also move the ship with the Rigidbody though

harsh hollow
harsh hollow
snow willow
#

i mean

#

what I said

#

move the ship with the Rigidbody methods

#

not via the Transform

#

in your code

harsh hollow
#

Alright

#

Let me try

#

So basically

#

I ahve to get the rigidbody2D in the Start

#

Then in the code which I use to move the spaceship

#

So right now my code for moving is like this:

#

float Inputhorizontal = Input.GetAxis("Horizontal");
float Inputvertical = Input.GetAxis("Vertical");
transform.Translate(new Vector3(Inputhorizontal, Inputvertical, 0) * _speed * Time.deltaTime)

snow willow
#

yep - Translate is no bueno

#

it ignores physics

#

You have to either set rb.velocity

#

or use rb.MovePosition

#

in FixedUpdate()

#

or rb.AddForce

harsh hollow
#

Ok

#

I know the AddForce one

#

Thank you!

#

Ok if I dont use the Rigidbody2D

#

But I want to write in the coding

#

that the spaceship can't pass through a certain X

#

As if there's a wall there

#

How can I do it?

#

So it's like I have the wall with collider, and if my spaceship's OnTriggerEnter2D hits the wall's collider

#

What kind of code do I write so that the spaceship remains there even if I press the left arrow

snow willow
#

you'd have to do your own custom raycasting, find where the wall is, know your ship's physical extents, and only move your ship up to where the edge of the ship would touch teh wall and no further

#

the code is a bit more complicated

#

not that complicated though

harsh hollow
#

I'm trying to add a bool

#

And make the MoveLeft and MoveRight 2 different voids

#

So when the spaceship hits the wall, the bool _stopMovingLeft is true, and the spaceship can move towards right side

prisma ocean
#

Can I not make a simple tile asset? or does it have to be rule tile?

eager gyro
#

so in your update move you simple do cs if (Input.GetKey(KeyCode.D) && canTurnRight) or something

harsh hollow
#

Okay I added the rigidbody and found a script to move my spaceship with rigidbody

#

float Inputhorizontal = Input.GetAxis("Horizontal");
GetComponent<Rigidbody2D>().velocity = new Vector2(Inputhorizontal * _speed, 0.0f);

#

But why my spaceship still passes through the wall....

#

I even tried to Debug.Log if the collision has been detected

eager gyro
harsh hollow
#

Yeah I saw it, but I wanna try different methods

#

So I can learn more

eager gyro
#

raycasting is fundamental

harsh hollow
#

I know

eager gyro
#

you can also limit the transforms axis by certain range

harsh hollow
eager gyro
#

if you move left to right limit the X

#

etc

#

that's two things to learn right there

harsh hollow
#

Okay

#

Thanks

fierce cairn
#

yo i havent used unity in a while so i sorta forgot this but how do i change the time the animation starts and its speed within the unity animator

fierce cairn
#

yea

#

lemme show

eager gyro
#

click on the arrow transitioning one clip to another

fierce cairn
#

so thers 2 problems

#

first when i move just a little bit

eager gyro
#

speed is in the clip itself or you can use multiplier variable

fierce cairn
#

it startts at the wrong frame

#

so theres no step

#

second for sprinting i need to up the framerate

#

so how do i fix those two probs

eager gyro
#

screenshot your transition from idle to run or w/e

fierce cairn
#

thats the main anim

#

idle > playerrun

eager gyro
fierce cairn
#

wouldent they overlap

#

and prob create some really weird animation

fierce cairn
eager gyro
fierce cairn
#

is there a way to like

#

smooth between the two

#

or no

eager gyro
turbid heart
# fierce cairn

you can drag those bars, or open up settings to adjust numbers

eager gyro
#

the tab settings you can decrease more of the transition time yes but also moving bottom clip closer helps

fierce cairn
#

oh yeah srry

fierce cairn
#

like that entire thing is just one time

#

cuz ive been moving it closer very slightly lmao

eager gyro
fierce cairn
#

theres like very small movement bugs but i dont have enough ocd to need to fix that rn

#

overall its fine now

eager gyro
#

its better though?

fierce cairn
#

yeah

eager gyro
#

ok yeah, if you want smoother look into learning blend trees

fierce cairn
#

even the smallest movements are animated now

#

so yeah

fierce cairn
#

ill prob do that when i decide to fix the mini movement bugs

spring compass
#

is there a way to check on OnTriggerEnter2D if the object isnt colliding with anything? i want the same button press to have a different action depending on the object colliding or not

ancient path
#

you can use a collider cast

#

capsule cast
box cast
circle cast

spring compass
#

oh i forgot about that thanks

pale jasper
#

I still cant code movement ive tried using tutorials such as brackeys but it hasnt worked would anyone has like a movement test file i could use

turbid heart
pale jasper
#

i dont know what wrong

#

ive been working on this for the past week as a hobby

#

i feel like i am going insane like its a big joke i cant stop laughing

waxen citrus
#

help

#

ive never coded

turbid heart
turbid heart
waxen citrus
#

i have a hard time following videos

#

i prefer to have a class where i can ask questions

turbid heart
#

well then.. go to school and pay money

#

or you know, actually go through that and ask questions here?

waxen citrus
#

im 13

turbid heart
#

you'd know that if you went through the C# tutorial like I said, and not just glanced at how "oh, there's a video up top", it's not videos

#

it's interactive exercises where you read, and try out coding yourself

waxen citrus
#

okay

coral tusk
#

Hello, I am using Physics2D.CircleCast to check for collisions. It seems that it first checks from the right side of the object, then traces around the circle clockwise, causing first point of contact to be the right side in cramped spaces

#

How can I tell unity to start the collision check from another point (such as the bottom of the circle?

clear vector
#

how do i play a sound on a collisiion trigger in 2D?

turbid heart
clear vector
#

รถk

orchid pewter
#

how do i wait til an animation has finished playing?

orchid pewter
#

thank you loki

timber shore
#

The character moves automatically and I can't control where it does, I suspect it's prolly in this part of the script:

private void FixedUpdate() {
  float x = Input.GetAxisRaw("Horizontal");
  float y = Input.GetAxisRaw("Vertical");

  Vector3 moveDelta = new Vector3(1f, 1f, 0f);

  transform.localScale = new Vector3(-Mathf.Sign(x), 1f, 1f);

  transform.Translate(moveDelta * Time.deltaTime);
}```
compact knoll
#

also there is a good chance you probably don't want to be using transform.Translate for movement, unless you don't care about physics/collisions working correctly (or you are planning to implement your own collision detection)

alpine pumice
#

are there any up to date tutorials for 2D? It seems like a lot of the tutorials I'm finding were made before Unity included more 2D functionality to the engine.

subtle vessel
#

Off the top of my head, most of the 2d improvements were in rigged 2d animation, tilemaps, and the spriteshape tool. Physics and other basic functionality hasn't really changed.

atomic adder
#

I need helo with AI patroling

#

help*

#

it doesn't have errors but it has a seizure every time it plays

#

thats the code

alpine pumice
#

@subtle vessel I played around with unity about 6 years ago when 2D stuff wasn't that good. had to use an asset packaged called TK2D to do stuff like loading sprite sheets, animation, camera, etc.

#

now it looks like a lot of that functionality is built into Unity, but a lot of tutorials I'm finding don't show how to use that and instead rely on an outdated library to do 2D stuff or they use their own system

amber socket
#

I am trying to create a game that uses the right click button to hold and rotate the camera around an object in 2d.

My main issue is about having the camera not instantly switching around because of relative x positions.

Here is my current code:

//Camera Controls
        if (Input.GetMouseButtonDown(1) == true) //As soon as the mouse button is clicked.
        {
            pMousex = Camera.main.ScreenToWorldPoint(Input.mousePosition)[0];

        } else if (Input.GetMouseButton(1) == true) //The frame after. (when it is being held down)
        {
            mousex = Camera.main.ScreenToWorldPoint(Input.mousePosition)[0];

            player.transform.rotation = Quaternion.Euler(0, 0, cameraSensitivity*0.1f*(mousex - pMousex));
        } else if (Input.GetMouseButtonUp(1) == true) //As soon as the user lets go of the button.
        {

        }
#

I'm not currently sure as to what I should do so it starts off rotating from it's last set position

unborn sundial
#

Each call to Update() is a new frame. A single pass through Update() is always the same frame.

#

Within that call, "Input.GetMouseButton(1) == true" will always have the same value

#

If it is true, then the first "if" clause runs, the later ones won't because that's how if/else works

snow willow
unborn sundial
bold crown
#

how do i make an animation play when i am attatched to a wall? it keeps getting l stuck after i jump off of the wall instead of when i am on it

i have a transition from run anim to the wall anim which has conditions set as run = false and wall = true
i also have a transition from the jump anim which is wall = true

https://pastebin.com/AJED1jkr

brittle smelt
#

i'm trying to make a random generated towerd defense game i followed a tutorial on this code and everytime i started the game it displayed an argument out of range massage, how do i fix it?

vocal condor
#

Double clicking the error takes you to which line?

brittle smelt
vocal condor
#

Show the complete error in detail.

brittle smelt
#

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
MapGenerator.getBottomEdgeTiles () (at Assets/Script/MapGenerator.cs:38)
MapGenerator.generateMap () (at Assets/Script/MapGenerator.cs:59)
MapGenerator.Start () (at Assets/Script/MapGenerator.cs:17)

vocal condor
#

Map Generator line 38

brittle smelt
vocal condor
#

Which line is line 38?

brittle smelt
vocal condor
#

Eh?

#

Why 1 < mapWidth?

brittle smelt
#

it should have be i, i think

#

typo

vocal condor
#

Perhaps you meant i < mapWidth

brittle smelt
#

typo

#

thanks for the help

vocal condor
#

Did this solve the problem?

#

Cool ๐Ÿ‘

brittle smelt
still tendon
#

i got an error saying The referenced script (Unknown) on this Behaviour is missing. does anyone know how to fix

abstract olive
still tendon
#

The referenced script (Unknown) on this Behaviour is missing.

#

that is the error

abstract olive
#

Show your console

native hatch
#

show ss

still tendon
abstract olive
#

Your entire console.

still tendon
abstract olive
#

Jeez, as in, the entire window. What's with these partial screenshots, damn. The point is, to check if you've hidden compiler errors.

#

There's three buttons at the top right of the console. Is the first one disabled?

still tendon
#

clear or collapse

#

oh top right

#

no

abstract olive
#

Try removing the component and adding the script you want.

still tendon
#

k

#

didnt work

vocal condor
#

How'd you add it if it's missing?

#

Did the error change?

#

Ah cross posted...

still tendon
#

damn plagiarizing is hard

#

welp time to do what i came here to do

#

I added a dash script from YT and its not working

brittle smelt
#

How do i fix game object destroying it self even though there is no destroy function in the script?

turbid heart
turbid heart
brittle smelt
turbid heart
brittle smelt
#

i've tried

turbid heart
brittle smelt
turbid heart
brittle smelt
turbid heart
turbid heart
#

are you sure it's destroyed?

#

can you take a video and show what's happening?

still tendon
turbid heart
# still tendon wdym

have you ctrl+s? it needs to be saved before the code gets compiled. I see a dirty marker on the top, that's why I asked

still tendon
#

yeah

turbid heart
# still tendon yeah

then you're going to need to be more specific on what doesnt work. are there also any errors?

still tendon
#

nope

#

there is nothing wrong except that i added a shift dash code and it does not work at all

#

and i have no idea why

turbid heart
#

use Debug.Logs to check which of the conditions it's not fulfilling in the if statement

still tendon
#

is there something wrong with the script?

turbid heart
turbid heart
#

learn to debug it

#

use debug.logs. print values. check.

brittle smelt
still tendon
turbid heart
brittle smelt
turbid heart
earnest aspen
#

do anyone know a good asset/tool for 2D movement or character controller? , cuz most of them are more related to 3D

still tendon
#

Anyone help me with the Dash script that i added it doesn't really work or give any errors

still tendon
turbid heart
still tendon
#

does not exist in the current context

turbid heart
still tendon
#

.

fluid island
#

I'm having trouble adding a rigidbody2d. I added it in my script, no errors. However, when press the play button (to add the rigidbody2d), it adds it perfectly fine but skips ahead.

turbid heart
fluid island
#

It adds the rigidbody2d and like 3 seconds later, gravity takes over and it goes falling

fluid island
#

any clues?

eager gyro
fluid island
#

I don't think it's because of the amount, if I have just one it does the same.

fast gyro
#

if im making 2d animations in aseprite for unity, would i need to make all new files for each animation, jump, run, walk? or do i do it on new layers

orchid pewter
#

when i buy sprite sheets from the Unity store they are in 32x32 frames each frame of animation in its own image file @fast gyro

fast gyro
#

ok thanks

orchid pewter
#

even if they were all on the same image you would still have to slice the image file

fast gyro
#

you think it has to be 32x32?

#

@orchid pewter

compact knoll
fast gyro
#

ok thanks man

orchid pewter
carmine token
#

Hello, I'm trying to toggle the SpriteRenderer component of an array of 2D objects with a given tag. How can I change them collectively rather than connecting each individual renderer? An image of my script is attached

lament barn
#

heya, is there any way to change the alpha of a whole tilemap without going tile by tile with a foreach loop?

nova jungle
#

Simple question probably (I'm a beginner), but how would you get a character to collide with the border of the camera? Want to have something to prevent them from moving offscreen

turbid heart
#

Better way of doing the second method is to use some form of ViewportToWorldPoint or WorldToViewportPoint thing, where viewport is the coordinate of your camera's view

#

starts from 0,0 at bottom left. 1,1 at top right

nova jungle
#

The first method seems to work good enough, thanks!

#

Simplest solution seems to work the best for what I need for now.

blazing mica
#

Hi, I want to make a "rubber-band" like physics in my project, where a link will be connected to a fixed point, and an object at the end of the link. The link can be stretch or shrink based on the distance between the fixed point and the object. How can i do this

blazing mica
#

because when you put the Frequency too low, it has very little effect to control over their maximum distance too

ruby karma
#

the frequency?

blazing mica
#

ahh, I found what I wanted, which is DistanceJoint, but it does not have the elastic properties like SpringJoint, maybe I can combine them?

blazing mica
zenith snow
#

Guys, I am trying to make a function that lets me know if a tile at a certain position is in an island or it is connected to land.

This image is an example (it is procedurally generated). If a sand tile within the red circle is taken, it should say it is part of an island, the other tiles instead are part of land.

modest cargo
lament barn
#

but now ive come across a whole new problem

#

I'm using rule tiles in my project, and now that i have tiles that disappear when you touch them, id want them to blend in with the normal foreground

#

but i have no clue how to do that

orchid pewter
#

do you keep your tileset inside the same folder as your tile palettes?

lament barn
#

i do

orchid pewter
#

i'm trying to design a project layout

#

i'd look to peek at how the professionals do it

opal socket
#

You mean assets folders etc or something else?

#

If you mean folders, we donโ€™t have a special way to do it and itโ€™s hit or miss on professional projects xD

orchid pewter
#

a tiny desktop makes for an easy project

#

i'm trying to organize everything so whenever i want to update the game in the future its really simple

#

at the moment i'm working on folder layouts for tile palettes and a naming system

orchid pewter
#

i've been coding thinking that anim.GetCurrentAnimatorStateInfo(0).IsName would return a false output once it finished playing the animation haha oof

#

while not looping

#

you live and learn

exotic token
#

Hello! I am looking to create a way switch a bunch of tiles with other tiles via code.

My end goal is to make a sort of season effect. Eg. at one point tiles are grass, and another time snowy.

What would be the best approach to this problem?

exotic token
#

Iโ€™ve seen that, but I donโ€™t know if this would be the best solution. As it would require a bunch of if statements for each type of tile?

#

Actually, I think this may work if I have both the snowy and grass tiles with the near identical names (maybe like โ€œgrass0โ€ and โ€œsnow0โ€). So then I will be able to get the name of the tile and replace it with the other tile

hoary ginkgo
#

Any reason why a jitter between two gameobjects on collision would randomly start occurring? Everything was smooth until now.

#

Well, I went in a changed my camera to fixed update and it fixed not sure why after 100s of hours of developement this issue just started

orchid pewter
#

doesn't the pixel perfect camera stop jittering movements?

honest glen
mossy fossil
#

ok so i found the tut

#

sort of

still tendon
#

part of my pixel art is cut off(the sun) anyone know why

orchid pewter
#

is it possible to do this "if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 1)" but for a specific animation not just whatever animation is currently playing?

opal socket
meager mural
#

I'd say this is pretty clean

abstract olive
#

What is your experience in making anything with Unity?

tight wraith
#

If i have a sprite with multiple colliders on it how can i detect which collider collided with something?

snow willow
final prism
#

Hope a small picture is alright. I'm looking to create a similar 2D map for a project, ideally something I can position sprites around and handle mouse interactions. Anyone have any suggestions on how to approach this?

Trying to avoid the Tilemap if I can, it's a bit much and doesn't provide the seperator lines between the tiles at runtime anyway.

covert whale
# final prism Hope a small picture is alright. I'm looking to create a similar 2D map for a pr...

i'd personally use the tilemap and have the sprites have a faint white outline so that it looks like the grid, but if you really don't want a tilemap then i'd do an executeineditor script that has a field for the size of the grid, the size of each tile and a prefab for the default tile then do something like

[pseudo code]
for(i = width)
{
   for(j = height)
   {
         Vector3 position = new Vector3(i * tileSize, j*tileSize);
          Instantiate(tilePrefab, position);
    }
}
#

for this to work u'd have to have the size of tilePrefab the same as tileSize, and only have this script run once so disable the script after the firs time it runs so that u don't have lots of tiles

#

then u could manually change out the sprites for whatever tile u want

#

and it would be neater to have all tile objects under one parent so assign that when the tile is instantiated

blazing mica
#

For detect and interacting with items in 2D, which way is more preferable?

A) Raycast
B) An Invisible TriggerCollider as detection

What are the pros and cons of using this 2 methods?

placid briar
#

help whenever my 2d character is supposed to run infinitely but keeps on stopping on the way like there is sth invisible blocking
Its being animated and root motion is turned off and i have frozen the z rotation on the rigidbody.

orchid pewter
#

is there a way to check if a specific animation is playing not just if an animation is playing?

grand coral
placid briar
#

already solved it

#

thnx

grand coral
#

oh ok awesome

placid briar
#

i was using a polygon colllider that got left behind

#

by the player\

frigid minnow
#

Hey, so, when I create a sprite using Sprite.Create(...), how might I go about saving that to the assets in-editor?

#

Is it possible with AssetDatabase.CreateAsset?

#

As far as I'm aware, you need a file extension for that, right?

#

Can you just use .asset?

#

Actually, it seems like "yes" is the answer

frigid minnow
#

Alright, so I've encountered an odd bug

#

Basically, I've created a script that will rip a texture into separate sprites, then save the sprites, then compile the sprites into animations, and finally an animation controller

#

For some reason, though, the resulting animations have some weird behavior

#

Particularly, each generated animation will only play the first frame, unless you do this:

#

I assume this refreshes the animation or something and establishes that these frames actually exist

#

But you can't just do this once

#

This happens every the game is played

#

Just locks up on the first frame until you move the keyframes back to where they actually go

#

Dunno

#

The problem also doesn't get fixed by restarting Unity

#

Somehow something just isn't interpreting the presence of the keyframes until I manually set them

#

The animation preview in editor also gets locked up on the first frame until I do the above, but in play mode, it needs to be done again

#

So I can't even just replace the frames in the editor and be done with it

chrome grove
#

Has anyone done 2D Topdown lighting?

#

I guess that of similar of say, ALTTP. But rather then the shadows being baked into the sprites themselves, they're dynamic?

orchid pewter
#

maybe you could fake it with a shadow layer

#

@chrome grove

chrome grove
orchid pewter
crisp narwhal
#

Is there a simple way to make the camera be the perfect size to fit for example 10 tiles by 10 tiles without cutting halfway through a tile at the side

snow willow
#

and then the width is based on your resolution aspect ratio

crisp narwhal
#

Yea i cant find a balance idk if im being dumb

snow willow
#

so if you want to set the width properly you'll need to do a little math with the aspect ratio

crisp narwhal
#

a ill try tomorrow again ig its been a couple days out of frustration lol

snow willow
#

the math is fairly straightforward:
aspect ratio: AR
height: H
width: W

AR = H / W
W * AR = H
W = H / AR
also
H = AR * W

#

So if you want the width to be 10, then you do:
H = AR * 10

#

aka just multiply the aspect ratio by 10 and that's the orthographic size to set to the camera

crisp narwhal
#

width and height are in tiles as its unit right

snow willow
#

they're in units

#

aka meters

#

if your tiles are 1x1 then yes

crisp narwhal
#

ah okay

prisma ocean
#

How would I apply a prefab to a tile that isn't a rule tile? particularly during run time

prisma ocean
#

Or would I just make a rule tile?

strange cove
#

anyone know why this wont decrease the enemys health? ```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour
{
public float health;

private Bullet bulletScript;

void Start()
{
    bulletScript = FindObjectOfType<Bullet>();
}

private void OnCollisionEnter2D(Collision2D other)
{
    if (other.gameObject.tag == "Bullet")
    {
        TakeDamage();
    }
}

void TakeDamage()
{
    health -= bulletScript.damageAmount;
    if (health <= 0)
    {
        gameObject.SetActive(false);
    }
}

} ```

hollow crown
#

Add some logs or use the debugger to see what's being called

hollow stratus
#

vertx you gotta try a little man

hollow crown
#

They do.

strange cove
hollow stratus
#

on the enemy?

strange cove
#

yes

hollow stratus
#

other.TakeDamage()?

#

I don't see that

hollow crown
#

This code is on the Enemy

#

other is the bullet.

hollow stratus
#

haha I'm an idiot

#

sorry dude

strange cove
#

yea

hollow crown
#

Also, the logic for getting the bullet seems flawed. This would only work if there was only one bullet. You should be getting the bullet component from other.gameObject

hollow stratus
#

is damageamount a property?

hollow stratus
#

you might need to do damageamount()

strange cove
#

of

hollow crown
#

Or, you should inverse all this logic as Master Bronze Elite implicitly suggests, and have the bullet handle dealing damage to the things it hits (via an interface perhaps)

hollow stratus
#

you need to put parantheses

#

if it's a property

hollow crown
# strange cove ?

"?" is unhelpful. If you have a question about what I wrote, ask it.

hollow stratus
#

make damageamount this

public void DamageAmount()
{
   return damageAmount;
}

then call it using

bullet.DamageAmount();

#

try that

hollow crown
#

Not sure how that changes anything

hollow stratus
#

he said it's a property but I don't see him calling it with parentheses

strange cove
hollow crown
#

Properties are not called like methods

strange cove
hollow crown
#

It's likely a field, but regardless, if it was a property it's still invoked the same

#

It's not an attribute. All of this is irrelevant anyway. You haven't debugged whether any of this is being called at all

hollow stratus
#

wait can I just see your bullet code?

#

post that

strange cove
#

yea

#
using UnityEngine;

public class Bullet : MonoBehaviour
{
    public float speed;
    public float damageAmount = 1.0f;

    [HideInInspector] Enemy enemyScript;

    void Start()
    {
        enemyScript = FindObjectOfType<Enemy>();
    }

    void Update()
    {
        transform.Translate(Vector2.right * Time.deltaTime * speed);
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            Debug.Log("Destroyed First");
            Destroy(this.gameObject);
        }
    }
} ```
hollow crown
#

Because you are moving the bullet via its transform it's likely not interacting with the physics engine at all, and the physics messages will not be called.

strange cove
hollow stratus
#
private void OnCollisionEnter2D(Collision2D other)
    {
        Debug.Log("Step 1");
        if (other.gameObject.tag == "Bullet")
        {
            Debug.Log("Step 2");
            TakeDamage();
        }
    }
#

^do that

#

then tell me what you see in console

#

if you don't get either

hollow stratus
#

no in the first script u sent

#

enemy

#

just add those 2 debug lines

hollow crown
strange cove
#

alright

#

ill try his first

#

it says step 1 first

#

but when the game runs it does

hollow stratus
#

wdym

#

so it only appears when the game starts?

strange cove
#

yes

hollow stratus
#

is there a number to the right of it?

#

that gets bigger

strange cove
#

because its out of the if other.gameobject.tag == "Bullet

hollow stratus
#

yeah that's intentional

#

to test both parts

strange cove
#

Also i never see step 2 when i shoot it

hollow stratus
#

is there a number to the right of it though

#

the step 1

#

or no number at all

#

^ like the 8 there

strange cove
#

no

#

it just says Step 1

hollow stratus
#

are you shooting it multiple times?

#

or just once?

strange cove
#

2

#

1

hollow stratus
#

21 times?

strange cove
#

1

hollow stratus
#

shoot it multiple times see if more step 1's pop up

strange cove
#

i dont see anything when i shoot it twice

hollow stratus
#

oh

#

check if your bullet even has its tag set correctly

strange cove
#

it does

hollow stratus
#

and make sure it's capitalized the same way

#

is it spelled Bullet exactly?

#

same capitilization?

strange cove
#

yes

hollow stratus
#

hmmm

#

oh

#

try changing the oncollisionenter

#

to a ontriggerenter

#
OnTriggerEnter2D(Collider2D other)
#

I think it may not be colliding with the bullet

#

it's probably just colliding with another random object

#

and on your hitbox component

#

check the "is trigger"

#

also make sure everything has a collider on it

#

the bullet and enemy

strange cove
#

it doesnt even collide with the enemy

#

the bullet is also a trigger

#

nvm the enemy falls through the ground

#

because it has a rb

hollow stratus
#

does your bullet's ontriggerenter work?

strange cove
#

wdym?

hollow stratus
#

like does it destroy itself

#

after touching the enemy

strange cove
#

Yes

hollow stratus
#

does your bullet have a rigidbody?

strange cove
hollow stratus
#

I think for oncollision to work it needs a rigidbody

#

because it needs to collide with something physics related

strange cove
#

but the bullet destoryed when the enemy wasnt a trigger

hollow stratus
#

because ontriggerenter doesn't require a rigidbody

#

but oncollision does

#

pretty sure

snow willow
#

onTriggerEnter needs at least one of the objects to have a Rigidbody

#

the Rigidbody can be kinematic if you want though

hollow stratus
#

oh yeah that's right

strange cove
#

so i gave the bullet a rb and made the gravity 0 and it collides with the enemy but still doesnt decrease the health

snow willow
#

and for OnCollisionEnter at least one of the obejcts needs a dynamic RIgidbody (not kinematic)

hollow stratus
strange cove
#

no

hollow stratus
#

can I see the tag you have

#

on the bullet

strange cove
#

wait yea

hollow stratus
#

just screenshot

strange cove
#

it does

hollow stratus
#

oh nice

strange cove
#

but then i get a nullrefrenceexeption for takedamage

snow willow
#

then it's working

snow willow
#

but that's no longer related to the collision code

hollow stratus
#

that means bulletscript is null

#

probably

strange cove
#

but im confused cause it looks right and seems right to me

snow willow
#

I don't understand why you have a bulletScript reference on your ENemy class

#

that makes little sense

strange cove
#

so i can acess the damageamount

hollow stratus
#

yeah I was confused too because his system should be flipped

#

but I went with it

#

lmao

snow willow
hollow stratus
#

ok add this in front of your code

#

[SerializeField] private Bullet bulletScript;

snow willow
#

let the bullet handle its own damage and tell the enemy how much damage it took

strange cove
#

uhhhhhhh i have alot of questions what is trygetcomponent and out

hollow stratus
#

then run your game and check bulletScript

#

you should be able to see it on the right when you click on the enemy

#

if it says "none" then you found the problem

snow willow
#

same thing basically

strange cove
#

uh

#

im doing a 2d game not 3

#

3d

snow willow
#

so?

strange cove
#

u used oncollisonenter

snow willow
#

ok fixed

strange cove
#

doesnt work with 2d

snow willow
#

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

#

it's fixed now

strange cove
#

so that goes on my enemy?

snow willow
#

nop

#

it goes on your bullet

#

it just does this:
when you collide with something, check if the thing you collided with has an Enemy script on it

strange cove
#

i would need a refrence to my enemy script

snow willow
#

if it does, apply damage to it

#

The code is getting the reference to the enemy script

#

right there

#

Enemy collidedEnemy = col.collider.GetComponent<Enemy>();

#

it's grabbing it from the collision

#

this is the right way to get a reference for a collision

hollow stratus
#

alright blue you help him I had my go at it already ๐Ÿ˜†

snow willow
#

Then you just change your TakeDamage function on the enemy so it takes a parameter:

    public void TakeDamage(float amount)
    {
        health -= amount;
        if (health <= 0)
        {
            gameObject.SetActive(false);
        }
    }```
#

boom done

#

no weird references to worry about

#

(and make it public)

strange cove
#

OnCollsionEnter2D is red

snow willow
#

why

strange cove
#

it says Method Must Have A Return Type

snow willow
#

yeah you forgot to write void

#

but wait were you using OnTriggerEnter2D?

#

and that was working?

#

you should use that if that was working

strange cove
#

yes

hollow stratus
#

the issue was a null

snow willow
#
void OnTriggerEnter2D(Collider2D col) {
  Enemy collidedEnemy = col.GetComponent<Enemy>();
  if (collidedEnemy != null) {
    collidedEnemy.TakeDamage(this.damageAmount);
  }
}```
hollow stratus
#

I think bulletscript was null

vocal condor
#

null

snow willow
#

oh sorry

#

I'm trying to type too fast

hollow stratus
#

what you should do for referencing is just to assign them before you run the game IMO

snow willow
#

disagree

#

in this case you should absolutely be grabbing the reference from the collision

vocal condor
#

Copy pasting will cause a lot of potential issues; which I'm assuming he's doing due to previous return type issue.

snow willow
#

nothing else makes sense for a projectile hitting a target

hollow stratus
#

actually what you should do is just put the damageamount in the bullet code

#

and do

other.damageAmount

#

instead of having a separate bulletscript thing

strange cove
#

im confused ill just figure it out tmrw

hollow stratus
#

lol good luck

full light
#

Hi I wanted to ask how I could detect objects in 2D (Im making an endless runner and I want to make it so that there is a chance to spawn powerups in empty lanes)

vocal condor
hollow crown
full light
#

Ok sry

glad wagon
#

hi would anyone be able to help me? my aim is to have triangle prefabs (enemies) spawn just outside the "screen" and as they spawn they would move across the screen. So if they spawn on the right they must leave on the opposite side that being the left (vice versa) An approach i have thought about is; 1. Identify the area the enemies can spawn from (probably need to know screen size) 2. Instantiate the prefab 3. Move the prefab

jolly narwhal
#

Sounds like a good approach, go for it

glad wagon
vagrant nexus
#

you can turn a screen position into a world position by using yourCam.ScreenToWorldPoint(0, 0); // would be the bottom left of the screen in worldspace and yourCam.ScreenToWorldPoint(Screen.width, Screen.height); // would be the top right of the screen in worldspace, where "yourCam" is whatever reference you have to the camera

#

you could then use these two points to calculate the X positions of the left and right spawn, as well as the Y range they are allowed to spawn at

placid briar
#

im trying to make a 2d shooter game and i want to make the character to be able to shoot while running
but these are 2 diff animations
how do i go about it
?
is there like a spine for 2d characters

glad wagon
# vagrant nexus you can turn a screen position into a world position by using `yourCam.ScreenToW...

ohh ok thanks, would i also be able to do something like this? i used this code to set the boundaries of the screen for my player object so that it couldnt go outside it ```cs
private float minX, maxX, minY, maxY;
private float playerRadius;

// Start is called before the first frame update
void Start()
{
    float camDistance = Vector3.Distance (transform.position, Camera.main.transform.position);
    Vector2 bottomCorner = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, camDistance));
    Vector2 topCorner = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, camDistance));
    
    CircleCollider2D playerCollider = GetComponent<CircleCollider2D>();
    playerRadius = playerCollider.bounds.extents.x;

    minX = bottomCorner.x + playerRadius;
    maxX = topCorner.x - playerRadius;
    minY = bottomCorner.y + playerRadius;
    maxY = topCorner.y - playerRadius;
}

void Update()
{
// current position
Vector3 pos = transform.position;

    // horizontal constraint
    if (pos.x < minX) pos.x = minX; 
    if (pos.x > maxX) pos.x = maxX;

    // vertical contraint
    if (pos.y < minY) pos.y = minY;
    if (pos.y > maxY) pos.y = maxY;

    // update position
    transform.position = pos;

}```

vagrant nexus
#

yes you could easily reuse a lot of this code, its basically the same logic

#

you just take the corner positions, grab their X value, and thats the left and right of the screen

#

so you could just subtract or add some to that X value to make them spawn a little offscreen

vagrant nexus
#

there should be a 2D rigging package in the package manager that you can import, but it takes quite a bit of setup and decent animating skills to really get the hang of

#

there are some tutorials online

#

if it's hand animated at the moment though, there would be no real way to do it without making a new animation that has both attacking and running hand-animated as a new animation

prisma ocean
#

I want to implement a construction mechanic where if you hold the button down on a tile then it "constructs" it, similar to the mechanic in space engineers. Is there a way to apply a prefab to a generated tile that isn't a ruletile during runtime or should I look at making a "tile" class and an instance for every tile, that could then be accessed from a dictionary based on where I'm clicking?

visual shell
#

        float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
        
        
        
        transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);```
how can i stop the revolver from going all the way back like this? I want it to flip and be right side up when it passes over the head
vagrant nexus
#

if the rotZ + offset is over a certain amount, you flip the spriterenderer on the Y

#

as in, you use the FlipY property

#

it might just be rotZ, I dont really know what your offset var represents

visual shell
#

offset is just in case the sprite doesnt line up

#

it doesnt do much

vagrant nexus
#

alright, well what I said still applies, just without the + offset

visual shell
#

sth like this?

vagrant nexus
#

well it would be like

renderer.flipY = rotZ > 90f || rotZ < -90f;
#

I dont know if those values would work though, not sure

visual shell
#

i tested them, they should work

vagrant nexus
#

then go for it

visual shell
#

ight lets see

vagrant nexus
#

but the thing is that

#

you might be missing a negative sign

#

because if its greater than 90 OR less than 90, thats basically always true unless its exactly 90

visual shell
#

oh yeah sorry i missed the negative

#

it works like a charm though

#

thanks m8

vagrant nexus
#

alright sweet!

#

np

dusky wagon
#

Can someone help me figure out a concept for a rail? I have a rail component that has two arrays of transforms. One if the object is coming from the forward direction, and one if it is coming from the backwards direction. When an object hits the rail, I want it to follow the rail, depending on where it landed and which direction it is heading. My main problem is to figure out at which transform in the array it should continue. My idea was to add a direction parameter as wheel as an index in the array to the array, but I am not sure, how to figure out which transform is the next one that the object should travel to

#

Here is a rail as an example. The yellow things are its transforms in the array and the white thing is the rail itself

chrome grove
#

How do you guys handle shadows? If I make them transparent, I BELIEVE the left will happen, but obviously, the right would be preferred.

dapper zinc
#

Hey Folks, i try to create a puddle from a huge rain drop on a floor in 2D Space. The puddle is the sub emitter of the raindrop particle system. The problem is, that the puddle appears above the collision ( on the centerpoint of the drop). I dont use a shape on the sub emitter. Is there any good way make the puddle appear on the intersection of the collision ?

dusky wagon
mossy fossil
fleet knot
#

Hello Community ,i want to ask Something again how to ignore game object parent transform rotation?, or just make Child object transform always in 0,especially Z axis

#

Thanks before

turbid heart
strange cove
#

what is the better way of doing movement instead of transform.translate?

turbid heart
strange cove
turbid heart
#

you'll need physics based movement if you want your player to respect colliders

strange cove
fleet knot
finite garden
#

If I change the position of an object emitting a trail, will the trail lead from it's old location to new location?

turbid heart
finite garden
#

I'm changing my bullets from projectiles to raytracing and wanted to keep the "tracer" effect

#

so my plan is to instantiate the tracer object at the gun barrel and then just move it to hit.point

finite garden
#

yeah, i'm half asleep right now. don't mind me

turbid heart
#

again, you should probably test that yourself since you have the means to do so pretty much set up already

#

it's a bit too specific for someone to have the answer to right off the bat. unless you wait a bit

finite garden
#

I'll give it a test, was hoping someone might have known already but no worries :3 i have it all set up on my end

subtle vessel
finite garden
#

well, originally i wanted projectiles but it proved to be impractical for both the players, and for balance

subtle vessel
#

hitscan weapons are fine

#

if that works better for your game

finite garden
#

i thought it would, but it doesn't. The type of game it is vs the projectile system makes the gameplay stale when someone outguns you because their projectiles move faster

#

once taking into consideration the firerate of certain guns and the damage they deal over range, it makes no sense to me to keep a projectile system

vocal condor
#

Cross posting is against #๐Ÿ“–โ”ƒcode-of-conduct. We know you'll receive faster support but it's not acceptable and cause folks to respond/answer already answered questions.

frank wedge
#

hey quick question, is there a good way to trigger Invoke() with a keyframe instead of a time?

#

I'm trying to sync up an attack sweeping animation with a hit detector

frank wedge
#

ah i've never actually used those before

#

i'm really new to unity

turbid heart
#

well, it sounds like it's exactly what you're looking for ๐Ÿ™‚

frank wedge
#

ye it is, how does one use it?

frank wedge
#

pog thx

#

omg it was so easy

#

i love unity

#

here i was trying to calculate the exact number of frames between point a and point b

lunar quiver
#

what can i use for simple movment, no jumping. just up down left right

turbid heart
lunar quiver
#

heres the thing, i dont know how to code

lunar quiver
#

i have this code just to move a circle sprite, but when i use wasd it wont move, can anyone help?

compact knoll
lunar quiver
#

so i thought i added the script to it already

#

turns out i didnt

#

but when i try to add it

#

it says "cannot add script because script class couldnt be found"

compact knoll
#

make sure the file name and the class name are exactly the same, it is case sensitive. make sure there are also no errors in your console

lunar quiver
#

so my sprite is labeled as "Player" and the script is called "PlayerMovment"

#

i have no idea where to find script class

compact knoll
#

your class is named movement2D

lunar quiver
#

so do i rename it that?

compact knoll
#

either rename that to the same name as the script file or rename the file to movement2D

lunar quiver
#

wait wait wait, file? what file?

compact knoll
#

the script, it is a file on your computer. it has a name that you said is PlayerMovment

lunar quiver
#

so do i rename it in unity or do i have to go into the file?

compact knoll
#

whichever is easier for you because renaming it in unity is renaming the file

lunar quiver
#

ok

#

thanks it works now

#

sorry if i was a bother, i havent used the program in years

compact knoll
#

no worries. i do recommend maybe brushing up on C# using the tutorials linked in the pins of #๐Ÿ’ปโ”ƒcode-beginner
those tutorials should go over what each part of the script is and how to spot common syntax errors.
also make sure you set up your IDE using the steps linked in #854851968446365696

lunar quiver
#

oh now i have a new problem

#

so still wasd doesnt work

#

even after all that

lapis sundial
lunar quiver
#

my sprite wont move

lapis sundial
compact knoll
compact knoll
compact knoll
#

can you show a screenshot of your rigidbody2d settings on the sprite object?

lapis sundial
compact knoll
#

uncheck the x and y boxes in the constraints. those are literally freezing the position on that axis

lunar quiver
#

right

#

there we go

#

thank you guys for all your help

lunar quiver
#

what is a script i can use for my camera to follow my sprite?

ancient path
#

cinemachine

lunar quiver
#

i tried that, but it wont show up

#

nevermind

#

so cinemachine is not what i need

#

it like pulls on my sprite

#

like rubber

#

it wont let me go anywhere

compact knoll
# lunar quiver so cinemachine is not what i need

cinemachine is exactly what you want unless you want to write your own script for camera movement. You can set the sprite object as the follow target for the vcam. You can modify the body properties to get the follow effect that you prefer

lunar quiver
#

then how do i fix my sprite not being able to move a far distance?

compact knoll
#

are you certain the sprite is being stopped by the cinemachine camera?

lunar quiver
#

waitr

#

im so confused

#

i have it set to follow player

#

but it wont

#

i just want to do a script

#

i hate cinemachine

compact knoll
#

i think you may be confusing the soft zone for it not following/doing what you want. change the soft zone width and height to 0 and it will always have your player centered in the camera

lunar quiver
#

where is softzone?

compact knoll
#

in the body settings for the vcam

lunar quiver
#

nope

#

doesnt work

compact knoll
#

you need to be much more specific than just "doesn't work"

lunar quiver
#

so i have a cube just off screen

#

if the cam follows the sprite

#

then it should show the cube

#

but everytime i move

#

i know for a fact my camera isnt following the sprite because the cube never shows up

compact knoll
#

if you manually move the camera in the editor, does it show the cube in game view? because it may not actually be able to see it if it does not

lunar quiver
#

ive move the cube

#

and in game view it shows up

#

will it be easier if i just show my screen?

compact knoll
#

a screenshot or something that shows what is happening would probably help clear this up

lunar quiver
#

i can prob do a video

#

would that help?

ancient path
lunar quiver
#

sorry i cant do a mp4

ancient path
#

you can just change the file type manually

lunar quiver
#

really?

ancient path
#

yes

lunar quiver
#

wait

ancient path
#

it doesnt corrupt these files

knotty barn
#

@lunar quiver If you are in OBS, there's a remux feature to change it to mp4

lunar quiver
#

ok

#

ill be right back

compact knoll
#

your video shows that your camera is clearly not following the player so it just isn't set up right

lunar quiver
#

ok

#

cani have help setting it up right?

ancient path
#

yes

#

thats whats this server is for

lunar quiver
#

ok

compact knoll
#

show your vcam settings and your main camera settings

lunar quiver
#

my vcam settings

#

my camera settings

compact knoll
#

your main camera doesn't have the cinemachinebrain on it and it looks like you are using a 3d vcam

lunar quiver
#

well i clicked 2d

compact knoll
#

remove the vcam from your scene then right click your hierarchy and go to Cinemachine > 2D Camera. it will add the cinemachine vcam to the scene and should automatically add the brain to the main camera

lunar quiver
#

oh wait

#

my bad

#

cinemachinebrain is on my main camera

#

i just didnt get it

#

into frame

compact knoll
#

you sure about that? also the camera you showed a screenshot of isn't even tagged as MainCamera

lunar quiver
#

oh yeah

#

i was in a panic and accidentally deleted main camera so i had to put a new one

#

uh