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

1 messages ยท Page 39 of 1

warped viper
#

Then it will only divide it in the display not in the actual data right?

distant pecan
#

goldText.text = $"Gold Coins: {data.gold / 1000}K";

hybrid yoke
#

correct

warped viper
#

Why huh

#

I

#

I'll try that

hybrid yoke
#

might need parentheses not sure

#

or just use gabriel's interpolated string

warped viper
#

Noice

#

Thanks guys

#

This saved me from spending an evening figuring this out

#

Umh, I might wanna show one decimal tho

#

If it's not too much, like how to change it to show 1.1k 1.2k

hybrid yoke
#

make it a decimal instead of an int

#

then look up how to round with Math() or something else

#

in C#

#

(data.gold / 1000).ToString("0.0")

#

if gold is switched back to a double or decimal

dapper otter
#

hi guys I'm currently facing a problem. I'm trying to make a dash for my character but it's in conflict with the movement script

#

whenever Dash() is executed, it doesn't do anything because the velocity x is used by the movement

#

is there a workaround for this?

lofty wigeon
narrow jacinth
#

can i have a screenshoot of your rigidbody2D set up?

narrow jacinth
# dapper otter

I'd do a boolean isDashing, and if the Dash btn is pressed, call the code in fizedUpdate, else, use the one you already have (movement)

dapper otter
dusty python
#

for some reason i can't get 2d raycast to work, it just ignores colliders

narrow jacinth
brazen halo
#

If you get only nulls, (and you believe it should be working), debug draw the raycast to see how it actually looks. You can use Gizmos.drawline for that.

#

If the line actually shows that you hit the collider, your issue is with layers or physics.layer collision settings

#

if the line is wrong, you setup the raycast wrong

dusty python
#

huh, there's something wrong with the references or something in the raycast line

narrow jacinth
#

it is a long code? could youshare?

dusty python
#

wait no its in the next line where i try to log the name of the collider

narrow jacinth
#

mean it didnt collide

#

Satiris' option is good to see where are you shooting your ray

dusty python
#

i checked it before and it shoots in a needed length and direction

narrow jacinth
#

can you put the debug line after the "if" and remove the comparteTag wall? and show me

dusty python
#

god dammit, why does the solution always needs to be so painfully simple

#

ughh the wall object was just on -8 on z axis

#

now it works

lean estuary
#

@narrow jacinth Don't post off-topic media

narrow jacinth
#

gtk

dapper otter
#

oh hello another quick question. How do I access non static variables from a different script in my project?

#

Ik there's t he GetComponent thing but I don't really understand the namespace

brazen halo
#

you can, [SerializeField] ScriptName scriptName assign it in the editor, and then access it:
scriptName.VariableName, assuming the VariableName variable is public.

dapper otter
#

the second scriptName I can name it anything right

#

ScriptName is my actual script name

#

I'm assuming

brazen halo
#

ScriptName is the actual script name, like Player

dapper otter
#

ah got it

brazen halo
#

scriptName can be anything, but it's good to name it the same, I guess

dapper otter
#

also what does SerializeField do

brazen halo
#

serializes private field

#

so it can be assigned in the editor

#

like this

dapper otter
#

ohh gotcha

#

I put this under Start() and it's giving me error that I need a bracket?

bright bluff
#

the SerializeField can't be in the void start it needs to be above it

dapper otter
#

I get this error whenever it's above it

bright bluff
#

what I did instead of searializeField is using public

brazen halo
#

show whole class

bright bluff
#

what is playerMovement ? is it a gameObject a script something else ?

dapper otter
#

oh wait

#

nvm it works

#

when I run

#

LOL

#

thanks guys

bright bluff
#

Nice XD

dapper otter
#

sangry why's coding so hard

bright bluff
#

idk I'm still trying to make multiplayer work well but I keep finding problems

dapper otter
#

I

#

I got another problem

#

I'm using velocity to make my character walk

#

whenever the D or A key is pressed

#

I'm also using velocity to make the character dash

#

but the two velocities conflict with each other, so I made it whenever J is pressed, the velocity movement isn't used

#

but there's a really big delay for when that happens so my dash isn't instant

#

anyone know how i can solve this

terse thorn
#

i have a quick question, if my object is rotated 90 degrees (to the left) ho i make it move to his local Y position + 3 game units so the object will fly to the front of where it is aiming, im currently using this:


    target = new Vector2(transform.localPosition.x, transform.localPosition.y + 3);
  }

void Update(){

    transform.position = Vector2.MoveTowards(transform.position, target, speed * Time.deltaTime);

    if(transform.position.x == target.x && transform.position.y == target.y){

      DestroyProjectile();
    }
}```
#

but what seems to happen is that the object i want to move is just flying upwards while his target is the left because the object that instantiated it made it point the left

hollow crown
#

transform.position += transform.up * 3; would move 3 units in the direction that its local y is pointing

terse thorn
#

wait

#

i tested it and is not what i want

#

i want it to increase his local Y position

#

each frame

hollow crown
#

then multiply it by Time.deltaTime

terse thorn
#

ok

hollow crown
#

if you actually want it to move in local space then transform.localPosition += new Vector3(0, 3 * Time.deltaTime, 0);

terse thorn
#

it works thank you

novel harbor
#

Please help me find mistake on code

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GameManager : MonoBehaviour
{

    public GameObject PlayerPrefab;
    public GameObject GameCanvas;
    public GameObject SceneCamera;

    private void Awake()
    {
        GameCanvas.SetActive(true);
    }


    public void SpawnPlayer()
    {
        float randomValue = Random.Range(-2f, 2f);

        PhotonNetwork.Instantiate(this.PlayerPrefab.name, new Vector2(this.transform.position.x * randomValue, this.transform.position.y), Quaternion.identity, 0);
        GameCanvas.SetActive(false);
        


    }



}``````

This random thing spawns that falls into nothingness.
rotund imp
#

I have a question

#

where can I find a source that can teach me how add movement to my character? (wasd)

rotund imp
#

I couldn't find what I wanted

#

on youtube

abstract olive
#

Well nobody here is going to be your personal secretary until you find what you want.

#

There are countless tutorials on the internet to handle movement.

#

Any one of them would be more than enough. Saying that none of them suit your needs is just ignorant.

rotund imp
#

alr thanks

abstract olive
#

If you have specific questions regarding implementation of them, after the fact, then you're welcome to ask for help.

#

But at least make an effort.

rapid wagon
#

Hey, does anyone know how to make it so that the player character only does something each time you push a button, and it doesn't repeat as long as you hold the button down?

rapid wagon
#

Okay, thanks!

terse thorn
#

np

digital fjord
#

Hi, I have a question, how to make 2d randomly generated world with tilemaps on different layers, or if it's not possible on 1 layer?

distant pecan
#

there's a lot of ways you can do it, a lot of algorithms to use

#

after having the logic you'll just make a script to loop through your generated map and put it in the tilemap

#

here's how i did it

#

maybe it will be helpful to you

#

the way it works: firstly it generates a random "noise", then it fills the close noises and remove the distant ones, expand it, detect rooms and connect in a way all of them are connected

#

and the end result

#

also it can generate using a seed, this way the map generation would be the same if the seed is the same

digital fjord
#

Thank you so much, that exactly what I was looking for UnityChanCheer

boreal jetty
#

hey i need a code with a charactercontroller 2d for an endless runner and i need an automatic Map generator

snow willow
#

Get writing!

abstract olive
boreal jetty
snow willow
#

Someone generously sharing their work

boreal jetty
#

i can do all and let me ask!

long dagger
#
using System.Collections.Generic;
using UnityEngine;

public class NoteScorer : MonoBehaviour
{
    private int playerScore;
    public int perfect = 5, great = 3, almost = 1, miss = 0;
    public int CalculateScore(float noteScore)  
{

        if (noteScore > -.4f)
        {
            Debug.Log("Almost");
            playerScore = almost;

       }
        else if (noteScore > -.2f)
        {
            Debug.Log("Great");
            playerScore = great;
        }
        else
        {
            Debug.Log("Perfect");
            playerScore = perfect;
        }

        return playerScore;
    }
}```
#

