#πŸ–ΌοΈβ”ƒ2d-tools

1 messages Β· Page 30 of 1

inland jacinth
#

@winged kiln Are you using the Sprite-Lit-Default shader?

inland jacinth
#

You could either duplicate that and edit it via code, or you could use Shader Graph to make your own sprite shader

#

I can help you with either

winged kiln
#

I don't think so, I doubt you can do that with animation. I mean you can combine both animation into one. It create an animation blend tree and transition between them maybe

winged kiln
inland jacinth
#

Have you ever used Shader Graph? If not, I'd probably go the route of editing the shader directly.

still tendon
#

How can i combine both?

winged kiln
#

Probably editing it then?

winged kiln
winged kiln
inland jacinth
#

I'm not 100% sure it can be done in Shader Graph, so I'm going with editing the shader.

winged kiln
#

okay

inland jacinth
#

Start by copying everything in that file and paste it into your own .shader file in your project

#

And give it a different name, both in file name and in the first line of the shader

winged kiln
#

okay i will do that now

#

what do i do next?

inland jacinth
#

I'm making a new URP project so I can make sure all the steps are correct. Just a second.

winged kiln
inland jacinth
#

But it's still a tiny bit visible if the green sprite is also casting shadows.

#

If it isn't casting a shadow, like in your screenshot, then it's completely invisible.

winged kiln
#

nothing will cast shadows except the red sprite which in my case the wall

#

but what did you change in it?

#

BUT THANK YOUUUUUUU

#

I REALLY DONT KNOW HOW MUCH TO THANK YOU

#

thank you so much, you dont know how much i been looking into that

inland jacinth
#

No problem!

#

Things like SHADOW_COORDS(TEXCOORD1), APPLY_SHADOWS(i, color, _ShadowIntensity);. These are all helper functions to draw shadows, but I don't think they're documented.

#

So I copied those and put them in the same place, then the main part is this:

half4 shadow = saturate(SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.shadowUV));
main.a *= 1 - shadow.r;
#

I'm doing this at the end of the fragment/pixel shader. Sampling what the shadow intensity is at the current pixel and multiplying the alpha of the main sprite color with 1 - shadow intensity

#

So if the shadow intensity is at 1, then main.a *= 1 - 1 = main.a *= 0, so alpha becomes transparent.

winged kiln
#

ohh i see

#

i will have to look more into shaders, and try to understand them

#

but thank you again tho, really thank you

#

it does still give me this, but i think that should be fine since it would be away from the screen

inland jacinth
#

Looks like the shadow mesh only extends as far as the light radius

winged kiln
#

i see

#

thank you again, i really appreciate it

inland jacinth
#

Just need to create a texture property with the name _ShadowTex to reference the global shadow map texture and sample it with the screen position

#

Then you do the same logic, multiply the alpha with 1 - shadow.r

winged kiln
#

also for some reason my shader graph looks different then yours.

#

is it because of the version of unity?

inland jacinth
#

Could be, I'm on 2020.1

winged kiln
#

am on 2020.2

#

am going to try to recreate what you have there

inland jacinth
winged kiln
#

okay

inland jacinth
#

Then you sample it like any other texture, except instead of using UV0 as the UV, you use the Screen Position Node

inland jacinth
winged kiln
#

yep it does

#

when i try to have reference on it, it doesnt show that option

#

so am searching it up to see how to enable it or something

inland jacinth
#

Which option?

#

When I use the word "reference", I just mean referencing it by name, which is "_ShadowTex"

#

You don't need to find the shadow tex anywhere, that property will be set to it automatically so long as it has that exact name

#

Because it's a global texture

winged kiln
inland jacinth
#

Can you screenshot it?

#

You don't have the Reference field?

winged kiln
#

yea

#

let me do that

#

oh wait, its in the node setting in another window smh lol

#

lol

#

they moved it to the graph inspector πŸ˜‚

#

oh wait, it works nvm, it was my fault

#

if you dont mind me asking, why do you do one minus only on the red channel?

inland jacinth
#

@winged kiln The shadow map uses the different channels for different things

#

And I'm not exactly sure what data the green and blue channels contain

winged kiln
#

oh thats interesting

inland jacinth
#

But I know that the red channel is the basic shadow or not shadow channel

#

Where more red is more shadow

winged kiln
#

where do you learn all these things πŸ˜…

winged kiln
inland jacinth
#

I inferred it from the shader code that uses the channels:

#define APPLY_SHADOWS(input, color, intensity)
    if(intensity < 1)
    {
        half4 shadow = saturate(SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, input.shadowUV));
        half  shadowIntensity = 1 - (shadow.r * saturate(2 * (shadow.g - 0.5f * shadow.b)));
        color.rgb = (color.rgb * shadowIntensity) + (color.rgb * intensity*(1 - shadowIntensity));
    }
#

Its clear that the RGB channels aren't being used as colors here because they are being used strangely

#

Also, colored shadows doesn't make sense in the first place

winged kiln
#

thank you again.

#

do you mind if i dm you if something comes up with the shader? am not going to trouble you much

inland jacinth
#

@winged kiln Sure, I don't mind.

winged kiln
#

thank you

#

am about to crash because its 4Am where am at

#

talk to you later, thank you again

flat dome
#

And how can I use data base for my game?

tropic inlet
#

Have you used SQL before?

last surge
#

hey can any one help me i cant get my states to work for my animationhttps://paste.myst.rs/a65skhnk

karmic storm
#

I am using this code to make my player move. Is there a way to delay the input a bit so that the player moves for a few seconds even if the button isn't pressed anymore?

meager mural
#

You shouldnt be doing your Input polling in FixedUpdate

#

Put it in Update. the only line that should bein fixedUpdate here is the rb.MovePosition line

#

If you want that, i think you want to use rb.velocity

#

Because MovePosition i think is teleport movement

vocal condor
#

Move position should be fine if he's moving in small increments. However the input should definitely be decoupled and handled in Update.

last surge
#

Hey can anyone help with my script
My animation arent playing

vocal condor
#

A delay would require some buffer time with either timer, invoke later or coroutine.

last surge
#

Is there something wrong with my script

meager mural
#

Dalphat. You only speak / write english?

vocal condor
meager mural
#

I'm doing localizations and wondered if you would be kind to just go over the google translate and make sure its not trash?

#

Depends on your language though. And if you want to do it. Completely fine if you dont πŸ˜›

vocal condor
#

Aaahahaha, non programming languages aren't my forte.

meager mural
#

Aaa ok i see, perhaps i should of worded it better

grizzled grove
#

For example, I would like to re-use this animation, but with different sprites

winged kiln
craggy kite
grizzled grove
dense flame
#

I think there was something named rigging, but I don’t think you can change animations in runtime

winged kiln
#

yea same ^^

#

why not create your own animation system?

#

i mean all it does it goes through some sprites at a certain rate per second

grizzled grove
craggy kite
#

yeah, instead of using animations, just switch through your sheets and jump from position A1 in spritesheet 1 to the same in 2 for example

grizzled grove
craggy kite
#

You can also work with alternate sprites for one sprite, I think

winged kiln
#

yea, simple sprite animation is very simple in unity tbh

winged kiln
# grizzled grove

i mean tbh it looks like the hue is different, so maybe change the hue in code through shaders?

grizzled grove
#

I'm planning on using spritesheets that have different size and sprites

#

but still keeping the 3x4 layout

craggy kite
#

I would write my own animation system for that, tbh. Fiddeling with unitys build in one which actually just jumps from sprite to sprite in 0.1 seconds isnt a benefit for your term, I guess.

grizzled grove
#

alright, thank you for the insights, I'll do that then

winged kiln
winged kiln
craggy kite
winged kiln
#

i would say the complicated part would be to get the sprite texture position in the spritesheets, i dont know how to do that, but there are a lot of smart people here who probably did it already

winged kiln
craggy kite
grizzled grove
winged kiln
#

yea but how would he be able get the sprite itself?

craggy kite
#

from the spriterenderer?

winged kiln
#

well it would be from the texture itself where he might assign, right?

grizzled grove
#
Sprite[] sprites = Resources.LoadAll<Sprite>("aliens");
#

and then when I want to render the sprite from the spritesheet I just index it

craggy kite
grizzled grove
#

so now I need to create animator class somehow

winged kiln
#

oh waw, so it is pretty simple πŸ€”

knotty shuttle
#

Why does my player and enemy flies up in the air at collision? They only do that if the enemy is patrolling, i have tried to set a bool

{
patrolling = false;
}
else
{
patrolling = true;
}
if (patrolling)
Patrol();
}

Why do they still fly away? If I comment out Patrol () they don't

knotty shuttle
#
{
                if (mustFlip || bodyCollider.IsTouchingLayers(groundLayer))
                {
                    Flip();
                }
                rb.velocity = new Vector2(speed * Time.fixedDeltaTime, rb.velocity.y);
}

Just walk πŸ˜…

craggy kite
#

you are setting the velocity to speed on x axis... is this the player or enemy?

knotty shuttle
#

This is the enemy

craggy kite
#

What are you rigidbody settings? Maybe they dont use gravity?

knotty shuttle
craggy kite
#

They are kinematic, so they will never use unitys physics engine, so once velocity is set, it stays that way.

knotty shuttle
#

What settings should I use? Dynamic?

#

This worked for me:
Dynamic
Linear drag 999
Angular drag 999

#

Thank you so much!

craggy kite
#

The drag stuff is another story, but yes, dynamic should use gravity and all that needed for your rbs to not fly into heaven πŸ˜„

knotty shuttle
#

But when I press play they go back to kinematic, do you know how I solve that? πŸ˜…

#

Haha, and nope, it did not work, I had just good luck when I tried that time

steep horizon
#

How do I make my character stop be able to jump mid air, using the Linecast technique but I don't understand it

karmic anvil
#

I'm making a incremental game, but I don't want to use scientific notation, i'd like to make the numbers just have M, B ,T etc, how would I approach this

robust ivy
#

id make an array of int, each array value is 0-999, when array[0] reach 999, it turn to 0 and set array[1] to current value + 1

#

that way you can work out with freaking huge numbers

#

then you just reverse array to a string to get the real number, you know if you are at array[1] it will be the thousands, array[2] the millions

#

bit touchy mentally but i think its the best way πŸ˜›

#

eventually as you get in very high number

#

you can even ditch the first few array row and just increment the later one

oblique sinew
#

hello people, after i implemented coin counter my game broke. after i press A or D, my camera flips - making the "game" unplayable.

in the time i was doing the change, there was also a code with name "~movement (Assets)" that i closed because there were some changes that werent saved so i decided to close it, because i didnt change anything in that code. (also, i didnt find any code with the "(Assets)" in the end)

any help?

craggy kite
#

Any error? Like we need code to check against, otherwise we won't know what your issue is

winged kiln
# karmic anvil I'm making a incremental game, but I don't want to use scientific notation, i'd ...
int x = 3;
int coins = 1000;
int CalculateCoins(int coins, ref int x)
{
  // This will give you 1 for coins when x is 3 
  // coins / (10 * 10 * 10) = 1000 / 1000 = 1 <-- this 1 can be 1M for example
  return coins / Mathf.Pow(10, x++);
}

// Maybe have another function here where it would add an M, B, etc to the end of the 
// Text field based on the value of x, if its a multiple of 3 it means its divided by a 1000
// So you can maybe have it so that it would divide by a thousand and every thousand would result in a new letter at the end.

// so maybe something like this:
if(x / 3 == 1) coinsText.text = coins + "M";

// That just means if you have 1 multiple of three then just add "M" to the end,
// you can do if 2 then its basically the coins was divided 1000 * 1000 times. So that can be "B"

// to get the actual value of the coins you would do:
int GetActualCoins(int currentCoins, int multiple)
{
  int coins = currentCoins;
  // multiple being "x"
  for(int i = 0; i < multiple; i++)
  {
    // if the multple was 6, meaning coins were divided 1000 * 1000 then multiply the coins 
    // by 10 * 10 * 10 * 10 * 10 * 10.
    coins *= 10;
  }
  return coins;
}

// then you store both the coins value and the multiple value
oblique sinew
#

gimme a sec

#

should i just copy paste everything there?

#

or to the direct messages?

last surge
#

Hey can anyone help with my animations my jump and falling animations aren't working is there something wrong with my states in my script?https://paste.myst.rs/a65skhnk

craggy kite
last surge
#

I am

#

My animator is using the state method

tropic juniper
#

Hi i have a question. I just imported post processing into my game and now am messing around with the camera filters. The only problem is that now when I try to play my game nothing will happen and im wondering if I am doing something wrong. can someone help?
also is there a way to add image effects to a certain object?

craggy kite
last surge
#

Well i am new to unity soooo i have no idea how to debug

tropic juniper
#

o

craggy kite
last surge
#

So debugg each state

craggy kite
#

Yep, just check that you are while jumping actually in the jumping state. Also check your animator graph if its hitting anything weird or looping only one animation

last surge
#

Soo thanks for the line of code but where do i use ut

#

It*

#

Like under my private void Velocitystate()

#

Or private void update

#

Or private void start

craggy kite
#

@last surge Give it some testing, you are better with just testing around than making me write the code for you πŸ˜‰

last surge
#

Okie dokie imma go start up unity then

upper rune
#

Hi guys, i have a question. On a project I am working on I have implemented wall sliding but when I test it my player bounces off the wall instead of sliding. Could any one help pls

oblique sinew
karmic anvil
#

How do I make my score go up when the screen gets tapped πŸ€”

gleaming sphinx
#

Ok I feel like an idiot currently: I am trying to edit an png during runtime an then display it and I just can not find a way to diplay any changes I make? Am I supposed to use a shader for changes during runtime?

#

^^ forgot I ever mentioned it apparently I have to call apply after setting pixels

mortal mango
#

ihronn, maybe add a canvas with a transparent panel that covers the entire screen, and then add a button component to that panel. Make a script that has some way of referencing and changing the score which can be done with this

public GameObject ThingWithScoreScript
ThingWithScoreScript.GetComponent<TheScriptThatContainsTheScoreVarible>.score += 1

and add this to the onclick on the button.

empty garden
#

hey so i have looked all over the internet to get the simple task of two things happening, getting a bool from one script in another and then getting code to pick a random string from an array. i think i got the bool part down but it either caused problems later on that wasnt in VS or that i just got the random string thing wrong

#

can i get some help

#

the array has 6 elements and i need it to pick one

empty garden
#

i mean that i tried to google it and apply the googled knowlege but it still wont work

#

also i need a bool from one script to be seen in another

#

and then a random string from an array

#

sorry

rocky vault
#

hmm

#

i think you need public static bool bool_name

#

and any random string

#

@empty garden

#

let me give you for random string

empty garden
#

one sec

#

ok so in my code where the bool originates do i make it a public static bool? will that let me reference it in other code

rocky vault
#

my internet go brrrr

empty garden
#

no not any random string a string from a pre set list array