My ddr game keeps calculating scores as almost than the other scores. I don't know why

#

The notes are moving sideways

abstract olive
#

Debug the noteScore value coming into CalculateScore to see what it's giving you.

#

Also, you probably want to do do playerScore += almost; so that your variable accumulates.

long dagger
#

Should I do += for great as well?

#

And the CalculateScore is part of the activator script so the activator knows when it collides with the note, calculating the input as the given score

snow willow
#

"Perfect" will run only if the score is less than or equal to -0.4 with this code

long dagger
#

I should switch the values then?

snow willow
#

do you think that would help?

#

can you express in english first what you want to do?

#

that might help with writing the code

long dagger
#

I want the code to essentially show a score when a note is destroyed by the activator. Depending on how close the note is to the center of the activator, I want it to show whether the button input was almost, great, perfect or a miss

snow willow
#

yes but

#

let's get into the details of the score analysis

#

you have a number right?

#

What's the valid range of that number

#

seems like it can at least be negative?

#

is it like -1 to 0?

long dagger
#

The activator has an x position of -19. I want the note to print a score whether it is dead center to it or close. I tried implementing values that are close and went from there, but it still prints as almost

snow willow
#

ok be precise though

#

this is code we're talking about

#

something like

#

"If it is less than -1, it's a miss"
"If it's closer than -1, but less then -4, it's an Almost"

#

etc..

long dagger
#

if (noteScore < -24, it would be great)

#
using System.Collections.Generic;
using UnityEngine;

public class Activator : MonoBehaviour
{

    public KeyCode key;
    bool active = false;
    GameObject Note;
    private float arrowLocation, activatorLocation;
    private float noteScore;
    public int playerOneScore;
    public int playerNumber, damageToDeal;
    public bool playerOneHit;

    public DamageScript damageScript;
    public NoteScorer noteScorer;


    // Start is called before the first frame update

    void Start()
    {
        activatorLocation = this.transform.position.x;
        //Debug.Log(this.name);

    }

    // Update is called once per frame
    void Update()
    {

        if (Input.GetKeyDown(key) && active)
        {

            arrowLocation = Note.transform.position.x;


            Destroy(Note);
            noteScore = Mathf.Abs(activatorLocation - arrowLocation);

        if(playerNumber == 1)
        {
            damageScript.playerOneDamage = true;
            damageScript.playerOneScore = noteScorer.CalculateScore(noteScore);
        }

            //Debug.Log("Player One did " + playerOneScore + " damage");
        }


    }

    void OnTriggerEnter2D (Collider2D col)
    {
        active = true;

        if (col.gameObject.tag == "Note")

            Note = col.gameObject;

    }

    void OnTriggerExit2D(Collider2D col)
    {
        active = false;
    }


}
#

As a reference, this is the activator code that calls the NoteScorer

still tendon
#

where can i create pixel art for unity?

#

which program or app?

snow willow
still tendon
#

ok thx

snow willow
#

at least seems good to an amateur like me ;D

still tendon
#

well...

tulip saffron
#

Ok i have a nooby question coming in. It's basically my first day of unity but I can't figure this out.

tulip saffron
#

This is about the 2D physics engine. I have gravity set to the default, -9.81, and a rigidbody with a mass of 1. When I apply a force of 9.81N upwards, the block moves upwards even though the net force should be 0. Can anyone explain why this is or if i'm just doing something stupid?

snow willow
#

In Update?

#

FixedUpdate?

tulip saffron
#

yeah in void Update()

snow willow
#

Use FixedUpdate for physics

still tendon
snow willow
#

the game engine applies gravity once every FixedUpdate

tulip saffron
#

Oh I see

snow willow
#

Update runs a lot more frequently

#

depending on your framerate

snow willow
#

I'm never tried it personally

tulip saffron
#

That works for me. Thanks so much

long dagger
still tendon
#

i downloaded a png file but i cant add it to unity?

snow willow
snow willow
still tendon
#

but i made an animation and now its just a photo how to make it an animation?

snow willow
#
Unity Learn

Sprite Animations are animation clips that are created for 2D assets. There are various ways to create Sprite Animations. One way is to create them from a Sprite Sheet, a collection of Sprites arranged in a grid. The Sprites are then compiled into an Animation Clip that will play each Sprite in order to create the animation, much like a flipbook...

still tendon
#

it says : unaplied import setting

snow willow
#

apply it ๐Ÿ˜„

still tendon
#

but then it dissapears

rotund imp
#

what is the difference between sorting layer and order layer?

snow willow
#

order in layer controls sorting within a single sorting layer

rotund imp
#

ohh

#

does that mean it's mainly used for animations?

snow willow
#

to be honest I haven't played with that stuff much

#

idk what people use it for

#

I could imagine something like - let's say a multiplayer game

#

all the "players" are on a certain layer

#

but your character is always sorted within that layer to draw on top of everyone else

#

so you can see yourself

#

that kinda thing I imagine

rotund imp
#

alr thanks for the help

still tendon
rotund imp
#

me a *

still tendon
#

i can screenshare

rotund imp
still tendon
#

yes

rotund imp
#

And do you know how to use them

still tendon
#

but i want to animate a sprite

rotund imp
#

can you call me on discord?

still tendon
#

yes

still tendon
#

soo how can i make a pixel art not blurry ?

lean estuary
still tendon
#

well that not solved my problem

lean estuary
#

@still tendon Why are you pinging me? You didn't post any problem. You asked about pixel art I pointed you to resources.

still tendon
#

i just want to know how to unblurry something not 10 page of stuff

#

how to make it not blurry?

snow willow
#

Sometimes the answer to your question doesn't fit into a single tweet

still tendon
#

well i got it filter mode

still tendon
#

how can u make your camera move with your character?

#

help please

#

fore some reason the seconds "position" is marked as an error in visual studio but it should work

still tendon
#

oh

#

ye works when i swapped spawnlocation to a transform ty homie

still tendon
#

can i get a script for moving in 2d?

lean estuary
still tendon
lean estuary
#

Have you tried learning from them?

still tendon
#

well my character is falling with 20000km/h right now

tulip saffron
#

Hi, this is probably an obvious question but I can't find a simple answer. I have 2 circle sprites in my 2d world and in one of my scripts I can select the rigidbody of the component its applied to, but how can i select another rigidbody in the scene?

turbid wasp
#

I'm not going insane right?
This should only become true when the box is coming in contact with an object on the "Walkable" Layer defined in the Inspector?

public LayerMask walkable;
    public void GroundCheck() 
    {
        isGrounded = Physics2D.OverlapBox(groundCheckPosition.position, new Vector2(box_X, box_Y), walkable);

    }
tulip saffron
#

Awesome, cheers.

heavy gale
#

Uh guys?

RaycastHit2D does not detect a hit if the target object slides into the ray?

#
    {
        proximity = Physics2D.Raycast(enemyCollider.bounds.center, transform.right, 12.5f, playerLayerMask);
        return proximity.collider != null;
    }```
snow willow
#

it will be a problem with some combination of the parameters you're passing in and the setup of your scene

#

e.g. is the ray origin at the right place and in the right direction?
Are the objects in the right place to get hit by the ray and in the correct layers (and do they have colliders?)

slate parrot
#

I have an OnTriggerExit2D that's not calling

#

The enter does, but not the exit

snow willow
slate parrot
#

No

#

OnEnter, some text appears. On exit, it should go away

snow willow
#

Did you Debug.Log to make sure the code is running

slate parrot
#

I put a Debug.Log() and it logs the enter, but not the exit

#

Yeahh

snow willow
#

show code?

slate parrot
#

Sure

heavy gale
slate parrot
#

Enter:

        if (trigger.gameObject.name == "triggerDetector")
        {
            Debug.Log("Enter");
            triggerText.SetActive(true);
        }

Exit:

if (trigger.gameObject.name == "triggerDetector")
        {
            Debug.Log("Exit");
            triggerText.SetActive(false);
        }
snow willow
heavy gale
#

every frame

#

not even in FixedUpdate

snow willow
#

the ray is not really something that can be "slid into"

#

it's just a query that happens immediately when you call it

#

so somethign is just not set up right

snow willow
heavy gale
#

hmmm
Thanks for the tip

slate parrot
#

Where? Still inside the void, but just outside the if?

snow willow
#

void is the return type of your method. But yes inside the method/function and outside the if

slate parrot
#

Ok

heavy gale
slate parrot
#

Nothing happens

heavy gale
#

Had the check nested in flip()

snow willow
slate parrot
#

The text that shows up when you enter works, but when you exit the trigger, that text is supposed to go away. It worked before, but suddenly stopped

snow willow
#

the text doesn't happen to be the same object that has the collider or a parent of it, does it?

slate parrot
#

No

#

OMG

#

I FOUND OUT WHY! The TriggerEnter is 2D, as it should be. The Exit, however, isn't!

snow willow
#

yeah

#

share the whole function next time ๐Ÿ˜„

slate parrot
#

I don't know how that happened, but. Huh

slate parrot
#

lmao well thanks for your time

blazing narwhal
#

hi, i have a problem trying to instantiate a "prefab". And it is that after coding it I can see the correct behavior of the "prefab" in the scene, but in "game" nothing is seen. Can someone help me?

warped viper
#

Does everything needs to be in the same public void Update() or can create more and they'll function as one in the same script?

heavy gale
#

The prefab object and the in-scene object will work differently

#

If that is the issue, simply apply the modifications to the prefab by either opening the prefab or right clicking on modification/component-> apply

#

What would be the best way to find if my player is to the left of to the right of my player?

blazing narwhal
# heavy gale If that is the issue, simply apply the modifications to the prefab by either ope...

Thanks for answering, but no, that is not the problem, when I put the "prefab" in the scene manually, in the "Game" window I can see it without problems and when I give Play the "prefab" will move with the behavior that I have programmed. But those that are programmed in the Spawn are not instantiated on the screen,
but if I can see them behaving correctly in the scene screen. I divide into 2 seeing the same "Scene" and "Game" and in "Scene" everything works correctly, but in "Game" the "prefabs" are not instantiated.

heavy gale
#

Is instantiation of the prefab dependent on the gameObject present at start?

#

Did you give the right reference?

#

The reference for instantiation should be the prefab in your assets window

#

not the hierarchy window

blazing narwhal
heavy gale
#

Then i'm out of ideas dude, can't help ya

still tendon
#

rb.AddForce(new Vector2(dash, 0), ForceMode2D.Force);

#

how do i make it go opposite way

heavy gale
#

-dash(minus dash)

still tendon
#

@heavy gale thx

heavy gale
#

np

abstract olive
#

@blazing narwhal Don't cross-post.

blazing narwhal
gray iron
#

Why isnt my Character Moving? i used the Same Script and it used to work, now i added a different Sprite, made some Animations and when i wanted to use this Script he just wasnt moving

using UnityEngine;

public class BasicMovement : MonoBehaviour
{
    public float MovementSpeed = 1;
    private void Start()
    {
        
    }

    private void Update()
    {
        var movement = Input.GetAxis("Horizontal");
        transform.position += new Vector3(movement, 0, 0) * Time.deltaTime * MovementSpeed;
    }
}
snow willow
#

Try disabling the animator to see

gray iron
#

well how do i figure that out? i got no animations assigned as far as i know

snow willow
#

disable the Animator on your character

#

and see if movement works again

gray iron
#

its disabled

snow willow
#

and?

gray iron
snow willow
#

ok is it working?

gray iron
#

still nothing sadly

snow willow
#

ok then your problem is not that

#

is your movement code running

#

use Debug.Log to find out

gray iron
#

yeah one sec

snow willow
#

then if it's running, check movement speed, check the input values, etc...

#

also do you have a CharacterController

#

or Rigidbody?

gray iron
#

Rigidbody yes

snow willow
#

of course fix all compile errors first...

gray iron
#

nah that happened when i added Debug.log

#

lmao

rotund imp
#

So I have a question, I am watching a tutorial video and the guy shows us how to make the bird that we are making fall, I know how to do this and I decided to try it by my self instead of watching that part and I used box colliders (2d) and rigid body, it didn't work so I watched the video and the tutorial guy used polygon collider instead of box collider because the bird it's an oval. What I don't understand is why doesn't the box collider work? Why do we especially need polygon colliders for ovals?

#

I hope you understood my question

spring adder
#

Itโ€™s hard to say without knowing how it didnโ€™t work.

heavy gale
#

A collider diff is definitely not a problem, check layer interaction in edit->project settings

snow willow
#

you can make it whatever shape you want

rotund imp
snow willow
#

what didn't work

rotund imp
#

instead it worked in the polygon

snow willow
#

define "didn't work"

rotund imp
#

the bird didn't land on the ground

#

it went through

snow willow
#

Did you use a BoxCollider

#

or a BoxCollider2D?

rotund imp
#

2d

snow willow
#

Then the only difference is the shape

#

if it went through it would be because it was set as a trigger

#

or on a layer that didn't collide with ground

rotund imp
#

alr thanks for the help

narrow halo
#

Can anyone help me figure out why this is throwing an error?

'Collider2D[] hitColliders = Physics2D.OverlapCircle(Vector2 currentExplodePoint, float radius);

#

"syntax error ',' expected"

#
Collider2D[] hitColliders = Physics2D.OverlapCircle(currentExplodePoint, radius);

will give me a Cannot implicitly convert a UnityEngine.Collider2D to Collider2D[]

#

nevermind, the Google came thru;
https://answers.unity.com/questions/1261957/cannot-create-a-2d-collider-array.html

Physics2D.OverlapCircle only returns one Collider2D. That's why the error. Use OverlapCircleAll, which returns the desired array of Collider2Ds, which is probably what you intended to do

rotund imp
#

What is the difference between these 2 codes? and which one is better?

Vector3 newPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = new Vector3(newPosition.x, newPosition.y) ;

Vector2 newPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = newPosition ;

snow willow
#

the second one is sensible

rotund imp
snow willow
#

definitely

#

it's shorter

#

easier to read

#

and probably faster too

#

since you don't have to call the Vector3 contructor

rotund imp
#

I have done a better code than the tutorial guy that I was watching ๐Ÿ˜Ž

#

Thanks for the help

still tendon
#

freezing rotation on a square?

magic rivet
#

    // Update is called once per frame
    void Update()
    {
        Debug.Log(Circle.position);``` so im trying to debug.log the position of a circle thats moving but it gives an error "the variable circle of camerafollow has not been assigned"