#

so like

#

["one","two"]

#

sorry

#

idk

rocky vault
#

why sorry? πŸ€”

empty garden
#

maybe i wasnt being clear

rocky vault
#

yeah

#

somehow

#

for random you need to go with
random.Next()

empty garden
#

ok

rocky vault
#

int index = random.Next(array.Length);

empty garden
#

when i do that Next has an error

#

random does not have a defintion for next

#

or yeah

rocky vault
#

umm

#

random.Next

#

i thikn you wrote Random.Next

empty garden
#

one second

rocky vault
#

ok

empty garden
#

random does not exist in its current context

#

with lower case

rocky vault
#

ok

#

using System; maybe

#

yeah

#

using System;

#

@empty garden

empty garden
#

yeah

#

i added using system

#

wait

#

not at the top right

rocky vault
#

u need to add in top

empty garden
#

yeah that didnt do anything

rocky vault
#

ik

#

so you have to make a variable

#

as i gave you

#

have you assigned variable?

#

@empty garden

empty garden
#

i mean what a rand varible?

rocky vault
#

yes

empty garden
#

i didnt know we were declaring one

#

there was many ways they told me to use rand.next

#

so i used it weird

rocky vault
#

then you can get the string using:-
array_name[var_name];

empty garden
#

maybe thats it

rocky vault
empty garden
#

oh

#

i forgot you told me to do that

#

sorry

#

wait

rocky vault
#

ok

empty garden
#

no?

#

one second im lost but ill try what you said

rocky vault
#

if any error comes tell me

#

@empty garden

empty garden
#

ok

rocky vault
#

i am mostly available

empty garden
#

idk man i dont know what you are telling me to type becuase it errors out. i even gave array name a string

rocky vault
#

wait what?

empty garden
#

let me show you what i had

#

idk

rocky vault
#

ok

#

give me your code

empty garden
#

ive done this in C++ three times

#

ive never done it in unity

#

or C#

rocky vault
empty garden
#

im sorry but your not being clear

rocky vault
#

ok

#

can you give me code??

#

there is one more way

empty garden
#

this doesnt error

#

string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };

#

thats my array

#

i cant find out how to make it pick one random one

rocky vault
#

hmm

#

ok

#

let me do it

#
string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };
int rand = random.Next(possibleAttacks.Length);
Debug.Log(possibleAttacks[rand];
#

@empty garden

#

if this gives error tell me

empty garden
#

ok

#

im sorry btw

#

yeah

#

random does not exist in its current context

#

maybe using time?

rocky vault
#

using System

#

namespace

rocky vault
#

it is in System namespace

empty garden
#

using System namespace;

#

like that

rocky vault
#

nah

#

using System;

empty garden
#

i did

#

it didnt work

#

io had it there

rocky vault
#

ok one more way

#

let me copy that and use another way

#
string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };
int rand = Random.Range(0, possibleAttacks.Length);
Debug.Log(possibleAttacks[rand];
#

@empty garden

#

are you there?

empty garden
#

ye

#

it says that random is an ambogious reference to system random

#

and unity random

rocky vault
#

ok ok

#

now you can remove using System;

#

@empty garden

#

this is in unity namespace

empty garden
#

ok that worked

#

ty i think i have static reference pulled up ill let you know if i have any trouble with that

rocky vault
#

ok

empty garden
#

ok i got the bool thing done

#

but wait

#

ok

#

let me see

#

there is no way for me to know if this code works becuase it doesnt go into the debug.loog

rocky vault
#

wdym?

empty garden
#
if (playerController.playerMoveSelected == true)
        {


            string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };
            int rand = Random.Range(0, possibleAttacks.Length);
            Debug.Log(possibleAttacks[rand]);

        }```
rocky vault
#

ummm

empty garden
#

it goes true when i click something in the game

rocky vault
#

why didn't you click

#

click and you will know

empty garden
#

i did

#

and it doesnt go into debug

rocky vault
#

where are checking it?

#

in start?

#

@empty garden

empty garden
#

no

rocky vault
#

update?

empty garden
#

no

#

maybe it should be in update

#

i think i know why maybe

#

but let me see

rocky vault
#

umm

#

gud

empty garden
#

well it doesnt work without it but maybe if i put it in update

#

i forgot i made this its own function

#

so i need to do something

rocky vault
#

it can be solved

empty garden
#

ok

#

i made it print+

#

but it just printed all of them

rocky vault
#

wait what?

empty garden
#

wait

#

nope

#

nvm

rocky vault
#

are you using my code or something else?

empty garden
#

i did abad

rocky vault
#

so it worked??

worldly jackal
#

i like men

#

i like men

#

i like men

empty garden
#

no

worldly jackal
#

i like men

#

i like men

empty garden
#

wait

#

OH

rocky vault
#

hmm

empty garden
#

I SEE WHAT AND WHAT I DID WRONG

rocky vault
#

he run py autogui?

#

@worldly jackal

empty garden
#

this should work maybe?

rocky vault
#

what?

empty garden
#

ok

#

so i put it in update

rocky vault
#

oh

#

yeah

empty garden
#

like ```randomEnemyAttack();

#

but

#

it might work

rocky vault
#

then it should work

empty garden
#

becuase what i awnt to do

#

and didnt do yet

#

is that later on it will turn off the playerMoveselected

#

i can do that now

#

fuck yes its good now

#

ok

#

so i think i got litterally all of it from here.

#

watch me come back soon

rocky vault
#

ok ok

plain oxide
#

hi guys is it possible to go to the next scene once the dialogue has ended?

burnt narwhal
# plain oxide hi guys is it possible to go to the next scene once the dialogue has ended?

If you're talking about dialogue you control, ie it's regulated in a script, just make a line of code that loads the next scene using the scene manager;

this goes at the very top;
using UnityEngine.SceneManagement;

Then, you can access it through code once your dialogue is done;

SceneManager.LoadScene("name of your scene");

or, if it really is the next scene in the index, you can use the index number on the scene list in build settings;

SceneManager.LoadScene(index number);

I hope this was what you were looking for!

plain oxide
#

thank you so much !

empty coral
#

why does this happen?

public class Adebug : MonoBehaviour {
    public Object testObj;
    public Sprite local_button_s;
    private Texture2D local_button;

    void Start () {
        local_button = new Texture2D( (int)local_button_s.rect.width, (int)local_button_s.rect.height );
         var pixels = local_button_s.texture.GetPixels(  (int)local_button_s.textureRect.x, 
                                         (int)local_button_s.textureRect.y, 
                                         (int)local_button_s.textureRect.width, 
                                         (int)local_button_s.textureRect.height );
         local_button.SetPixels( pixels );
         local_button.Apply();
    }
    
    // Update is called once per frame
    void OnGUI () {
        GUI.skin.button.active.background = local_button;
        if (GUI.Button(new Rect(35, 80, 121, 56),""))
        {
            Destroy(testObj);
        }
    }
}
normal jolt
#

Hi, I 've done 2D platformer character controllers before, but now I'm making a new game, where want the player (the circle) to roll like a wheel and move around rolling

#

But I can't figure out how to do it

#

If i rotate the gameobject itself, it doesen't move at all

craggy kite
#

@normal jolt how do you rotate it?

burnt narwhal
normal jolt
#

I', doing it using the transform, but it doesn't even matter because it doesent work

transform.eulerAngles += new Vector3(0, 0, 1f);
burnt narwhal
#

Bc in 3d, using gravity and an object with collision and friction, an object will naturally roll. I don't think transform gives it any physical movement, it just rotates the applicable gameobject.