#

camerafollow is the name of my script

abstract olive
#

Have you assigned a transform to Circle? It's literally telling you that's what you haven't done, if you read the error.

magic rivet
slate parrot
#

So, public means it can be reached from other scripts, right? So, I should be able to reach a function from one script, from inside a different one, right?

abstract olive
#

Generally speaking, yes.

slate parrot
#

So I don't get why I can't reference an IEnumerator from a different script. I've referenced variables before, but never a function, so I'm not too sure how it works

snow willow
#

keeping in mind that generally if you have a function that returns an IEnumerator it's probably a coroutine

slate parrot
#

Well yeah, it's a coroutine I'm trying to run from a different script. If x happens, run this coroutine

snow willow
#

ok

#

so what happens when you do that

#

compile error? Runtime error? Nothing happens?

#

Are you just calling the function, or are you calling it with StartCoroutine?

slate parrot
#

I tried referencing it like a static variable, example:


ScriptName.FunctionName

That's how static variables are reached, but that's not happening with the coroutine

snow willow
#

Well a coroutine is afunction

#

you call functions with ()

#

The ohnly time you really reference a function without the () is when you're doing delegates which is a more advanced topic

#

but beyond that

slate parrot
#

An object reference is required for the non-static field, method, or property 'FoodSpawn.RandomSpawn()' [Assembly-CSharp]csharp(CS0120)

Is what it says

snow willow
#

it's a Coroutine and to call coroutines you need to use StartCoroutine()

slate parrot
#

Yeah

snow willow
#

same as it is with fields

slate parrot
#

StartCoroutine(FoodSpawn.RandomSpawn());

snow willow
#

that only works if it's static though

#

otherwise you need an instance

#

e.g. public FoodSpawn foodSpawnInstance; < assign in inspector
StartCoroutine(foodSpawnInstance.RandomSpawn());

slate parrot
#

Ohh

snow willow
#

so basically the only difference between a field and a method is you call methods with () or (parameter1, parameter2)

#

the rules for accessing them are the same

slate parrot
#

Alright, thanks for the help

slate parrot
#

I can't get triggers to work on anything right now. No matter if I make an entirely new project, add a couple of GameObjects, make one isTrigger enabled and add an OnTriggerEnter2D to the other one, it does. not. trigger.

#

I took isTrigger and set it to false while the game was running, and I pass right through it, and it passes right through me. Both GameObjects have Box Collider 2D

abstract olive
#

One of the objects needs a rigidbody.

slate parrot
#

I had no idea.. All this time, and that's what it was. Thank you.

hollow crag
#

Trying to make stat files in CSV (unless you guys recommend another file format). Wondering how to grab the gameobject's name the script is applied to. Am I on the right track at least?

#

Also, I'm aware I don't need to make it a public void, I no longer intend to call it via other scripts.
If I'm spawning in waves, should I temporarily store the attributes? And how would I do so?

still tendon
#

i am very cool

loud glade
#

Hello people i need a help. I have edited a vs console code to display the output in Unity console. But it is not working as i expected. Can anybody help me with this. I am a beginner to these field. Someone suggested me to add void start update functions. But i have no idea what to implement inside those functions Here is my pastebin code
https://pastebin.com/Qw2x59AA

lament pollen
#

yes

spice ridge
#

Pls learn to never use Regions

#

I don't see any code that uses these methods so I have no idea what is supposed to happen

rotund burrow
#

Can someone help me out. Im tryna make a 2D platformer and everything in my code works fine except for when i press space my character wont jump, I even added a Debug.log and it works. But i cant figure out why the rb.addforce wont work

#

Here's my code

heavy gale
fossil linden
untold badger
#

@rotund burrow remove Time.deltaTIme

rotund burrow
#

ok

#

doesnt work

untold badger
#

@rotund burrow is ur ground set to isTrigger?