normal jolt
#

Where can I learn more about the difference between using transform, using rigidbodies e.t.c.? because I've been using Unity for a few months but I still feel completely new when it comes to working with this kind of stuff.

burnt narwhal
#

yeah, me too. As far as I know, rigidbodies pay more attention to collision and friction, while transform only worries about moving the object.

empty coral
vocal condor
#

Transform is the standard way to move and rotate. Rigidbody does so using Physics. Character Controller uses RB under the hood.

normal jolt
#

I think i'm not explaining myself, i did not used any premade character controllers before, I done them myself using rigidbodies, but I used because it was the first thing i thought of, but I didn't really understood the difference.

vocal condor
#

Between CC and RB? They have different restrictions.

#

RB you're working directly with forces and velocity.

normal jolt
vocal condor
#

CC is an interface that manages an RB for you. It's supposedly much more easier to jump start applying movement but much more difficult to add/reimplement hidden RB features from CC.

normal jolt
#

I didn't even know about the existance of cc

vocal condor
glacial forge
#

hello

vocal condor
#

Other than those two, Transform is the default handler for manipulating an objects translation, rotation, scale and the node; every object must have a Transform component.

glacial forge
#

i need some help with texturing a scrollBar

#

if someone could help, i would be so thankful

normal jolt
#

I get it, thanks for the advice @vocal condor

glacial forge
craggy kite
#

Your image is not sliced, I guess

glacial forge
#

couple of my friends told me to use GUIStyle

#

but

#

the idea of adding 2 textures to 1 GUI style confuses me

craggy kite
glacial forge
#

well

#

the problem is in coding tho

#

i got the textures

#

2 separate textures

craggy kite
#

You are showing a graphical issue and say its coding? πŸ˜‰

glacial forge
#

yeah just wait

#

so

#

GUI.skin.verticalScrollbar.normal.background = this.background; GUI.skin.verticalScrollbarThumb.normal.background = this.thumb;

#

i used this for applying the textures

#

but this aint the way is it

craggy kite
#

Still the textures might be the right ones, but the settings on your Image components are messed up, thats what I am guessing

glacial forge
#

now idk how to apply these both to a guistyle and not break up

craggy kite
#

Or the settings of your textures

glacial forge
#

the textures should be ok tho

#

now the problem is

craggy kite
#

did you compare the standard thumb texture with yours?

glacial forge
#

the thumb doesnt go outside the bar

#

the size of the scrollbar can be changed, now the thumb is being streched and contained inside of the bar it self

twilit gale
#

I'm making a top down rpg, and I need to fetch tiles from an external web api. Which I successfully do, but how do I draw this 64x64 png file to the map? Sorry I'm all new to Unity.. Should I use a tiemap grid?

glacial forge
#

wel even if u guys help me solve the streching, i could change the texture design

#

its no big deal

craggy kite
#

And again, can you show the inspector when the thumb is laoded of your image component?

glacial forge
#

by inspector, do you mean what I use to load the file into a texture2d?

craggy kite
#

Inspector, of Unity, the image in your scrollbar?

glacial forge
#

im not even using unity actually

#

im coding and using textures

#
        if (this.thumb == null)
        {
            this.thumb = www.texture;
            this.thumb.Apply();
        }```
craggy kite
#

So you are using Unity Coding but not using Unity? How can you see the scrollbar then? ... come on...

glacial forge
#

??

#

Im not using Unity program to model the scrollbar

#

im using namespaces and OnGUI

craggy kite
#

... I know, but you are loading a skin into the component of the scrollbar...

glacial forge
#

yeahhh

#

and i want to fix the streching atleast

craggy kite
#

I'm out, got no time. If you don't wanna show the inspector, fine πŸ˜„ got work to do.

glacial forge
#

bye ig

grizzled grove
#

Hello, how can I make sure that the tiles in tilesheet, won't have these gaps between them?

winged kiln
grizzled grove
winged kiln
#

oh that works too

#

is it pixel tho?

terse thorn
#

i have this problem with spawning enemies with a button. the button parent has the code to update the destination of the DemonAlien to the transform of the ship

what i want to happen?:

i want the enemy to instantiate in scene when OnButtonPress() and start following the coordinates of the ship given by the button parent script

what is happening actually?:

when i spawn the enemy (click the button) he is in screen for one second and then goes flying away and its coordinates go mad and i dont know what to do...

#

(*sorry for the flood)

tropic inlet
#

I didn't know Rigidbody2D.rotation existed
it looks so convenient

terse thorn
#

if you put .rotation at the end of a gameobject you directly acces to its rotation

tropic inlet
#

I know, but, the reason I think it's convenient is because

#

Rigidbody2D's rotation is a float as opposed to a quaternion.
I expected it to be a quaternion like Rigidbody.rotation.

upbeat vault
empty garden
#

hey quck question, how do you make this code only accpect strings, becuase i cant covert a int to string and idk how to get it to not do that string eSelectedMove = Random.Range(0, possibleAttacks.);

#

wait

#

there might be something missing there but idk

#

i was fiddling with it and gave up

#

string eSelectedMove = Random.Range(0, possibleAttacks.Length);

#

thats what it is when its done

#

need it to be string to string

#

can anyone help? i have to go for a while soon

ornate lava
#

@empty garden eSelectedMove is declared as a string.
Random.Range, as you are using it, is returning an int

#

Where is the string value expected to be coming from ?

#

Are you meaning to use the Random int value as in index into a list ??

#

something like this ?

string eSelectedMove = possibleAttacks[Random.Range(0, possibleAttacks.Length)];
night vault
#

so i need some advice about something im trying to do

#

im making a top down shooter and im partially using this tutorial since im new

#

in the tutorial they essentially have the sprite and just rotate it when you move the mouse, which in turn rotates the fire point on the player body, which redirects where you shoot from

#

which would work well except im trying to make it so that the sprite itself doesnt rotate, my game will be more isometric and the character will animate to face towards the mouse in 8 directions, basically

#

whereas the tutorial just rotates the character which only works if the camera perspective is completely directly overhead

#

so, i dont know how else to shoot where the mouse is pointing other than rotating the player to move the fire point to the proper position

#

how would you deal with this? im not sure how other top down games achieve this

#

im thinking about just making the player object rotate like in the tutorial and just have a player sprite over the invisible body and animating the sprite? does this sound like a smart solution or is there a better way?

empty garden
#

@ornate lava sorry im back

#

let me show some more of what i was trying to do

#
            string eSelectedMove = Random.Range(0, possibleAttacks.Length);
            Debug.Log(possibleAttacks[eSelectedMove]);``` this should be all  that is needed to know idk
#

and i want to randomly pick one string from here

#

then im trying to make it so that if lets say "cut" is the string chosen that it will then do something ele but i know how to do that

ornate lava
#
string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };
int eSelectedMoveIndex = Random.Range(0, possibleAttacks.Length);
string _attack = possibleAttacks[eSelectedMoveIndex] ;
Debug.Log($"_attack mode : {_attack}");

@empty garden Perhaps something like this ?

frozen anvil
#

I have a player who can move left and right and the weapon kind of just floats infront of him. I made the weapon a child of the player. When the player turns around he flips and the weapon is supposed to float in front of him again but instead it floats behind him. What do I do to fix this?

#

Nvm fixed it

ornate lava
#

@frozen anvil How, ? did you multiply the child localScale X by -1 ?

empty garden
#

@ornate lava this might work sorry for the late response. at six i have a class that can help me further i just wanted to do more so i will have more done before then

ornate lava
#