rotund burrow
rotund burrow
# rotund burrow
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour
{
    public Rigidbody2D rb;
    public float moveSpeed;
    public float jumpForce;
    private float horizontal;
    private float vertical;
    public bool grounded;
    public bool activateJump;
    public bool jumped;

    private void Update()
    { 
        horizontal = Input.GetAxis("Horizontal");
        vertical = Input.GetAxis("Vertical");

        if (Input.GetKey(KeyCode.Space))
        {
            if (grounded)
            {
                if (jumped == false)
                {
                    activateJump = true;
                } 
            }
        }
    }
    
    private void FixedUpdate()
    {
        rb.velocity = new Vector2(moveSpeed * horizontal * Time.deltaTime, rb.velocity.y);

        if (activateJump)
        {
            Debug.Log("code works");
            rb.velocity = new Vector2(rb.velocity.x, jumpForce);

            activateJump = false;
            jumped = true;
        }
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Ground")
        {
            grounded = true;
            jumped = false;
            Debug.Log("You are grounded");
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.tag == "Ground")
        {
            grounded = false;
            jumped = false;
            Debug.Log("You are no longer grounded");
        }
    }
}```
updated code
untold badger
#

Does it print code works?

still tendon
#

my character keep falling trought the platform, why?

untold badger
#

@still tendon check if your player and platform are having colliders

still tendon
untold badger
#

If it's a 2d game use box collider 2d and rigid body 2d and make sure u don't have is trigger check for colliders

untold badger
#

Send a picture of scene window.

still tendon
#

i just cant screenshot it

still tendon
#

i get this error message : this collider will not function with an effector until there is oce enabled 2D effector on this gameObject

slate parrot
#

I have a question: I'm new to using instantiate, and I need to know how to Destroy(gameObject) and make a clone of it. I managed to make a clone with the instantiate how I want, but after the original is destroyed, and the clone spawns, not only does the clone have its box collider 2D off, when you turn it on and trigger it, no more spawn

turbid wasp
#

Hi guys, this should only become true when it's in contact with an object within the "walkable" layer. right?

slate parrot
still tendon
slate parrot
#

On your GameObject that needs the effector, click "Add Component", and search for "2d effector" and click the one you need

still tendon
#

oh ok

still tendon
slate parrot
#

Well, which one do you need?

#

I have to go, but best of luck to you figuring it out. You got it!

still tendon
#

its not workinggggg!!!!

#

i tried every combination and its not working

severe flint
still tendon
severe flint
#

ok send me (in DM) a screenshot of your platform and you character

still tendon
#

yeah about that its not working i cant screenshot but i can screenshare

gray iron
severe flint
gray iron
#

can someone help me understand why it is only letting my character jump once

#

it is supposed to be a double jump

still tendon
gray iron
#

but somewhy i can jump once, and then never again

#

i can only jump once per "starting the game"

severe flint
severe flint
gray iron
#

oh....

#

lmao

#

alright gotcha haha

still tendon
severe flint
#

you can easly download a software for screenshot

gray iron
#

download lightshot

#

quite good

still tendon
still tendon
#

i still cant fix it...

severe flint
#

thats really strange its all correct setted up

still tendon
#

rly?

severe flint
#

yep for what I saw. Try to put the screenshot here. Maby someone can help you

still tendon
still tendon
#

im keep falling trought the plat

abstract olive
still tendon
#

whats that?

abstract olive
#

You need a collider on both objects for physics to work. One on your object that has the rigidbody and one on the environment, like your platform.

nocturne crystal
#

Hey ! I'm working on a dash system,
I want that the player can dash on the actual orientation and that the dash have a flat distance. My actual problem is that my horizontal power of dash is not the same as my vertical power (when I press the dash key, if I dash in Y axis, my character will dash a lot far than if he just dash on the X axis), I probably miss something ^^
someone have an idea why ?

#

There's also the dash effect instantiate on this code, this one works

still tendon
#

ohh yeah its working now i can have a character on a platform now finally onjly took 2 days to do it

still tendon
#

soo can i get some movement script pls

turbid wasp
#

I know I posted this before but I'm still having trouble with.

#

it works fine in some scenarios such as in this image. represented with a yellow Gizmo

#

but if I add a object close by, it doesn't seem to work properly

#

The Gizmo

#

I have no clue why it does this.

left lotus
#

DrawWireCube parameters are a center and size. Not a TopLeft/BottomRight pair of points

turbid wasp
#

I see, is there a Gizmo that uses a Topleft and bottom right?

left lotus
still tendon
#

2d movement script pls

left lotus
#

No one is going to write your code for you, if you have specific questions we can help

still tendon
turbid wasp
#

I suppose it would be easier if I used a sphere since it will use a radius

#

Well, thanks Squeaky clean for pointing that out for me.

left lotus
#

No problem. Yeah a bit inconsistent in their parameters. It's not too difficult for a square to convert back and forth between center/size and two points. You could make a pair of functions to swap back and forth as you need

#

The position of the two points is basically center +/- (size / 2)

dense violet
#

Just wondering, if using a tileset for the grid should I change the scale of the grid or the cell size if I want to make it bigger or smaller?

#

they seem to do the same on the surface just wondering if there is something im missing

left lotus
heavy gale
#

Uh guys

#

Is there a special function for manipulating some value of all gameobjects in camera's view?

#

Like inbuilt?(something like OnCollisionEnter2d())

#

Even getting a reference of all those objects would be nice

dense violet
#

@left lotus I'm not sure if I completely understand but it seems to be working fine changing the cell size, thanks anyway

weak sinew
#

I have 7 errors and i think this code could be some part of the problem

#

...

still tendon
#

hey, so im trying to make the player flip (gravity) when it touches a square

#

here's my code btw

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

public class FlipPlayer : MonoBehaviour {

    void OnTriggerEnter2D(Collider2D other)
    {
        if(other.CompareTag("Player"))
        {
            //what do i do
        }
    }
}
left lotus
#

This is assuming you're using the Unity physics and gravity. And that you haven't written your own code to handle gravity instead

still tendon
#

oh cool thanks

weak sinew
#

or should i just reset the code and find a better tutorial

still tendon
#

check out the platformer tutorial by muddy wolf

#

its pretty good and started me out

weak sinew
#

k

#

can i use the code i already have as a base or should i reset it @still tendon

still tendon
#

reset

#

i think

weak sinew
#

mmmmm

#

k

still tendon
#

or do you only want the jump script

weak sinew
#

i only want to use a new jump script

still tendon
#

because wolfs script is movement + jumping

weak sinew
#

so, could i add in the jump script to my current movement script?

still tendon
#

idk

weak sinew
#

.

#

k

#

and ive forgot where i put my Ground Check code to delete it...

still tendon
#

how can i make clouds go slowly without script?

nocturne crystal
#

public variable that you can manually increase?

left lotus
#

Use the animation system?

still tendon
still tendon
#

rb.constraints = RigidbodyConstraints2D.FreezePositionX; is it even possible to unfreeze it and how?

still tendon
#

like i want only x position to be unfrozen

abstract olive
#

Seems like the the answer in the link explains how to do exactly that.

upbeat sinew
#

Hey everyone! Newbie developer very much enjoying his first few weeks in Unity, was hoping someone could send me to a tutorial regarding using 3d shapes in a 2d world. Video tuts are best but any reference would be appreciated ๐Ÿ‘

left lotus
#

I don't have specific videos to recommend, but searching with the term "2.5D" will help you find what you want

upbeat sinew
#

haha thanks squeaky, yes lots out on that subject

#

@left lotus is it alright to post a picture here?

heavy gale
#

Why is this hapenning?

left lotus
upbeat sinew
#

this is along the lines of what I am aiming to build

#

just don't know enough to call it 2d, 3d or between haha. Would you say this is 2.5?

#

that's a wonky error @heavy gale

abstract olive
#

That particular image looks like it's using sprites, so it would be 2D isometric.

upbeat sinew
#

Thank you Osteel, the terminology will help alot I'm sure

nova remnant
#

I'm doing a top down 2d game and I want the camera (which follows the player centered on it) to be able to move forward (not infinitely) with the mouse pointer when the player aims down

#

I'm kinda lost... Any suggestions on how to do this?

#

I'm thinking of something like getting the vector between the player's position and the mouse's to get a sort of halfway point

left lotus
#

That sounds like a good idea to start with yeah, and maybe a maximum distance, at which the camera stops following your formula

nova remnant
#

I tried this but no luck

left lotus
#

So Vector2.Lerp doesn't take a speed, it takes a value between 0 and 1 that represents how much it should interpolate between the first Vector2 and the second Vector2

#

e.g. with the third parameter equal to 0.0, it's the same as the first Vector2. If it's equal to 1.0 it's the second Vector2. If it's 0.5. it's halfway between both

still tendon
#

what does this mean NullReferenceException: Object reference not set to an instance of an object

nova remnant
#

it means you're calling an object that's not properly assigned to

still tendon
#

oh

nova remnant
#

can you click on the error

#

and send a screenshot/copypaste the line that's giving you trouble?

still tendon
#

when i click on it it leads me to this line

nova remnant
#

okay... can you show me where you assign playerActionControls, Land, and Move?

#

The problem is probably there

still tendon
#

Sorry bro my WiFi went out

#

ok, so i have my gravity switch

#

and i can't jump while upside down

left lotus
#

Your jump is probably applying a globally upwards force

still tendon
#

when i multiply the jump force by -1 on the key press and flip back regular, the jump kinda breaks

gleaming nebula
left lotus
#

How does the jump happen. Does a jump force of -1 work with however you're doing the jump force?

gleaming nebula
gleaming nebula
#

hey im having in issue with unity2d where if I view my panel its not there in the game view. any ideas?

#

the top photo is what i want it to show but the bottom photo is what it is showing
hang on i think i know
nvm it didnt work
i was thinking it was showing the main camera but when i move it to show it it still doesnt show it
yea wherever the main camera is it shows the bottom photo

still tendon
#
 private void Update() {
        mx = Input.GetAxisRaw("Horizontal");

        if (Input.GetButtonDown("Jump") && IsGrounded()) {
            Jump();
        }
#

heres my jump script

#

theres also a float of jump force = 20f

left lotus
#

That's not the jump script, Jump() is your jump script

#

Though actually, could it be related to IsGrounded ?

still tendon
#

it is, i just realised

#

because the groundCheck is on the bottom of the cube

#

thanks

#

wait but how do i move the groundCheck up on the keypress?

gleaming nebula
#

any ideas on why i cant see an object in game view?

dreamy egret
#

i think there's not enough info...
do you have any code in that object's start() or update() that might be hiding it?
or a sorting layer issue?

gleaming nebula
#

Whenever I use the UiCamera it only shows that panel

#

But with the maincamera I see all three panels but the middle one isnt there for some reason

dreamy egret
#

are all three panels on the same layer?

#

sounds like possibly some of them are on UI and not others

karmic jetty
#

@gleaming nebula Can u share scene view during game play?

gleaming nebula
#

Ya here lemme show you

karmic jetty
#

Which using canvas type? Screen-space or overlay?

gleaming nebula
#

It says screen space - overlay

still tendon
gleaming nebula
#

?

still tendon
#

in render mode

gleaming nebula
#

oh

#

It gives me the shade of green i uave

#

It covers the screen

still tendon
#

hmm

#

are you editing the canvas?

#

as a parent

gleaming nebula
#

I think so

#

Key word think

karmic jetty
#

@gleaming nebula Can you try put camera to scene and select render screen space - camera from canvas

gleaming nebula
#

camera to scene

#

Like put it in the inspector

#

Or In inside the canvas

karmic jetty
#

like this

#

without parent

gleaming nebula
#

Ok

karmic jetty
#

and select render mode of canvas to screen space camera

gleaming nebula
#

Ok

#

So canvas is at screen space camera and I added a camera

#

To the scene

karmic jetty
#

okay can you see new field on canvas

#

Camera

gleaming nebula
#

Ok it shows now but here is what is wrong now

#

So i drag to go to the next page

#

And when i drag it goes through all the pages then out of the panels

karmic jetty
#

You can try add canvas scaler to canvas

gleaming nebula
#

Also why is the checklist now in the same page as page 1?

#

Should I move it till its right?

karmic jetty
#

Do u have a any remote controller app? like team viewer

gleaming nebula
#

Ill get it real quick

#

I have teamviewer now

karmic jetty
#

Can u share your id & password privately

gleaming nebula
#

Ye

#

Just dmโ€™d u it

still tendon
#

quick question, how come this isnt working? it doesnt seem to change the boolean (sorry im new, and I'm still learning)

#

Yea, I know there is Input.GetAxis but I kinda wanna use GetKeyDown at the moment

hollow crown
#

you've declared it locally as true, so it'd always only enter the first if statement and only on the single frame where you press space

#
private bool goingDown;

void Update () {
  if(Input.GetKeyDown("space"))
    goingDown = !goingDown;

  if(goingDown)
    transform.Translate(down-etc);
  else
    transform.Translate(up-etc);
}```
#