? at six ?

#

ahh later

empty garden
#

yeah the thing is ive done this in c++ three times becuase i try to make it in command line

#

but always dont have enough skill to do it

#

so im trying to see how far i get in unity

#

so i know the path on what to do not how to do some of it

ornate lava
#

This makes it easier to understand, perhaps

string[] possibleAttacks = {"Cut", "Poke", "Bash", "Block", "Parry", "Grapple"};
int eSelectedMoveIndex = Random.Range( 0, possibleAttacks.Length );
string _attack = possibleAttacks[eSelectedMoveIndex];

print( $"possibleAttacks.Length : {possibleAttacks.Length}" );
print( $"_grapple mode : {possibleAttacks[possibleAttacks.Length - 1]}" );
print( $"Random Index and _attack mode :  {eSelectedMoveIndex } == {_attack}" );
vocal ravine
#

Can someone help me? Whenever i move my arms my whole body connects weirdly to it

#

(first 4 secs the game loades)

mossy bough
#

@vocal ravine irl or in your game?

vocal ravine
mossy bough
#

dont you want the arms to be attached lol, dont see anything wrong with that gif

vocal ravine
#

i want them to be attached but when i move them my body stars flying

#

the collision is turned off

civic knot
#

So you didn't jump on purpose in that gif?

terse thorn
#

that looks like you are just moving them

vocal ravine
terse thorn
#

(to rotate the arms)

vocal ravine
#

ok

terse thorn
#

i recommend have a parent object and make that rotate towards the cursor with help of video

oak sage
#

So im having this issue where my particle wont show however it does spawn can anyone help me?

hasty mason
#

so Vector2.up, Vector2.left and so on exist...is there something similar for the 4 cardinal directions of a single Euler angle?

#

eh, nevermind

#

not all that important

#

got the thing working I wanted this for, too

scenic ether
#

anyone good with trig willing to check my work here?

#

trying to calculate the distance of the ?

#

all known values are labelled

#

ping me if you have anything for me

compact blade
#

@scenic ether Looks good to me. A simple tangent calculation. as long at that O isnt a zero lmao. Tangent is Opposite over adjacent, and you isolated the Opposite/the ? correctly. You calculated the angle right, that angle inside the triangle is pi/2-n(Theta). I think your right.

#

I dont se any problems with your math

scenic ether
#

O is a label, i shouldve chosen a better label haha

compact blade
#

Yea, i figured that out when ?/O wasnt undefiened lmao

scenic ether
compact blade
#

But what are you using this for? what game mechanic do you need this trigonometry for?

scenic ether
#

basically i was trying to create my own collision physics system

#

the diagonal line there is a wall, and the line formed by (sx, sz) and (ox,oz) is the velocity vector

#

i was trying to calculate the missing side to determine how much the velocity needed to be adjusted to avoid a clip

#

but since then i've decided on a different approach

supple vine
#

Can somebody please help me fix my script? I have no idea what's wrong and no idea how to fix it......

hollow crown
#

Then you need to provide more context about what on earth GetDebuggerDisplay is

supple vine
#

I have no idea it was Unity who put it there as part of the default code

hollow crown
#

I have never seen Unity do that

supple vine
#

Do I delete it then?

hollow crown
#

Yes, that attribute is not relevant

supple vine
#

ok

hollow crown
#

You also have other basic mistakes that should be highlighted and avoided when your IDE gets configured

supple vine
#

I'm configuring Unity to use visual studio code rn

#

What's an IDE?

hollow crown
#

Visual Studio/Visual Studio Code and likewise

supple vine
#

oh ok

#

My version of unity doesn't have the "Editor Attaching" checkbox. What do I do?

hollow crown
#

Ignore that step

supple vine
#

ok

hollow crown
#

Both misspelling/incorrect names

supple vine
#

...

burnt tartan
#

@supple vine The red squiggly underlines are pointing out the errors for you.

supple vine
#

Thanks for pointing that out Captain Obvious

burnt tartan
#

😐

hollow crown
supple vine
#

I said "..." because I was embarrassed about the spelling mistake

mortal palm
#

I'm making a platformer and I want the camera to slide left or right once you've left it's view. Any idea on how to do that?

burnt tartan
#

@mortal palm Look up cinemachine

mortal palm
#

Thanks, I had no idea what to search

burnt tartan
#

In the package manager FYI

fathom ermine
#

hello can some one help me with my code my weapon startes chnaging its rotation by its self

#

its a bit complicated so i want to screen share

mortal palm
#

It's probably reacting to gravity, try changing the Body Type in Rigidbody 2D from Dynamic to Kinematic

mortal palm
#

its caused by the flipping

fathom ermine
#

only when i look down or up my weapon rotation starts changing

mortal palm
#

it doesnt know where to flip when youre not to the right or left

#

so its trying both

#

Try this:

else if ((Mathf.Abs(weapond.transform.rotation.z)) < 0.7f)
{
    player.transform.localScale = new Vector2(0.8f, player.transform.localScale.y);
    weapond.transform.localScale = new Vector2(1.25f, 1.25f);
}
#

actually, it might not fix it either

fathom ermine
#

so do i do it?

mortal palm
#

try it

#

someone else probably smarter then me is typing though

normal jolt
#

Hi, yesterday i asked about how could I make a ball roll around the screen, I just wanted to share that I tried a bunch of things, but what worked best was simply using AddTorque with the rigidbody, and works very nice :D

rb.AddTorque(Input.GetAxis("Horizontal") * speed);
#

Here is a video of the game working

hushed solar
vocal condor
hushed solar
#

How so ?

vocal condor
#

It's saying that you've got this script file that doesn't have any matching class inside so Unity will not let you use it at a component.

#

Just look at the class name in the file and the filename. Do they match?

#

Exactly, letter for letter; case sensitive.

hushed solar
#

I did their names the same.

vocal condor
#

Show an image of the class name

hushed solar
#

DegiskenManager

vocal condor
#

Show an image.

#

Also, make sure to save.

hushed solar
vocal condor
#

That isn't the class name

#

The class name is the name of the class inside the script file.

hushed solar
#

I don't know because I just got into this job, I'm sorry.

vocal condor
#

That's the object name and the one in the assets folder is the script/file name

#

You need to make sure the file's name is identical to the class' name; inside the file.

hushed solar
vocal condor
#

Save it.

#

And the error you posted before should go away.

hushed solar
#

how do i fix 😞

vocal condor
#

What're your current errors?

#

Check the console tab in Unity Editor.

#

And you've got errors in your code.

#

You aren't properly assigning the string a string literal. And your debug log is incorrectly used.

#

Should probably ask for scripting help in #πŸ’»β”ƒcode-beginner and they may point you to some tutorials on basic c# and Unity scripting.

hushed solar
#

Thank you for help me

fathom ermine
#

there is an error that idk how to fix