Unsure whether this is what you were going for, but that's how I would write it simply

#

@still tendon sorry for the slow response!

still tendon
#

No need to be sorry!!
Thanks so much for the help!

#

I forgot that I added it into the update instead of start lol

weak sinew
#

and good tutorials for a 2d platformer aim and shoot?

heavy gale
#

Makes the gameObject flicker tho

#

any ideas?

weak sinew
still tendon
#

anything with decimal points has to have an f after it right??

#

i.e ```cs
yield return new WaitForSeconds(0.3f);

abstract olive
#

Anything that is of type float, does yes.

snow willow
hollow crown
#

typically there's little in Unity that uses doubles (ie. decimals that don't have an f)

still tendon
#

oh wait f stands for float?

hollow crown
#

yes

still tendon
#

neat

still tendon
#

soo how can i make an invisible wall like at the beggining of the level but i cant see trought you know what i mean?

hidden cypress
#

Make an empty gameobject and add a collider?

still tendon
#

but the camera can see trought

hidden cypress
#

I'm confused, dont you want it to be invisible?

still tendon
#

oh sorry cant*

#

you know like in mario at the beggining of the level there is an invisble wall you cant go trought and the camera is not moving

hidden cypress
#

You mean like on the left side of the screen?

still tendon
#

yes

hidden cypress
#

Oh, okay. Thats a but tricky, you'll have to define a region on the screen where the player is "progressing" and while thats true move the camera with the player. Are you using physics to move your character?

still tendon
#

what?

hidden cypress
#

Is there a rigidbody on your player?

still tendon
#

yes

hidden cypress
#

Okay then you can just attach a child to the camera that is just a big collider, and use layermasks to make sure it can only hit the player

still tendon
#

ooooohhhh got it thanks

#

oh wait

#

i fckd up

#

help

#

i deleted the main camera

hidden cypress
#

just add another one from the menu or ctrl z

still tendon
#

the cinemachine is not working now

heavy gale
#

Can somebody give me an idea here

I want all my enemies visible on screen to get alerted if one of them gets alerted
how do I do that?

#

basically using a raycast hit 2d to turn isAlerted to true, how to set isAlerted =true to all enemy entities present in screen?

hidden cypress
#

Easiest way is find all by tag and then check if they're on screen

heavy gale
hidden cypress
#

There are probably like a dozen ways to do that, so which ever way you like/works for you/performs well is good

heavy gale
#

I tried with Renderer.isVisible but apparently the gameObject is visible at all times

heavy gale
hidden cypress
#

renderer.isvisble is totally fine and probably the best performance wise. If you need to have more control you can do worldtoscreenpoint and manually check it

thorn dirge
hidden cypress
hidden cypress
#

But yeah otherwise thats the best way

boreal knoll
#

Guys, I want to make DASH like Maplestory, can someone tell how to make it? I have tries many ways, but the result isn't the thing i want.

#

I dont want to make a dash by setting rb.velocity = new Vector(dashSpeed * direction)

#

I had tried to make a timer to let it run ใ€Œrb.AddForceใ€several times

#

I had tried both Impulse and Force , but ...

#

I Want to make a effect looks like the player is pushed by a Force.

#

My english is a little bit bad, so if there is something can't be understood, i will try my best to explain...

ruby karma
#

ForceMode.Impulse is what you want

#

how were you using it?

boreal knoll
#

no, I tried...

#

it just...looks like dash in a straight line in the air

#

that is not the thing i want

#

If (GetButtonDown) rb.AddForce(new Vector3(dashSpeed*faceDirection,0),ForceMode2D.Impluse);

#

It will be so weird

#

I saw an article said it will be better if you use GetButton, but it will be better if we can use GetButtonDown to DASH

ruby karma
#

GetButtonDown fires once when you press a button
GetButton fires every frame the button is pressed

boreal knoll
#

I know, I know

ruby karma
boreal knoll
#

well... wait me about five minute

#

I want to record dash in maplestory

#

and the dash in my game

ruby karma
#

okay

boreal knoll
#

There is a weird move in the second video, it is my dash

#

not the double jump

#

if we use getButtonDown to Dash, it will suddenly teleport to right/left, or just do nothing

#

by the way , i use impulse

boreal knoll
#

...WELL, SORRY About wasting your time, BUT I KNOW HOW TO deal with it...now...

ruby karma
#

uh, could have pinged me but okay

boreal knoll
#

wait me a second, i will post my video how did i deal with it

#

THE Reason is the dashtime is not longer...enough

compact gate
#

Hi, a quick question, is there a way to zoom in and out while being "pixel perfect" ? I guess it is not as it involve using float number zoom level to smoothly go from one zoom level to another

#

My goal would be to achieve a smash bros like camera, with pixel art assets

cloud spade
#

Hi, I am trying to make my first 2D game. For some reason, this doesn't work. Any idea why? (I will include the errors below)

snow willow
heavy gale
#

I want my enemy to shoot repeatedly with certain intervals between each shot

#

How do I instantiate multiple bullets with some delay ?

#

very dumb doubt but I'm very stuck

cloud spade
#

thanks!

boreal knoll
#

@heavy gale I haven't tried the code, but I can give you some idea?

heavy gale
#

sure

boreal knoll
#

assume a value which is called delayTime, put it into update and: delayTime = delayTime - Time.deltaTime

#

it's a concept, like timer

#

if delayTime < 0, shoot one ammo and reset it

#

then repeat, until something disable(shoot == false)

heavy gale
#

Thanks @boreal knoll

#

How about using InvokeRepeating(function, timeToStart, repeatRate)

boreal knoll
#

I don't know much about this code

heavy gale
#

And using gateway boolean to execute actual code

boreal knoll
#

I 'm sorry ๐Ÿ˜ฆ

heavy gale
#

Hey no problem thanks for an idea

boreal knoll
#

I just saw this program today, so I haven't studied it yet.

still tendon
#

how to change mouse cursor position

chrome anchor
#

does anyone know how to combine two different objects into one object (spawn an object and delete the two objects) properly? i tried a tutorial but it didn't work for different objects

left lotus
chrome anchor
#

Ok

#

So basically I want to do a combine game where you take two objects and merge them together into a single, new object such as combining an acorn and a mana crystal into a tree

#

i use the mouse to drag and drop them together

#

this is what i tried for the combine method, it works for duplicate objects that are the same (mana and mana) but not different objects (acorn and mana)

left lotus
#

Could you just place both of them inside an empty gameobject, so that gameobject is now the parent of both? (and you can have any components related to combined objects on that parent gameobject)

chrome anchor
#

ohh i see

abstract olive
#

How many of these recipes do you plan on having?

chrome anchor
#

a lot of different combinations

#

i want to put them in a recipe script

abstract olive
#

You may want to look into learning how ScriptableObjects work, then.

#

If you find yourself having to manually type "Mana" and "Acron", it's already too hardcoded.

chrome anchor
#

๐Ÿ‘

warped viper
#

I wanna toggle my button, what do I need to put after the . ?
buymobButton.GetComponent<Button>().

#

I need a method that can toggle the button completely

#

Do I need to make my button static?

abstract olive
#

Toggle, how? Make it invisible?

mossy shale
#

Hey Im trying to make a 3D game, but using sprites in a 3D space. An issue im coming up against immediately is how the sprites look when i run the game. As you see in this image they are a little distorted? Any thoughts what would cause this?

dapper otter
#

probably perspective of the camera

#

you can probably model a 3d shape of the 2d sprite and put it into the game

#

easier to control that way i think

snow willow
mossy shale
#

I guess im wondering why, when my sprite is 16x16, why its cant keep its quality, and just get bigger/smaller? why does the perspective make my edges wobbly

snow willow
#

in the import settings

#

but if that's what you were concerned with your image didn't illustrate it

mossy shale
#

yeah I have set that

snow willow
#

so wdym by wobbly

mossy shale
#

ill get a better screenshot

snow willow
#

doesn't really mean anything unless you show what it's supposed to look like?

mossy shale
jade elm
#

Hio guys. who can explain me how to create maps? But not simple tile map or such

#

Korean-Chinese like tile maps.

#

For example, we have a bunch of images 300x300 from pre-drawed map

#

Like that

#

Umm, and any example how to create such background + probably they have a +1 layer above for virtual "tiles" where is defined where you can walk and where nope. And such grid also used for character walking..

#

But i did not find any tutorial for such type of maps... Mostly of them - simple tile map and not like this. Hmmm

heavy gale
#

TryGetComponent is returning false even if gameObject has target component?

snow willow
heavy gale
#

yes just a sec

#

The gameObject is named General, and has an animator attached

snow willow
heavy gale
#

yes

#

Could it be because anim component is public?

snow willow
#

just to make sure - i notice this screenshot is from using the debugger - did you check the gotAnimator bool during this screenshot?

#

Becaus ethat line of code has not run yet in this screenshot

snow willow
#

no public won't affect things

#

try this on the next line:

heavy gale
#

Log the bool?

#

i'll do that

snow willow
#
if (!gotAnimator) Debug.Log("This object does NOT have an animator", this.gameObject);
#

then when you see that log in the console

#

click on it

#

one time

#

it should take you to the object in the hierarchy

#

just to make sure you're not getting a false negative from another random object you accidentally left this script on or something

heavy gale
#

Turns out after logging the bool, I do get gotAnimator as true

#

But then why in my script is it skipping that check completely

snow willow
#

where

heavy gale
#

wait let me paste my code

#

public int health = 10;
    public GameObject deathEffect;
    public Animator anim;

    private bool gotAnimator;

    private void Start()
    {
        gotAnimator = TryGetComponent<Animator>(out anim);
        Debug.Log(gotAnimator + "yes");
    }

    public void TakeDamage(int damage)
    {
        health -= damage;
        Debug.Log(health);

        if(health<=0)
        {
            Die();
        }
    }
    void Die()
    {
        if (gotAnimator)
        {
            anim.SetBool("isDead", true);
        }
        else
        {
            GameObject newExplosion=Instantiate(deathEffect, transform.position, Quaternion.identity);
            Destroy(gameObject);
            Destroy(newExplosion, 0.725f);
        }
    }```