#
Copyright (C) Microsoft Corporation. All rights reserved.```
uneven nova
#

Hey, is there a way to flip a child gameObject at the same time I'm flipping the parent sprite in my sprite renderer component ?

still tendon
uneven nova
#

@still tendon Yep, I just found out I could do that, thanks

scenic ether
#

does RaycastHit.normal return a normal that points inward from the collision surface or outward?

tropic inlet
#

outward

#

u can test it by

#

rigidbody.AddForce(normal * 100.0f);

scenic ether
#

i know i can test it, i figured it'd be quicker to ask

#

thanks though

frank pulsar
#

Hello, so I’m trying to make a game using a mega man sprite and I am trying to make it shoot but the issue I am having that the shooting animation keeps overlapping the idle animation. So the shooting animation is two short. Can anyone help me solve this problem?

deep dove
frank pulsar
#

I tried that and nothing happened

deep dove
#

Than posts details / screenshots how you configured transitions and animations

frank pulsar
#

okay so im waiting for my Unity to boot up right now, but I did all my animations in code, the issue im having is that my idle animation is always player when im on the ground. So I need a way to stop it from constantly playing the idle animation so It can play the shooting animation

deep dove
#

Animator setup, you graph and transitions?

frank pulsar
deep dove
#

Thats the problem, you need to setup transitions and blending between animations

frank pulsar
#

Yeah but I have other animations working off of pure code

#

I'm fairly certain that I need condition that checks if I am playing the shooting animation, I just dont know how to write that

deep dove
#

It's much easier to achieve with animator. For code writing: try, fail, repeat

frank pulsar
#

Probably, but Ive been going off of this tutorial https://youtu.be/44djqUTg2Sg

β–Ί Easily Make Platfomers in Unity - http://u3d.as/2eYe​
​​► Easily Make Car Games in Unity - http://u3d.as/1HFX

Wishlist my game Blood And Mead on Steam!:
https://store.steampowered.com/app/1081830/Blood_And_Mead/

How I nearly destroyed my game, but Nintendo wisdom saved it:
https://www.youtube.com/watch?v=a4M-21AMiQE

In this game dev tutori...

β–Ά Play video
#

So I dont know how I would transition to that

deep dove
#

Do some animator tutorials, learn, refactor.

frank pulsar
#

Alright

elfin sandal
#

I'm trying to use Physics2D.OverlapCircle
but I'm having trouble setting a layer filter to a contact filter object

pastel fern
#

does anyone have top-down code

elfin sandal
#

I used

ContactFilter2D filter = new ContactFilter2D();
filter.SetLayerMask(LayerMask.GetMask("Enemy"));
#

but it doesn't work

pastel fern
#

or any yt videos to suggest

#

hello

elfin sandal
#

hi

pastel fern
#

do you have top down code on hand

elfin sandal
#

no

pastel fern
#

might you know any videos

elfin sandal
#

brackeys

pastel fern
#

ok

#

will go and check it out

#

found the video and it has the animation in it

shell whale
#

Hello I'm trying to make a toggle that loops a slider over a period of time.
If the toggle is on -> slider goes up -> if slider reaches max then it starts over and loops.
Any help would be appreciated πŸ™‚

deep dove
#

Check dotween asset, it's easiet way to achieve this

compact blade
#

So, im going to have to paste a large chunk of my code in here, cuz there are several posibilities of what could be wrong with my code. and i dont really know whats happening. I also will share a link to a streamable of the video of whats going wrong.

#

not too large, but a chunk

hollow crown
#

Just send your code via a service like hatebin

compact blade
#

I tried that earlier but im confused on those. like i dont get it it wont give me a link to paste, only the code.

hollow crown
#

You just click save

compact blade
#

ok nvm im retarded

hollow crown
#

and then copy the url

#

Please don't use ableist language thanks

compact blade
#

https://streamable.com/d0fuvo

https://paste.myst.rs/vrhxa0vi
This script is put onto my camera, and i have properly assigned the object Character to the sprite i was controlling by drag and drop. I am trying to have the camera follow you on the y axis only when you get close to the edge of the screen. it works for when i drop down, but not when i go up. It teleports off somewhere, i do not understand it.

#

i dont know why. and that - or minus with the Character.position.y + (Size-1) on line38 i have changed back and forth. It should be -.

hollow crown
#

Wrong dimension

compact blade
#

huh.

#

i couldve sword that was z. Thanks

#

now to implement it slowly returning to the right y position once he is not in the air.

#

loop time lmao

dusk escarp
#

how can I change the depth of a bone from code?

compact blade
#

Im trying to have a camera decelleerate as it is panning to a specific postion depending on how far away it is. Do i have to use rigidbody2d? is that going to screw with my current camera system where i just set the position to where i want it?
how would i even go about it doing that? for loops?

#

i would need some way of approximating that im close enough to a position and then teleporting to it.

dusk escarp
#

@compact blade you could use rigidbody2d but you could also do that just by modifying the transform

#

i'd start by writing out an equation that relates the variables you care about: the position of the camera, the position of the object you're moving towards, and the speed you're moving

#

once you've got that, you can set the position of the camera (its transform.position) to the result of that equation in Update() (making sure to multiply by Time.deltaTime, which is the amount of time since the last frame)

#

i don't think you'll need loops

fervent cosmos
#

Hey I am new to unity and C# in general and i was wondering how to make a death zone in my 2d game.

dusk escarp
#

@fervent cosmos what's a death zone?

fervent cosmos
#

a place where a player will die and then respawn

#

like in a platformer game where a player goes off the screen it will respawn the player at the beginning

dusk escarp
#

high level, you would use make an empty gameobject and move it to where you want the respawn point to be

#

then, when the player "dies", set their position to that gameobject's position using a script

fervent cosmos
#

ok thanks

dusk escarp
#

if the player dies by going out of bounds, you'll want to look into colliders

fervent cosmos
#

ok

compact blade
#

Ahh dangit the one this that i didnt want to break isnt working right.

#

thing*

#

my isGrounded Check was not coded by me, but by a friend and i dont understand it. it doesnt properly detect im grounded if im at the very edge of a collisionbox.

#

Is it possible that i could send a link to the pastebin of it and someone could explain it to me in rough terms?

#

i think it might be something i need to understand lmao

supple bison
#

How do I make a softbody shape?

#

I can't figure it out

barren lark
#

Got a pretty interesting problem to solve.

#

I have a small sprite object that takes up maybe ~10-15% of the whole screen, situated automatically to be in the top-left based on camera position. Like this:

#

What I want to do is
to not only clone that square sprite until it fills up the entire screen (it's okay if the sprite goes past the right-side or bottom-side edges, but if we clone it after that, it's redundant)
BUT also find a way to move this entire new sprite "mass" a la a scrolling background (think Animal Crossing menu background.)

#

My idea would be that I'd make all the clones children of the parent... But then I don't have a good way to gauge the size of the entire thing.

rocky vault
#

are you talking about anchors? @barren lark

barren lark
#

No, tell me

#

Or, let me say it like this: No, but I'm curious as to what those are.

rocky vault
#

so are you using anchor to put sprite on top-left??

barren lark
#

No, I'm not -- I do it like this:

rocky vault
#

if not me wrong anchor makes it very easy

barren lark
#

Oh, well I've already taken care of that part.

rocky vault
#

so you want it to bottom left (a clone of obj) πŸ€”

#

@barren lark

barren lark
#

I want it to fill up the whole screen, and then move diagonally.

rocky vault
#

OoO

#

kind of animation

#

size according to screen is easy

#
obj.transform.scale = new Vector2(Screen.width, Screen.height);
#

may people use transform.localScale

#

@barren lark

#

and then you can use for bottom left

#
obj.transform.position = new Vector2(Screen.width - Screen.width, Screen.height - Screen.height); // means 0 lol. I am fooling you 🀣🀣🀣
#

@barren lark

barren lark
#

Ah, that's still not one I'm talking about. I'm having dinner now, please don't mention me again. But I appreciate your effort to help nonetheless.

rocky vault
#

oh ok

barren lark
#

What I mean is that...

#

All these cubes are clones of the shaded cube, therefore making a tile pattern.

#

I need to figure out how to dynamically "wrap" them as the entire group of tiles moves horizontally, vertically, or a mix of both.

#

I also need to figure out how to arrange them on-the-fly.

coral dawn
hollow crown
#

Also, sounds like you haven't declared shouldDie, and timeBeforeDestroy is not a method. The errors seem pretty clear about it all

wooden valley
#

Essentially.. the "physical" object is responding to the clamp, but the rigidbody itself... isn't?

fervent cosmos
#

Does anyone know a easy teleportation code for my 2d game. I want the player to teleport to a place when a game object is touched

meager mural
#
void OnCollisionEnter2D(Collision2D other)
{
  if(other.gameObject.CompareTag("Player"))
  {
    player.transform.position = newTransformGameObject.position;
  }
}```
fervent cosmos
#