#

if condition doesn't get passed, all objects having

#

isDead and an animator

#

execute the else function

#

Which is just an anim of a pixel art explosion

snow willow
#

debug that part of the code?

heavy gale
#

Wait I'm just really dumb

#

Sorry mate this was so bad

#

It works all right

#

the animator controller state had no motion

snow willow
#

no worries

weak sinew
#

anyone know a decent free laboratory/factory bg for a placeholder bg?

sage cloud
#

umm hello i would like to ask some help with my project
I'm new to unity and with help from tutorials I manage to make this

its a tower defense game. I'm working on placing towers for now and i manage to make so that whenever I click on the green circles it will spawn a tower but I can't choose which towers i want to place on that spot, i was thinking of making it like Plants vs Zombies where you can drag the tower you like on the spot but i don't know where to start

sage imp
#

Hey

#

How would make top down movement where my character faces the direction it is moving in

#

But smoothly

latent hazel
#

So, I am very much not a great programmer but I am working on a project in Unity. I am making a minimalist 2D city builder with Tetris mechanics. In terms of establishing a baseline bit of coding, I have some idea of what to do, but it will be tricky. Essentially I want the player to be able to drag and drop their given piece and then once it's placed I want it to snap into place, sort of like placing a tile in a tile placement game. Are there any tutorials that would be helpful for making this sort of thing?