ok thanks

#

@meager mural when i run that code it give me 2 errors. 1. The name 'player' does not exist in the current context. 2. The name 'newTransformGameObject' doesn't exist in current context.

#

This is the code

meager mural
#

Yes. Because is psuedo

#

Substitute those variable names for what you use / are going to use

fervent cosmos
#

ok

#

sorry im new to unity

uneven nova
#

Hey, how do you pixelate only one object in 2d ?

deep dove
uneven nova
#

Isn't there a way to do it via render texture and camera layers ?

deep dove
#

I don't know, try googling it

empty garden
#

so this thing i need help on might be better to do later but ill ask anyway to see if it should. basically i need to make an index, or list, or idk what to call it, of all the moves or attacks in my game, what they do, how they affect the player or the enemy, how much damage it does, and a value stored in them to seperate them into six categorizes

#

so let me explain

#

there are six move types in my game

#

slash, pierce blunt, block , parry, grapple

#

one move might have the slash pre-fix on it

#

another pierce

#

ive never been able to figure out how to do this but its important for my code

#

i might be able to figure it out over time, but i wanted to know if i can get help here

deep dove
#

You can use scriptable objects to store this configuration, or do you ask for something else?

empty garden
#

im not really sure

#

i mean the player and the enemy might use these, or only the player, or only the enemy

#

kinda like a big dictonary of moves

#

and it needs to do everythng the attack does

#

like if its a bleed effect

#

i need it to explain in the code, how bleeding works

#

in the game

#

if the target attacks with a bleed on them they take damage

#

that might be hard to get in at first but at least making the list of moves needs to start

#

poison would work the opposite

#

if the target defends they take damage

#

even if this doesnt do anything rn i should at least list it and comment what it would do

deep dove
#

Looks like you need to design class structure that holds all this information and the rest of the code can use it. As root object you can store it in Scriptable Objects.

empty garden
#

one second i forgot i needed to open unity

#

ok

#

when you say scriptable objects im reading it on the unity site what do you mean and how do "inherit" my script from the scripable object class

#

idk sorry very new to unity

#

is it just something you write in your normal c# script

#

or a special file you make

deep dove
#

yes and yes, special C# class that can be instantiated in editor as asset

empty garden
#

ok so just make a c# script and call it like moveIndex? then instantiated it in my class how? or wait i think your saying its different from a regualr c# script where is it found?

deep dove
#

Ok, best would be to follow some SO tutorial. Plenty of those.

empty garden
#

yeah i might read up on it for a bit sorry

#

ill be back if and when i figure it out quicklu enouigh

#

ok so scriptable objects cant be attached to game objects which may or may not be a problem idk yet

dark flicker
#

I mean you could make a new scriptable object and child it to the object

deep dove
empty garden
#

i mean yeah eventually there will be buttons and the player pressing on them to trigger the move's abilities but i think you can still use scripable objects still

deep dove
#

Yes, actual skill state can be stored in MB attached to entity that trigger it.

empty garden
#

ok whats annoying me is i cant find the create scriptable object button in the editor

#

thats what meant before

#

and i googled it a bit and its not where it should be

#

when i look in the same place the others did

#

i saw it was right under legacy but its not there for me

deep dove
#

you just create C# class and extends ScriptableObject base class

empty garden
#

oh

#

other people were showing its something you can create in the editor

#

ok i get it now

#

looked up so tutorial for it a bit

#

lemmie just get change the monobheavoir thing

#

to the sciptable object

#

ok im good and ready now i think

#

sorry

#

so i dont think i would use a separate function for each thing right? maybe a dictionary or something similar? when i tried to make this in Python dictionaries almost worked for what i needed them to do but i couldnt organize the dictionary into catergoires i think and thats when i gave up on python

#

i mean i could have made just 6 different dictionaries for pyhton looking back

#

but thats in the past i want to try to get it in unity to work

#

i dont know how i would orgainze all the moves in this class.

#

@deep dove you there? sorry for the ping

deep dove
#

But you make SO that holds commond definition for example you can name it Skill

#

add all things you need to configure differently between skill, and create instance for each skill in editor

#

If you need some really specific things for some skills you can create new class and expend base Skill

#

Or you can go for some composite approach design but this is usually harder and requires better class design experience.

#

I think I also saw some yotube tutorial exactly that someone creates some sample skill hierarchy based on SOs

empty garden
#

i mean i dont know how it would get really specific some might inflict a damage over time, or activate two different move types

#

so like a parry and a block in one move

#

maybe link it if you think it could help me?

#

also im looking at some sites i dont know what youmean by common defntion

deep dove
#

I think this is more design problem than specific unity problem. Like you need to design you class structure to support all cases. This is usally hard, easier is to start with something small and refactor to more complex design.

empty garden
#

hmmm ok i might wait on this then

deep dove
#
Unity Learn

In this recorded live training session from August 2016, we create a flexible player ability system which includes player abilities with cool downs, similar to those seen in MOBA or MMO games. The approach uses scriptable objects and is designed to allow game designers to create multiple variations of an ability and swap between them easily.

empty garden
#

i have a class on unity on tuesday so i might wait to ask there

#

i might come back later for the other thing i might need help with.

glad plume
#

Is it possible to hack the particle system into allowing the Experimental 2d Lights ?

craggy kite
glad plume
#

No, the particle system wants a normal light in in its "public variable slot" I'd like to try a 2d light. These lights spawn with the particles and inherit some things like intensity if i recall correct.

deep dove
#

use: while (transform.position - target < someThreshold)

#

Floats that are part of the vector can't really compared in this way

#

just assign final position when you leave loop, but don't compare vectors using !=

#

You never leave the loop because of imprecise float comparison, same exact position still may not be exact in the terms of how float comparison works on CPU

#

it doesn't matter why it works for some values

empty garden
#

so ive done this at least three times in command line c++ but im interested in maybe doing it a simpler way in unity

#

so the final part of the game that determines how combat works is a rock paper scissors type of code but with three six different ways to win

#

slash beats all defensive moves expect block, if you get blocked you take counter attack damage. if two of the same moves hit each other nothing happens (for now) and if two different attacks get each other then you both take damage. this works for all moves in the game

#

i did a very long way of doing in before

#

can unity help me do it quicker and simplier?

robust ivy
#

any logic like this mean coding and its probably the same way you did before, except c# syntax probably easier than c++, but yeah in general its gonna be the same thing

tropic inlet
#

pointer, template and variadic stuff, especially

#

Simpler doesn't always mean shorter

#

Simpler can mean more verbosity and code duplication

empty garden
#

what i mean is that is their a quicker more compressed way to do this code than what im thinking of which is a big if else statement

#

i think i did that

#

yeah

#

i did

#

or maybe it was case

#

either way i did a huge thing that was like if the player slashmove bool is true and the enemy block bool is true then the enemy wins

#

and i did that for like everything

#