still tendon
#

in game the floor is look like this but in scene its normal ,why?

stuck sorrel
#

Hi guys, i'm trying to move a ball on my screen. The thing is the ball is moving only in -Y. Any suggestion is appreciate, ty

sleek spoke
#

transform.Translate(ballDirection * Time.deltaTime * ballSpeed);

#

Vector3 ballDirection;

maiden karma
#

I'm trying to get a top down movement script to work but i'm extremely new to coding so i dont wanna f anything up. can someone help me?

#

and these are the errors that show up

#

got this ^^ from a youtube video.

snow willow
maiden karma
#

thank you

snow willow
#

at the beginning

maiden karma
#

that cleared up everything except

snow willow
# maiden karma

Assuming this is using the new input system, that name is going to depend on how you named your Action Map in the Input Actions Asset

#

Make sure the capitalization is correct

#

Is it Movement maybe?

#

ah yeah I can see in your screenshot in the bottom right

#

it should be Movement capital M<

maiden karma
#

that might be it

#

yeah

#

im trying it

#

if this works i love u

#

deeply

snow willow
#

otherwise it would be giving you auto suggestions etc

maiden karma
#

IT WORKED

snow willow
maiden karma
#

Thank you so much

#

for everything!

still tendon
#

@snow willow can i get some help too?

stuck sorrel
snow willow
stuck sorrel
#

Ty both of you. I will work on that. At least I understand a bit more about Vector.

toxic flax
#

Hello guys, i'd like to do a delay before an animation, do i have to put the delay on script (before i trigger smthg) or i can do it directly on animator of unity

maiden karma
#

PS: I'm very new to coding With that said. I need help connecting animations to movement

#

I've already set up the animations, i just dont know how to link so that when i press w (move upwards) it plays walk animation up

abstract olive
#

You can start by not capitalizing the start of each word.

#

But it means that you haven't told your game what winText is. You probably need to drag it into the inpsector.

weak sinew
#

so im looking at menu tutorials, but whenever i create a new scene, i always see the other scene, instead of nothing there

#

and then all the tutorials the other scene disappears

inner vine
#

how the frick do i add A FRICKING IMAGE ASSET!?!?

abstract olive
inner vine
#

now?

#

(ik im fricking stupid)

abstract olive
#

Now, what? What are you trying to do?

inner vine
#

add a fricking dirt .png

#

oh my fricking god i figured it out

still tendon
#

does anyone know why this isnt being triggered

inner vine
#

when i put a image why does it count the transparent part?

inner vine
#

hello?

snow willow
inner vine
#

where is that? ._.

snow willow
#

CLick the image in your project folder

#

there are import settings for it. And every asset

inner vine
#

confusion

#

._.

#

wdym by click the image in my project folder?

snow willow
#

The project window

#

in Unity

#

where all your assets are

analog sundial
#

why do my canvas is not is not applying to my prefab

#

when its public

snow willow
#

huh

analog sundial
#

its is on serialfield but even if i gonna do it on public still not working

snow willow
#

I have no idea what you're talking about

#

Some context if you want help

inner vine
analog sundial
#

if u gonna see on the right corner of unity there is a prefab of canvas

snow willow
#

there's a Canvas field

#

But this is a prefab right

analog sundial
#

ys

snow willow
#

you can't reference objects from your scene from a prefab

#

Not permitted by Unity

#

It wouldn't make sense.

#

What would happen if you instantiated your prefab in a different scene?

analog sundial
#

but how do i need to do it then

#

because without the prefab its not gonna worki

snow willow
#

Singleton pattern or FindWithTag

#

those are the most straightforward ways to find your canvas

#

or when you instantiate this thing you can run GetComponentInParent<Canvas>()

#

any of those three are quite straightforward

#

but it will have to be done in code no matter what

analog sundial
#

oke how do i need to do it in this code

snow willow
#

I just told you three ways

analog sundial
#

with tag

snow willow
#

tag your canvas

analog sundial
#

but how to find it

snow willow
#

and call GameObject.FindWithTag

#

Then GetComponent to get the Canvas component

analog sundial
#

but its not and gameobject

inner vine
snow willow
#

it should be open by default though unless you closed it

inner vine
#

oh

#

its there

analog sundial
#

if i gonna call the canvas a gameobject the canvas.scalefactor is not working

snow willow
inner vine
#

all it shows me is the image tho

snow willow
#

why did you click that

#

all we wanted was the import settings

#

underneath that open button

#

is all the import settings

inner vine
#

that did not help me

#

STUPID SPELLING ERRORS

#

idk what to change

#

bruh

#

nvm i fixed it

jovial cedar
#

https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/simple-2d-fog-storm-smoke-115617 I have tried implementing this code in my project. I can add it to the camera object and it works (it has to be on the camera object because it's using OnRenderImage(). Unfortunately my camera isn't strictly following the player but rather lerping towards the player to have a "smooth" camera and I think that's the reason the whole fog shader gets moved around as soon as the player starts walking. I don't really know how to fix this, any ideas?

Add depth to your project with Simple 2d Fog - Storm - Smoke asset from Akฤฑllฤฑ Mum. Find this & more VFX options on the Unity Asset Store.

inner vine
#

why the frick is this not working?

thorn dirge
#

and if you are making a 2d game use Vector2

#

basicallly the same as Vector3 but with the z coordinate removed

#

to avoid confusion

inner vine
#

ok

jovial cedar
#

variables usually don't start with a capital letter, use lower letters to differentiate them from methods

thorn dirge
#

plus why did you put it the speed at 1

#

put it at like 10

#

if the thing disappears

#

its working

#

coz sometimes it would be too slow to see its movement

inner vine
#

if what thing disappears?

#

the player?

thorn dirge
#

coz its so fast it ran off the screen

#

I doubt you made a camera controller yet so I am certain you wouldn't be able to see it fly to where

inner vine
#

im raging so hard rn bc its not moving

thorn dirge
#

try set it to 100

#

or even higher

#

so you can see its working

#

coz it dashed out

jovial cedar
#

you're a beginner so there could be a lot of reasons... is it attached to the player object? Are you in scene view or in game view? etc.

inner vine
#

you know what

thorn dirge
inner vine
#

ill try to make a dif game

jovial cedar
signal aspen
#

awe mate, don't give up on a 2d unity game

inner vine
#

but i did just now ._.

thorn dirge
#

wait a minute

#

why is your input

#

input and not Input

signal aspen
inner vine
#

im gonna work on a 2d platformer im done with the shooter idea

jovial cedar
thorn dirge
#

programming is about making the code more simple and easier to read so if you found an error you wouldn't just quit coz of lack of motivation

#

like me

jovial cedar
#

my movement logic is different but I actually tried his code and it worked