and the thing is i have to set it up in a way that allows for the flexible nature of different attack moves

#

because there could be 50 different slash moves but all slash moves are blocked by a block

#

and i get that it migth not be shorter but it needs to be flexible and be functional with future code

#

i can always change it but i want it so its here not set up not rigid

#

i mean the bool of the code might not make it matter wheater its slash attack a or b

#

becuase it checks for the bool

#

not what spefic attack its comming from

vocal condor
#

That way, you'd have a much more condensed logic for the comparison.

empty garden
#

i mean maybe i wouldnt know, basically the index of moves in the game that i wanted to do eariler will have a value attached with it. lets say slash. if the player chooses that attack it will make a bool go off, that bool will be compared to the other enemies bool then the combat outcome will happen

#

that was my idea

#

but i wouldnt know how to get yours to work

vocal condor
#

At the minor expense of determine or managing the weigh of the attack; ultimately depends on your design but this would definitely introduce flexibility.

empty garden
#

the attack values dont exist yet only the attack types

#

ok

#

i mean i wouldnt know how to do what you are saying though. thats the thing

#

so like rn the player can choose to do a slash attack and thats it, later they can choose what kind of slash attack to do

#

like the list of known moves

vocal condor
#

So let us say Slash-88 is worth 7 points and Fireball-63 is worth 4 points. You'd just have a comparison of if attack one's value was less than or greater than attack two's.

#

Good luck.

empty garden
#

wait but how would that work, this is rock paper scissors the rpg, it would get difficult comparing numbers right? why not... i forget what a single letter string iscalled but that, so A beats B and B beats C?

#

well im designing a script tho

#

i know what design to do

#

i dont know how to script it

#

for the best way possible

#

becuase i can do a simple/long if else statment for this

#

im looking for an alterative

robust ivy
#

id start by creating a project and beginning the coding in c# first ;p

empty garden
#

i did

#

this is like the last step i need to code in the other stuff ive always run into problems with command line C++

vocal condor
#

You've got to find the pattern in evaluating your attacks. Then you'll have a universal and flexible method to handle comparisons.

empty garden
#

i have buttons and everything

#

yeah exactly

#

i just dont know if my big if else statment will do that or if a different way ive never thought will

#

ive used characters 'a' like that to do comparisons before

#

but that got a little too messy

#

and confusing

vocal condor
#

You can usually condense repetitive code; which I suggested.

empty garden
#

yeah this is super repetive

vocal condor
#

But it would be dependent on your strength in design patterns.

empty garden
#

i would love a better way to not have it be so repeatiative

vocal condor
#

If you cannot determine find a solution, you may just have to stick with it or ask in #archived-game-design .

empty garden
#

yeah and thats where i probably fall off i can design ideas well but im an amature coder

#

ok ill check game design

vocal condor
#

You're the designer, so it's ultimately up to you but I can tell you your big (hopefully it's big enough to warrant optimization else you're wasting time with premature optimization) if-statement of attacks is likely condensable. You just need to make and completely understand the rules of your game.

empty garden
#

i mean ok lets think about it i have 6 moves

#

three attack three defenses

#

there are three things to happen to those moves

#

they can damage, be blocked get damage and damagaed, or get into a tie

#

four

#

actually

#

so i have to check im bad at math sometimes

#

3 times 3 times four? or is it 3 times 3 times 3 times four im bad at this

vocal condor
#

Depending on design, you could just simply have a class of attacks and overload what occurs depending on the other type πŸ€·β€β™‚οΈ; open ended.

empty garden
#

yeah that might work too but i have no idea what you just said

#

its just a simple comparison

slim galleon
#

Hey everyone, have a little problem that i am unaware of how to fix. My camera follows the bullet i shoot and my bullets are invisible.
The only component where camera is mentioned is on my player asset where i use it to rotate my player to cursor position.
The character movement code i made;

  public float speed = 10f;
  private Rigidbody2D rb;
  public Camera cam;
  Vector2 mousePos;

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

  void FixedUpdate()
  {
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");

    Vector2 movement = new Vector2(moveHorizontal, moveVertical);

    rb.AddForce(movement * speed);

    mousePos= cam.ScreenToWorldPoint(Input.mousePosition);
    Vector2 lookDir = mousePos - rb.position;
    float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg + 90f;
    rb.rotation = angle;



  }```
empty garden
#

but there is a lot.

#

not too much

#

enough to be annoying

vocal condor
#

If it ain't broken, don't fix it is my only advise then.

empty garden
#

again ive done it before in C++

#

the thing is idk if it will be broken going forward

#

becuase ive never gotten farther than this in C++ command line

vocal condor
#

I've program in c++ for 15 years but it's not relevant to the games design.

empty garden
#

but yeah

#

maybe for now ill just do it

vocal condor
#

If you had the logic block in your c++ application, you'll have it here too.

#

If you solved it there, it wouldn't have been a problem here.

empty garden
#

no its not that

#

i just didnt know how to proceed after this, also though

#

if it is comparing bools

#

the way i thought of it

#

how would it reference back to the attack it got the bool from

robust ivy
#

best way is to start coding it and the logic will come eventually

vocal condor
empty garden
#

how does my combatHandler know that the slashattack bool was triggered from Fire Swipe, a fire move

#

yeah

#

ill go there for now

vocal condor
#

The more you code/implement other designs such as A* (don't shoot yourself), the better your algorithms will get.

empty garden
#

i mean i get more direct help on tuseday

#

i wanted to see how far i could get without it rn

robust ivy
#

what is the problem

#

invisible bullet?

slim galleon
#

Well my camera follows my bullet whenever i shoot one

robust ivy
#

that is the problem?

slim galleon
#

yes

robust ivy
#

kk in some game its a feature

#

;p

slim galleon
#

πŸ˜„

#

Wellp lets make it one

#

Like my cam has no component

#

no script is touching camera

#

but it follows it

#

i am gonna restart the project i screwed something i cant find

robust ivy
#

the cam get attached to the bullet somehow

#

what is the bullet script looking like, or the way you instantiate the bullet?

slim galleon
#

its pretty simple actually void Fire(){ Instantiate(bulletPrefab, firePoint.position, firePoint.rotation); }

#

firepoint is an empty asset

#

bullet prefab is a prefab i drag to the component inspection

robust ivy
#

yeah that work

#

where are you firing from

#

show the update method

slim galleon
#

the only place where i mentioned camera is here mousePos= cam.ScreenToWorldPoint(Input.mousePosition); Vector2 lookDir = mousePos - rb.position; float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg + 90f; rb.rotation = angle;

#
    {
        if(Input.GetButtonDown("Fire1")){
            Fire();
        }
    }```
#

simples shit you can find

robust ivy
#

yeah that doesnt move it

slim galleon
#

i like simple code i can understand

robust ivy
#

as long as it work

#

is there a bullet script

slim galleon
#

people suggest me using premade character movement scripts and stuff but i prefere making it myself

#

yeah

#
    {
        rb2D = GetComponent<Rigidbody2D>();
        rb2D.velocity = transform.up * speed;
    }
}```
#

thats all

robust ivy
#

they often come with behavior you might not like and end up having to understand their whole code to change stuff

#

so yeah its better to make ur

#

unless its something big

slim galleon
#

yeah even attaching to the assets is hard when you copy a 100 line script

#

I think i am gonna open another project

robust ivy
#

i dont see why the cam follow ur bullet

slim galleon
#

if i could get a penny each time i opened a new project

robust ivy
#

cant think of anything

slim galleon
#

i just sent you the 3 scripts in my game πŸ˜„