#archived-code-general

1 messages · Page 160 of 1

versed loom
#

is there any way i can rename them all automatically?

gray mural
#

it works in code

versed loom
gray mural
versed loom
#

idk what are they called, the game objects that are recorded in the animation

gray mural
versed loom
#

tyy

gray mural
ashen yoke
#

and correct/add to what you are discussing

gray mural
#

it will give you "Leaving Discord" message

ashen yoke
#

ill just ignore posts like that, its easier

gray mural
ashen yoke
#

|| why || || is || || it || || good || || for || || me|| ?

#

for me and everyone would be good if we didnt have to jump hoops just to see what links you post

#

can you elaborate whats the idea behind posting link like that? what does it serve? what function

primal wind
#

Its more compact, especially if your link is long

#

Doesn't really bother me or most people i know tho

#

(also hovering the link just shows the URL)

tight fjord
#

Is this messy code?

    void changeVelocity(bool forwardPressed, bool backwardPressed, bool leftPressed, bool rightPressed, bool runPressed, float currentMaxVelocity)
    {
        //if player pressed forward, increase velocity in z direction:
        if (forwardPressed && velocityZ < currentMaxVelocity)
        {
            velocityZ += Time.deltaTime * acceleration;
        }

        // increase velocity in backward direction: 
        if (backwardPressed && velocityZ > -currentMaxVelocity)
        {
            velocityZ -= Time.deltaTime * acceleration;
        }

        // increase velocity in left direction:
        if (leftPressed && velocityX > -currentMaxVelocity)
        {
            velocityX -= Time.deltaTime * acceleration;
        }

        // increase velocity in right direction:
        if (rightPressed && velocityX < currentMaxVelocity)
        {
            velocityX += Time.deltaTime * acceleration;
        }

        // decrease VelocityZ:
        if (!forwardPressed && velocityZ > 0f)
        {
            velocityZ -= Time.deltaTime * deceleration;
        }

        // increase VelocityZ:
        if (!backwardPressed && velocityZ < 0f)
        {
            velocityZ += Time.deltaTime * deceleration;
        }

        // increase VelocityX if left is not pressed and velocityX < 0
        if (!leftPressed && velocityX < 0f)
        {
            velocityX += Time.deltaTime * deceleration;
        }

        // decrease VelocityX if right is not pressed and velocityX > 0
        if (!rightPressed && velocityX > 0f)
        {
            velocityX -= Time.deltaTime * deceleration;
        }


        // stops the running, when you just press Shift alone without also pressing "w":
        if (!runPressed && forwardPressed && velocityZ > 0.41f)
        {
            velocityZ -= Time.deltaTime * deceleration;
        }
    }
#

it just feels like a way to long "if, if, if, if, if, if, if, if, if" chain...

ashen yoke
#

quite

tight fjord
vagrant blade
#

Compose your input into a vector (every beginner tutorial on movement will show this), and use that as your direction to accelerate towards.

ashen yoke
#

where the backwards input comes from?

#

which input system are you using?

tight fjord
#

Its using the new input system and should be compatible with Keyboards and controller joysticks.

ashen yoke
#

new input system doesnt return a float?

#

havent used it yet, does it behave similarly to GetAxisRaw("Vertical") for example?

tight fjord
ashen yoke
#

how is this related

tight fjord
#

the player is a humanoid model. and besides the player movement, this script is for adjusting the walking animation of this humanoid model. keyboard WASD is just a 0 or 1 value, but a joystick is capable of multiple speeds between 0 and 1.

#

this script is not doing the player movement, it only affects the animation and the animationspeed of it.

tight fjord
# ashen yoke new input system doesnt return a float?

But the playercontroller script does handle the new input system movement like this:

        Vector2 movementInput = _controls1.Player.Movement.ReadValue<Vector2>();
        float xInput = movementInput.x;
        float yInput = movementInput.y;

(but this is not the problem, the problem was the messy if statements in the animation script of the player-model)

ashen yoke
#

you can do several things, first is to predeclare the booleans with conditions

tight fjord
#

9x if for the two dimmension animation controller.

ashen yoke
#

move duplicate lines into a single variable ie Time.deltaTime * deceleration;

#

use a single vector

#

combine all ops into one vector, mult/add at the end

#

convert input values into -1 /0 /1

tight fjord
tight fjord
swift falcon
#

I want to make a game with thick fog like this to obscure vision (like in SH1.) How was that done?

ashen yoke
# tight fjord I'm not sure how to apply that into this here...

sorry was busy, something like this```cs
void changeVelocity(bool forwardPressed, bool backwardPressed, bool leftPressed, bool rightPressed, bool runPressed, float currentMaxVelocity)
{
float accel = Time.deltaTime * acceleration;
float decel = Time.deltaTime * deceleration;
int vertical = (forwardPressed ? 1 : 0) + (backwardPressed ? -1 : 0);
int horizontal = (leftPressed ? -1 : 0) + (rightPressed : 1 : 0);
int verticalClamp= Mathf.Abs(VelocityZ) < currentMaxVelocity ? 1 : 0;
int horizontalClamp = Mathf.Abs(VelocityX) < currentMaxVelocity ? 1 : 0;

Vector3 velocity = new Vector3(VelocityX, 0, VelocityZ);
Vector3 accelerationVector = default;

accelerationVector = new Vector3(horizontal * xVelocityClamp * accel, 0, vertical * zVelocityClamp * accel);

decelerationVector = new Vector3(-Mathf.Sign(VelocityX), 0, -Mathf.Sign(VelocityZ)) * decel;
decelerationVector.x *= horizontal == 0 ? 1 : 0;
decelerationVector.z *= velocity == 0 ? 1 : 0;

// stops the running, when you just press Shift alone without also pressing "w":
if (!runPressed && forwardPressed && velocityZ > 0.41f)
{
    velocityZ -= decel;
}

}```

#

didnt finish, and didnt test wrote in notepad

tight fjord
#

looks smaller, but more complicated too.

ashen yoke
#

agreed, this is inferior, in some regards

tight fjord
#

is ". 0" a repeat of the same question "fowardPressed ?"

#

IDK it but it looks for me like it (but I dont know this code condiction)

forest linden
#

This is a weird one to choose the channel for as it is about animation but the problem I'm having is related to script.

PROBLEM
after switching the player model animator only works after manually interacting with it.

CODE- https://hastebin.com/share/xucaferora.csharp

#

Also even after manually updating the animator the animation rigging ik on the gun seems to lag behind

tight fjord
forest linden
#

converts a bool into 1 or 0

#

so true is 1 and 0 is false

#

you can also use it to convert it to other values such as strings

tight fjord
#

but why "?"

forest linden
#

syntax

#

idk

#

why do we use ; to end lines. same shit

tight fjord
#

I know that "!" means "is not" but what is "?"

forest linden
#

or

#

maybe

#

its only used in this context

#

The conditional operator ?:, also known as the ternary conditional operator, evaluates a Boolean expression and returns the result of one of the two expressions, depending on whether the Boolean expression evaluates to true or false.

(https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-operator)

tight fjord
forest linden
#

its two equals as one equals is used to write to a variable

small trench
tight fjord
#

it just seems that "?" does have the same effect like "=="
"==" means: "check, if it is same like... then (YES), if it is not the same, then (NO)"

small trench
#

Equals() and ==
Would give you the same results but it's better to use Equals() with non-primitive types

swift falcon
#

does anyone know why my monster sprite and character sprite are overlapping even if the z is 0 and fixed for both?

rigid island
#

just change order in layer

#

also not code question

swift falcon
#

alr thanks

forest linden
tight fjord
#

and what does "+" mean?
is it something like the common "&&" between two if statement conditions?

forest linden
#

can you go to code0begginer

fervent furnace
#

i am so lazy to read the code snipper sent from .cache but you can simply try all combinations
if both are not pressed then you get 0+0
if forward then you get 1+0=1
if backward the you get 0+-1=-1
if both are pressed you get 1+-1=0

tight fjord
#

thats always the problem with switching channels.

forest linden
#

but your asking what the + variable means

tight fjord
#

I think it means the same like "&&".

forest linden
#

why

#

it means add

fervent furnace
#

have you read my reply?

forest linden
#

your adding the bools together after they get converted from a true to false to a int 1 to 0 for forward and -1 to 0 for backward

tight fjord
#

I did not even noticed that it was converting something,

forest linden
#

the bools in this case are forwardPressed and backwardPressed

forest linden
#

oh i see

tight fjord
#

the first of my if statements (in my version) was:

        //if player pressed forward, increase velocity in z direction:
        if (forwardPressed && velocityZ < currentMaxVelocity)
        {
            velocityZ += Time.deltaTime * acceleration;
        }

I dont see here anything that would be converting, or am I wrong?

forest linden
#

why dont you use Input.GetAxis("Vertical") and Input.GetAxis("Horizontal"). Is it cause your using a different input system

prime sinew
#

Don't provide ai generated answers please

forest linden
#

aight then

forest linden
#

for him

tight fjord
#

the script I used, was from a 2 year old Unity project that I already cancelt, I only was visiting it to get some information's about a few old scripts in there that I want to recycle for my current project.

´Because I think it would be maybe usefull to know a if-statement alternative that needs way less codelines than the common if condition...

The only issue with it is, I don't really understand it cause it uses some letters I saw and never used before.

"?" and "+" are new for me, cause I never used them in the programming.

forest linden
#

what languages have you coded in that dont use +

fervent furnace
#

maybe asm.....

tight fjord
#

I never used more complex conditions that simple if, switch, while, for conditions.
but they sometimes need way more space, even if it also works.

forest linden
#

the only high level languages I found that dont use plus are brainfuck, whitespace, befunge, Ook and malbolge.

fervent furnace
#

i remember brainfuck have +
increment the current memory space by one

tight fjord
#

I took a example from my old script and asked here how to improve it, because I had no idea to get the same results of it with less lines of code. that why we are here with ternary operator.

tight fjord
#

I would be glad if I even would understand this single language good enough.

forest linden
#

So thtas why you should be in code begginer

tight fjord
#

but I dont think that "ternary operator" are beginner contents, if I look in this channel.
Beginner stuff is such content like if, while, switch....
ternary operators are complex as hell if I look into your GPT script.

vagrant blade
#

It's beginner and you are a beginner. The bigger issue here is you thinking reducing the line count on your bad code will make it good code.

#

You need to change the approach to your movement which means scrapping what you have.

molten isle
#

https://gdl.space/potufuyeze.cs why does the bomb spawn with gravity? I have been trying a couple of bools to make sure it works and also have set everything to the correct layers, but somehow it will just spawn without gravity. Does anyone know why? The colliders are also set correctly.

olive karma
#

I cant figure out how to program jump on my "man" character how should I do it?

molten isle
hidden compass
#

check for ground and ^ then do that

molten isle
brazen grove
#

just run into an issue where I was cloning a renderers sharedMaterial and assigning it back to the renderer's sharedMaterial, then another script (not mine) was calling renderer.material.SetXYZ, resulting in my clone being cloned. I guess assiging to .sharedMaterial flags the renderer as no longer having a copy material, which made me wonder if, apart from at edit time, should I ever assign materials to .sharedMaterial? Would assigning my clone to .material have the same affect but without affecting the instanced material flag?

olive karma
molten isle
tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

olive karma
#

cuz I applied it but I dont know if I applied it correctly

molten isle
#

I also asked GPT even he says he doesnt know why

molten isle
#

I would use a raycast to check if its grounded but that works too

#

If it doesnt jump try increasing the groundcheckradius

olive karma
#

so in the unity component inspector thingey should I create an empty gameobject at the players feet and then select it as the ground check position?

molten isle
#

I would either do it with a raycast or a trigger collider

molten isle
olive karma
#

is it possible that other scripts are making it not able to jump

brazen grove
molten isle
molten isle
olive karma
#

ok so it doesnt quite work but I know why it wasnt working it was because I had a script were the player character was always on the same Y level as the camera

#

because of weird bugs

#

now I can infinitely jump I will change that but for some reason the ground is not stable

#

what should I do to make it stable

molten isle
#

set it to static

#

Top right corner it has a checkbox that says static @olive karma

forest linden
#

PROBLEM
after switching the player model animator only works after manually interacting with it or saving and then compiling a script.

CODE- https://hastebin.com/share/xucaferora.csharp

loud flume
fervent furnace
#

are you trying to new a managed array in job?

loud flume
#

no i dont think so but im not entirly sure what u mean

fervent furnace
#

bool[] neighbors = new bool[8];

loud flume
#

im making an array of bool in a function to determine what kind of sprite to use rotation ect but I'm not trying to get that value as an output

#

there are 3 native arrays one for the rotation(int), sprite(int), and cellposition(int3) that i need as an output

fervent furnace
#

there should be some exceptions are thrown when you try to run the job due to allocation o f manage object, have you checked the console?

loud flume
#

theres a ton of index out of range exeptions

fervent furnace
#

the capacity of all native array you passed to the job should be width*height not height*height+width

#

and the first nested for loop should be x*width+y also the second nested for loop

#

and the arguments of job.schedule should be height not width

fervent furnace
#

for the managed bool[] array you may change them to fixed size buffer in struct and reuse them

unsafe public struct AAA{
    fixed int aaa[10000];
}
loud flume
#

what dose the unsafe part do?

fervent furnace
#

and the cs int randomRotation = UnityEngine.Random.Range(0, 4);you need to use Unity.Mathemathics.Random struct

#

you can use pointer in unsafe content (fixed size buffer is some kind of pointer)

loud flume
zenith sable
#

i really need help here, so i have a movement script that stop working when i kill or deactivate one istance of a gameobject using it

zenith sable
#

okay i may have found the problem, aftre one is deactivated all the others stop registing inputs

loud flume
fervent furnace
#

it should be index*width+x, but i see all indexer are this expression

#

for accessing [i,j] element the indexer is i*width+j normally unless it is column-row format

rotund burrow
#

when i instantiate an object with a monoBehaviour script, does it call Awake() immideatly?

latent latch
#

ye

rotund burrow
#

what if i need to set some fields there

latent latch
#

It's Awake() then start()

rotund burrow
#

before Awake

leaden ice
#

call a function after to do it

latent latch
#

The update of the mono should not run until next frame, so implement a init function

rotund burrow
#

if i call a function, will it be called before or after first Update() ?

leaden ice
#

right after Instantiate only Awake and OnEnable will have run

rotund burrow
#

Transform obj = Instantiate(...)
obj.GetComponent<Script>().field = ...
when will it be called?

leaden ice
#

when will what be called

rotund burrow
#

when will it set the field

leaden ice
#

right there

#

on the second line

#

also why not just cs Script obj = Instantiate(prefab); obj.field = ...

rotund burrow
#

so you said after Awake, what about start and update

leaden ice
#

what about them

#

they will run later

loud flume
rotund burrow
#

are you sure? i'm getting null references in start

leaden ice
#

or you assigned something to null

#

Add Debug.Log if you don't trust me

#

you will see it runs later

rotund burrow
#

you're right thanks for the help

jaunty sleet
#

Does anyone know why my button here wouldn't be working? I'm not sure what I'm doing wrong. I'm just trying to use a normal UI button and call a method on click

leaden ice
#

also not a code question

jaunty sleet
#

Oh ok, thanks. I'll go in the other channel next time lol

quasi flume
#

hi, does anyone have an idea how I can add a delay to WallGrab and WallSlide during the jump, because so far the character walking towards the wall catches it, which makes it impossible to jump? CODE: https://gdl.space/asiwideviy.cs

fervent furnace
#

have you changed the arguments passed to schedule? @loud flume

#

from width to height

forest linden
#

why, this has never happened before why

swift falcon
#

right after the jump, and what u want that function PrepareForJump do is set the IsReadyToJump to true, and there u have it

#

same thing with the wall grab and basically everything that you want to limit, bullet shooting etc.

quasi flume
#

ok will try to do that, thank you🔥

swift falcon
swift falcon
forest linden
#

its part of my weapon script and its to rotate the weapon away from walls to stop clipping

RaycastHit hit;
        float weaponRotTarget;
        if(Physics.Raycast(weaponAvoidRay.position, weaponAvoidRay.forward, out hit, weaponAvoidDistance))
        {
            weaponRotTarget = -(weaponAvoidMaxAngle * (weaponAvoidDistance / hit.distance));
        }
        else
        {
            weaponRotTarget = 0;
        }
        Debug.Log(weaponRotTarget);
        transform.localEulerAngles = new Vector3(Mathf.Lerp(transform.localEulerAngles.x,weaponRotTarget,weaponMoveSmoothness*Time.deltaTime),0,0);
quasi flume
rotund burrow
#

I'm making a ground visual effect and i want to make it work on stairs. Basically i need to project a shape on stairs. so i think it comes down to finding stair border points like in the image. How would i do that? or maybe you have a better idea

leaden ice
rotund burrow
leaden ice
#

I don't know what that means

rotund burrow
leaden ice
#

what does that have to do with stairs? And what do you mean by "a road"?

rotund burrow
leaden ice
#

so what's special about stairs?

fervent furnace
#

turn the get node return arry[(y + 1) * arrayWidth + x]; to arry[y*width+x]

faint delta
#

Hi guys, I'm trying to make a player have a small cutscene to jump into a teleporter every time he presses "e" on a teleporter. Where could I do that, or would I have to hard code that in. (Sorry if it sounds confusing, I can re-explain if you'd like) This is unity 2d

rotund burrow
soft shard
# quasi flume hi, does anyone have an idea how I can add a delay to WallGrab and WallSlide dur...

One thing I would suggest that may help a bit (but may not outright solve your problem), is to try and make 1 call to .velocity instead of having every part of your logic try and set it, they can instead set a Vector2, and after all calculations, that vector2 can then be passed to .velocity - I would also maybe add some Debug logs or make some events for each part of your problematic logic (in your case, jump, wall grab and anything else you think could be a conflict, maybe gravity?) then you can use UI to see when its changing, or make properties in the inspector to monitor the change - to me, it looks like your movement may be affecting y velocity, gravity could still be active in the frame your grabbing or jumping, or coll.onWall may be causing conflicts with wall grabin the frame your colliding, moving and jumping against the wall

loud flume
fervent furnace
#

is the exception showing the line?

#

also the boolean check of getnode is x<width not height

loud flume
rigid island
fervent furnace
#

i havent use ijobparallefor indeed but from the exception it seems that it is not allowed to use a for loop to write different index of native array (since you are using [index*width+x] and x is iterator)

#

i believe reading a readonly containers is allowed (the bool nativearrays) you can try passing width*height to schedule and retrieve the row and column from the index passed to execute()

faint delta
loud flume
fervent furnace
#

though idk why these indices 20035 and 4114 are produced, the different between them is huge most likely the expression in indexer is wrong
yes, dont do this row by row, just cell by cell so no loop in execute()

loud flume
soft shard
fervent furnace
#

and you access the result array directly by result[index (the argument of execute)]

loud flume
fervent furnace
#

i think you have to write more code if you want to change it to ijob
just stick to parallel unless other exceptions are thrown

loud flume
#

what should i pass in for the index

fervent furnace
#

what index?
for getting row and column in execute? or schedule?

near wagon
#

or well

#

at all

#

doesnt work at all its just really weird

#

the keybind for dash is e

loud flume
near wagon
#
canDash = false;
isDashing = true;
float originalGravity = rb.gravityScale;
rb.gravityScale = 0f;
rb.velocity = new Vector2(transform.localScale.x * dashingPower, 0f);
yield return new WaitForSeconds(dashingTime);
rb.gravityScale = 6;
isDashing = false;
yield return new WaitForSeconds(dashingCooldown);
canDash = true;
#

oh crap

#

thats the dash function

fervent furnace
#

schedule(width*height,some batch number)
you need to execute width*height times of execute since you have width*height cells

loud flume
#

ok the main reason i made it go line by line instead of cell by cell is because of the getnode function because to find which sprite and how it should be rotated i need to know variables of the neibors but if its just a single index i couldend think of a way to find which indexes are the neibors

fervent furnace
#

you can get the row and column from the index passed to job by index/width and index%width respectively

#

using ijob maybe faster since you can get rid of / and % (if width is power of 2 then fine) but you need to write some more lines of code

spring creek
#

Also, you can cache those waitforseconds instead of creating new ones each time

near wagon
spring creek
near wagon
#

yeah uhh

#

can I send it in a pastebin

#

the whole code

spring creek
#

Yeah, but there are ones specifically for code I would recommend. Like:
Hastebin.com
Or
Gdl.space

#

Ah, nm haha

loud flume
# fervent furnace you can get the row and column from the index passed to job by index/width and i...

so if i need the y value of the cell i need to do index/width cause i feel like that wouldent work becuase if u have a 10x10 grid for example and want to get the cell index is refenceing if index is 1 and both the width and hight are 10 you do 1/10 wich is 0.1 for the x and 0.1 for the y and if say u needed to refence the point 2,0 i feel like u couldent find that cause ur using one input index and trying to get 2 outputs by dividing with the same number

peak jacinth
#

does anyone know why this IMGUI code from docs doesn't work? The window is not draggable for me. I'm using 2022.3.5f1 https://docs.unity3d.com/Manual/gui-Controls.html

/* Window example */

using UnityEngine;
using System.Collections;

public class GUITest : MonoBehaviour 
{
                    
    private Rect windowRect = new Rect (20, 20, 120, 50);
    
    void OnGUI ()
    {
        windowRect = GUI.Window (0, windowRect, WindowFunction, "My Window");
    }
    
    void WindowFunction (int windowID) 
    {
        // Draw any Controls inside the window here
    }

}
spring creek
#

Ok, so it's a new input callback. You have others that work, so I would say just check to make sure the dash one is set up properly, and that you clicked save or have autosave enabled.

Just to start with, because the code looks fine at first glance

fervent furnace
#

since the index = some row*width+some column then you can retrieve row and column by / and %

spring creek
# near wagon i did already

Yeah, on watching that video, I see it halts you in the air, which proves it IS working somewhat (by setting your y velocity to 0, or maybe it's the gravityscale change)

fervent furnace
#
for(row=0;row<height;row++){
    for(column=0;column<width;column++){
        index=row*width+column;
    }
}

for(index=0;index<width*height;index++){
    row=index/width;
    column=index%width;
}```
peak jacinth
near wagon
fervent furnace
#

and 1/10 is 0 1%10 is 1

loud flume
spring creek
soft shard
# near wagon https://pastebin.com/02vqEPTX

In your Dash coroutine, you have rb.velocity = new Vector2(transform.localScale.x * dashingPower, 0f);, but you also have rb.velocity = new Vector2(horizontal * speed, rb.velocity.y); in Update, for your x, is it possible your overriding your Dash change with the Update change, and go nowhere horizontally because of it?

hidden compass
#

i have a setup that loads into my game's menu and it does this by having most of it persistent .. since its a splash screen it only has the BOOT_CANVAS object that doesn't need to.. so currently i just tell my loadmanager to go ahead and destroy it.. since from here on out we'll only need what we threw into DDOL..

loud flume
hidden compass
#
  private void LoadMainMenu()
    {
        // This method is specifically designed for loading the MainMenu scene.
        // It handles the loading and unloading of the MainMenu scene independently.
        // MainMenu should not be added to the scenesLoading list as it has a different loading process.
        if(FirstLoad)
        {
            SceneManager.LoadSceneAsync(MainMenuSceneIndex,LoadSceneMode.Additive);
            foreach(var x in purgeList)
            {
                Destroy(x);
            }
            FirstLoad = false;
        }
        else
        {
            ...
        }
    }```
#

the method bugs me... since it leaves behind an empty array.. / gameobject if i wanted

#

should i just put the Boot Splash screen in its own scene.. and load it up during the the Master scene

soft shard
# hidden compass should i just put the Boot Splash screen in its own scene.. and load it up durin...

I would maybe put a script on the splash screen canvas, and have that script destroy the object when its done, removing the script, splash screen, and removing the need for the 1-element array if you dont plan to populate it with anything else, normally I have a "initialization" scene as scene 0 to handle the splash screen, authenticating, loading settings, etc, then never load that scene again, having my menu as index 1, in your case it sounds like you want all of it to be in the same 1 scene, so you could just destroy the part of the scene you no longer need - though why is most of your main menu apart of DDOL?

spark flower
#
        Destructable _des = collision.gameObject.GetComponent<Destructable>();
        if (_des != null) {
            //do stuff
        }
    }```
i know there is a way to skip the if (atleast in code) and go directly to the execution in the brackets but cant remember the syntax
#

can someone help me

hidden compass
# soft shard I would maybe put a script on the splash screen canvas, and have that script des...

yea, i was thinking about having a simple script that destroys itself, but the loading screen has progress bars and varies in time.. so i'd need a reference to it one way or another.. this is the first scene of the game, it loads in all the managers, the audio stuff, settings save data etc, it also has the player object and that data so it first loads into the mainmenu, and then into other level scenes as well, so everything in it, apart from the graphics DDOL.. anytime i load into a scene it does it async, with the loading screen coming down as a curtain

#

easiest way i think would be to have the graphics as a seperate scene and unloading it after starting the gam

jade phoenix
#

anyone know why it takes so long for an accelerometer to respond

#

i tilt my phone, and at least a second goes by before it's triggered.

lean sail
jade phoenix
#

loosening the conditional values doesnt really help it either

spark flower
lean sail
#

That's lambda declaration, you dont need it here

spark flower
#

why

hidden compass
#
{
  if (fooFoozy)
        return;

    // Code that will only execute if fooFoozy is false (not skipped by the the conditional)
    DoSomething();
}
#

maybe u mean an early return? and inverted conditional? iono exactly wat u meant 🍿

#

TryGet was my 2nd thought

lean sail
# spark flower why

Lambdas are basically just used as syntatic sugar, to write shorter code when we really dont need to specify a whole bunch. Even if you could use a lambda there, the compiler is just gonna turn it around into pretty much the same thing you wouldve written with try get component

#

In this case the lambda might compile into something worse tbh

soft shard
spark flower
#
    private void OnCollisionEnter(Collision collision) {
        if (collision.gameObject.TryGetComponent(out Destructable _des)) {
            _des.Push(transform.position);
        }
    }```
i think i got it now
spark flower
#

so its a compile reason

lean sail
#

Well not really, you just dont need a lambda there

spark flower
#

but you say the compiler wuld change it

near wagon
hidden compass
# soft shard Wouldnt your initialization logic happen before you need to handle your loading ...

theres actually no intialization happening, just some gameobjects it checks if is there, but it would be checking if all the game managers and audio is present, (game initialization), im actually not very good at structuring these things lol, its just some coroutines counting atm.. but my save system and most the others are singletons that set themselves up.. my "loadingscreen" is basically just a title screen, during the boot up, but becomes the fast travel, in between loading screen after u pass the mainmenu.. when you load a scene thru its functions it checks for a (scene initialization) its similar to the game one, but sets up lighting, enemies, pathfinding etc..

lean sail
# spark flower but you say the compiler wuld change it

You would only really use a lambda if the statement was like 1 line, like a function or property just returned data directly for example

int x =5;
Public int X=> x;

Im typing on mobile so forgive if theres some error.
The above lambda is just a getter for x. I could write out the whole property and get but in this case I'd rather just use the syntatic sugar to write it for me.
In your case I only really mentioned the compiler because of something called closures. If your lambda has to reference some local variable, it may end up making a new class (you'll never see it) with the variable stored inside. It's not worse on performance in any way that you'll ever ever notice, it's just like an unnecessary usage

hidden compass
#

its just part of the master scene (all the important persistent stuff) that i load in first thing.. i wish i knew a better way that didn't undo a whole lotta work but alas im 'managing'

#
bool fooFoozy = ...; // Some condition that you want to check
fooFoozy?.DoSomething() ?? return;```
#

this ^ is crazy looking syntax to me does this work?

spark flower
hidden compass
#

i forget what those fancy combined symbols were called

lean sail
#

Lambda declaration is the actual symbol

#

Lambda is kinda just a general term for the whole thing

hidden compass
#

no but i mean the "text/ character" name

#

its not glyphs, maybe it was this.. i cant find it

lean sail
#

I'm unsure, dont even think mine combines like that

hidden compass
#

the font ur using has to support it

#

and theres some setting that you enable (maybe)

pure cliff
hidden compass
#

OMG thank you

#

😅 i was going crazy for a minute looking

spark flower
lean sail
spark flower
#

like what

lean sail
#

Literally just parameters, the same as you would a function

spark flower
#

i think i dont get something

#

im looking at it like an if statement or something

#

whats a usecase for this anyway

copper blaze
#

is it better practice to have a dedicated script for player animations (currently have animation in same script that handles movement) ?

dusk apex
spark flower
#

and then you just use refrences

#

so in your movement script you refrence the animation script

dusk apex
#

Otherwise, the if condition is necessary to check if null - null coalescing and nullable likely isn't applicable in this case.

copper blaze
#

in order for it be accessible from the animation script

spark flower
#

i dont know how you structure your animation+mobility stuff

copper blaze
spark flower
#

you have to make sure they dont conflict with eachother

copper blaze
#

sorry wdym by they dont conflict with eachother

copper blaze
spark flower
#

maybe there wont be a problem, its just im unaware how its structured

#

btw

#

by animation script i understand a script where the animations will call,

#

that code you dont need to separate in another script

#

altho it wont hurt if you do

soft shard
# copper blaze in order for it be accessible from the animation script

You could make properties for them to be accessed outside your script but not changed, or make events for when those actions start and end so your animation script can just subscribe and effectively update itself, personally I like using events often to mitigate direct references where possible

lean sail
soft shard
#

Also, "is Jump" to me seems like something that would happen by trigger once instead of a ground check bool, but I guess it depends on your setup

spark flower
lean sail
#

I did above with the property, and the docs do list quite a few

#

They really arent that important, which is why u might not see the value in them. It's just short form

copper blaze
pure cliff
# spark flower whats a usecase for this anyway

It is effectively storing a function as a variable you can hand to other things for Inversion of Control (IE a callback function the other thing will invoke when it pleases)

You also can do fancy stuff with Lambda Expressions as a mechanism to specify "selectors" for things, but that involves expression tree manipulation which is kind of advanced

#

If you use Linq you'll get very familiar with lambdas very fast, as you use them extensively

jade phoenix
#

would anyone know why lerping doesnt work when i build to iphones

spark flower
#

ive seen it being used here and there

#

and i think its definetly a thing i wuld learn

soft shard
spark flower
#

unity events are more convenient then actions, you just do event.addlistener(function) and thats all

pure cliff
spark flower
#

you dont have to subscribe and unsubscribe on enable and disable

#

@copper blaze

somber nacelle
#

you don't have to for regular c# events either. it's just common practice to avoid issues

spark flower
#

so if i have an object that subscribed to an event, and it gets destroyed without unsubscribing wont that create a leak

pure cliff
latent latch
#

oh yeah speaking of which, does GC happen if there's no ref to the object*, but the object itself is subscribed?

pure cliff
#

Instead they have some events others subscribe to, but they dont subscribe to any events. They just have exposed mutation methods on them, and their handful of MonoBehavior only events exposed if needed (OnPointerEnter, OnColliderEnter, etc)

somber nacelle
spark flower
#

i wuld assume with u nityevents this garbage disposal is taken care of

latent latch
#

I actually dislike auto GC. I feel like I need to debug much more to make sure no mem leak

lean sail
#

It's not really that massive of a deal though in this case, you can avoid it by unsubscribing on destroy or disable

spark flower
somber nacelle
#

unity events are serializable

#

that's literally their whole deal

lean sail
#

A unity event is just a serialized event, an event is different from an action

spark flower
lean sail
#

Remove listener

#

An event is different from an action, an event cannot be invoked from outside the class and only exposes the add and remove functions

#

An action is also just a delegate

spark flower
#

im not sure i get it

lean sail
spark flower
#

public unityevent variable; is pretty much the same as
public event action variable;

lean sail
#

In the context of both of them being events, yea pretty much the same.
Unity event is serialized though and you'll see it in the inspector

spark flower
#

yes aside from that

craggy veldt
lean sail
latent latch
#

I mean, we already do GC manually for the scene ;)

spark flower
#

if your talking about this guy, his last video is 7 years ago...

lean sail
#

A delegate has existed for longer than 7 years

#

I'm sure if you found a tutorial on how to add 2 numbers from 50 years ago, itd still be relevant today

spark flower
#

i get it

lean sail
#

Only thing you might be confused on in his tutorials is stuff that's not used in unity like the main function

#

Which you mightve not seen if you never learned c# outside unity

latent latch
#

Jamie actually help me get through a lot of my c# course. It's surprising how much his stuff holds up today for being a decade old

#

guys actually pretty dumb smart

#

Got me interested in some open gl stuff too

lean sail
#

I like how he pulls up the reflector a lot in the delegate series, it's nice seeing how stuff really compiles

spark flower
#

well main is basicly the main loop of the program?

#

so its basicly like update in monobehavior

lean sail
#

It doesnt loop

spark flower
#

but it contains all the code from my game right

lean sail
#

Unity structure is very different, outside of unity you typically have 1 entry point (main) and then just build everything around that. Unity is different because it already builds so much for you, then just calls a list of functions on monobehaviours everytime they're supposed to happen

lean sail
spark flower
#

main void {
//my game
}

lean sail
#

You should probably look at beginner c# tutorials if you're interested in how that part works.. because it's so very different itd take me awhile to even explain

spark flower
#

well i dont really care about it,

#

i dont think i need to know it at this point

lean sail
#

If you follow a tutorial and it has a public static void main, all you have to know is that's the entry point

#

That is where the code "starts"

spark flower
#

ok

earnest gazelle
#

Which one do you prefer?
Passing an argument to the base class and set that field into or define an abstract property in the base class and then override it into children classes?

 public class State<T> : State where T : MonoBehaviour
    {
        protected readonly T Character;

        public override GameObject Object => Character.gameObject;

 

 public class State<T> : State where T : MonoBehaviour
    {
        protected readonly T Character;
        public State(T character)
        {
            Character = character;
        }:base(Character.gameobject){}

pure cliff
somber nacelle
#

that's not a monobehaviour though

pure cliff
#

oh wait thats the restriction on the generic my bad

#

I misread that, I usually put restrictions on generics on second line

#

I would go with neither, I would use an interface since there's no actual functionality present in this example for why you need inheritance

earnest gazelle
pure cliff
earnest gazelle
#

OK, so which one do you prefer?

#

Sometimes, both work

pure cliff
#

neither as I said, Id use an interface instead for what you have there

earnest gazelle
#

passing it through ctor or override it with getter

pure cliff
#

it 100% depends on what you are doing with or need the property Object for

earnest gazelle
#

My question is not to change State, use class or interface.

#

Definitely, it has some functionality that I do not put it here

#

The question is about this line of code.
public override GameObject Object => Character.gameObject;

#

or passing it through base ctor

latent latch
#

They both seem to do the same thing, no?

pure cliff
#

but typically, interface is the right call, Inheritence I only use in 2 cases:

  1. I have to because I am consuming off some third party class already and thus am pidgeonholed into inheritance from the get-go

  2. I intend to serialize the class

Aside from that I always try and use Composition over Inheritance, its easier to debug, fix issues, maintain, and it forces you to keep your code better organized cuz you cant do weird circular Inversion of Control

earnest gazelle
#

I think passing it thought ctor is the right one because it is initialized only once and also all children can pass it through easily

pure cliff
latent latch
#

Yeah, top is cleaner, cause if you gonna have to implement the constructor in the children

pure cliff
#

But I typically wouldnt use either of those unless I 100% absolutely have to

earnest gazelle
#
 public class AnyState : State
    {
        public override GameObject Object { get; }

        private readonly List<TransitionStatePair> _states;


        public AnyState(GameObject obj)
        {
            Object = obj;
            _states = new List<TransitionStatePair>();
        }

grand gale
#

so i'm trying to save data between sessions right, and scriptable objects are the best for that from what i've heard (since it lives outside of the scene)

[CreateAssetMenu]
public class BakeMap : ScriptableObject { ... }

so i got this class. cool. but if i try to put it in a monobehaviour class, like this

public class Navigation : MonoBehaviour {
    [SerializeField] public BakeMap BakeMap;
    ...
}```
it doesn't show up in the inspector, at all. I cant set the asset to the ``Navigation`` script on any game object. why is that?
latent latch
#

What do you mean it doesn't show up? Have you created an asset from the SO?

somber nacelle
grand gale
#

and this is the navigation script

grand gale
somber nacelle
#

if the field is not appearing in the inspector then you are either using the wrong BakeMap type or you have compile errors. or you forgot to save to let unity compile

latent latch
# grand gale this is the SO asset

Oh, huh. I actually never tried to define without extending out the asset menu attribute. I guess it just makes a single instance in this case? Ah, nm it just flings it into the asset menu at the top level under the class name.

grand gale
#

the files are saved, i restarted unity, correct bakemap type

somber nacelle
#

one of them has to be. either that or you are modifying the wrong Navigation class

#

oh wait, are you using odin inspector or naughty attributes? if not you probably have a custom inspector which is fucking it up. but surely you would know if that is the case already

grand gale
#

oh

#

right

#

my bad

weary citrus
#

I'm not sure how to solve this issue. I'm currently using a trigger to wait and register whenever the left mouse button is clicked, which the animation will then play. However, it doesn't finish the animation completely, it goes to the last frame, until I click left mouse button again, and only then will it stop the animation and go back to my walking/idle animation. I've also attached the animator transitions to the both of them, any idea on what I might be missing?

latent latch
#

If it's not a problem with your state machine, then you've got exit lag on your animation.

#

Or rather if you're asking to finish an animation completely, then you want to add or blend it into the next transition.

#

The video makes it look like you're stuck in the attack animation, or am I incorrect?

weary citrus
#

yes i am stuck in the attack animation. I’ll click my attack button once, it’ll play the animation but stop on the final frame, then i must click it again if i really want to stop the animation or if i want to attack again. So, if i hypothetically wanted to do 3 attacks in a row, i would have to attack, stop the attack, and attack again

latent latch
#

The attack should just be a trigger and its animation should be interupted by walking, and ideally it should play out the animation completely and return to the idle animation when not moving.

weary citrus
#

yeah that’s what should be happening. i have it set as a trigger, so it should trigger, start the animation, and finish it, but it won’t finish the animation unless i press the trigger again

latent latch
#

You can run the animator sidebyside with the scene and it'll show you in real time what state it is in and animation is playing for debugging

#

if you believe your logic states are correct and animator logic is correct, then it could just be a slider problem for the transitions

wicked pawn
#

(Sorry i think i posted this before in the wrong channel)
but: So I have the basics of C# down, is it just stumbling from random tutorial to random tutorial now?
How did y'all begin figuring this out for yourselves? I don't even know what to start with for a basic feature

tawny elkBOT
#

🧑‍🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/

jade phoenix
#

whats the best way of checking the tag of something below, but not necessarily colliding with a gameObject

weary citrus
wicked pawn
# latent latch !learn

I see, im trying to learn this how I learned a bit of gms2.
oh it looks like there's seperate tutorials on different features on search! Sorry, im new to this engine. Thanks.

latent latch
wicked pawn
latent latch
#

Yeah, that sounds ideal, and there's probably a ton of tutorials out there for that in unity

latent latch
weary citrus
#

It holds that animation, even though it's a trigger. I have no idea why it's happening.

somber nacelle
#

look at the transition condition

weary citrus
somber nacelle
#

you literally have it highlighted through the entire video. the condition to transition out of the animation back to your idle animation is that the swordAttack parameter has to be triggered

bitter pewter
weary citrus
pure cliff
weary citrus
#

perfect thank you! There's also like a teeny tiny bit of delay from when I click left mouse button to when the attack actually starts, I've tried to change the speed of the attack and everything, but it just doesn't change that like wind up time. Is there any way to fix this as well?

#

it feels as if my character has high ping

pure cliff
#

I wish there was a specific 2d Animator that removed a lot of this stuff and worked for sprite animations better

#

Cuz pretty much always you want exit time to be zero and whatnot for most sprite things, because we dont have any kind of blending on em needed

weary citrus
# pure cliff yeah you need to set exit time on idle to be zero prolly

I figured out the issue but I don't know how to solve the issue. The attack animation must wait for the idle animation to be complete first, so if I click attack at the start of the idle animation, I must wait for the idle animation to finish, then run the attack animation. Do you know how that might be able to be solved?

pure cliff
#

Transition Duration I believe needs to be zero

#

and Has Exit Time should be false

#

On whatever your transition into Idle is

weary citrus
#

perfect, you're a life saver

pure cliff
#

I wonder if someone has made an animator that is better suited for 2d sprite stuff

#

like as an example, the Mirror property on Animator doesnt work for sprites, would be nice if the 2d version actually worked for it instead of needing to manually add custom code to handle flipping the sprite.

Its easy to do but still extra effort a custom animator could've handled for us

olive kindle
#

Hi, I wanted to ask a bit of a higher level question on how I should code something. My game allows the player object to go invisible, and when the player object is invisible, I want the player themselves to be able to see their sprite at like .5 alpha, but for other players to not be able to see the object at all. I was thinking about how to do this with layers and camera culling, but I'm not sure how to do it.

#

I'm using Fish Networking if that's of importance

weary citrus
lean sail
#

By some rpc

olive kindle
#

realizing that doesn't make sense now

lean sail
#

I'm sure you could but directly changing the material might just be easier

#

Hell it even be easier to just straight up disable the visuals for other people lol

olive kindle
lean sail
olive kindle
#

True but they said that with a custom observer condition they wouldn't even have position updates

#

which also might be more performant

lean sail
#

in my game im just saying fuck it, people can only play with steam friends. If you wanna hack then you just ruin/boost your friends experience

lean sail
lean sail
#

Ah I think I understand, that does seem pretty useful for your case actually

raven basalt
#

In the revolver prefab's inspector window, the inspector window is not allowing me to assign values to the revolver's Firearm script. How do I fix this?

copper blaze
#

currently using unity's tilemap system to make level design more efficient, however i can't seem to figure out how to add functionality to each tile (eg. destroy a tile when that specific tile collides with a player). Is there a way to accomplish this or do I just have to suck it up and make prefabs for the tiles that I want to have functionality

copper blaze
frigid glen
#

how can compare a value to more than one enum value? instead of doing something like this:
if(Value != BlockType.Air || Value != BlockType.Water){}

misty cypress
#

So umm i was working on my project and suddenly my camera scene view flipped and now the camera controls in the scene view are inverted (move mouse left and camera goes right) Helppp\ (image is being viewed from below Pov)

pure cliff
#

Blargh, I think rider's auto fix stuff borked the files in the auto generated cs projs...

Anyone know if theres a quick way to fix this? Do I just delete the .csproj files and regenerate them?

frigid glen
frigid glen
#

right-click and drag

misty cypress
#

oh shot

#

i am dum

#

Please excuse me I need some time in the time out corner

somber nacelle
frigid glen
somber nacelle
frigid glen
#

c# just keeps getting more complicated man, Thanks for the help!

somber nacelle
#

btw you would want to switch to and instead of or for the same logic as the if statement in your question. although if(true) works exactly the same because it cannot be equal to both at the same time so one of those conditions has to be true 😉

#

of course if this is for enum flags rather than just storing one value of the enum in a variable you have to do things differently

carmine wind
#

is there a way to bake and store navmesh data in code?

somber nacelle
#

did you google it?

carmine wind
#

It's not at runtime it's code executed in editor

carmine wind
somber nacelle
#

are you using the AI Navigation package or are you in an earlier version?

carmine wind
#

no I'm using LTS and default unity navigation

somber nacelle
#

by LTS do you actually mean the 2021 LTS? because the 2022 one uses the ai navigation package

carmine wind
#

2022

somber nacelle
#

otherwise the BuildNavMesh method should work. unless you've been trying it in play mode and expecting it to persist once you leave play mode

carmine wind
#

yea this works thank you

somber nacelle
#

if you are not using it while Play Mode in the editor is active then BuildNavMesh should work

carmine wind
sharp sky
#

For some reason this is happening to my project. I have not done anything to it for a long time and I am using the same version of unity to open the project and it worked the last time I used it. Now after transfering to a new computer, this opens up every time I open the project. It does not prevent me from being able to run the game though. Thoughts?

elfin tree
#

How can I spawn something in front of the player, at certain distance, but have the distance between the player and spawned object be the same, no matter the object's size?

crude mortar
#

you can increase the distance based on the extents of the object's renderer bounds

#

it is not a perfect solution though, since bounds are a bounding box and not a bounding circle, and various factors could make it be a bit inaccurate

#

a more perfect solution would be to create a custom offset per object (via the inspector + a gizmo for visualizing)

#

but that is not automatic

lean sail
#

even a custom offset that you set in the inspector would fail when it comes to rotations

#

realistically the bounds should just be fine

verbal granite
#

Hi, trying to decide between two designs, would like to know if there are any ideas of which one is better or if there's an even better alternative:

  1. creating an "attack" gameObject as a child of player every time the player performs an attack, which then destroys itself when the attack ends
  2. Have an "attack" gameObject created on Awake, which is always there, and creates/destroys components when the player performs an attack

Thanks.

soft shard
verbal granite
#

and so at any given time, the player can only be executing one attack, which must conclude before they can perform another one

soft shard
# verbal granite Basically the attack needs to generate hitboxes of certain size/position on spec...

Ah, if they were just colliders, you could use casting from a vector so you wouldnt need to instantiate/destroy, if you have other components you need, maybe you could try to pool generic attacks and change the values and visuals when you pull from the pool (one way is with ScriptableObjects, another could be your component approach), if only 1 attack can ever be active at once, a state machine for your attacks sounds like it could be a good idea, but those dont technically have to be mono's, though there may be other approaches you could take, the idea of having to constantly instantiate/destroy objects or components seems like it could be taxing on performance

verbal granite
#

like when the player attacks, set the positions of the hitboxes and enable those components, then disable them after

soft shard
# verbal granite I see. Would enabling/disabling the components be better performance wise?

Im not completely sure actually, I know that toggling child game objects have a performance hit depending on how many child objects there are (for example, if you had a parent with 12 child objects and you toggle the 10th child, the other 11 get set dirty and calculated the next frame even though they didnt change), not sure if that also applies for components, but that also means if you have say 200 attacks in your game, you have an object with 200 components, which youd probably want a reference to each so you dont have to GetComponent search every attack

verbal granite
spring creek
#

So, if it's for getting collisions only (and the timing could be handled separately), then have you considered overlapsphere/circle/box etc with the center positions where the attack is supposed to hit?

#

Oh wait. Did you mean being HIT in different spots causes different damage/effects?

verbal granite
#

(from melee) this is basically what I'm trying to implement

#

and yeah ideally, depending on which of those red circles contacts the "enemy", it could have different effects

spring creek
verbal granite
spring creek
verbal granite
#

Yeah thanks. I think I'll try with the overlap methods, as it feels cleaner than creating/destroying or enable/disabling things. I think the performance probably isn't a concern for my game

soft shard
#

When in doubt, theres always the Profiler to confirm how your solution ends up performing

verbal granite
#

oh thanks, I'll have to look into that at some point

raven basalt
fringe wedge
#

I'm wondering whether that could have something to do with it.

dense estuary
#

So, I'm assuming you didnt find a fix?

rain minnow
rain minnow
swift falcon
#

does anyone know how to make a nav mesh for 2d tile map or at least 2d. I have static tile map. I add nav mesh modifier to each of the children in the grid with walkable and non-walkable areas. And I have nav surface as parent and I bake with appropriate settings but it fill the nav data with anything.

#

nvm

somber nacelle
#

unity's navmesh does not work in 2d by default. you need an asset like NavMeshPlus or some other pathfinding asset

swift falcon
#

it's cus it wasnt rotated -90 on x

#

yea i was using navmeshplus

rain dove
#

Quick Question: Unity player setting has a option in Resolution and presentation by name "Render over native UI". I need this setting to be turned for a specific need; but as sson as i turn it on; any image /font or any game component that has alpha lesser tha 255; will start displaying actual screen of the operating system;

waxen canyon
#

Quick Question: Is there anyway, to spawn in predefined 2D structures on a tilemap?

mystic rock
#

how do i make an object rotate toward the player

prime sinew
#

Just add 2d or 3d, or if on any particular axis if necessary

mystic rock
#

fair

#

too much effort to try to find exactly what im looking for

prime sinew
#

Then you should provide more details on what exactly you're looking for

#

People here only know as much context as you can explain

mystic rock
#

well im just making homing projectiles in my game and transform.lookat isn't very dodgeable so i need the projectile to rotate toward the player at a set speed

prime sinew
#

Look up how to make homing projectile unity

steady egret
#

is objectively better to use the new input system with the Player input component and not the C# script?

rain minnow
latent latch
#

I use lookat for my homing too ;)

#

changing it eventually but good placeholder haha

rain minnow
#

Rip, lol . . .

latent latch
mystic rock
royal pulsar
#

what's the best approach for making an AI that roams by default, then if it is attacked or spots a player moves towards them, and if it is within X range of the player performs an attack animation? I'm currently using a FSM via interfaces but running into problems with script referencing.

#
{
    IState currentState;
    public RoamState roamState = new();
    public ChaseState chaseState = new();
    public AttackState attackState = new();
    private MovePositionPathfinding pathfinding;
    private GameObject player;

    private void Awake()
    {
        pathfinding = GetComponent<MovePositionPathfinding>();
        player = GameObject.FindWithTag("Player");
    }

    private void Start()
    {
        ChangeState(roamState);
    }
    void Update()
    {
        if (currentState != null)
        {
            currentState.UpdateState(this, player.transform.position);
        }
    }
    public void ChangeState(IState newState)
    {
        if (currentState != null)
        {
            currentState.OnExit(this);
        }
        currentState = newState;
        currentState.OnEnter(this, pathfinding);
    }

    public void TriggerOnHurt()
    {
        currentState.OnHurt(this);
    }
}
#

As you can see the statecontroller passes in the required data to carry out state logic in the UpdateState and OnEnter functions

#

the problem is, as the number of states increases, I am passing in more and more data through these functions which is messy

#

I cannot retrieve the data from the states themselves, as these aren't monobehaviours and just belong to IState

#

This is my first time making an AI and it feels messy. It seems like this approach would be fine if the states were very simple and did not require external data for their logic.

cobalt gyro
sand belfry
#

i wanna know if theres a way to add TTS?

cobalt gyro
sand belfry
#

text to speech

cobalt gyro
sand belfry
#

you know how?

prime sinew
sand belfry
#

yes but I havent found much

#

or anything thats free

prime sinew
unique cloak
#

How are these two different?

public int someInt = 3;

and

public int someInt;

void Awake() {
  someInt = 3;
}

thanks

swift comet
#
  1. Its initialised with 3 to start with when you create the object.
  2. Its only set to 3 when the object has Awake called on it, otherwise someInt is 0 up to that point (or whatever value set in inspector view in Unity)
sand belfry
knotty sun
unique cloak
#

Thank you :)

grand hemlock
#

lads how do i get a script from an object without knowing the name of the script?

#

Like I am trying to refine my shooting mechanic by adding different bullet scripts that fire differently

#

and all of them have a Fire() function i just need to call it

quartz folio
#

Use inheritance or interfaces

grand hemlock
#

wont the inheritance access the inherited script instead?

#

like if i do

GetComponent<Bullet>().Fire()
~```
wont it call the fire function in the `Bullet` script ?
quartz folio
grand hemlock
#

thanks vertx

tidal rapids
#

Hey guys this is kinda hard to explain but is there something that will act as any number

here is what I want to do

if (assetNames[j].Contains("("))
            {
                assetNames[j] = assetNames[j].Replace($" ({anyNumber})", "");
            }

Does this make sense?

#

Basically if i have 3 objects named

Box (1)
Capsule (4)
Tree (9)

I want the name of that object to be saved as

Box
Capsule
Tree

fervent furnace
#

no
i think you need regex

tidal rapids
#

Hmm I am unfamiliar with that

ashen yoke
#

which allows you to write a single mathematical expression to handle it instead of large if/else tree

lean sail
ashen yoke
#

you can use AssetDatabase.GenerateUniqueAssetPath which does what you want

#

sort of, without brackets

#

im wrong, misunderstood

tidal rapids
ashen yoke
#

without regex the simplest is to get LastIndexOf(')')

#

from there find the opening bracket, and get a new string with Substring

tidal rapids
#

problem is that when an object is duplicated it adds the (x) to the end of it in the hierarchy

ashen yoke
#

duplicated how?

#

you are instantiated already spawned object? cloning it?

#

or from prefab? if from prefab just use prefab name

tidal rapids
#

It is a prefab but by clicking on an object in a scene and selecting "duplicate" it will make that object + (x) at the end of the name

#

when make the array of those objects it includes that (x) and it messes with something I do later that needs just the prefab name

ashen yoke
#

        /// <summary>
        /// Assumes the object may have (n) as postfix
        /// </summary>
        /// <returns></returns>
        string GetNameWithoutNumber(string name)
        {
            int closeIndex = name.LastIndexOf(')');
            if (closeIndex != -1)
            {
                int openIndex = name.LastIndexOf('(');
                if(openIndex != -1)
                {
                    return name.Substring(0, openIndex);
                }
            }
        }```
#

may need -1 in substring

tidal rapids
#

hmm let me try this out

#

Thank you by the way I really appreciate the help

tidal rapids
ashen yoke
#

no

#

openIndex may end up exactly on (

#

so you just offset by 1 in case that happens

#

also trim it

#

return name.Substring(0, openIndex).Trim();

lean sail
#

you would also have to return the original string if it doesnt exist

ashen yoke
#

this will break if the object has (Clone) in the name btw

#

right

lean sail
#

I really would just go with regex, though it may look kinda messy since you'd have to do escape sequences on the brackets lol

#

*\(\d*\) would capture any amount of spaces followed by (, followed by any number, followed by )

tidal rapids
ashen yoke
#

regex is like rocket science to me, i could, but id rather not

lean sail
#

in most cases regex is honestly really easy

tidal rapids
#

Same haha I have 0 experience with it

tidal rapids
lean sail
#

your case for this is like one of the things you learn when starting out. You may just have to add extra escape sequences because c# doesnt like \( so it might have to be \\(

ashen yoke
#

its easy when you get into it, understand its fundamentals, learn the tokens and what they mean, work with it for a while

#

not saying you shouldnt do, im saying you have to commit

#

and who has time for that

tidal rapids
#

Nvm i realized the problem with the returning thing

lean sail
#

i never get into the actual hard regex, like when i see something online suggest a lookahead I just find a different solution 😆

tidal rapids
#

Ill look into regex if this does solve what im trying

lean sail
#

it does solve it, and u can also have it handle the (clone) at the same time

tidal rapids
#

The (clone) shouldnt be an issue but thats good to know

#

the only reason this is an issue is because its not at runtime so I cant fix it when the objects get instantiated

lean sail
#

blue means it matched, green means a subset was detected so dont worry about that part

#

it does look a little chaotic, but purely because its trying to match for () which are tokens already in regex. So we need to escape each with \

#

and then i have another pair of brackets and a | to say match (number or "clone")

tidal rapids
#

interesting

#

so once its found how would you remove that from the string?

lean sail
#

it does get somewhat confusing when you try to match a lot at once, but itd be the same case writing it all out with pure c# strings

#

theres just a regex.replace function

lean sail
tidal rapids
#

ohh gotcha

ocean river
#

in here, what is Constants.Horizontal?

tidal rapids
hidden parrot
lean sail
upper imp
hidden parrot
#

Nevermind, float values, forgor

#

Uh, maybe not all of the objects you have selected have a RandomPositionMover component?

upper imp
#

nvm i fixed it!

elfin tree
#

How can I spawn something in front of the player, at certain distance, but have the distance between the player and spawned object be the same, no matter the object's size?

#

(this code can even make the object spawn on the player if object too big)

ashen yoke
#

you will need to get the object bounds for that

winged mortar
#

Find a way to get the size of your object, and add that to the distance

ashen yoke
#

which is an annoying task

#

all the objects you spawn have colliders?

#

you can use both Renderer and Collider bounds

winged mortar
#

Also think bout your current use-case, does it make sense to have it float of the player hre? Spawn building sounds like a building system, wouldn't you want to raycast to the terrain to place it on the terrain instead?

ashen yoke
#

the algoright goes like this:
collect all Renderers and Colliders in the object
cache object rotation
set object rotation to zero
declare new Bounds
loop through all colliders and renderers, doing bounds.Encapsulate
set rotation back to original
use the new bounds to determine objects "size"

#

this will give you approximate total bounds of the object, which you can then use to get an approximate distance the object should be offset by

elfin tree
#

Okay, I think something like that:

#

My use case is simple but for complex object would have to do what you said above

steep herald
#

how can I build a hashtable that's modifiable from within the class, exposed to other classes but not modifiable by them, and where I don't have to duplicate the collection into a readonly collection every time other classes attempt to access it?

leaden ice
#

E.g.

public IReadOnlyDictionary<K,V> Example => myDictionary;```
#

Also if it's not clear you should use Dictionary not HashTable

steep herald
#

So this does not create a new dict/generate garbage?

leaden ice
#

nope

#

do you see new anywhere?

steep herald
#

very cool, thanks

elfin tree
#

How can I calculate the distance between the player and an object, but from the object's bound rather than it's center point?

#

(this is what i have that's better than not taking into account the building's size at all but it's still far from perfect)

#

i could probably just raycast but was wondering if anyone knew the 'maths/physics' approach

leaden ice
#

raycasting is the maths/physics approach

elfin tree
leaden ice
#

not at all no

elfin tree
#

that's what i was infering above, sorry was pretty unclear

leaden ice
#

you would need to do two raycasts

#

one against each object's collider from the other object's position

#

to get the two "edge" points

#

then check the distance between them

elfin tree
#

hmm, what i meant is, through code, so with the world position of the objects and the bounds, something like that could be achieved

#

but my head kinda hurts thinking about it so i'll just go for the single raycast approach which seems to make the most sense

leaden ice
elfin tree
#

thanks!

swift falcon
#

hey can someone review my code? its a item shop script for a vr game but it crashes my unity if i try to start the buying process, would be really nice becasue i ran out of options why its crashing and i dont know if its unity or my script whatever heres the pasty link if you want to have a look at it https://paste.myst.rs/c61jnzsh

steady moat
knotty sun
steady moat
#

That would be: while(isslecting)

swift falcon
#

hm i see

steady moat
#

You gotta use a coroutine if you want to use this approach.

swift falcon
#

oh oke i though i could use a loop like the update method and break it if the player is done selecting

steady moat
#

You cannot use a while(true) loop.

swift falcon
#

oh ok thx for teh help

dawn apex
#

/code

#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

swift falcon
steady moat
swift falcon
#

ok it worked

ocean river
#

layers are confusing... once i add a masking layer to raycast, it wont detect anything, no matter what layer it is in.

leaden ice
#

layermasks are simple - the raycast will only hit colliders that are on the layers in the mask

#

that's it

ocean river
#

code

                Debug.Log("HIT!");
                return true;

            }```

script in parent, there are 4 childs with collision in it.
it should only detect one of the three collisions in camera.
leaden ice
knotty sun
#

but... LayerMasks are bitmasks, not simply Layer Ids

leaden ice
#

use LayerMask.GetMask("lyr_blocks")

ocean river
#

ah i see

random oak
#

Hello how can I make Physics.RaycastAll follow correct order ? only LINQ?

leaden ice
fervent furnace
#

sorting

random oak
#

closest element is always 1st

fervent furnace
#

then sort it

random oak
#

I can use OrderBy?

leaden ice
leaden ice
random oak
leaden ice
#

but WHY

#

what's the goal here

random oak
#

each my box has a random number, I want to detect total number but closest first

brittle sparrow
#

can i put like 3 or more of the same collider type in a single gameobject and have them all pertain to a different behavior? like, a player having colliders on their sides so they stop at walls, but not to stop their fall if they're falling next to a wall (and in the same way, to not stop their running side to side when grounded at the bottom collider)

#

oh wait, is there such a thing as Collision2D telling you which collider got contacted?

thick terrace
#

it does have a collider field and a list of contacts if that's what you mean?

brittle sparrow
#

oh i found something called GetContacts

#

i wonder how that works

#

ContactPoint2D

#

it shows the actual position of contact

#

i could use this

#

yeah, definitely!

knotty sun
#

that's why Unity wrote documentation, so you could read it and learn

brittle sparrow
#

sorry

#

i'll do more research next time

blissful sable
#

3d text mesh pro is always facing the camera. is there a way to disable it?

leaden ice
#

it faces wherever you tell it to face

blissful sable
#

no for me it is

leaden ice
#

you've done something strange then

blissful sable
leaden ice
blissful sable
#

i disabled the parent constrant too but it still does no matter what

leaden ice
blissful sable
#

ik it shouldnt do it unless done by code or contrant

#

ive googled and found out about billboard but i dont have it. its a new project

leaden ice
#

maybe something in your scene is doing it

blissful sable
#

nvm i think i got it

leaden ice
leaden ice
#

what was the issue?

blissful sable
#

i removed all the contrants and it works now

leaden ice
#

ah

blissful sable
#

will figure ouyt which one was the problem and solve it

#

fixed it. script problem. thanks

narrow elk
#

Any help (video above) would be greatly appreciated!

slow trout
# narrow elk

I never see you initialize the BotRends list. You are using the .Add method on the list which isnt initialized yet. In other words, you are trying to call a method on a null object, hence the nullref exception.

narrow elk
#

Ok thank you I will check that. Out of curiosity, why does it work sometimes and the other times why does it work on the first element if that is true?

ashen yoke
#

this will not do what you think it will

#

you are accessing .material which means you get a clone of the sharedMaterial

#

so reset in this case assigns the new clone back the new clone

#

you are also calling .material on each submesh, meaning you are creating a clone for each of them

#

instead you should not access material at all, and instead use either MaterialPropertyBlock, or CommandBuffer to draw the flash

narrow elk
#

Thank you @slow trout that seems to have solved the issue

#

I will look into the MaterialPropertyBlock thank you

ashen yoke
#

first means you wont create clones but it needs a shader that flashes, second will simply draw same mesh with flash material on top of existing one without creating any additional scene overhead

narrow elk
#

Good. And that is using the Propertyblock?

ashen yoke
#

first - block, second - command buffer

narrow elk
#

So both should be used?

ashen yoke
#

one or another

#

they both solve a problem, in different ways, but both are more efficient than .material

narrow elk
#

Ok, thank you for your help/time

ashen yoke
#

can you post code?

#

the one with the list that isnt getting initialized

narrow elk
#

It is now that I changed it

ashen yoke
#

its for me

narrow elk
#
    private List<Renderer> botRends = new List<Renderer>();
    private List<Material> baseMats = new List<Material>();
ashen yoke
#

so far the only case when i know things like these happen is with statics

#

it is unclear to me why did it even work the first time

narrow elk
#

No statics here

ashen yoke
#

what code could potentially initialize it on first play, and not on second

knotty sun
#

Disable Domain Reload option

narrow elk
#

My thought exactly

ashen yoke
#

domain reload wont initialize the list the first time

narrow elk
#

Tried that, no effect. Had a similar issue with another script, its off

knotty sun
#

Just had a similar problem in Editor (i.e. not in Play mode)

ashen yoke
#

im asking why did it work the first play session, unclear

narrow elk
#

No idea.

#

I am looking into the MaterialBlockProperties now. Thank you

ashen yoke
#

are you on URP?

#

if so property block can be detrimental

narrow elk
#

I am

ashen yoke
#

then dont listen to me and ask in #archived-urp what is the best way to solve such cases, they changed too much for the old approaches to be applicable

#

what you really want to know is how urp handles .materal and lots of dynamic material changes

#

it doesnt behave the same way, im sure it still copies material, but im not sure it has the same performance impact as on built in

ocean river
#

back again. is it possible to set the origin (for rotation) in script?

leaden ice
#

the pivot is just... the position of the object

ashen yoke
#

pivot is something that doesnt actually exist, kinda

winged mortar
#

Better off describing your problem rather than your attempted solution

ocean river
#

tetris

#

i want to set the origin offset or something so it rotates in the middle

dusk apex
#

What's it currently doing?

ocean river
#

its a thread now

knotty sun
ocean river
latent latch
#

gotta implement wall kicks though too ;)

#

I think that feature is more relative to the newer tetris games though?

mellow sigil
#

Split it into multiple frames with a coroutine

hexed rover
#

Could someone help me with my spawner script🙏🙏

soft shard
hexed rover
#

So I’m making a wave shooter and I’m trying to spawn enemies at random points on the map, but if I just use random range it puts them in obstacles and walls that are on the ground, so now I’m trying to make it so they can only spawn on random points on their navmesh but can not figure out how

#

I can send an image of the code if that makes it easier

mellow sigil
#

No screenshots. !code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

hexed rover
#

My b

#

In that case I could do it

#

Dm

#

Not do

mellow sigil
#

No DMs either. Post the code here as per the instructions

lean sail
hexed rover
#

I mean it’s probably just a quick fix with the script

#

I don’t know if I’d call that tutoring

simple egret
hexed rover
#

I need this fix so bad man I’ve been staring at a couple lines for hours

lean sail
#

Would u rather fail to convince someone to tutor for free, or just post your question like a normal person

hexed rover
#

Oh

simple egret
hexed rover
#

I asked if anyone could help then someone said provide more details and I did

mellow sigil
#

We also asked you to post the code and you didn't

simple egret
hexed rover
#

Yeah but it’s on my computer and a picture would be a lot easier

#

If I could just post the picture of my computer and someone could look at it and tell me the problem I’d be very thankful

simple egret
#

Discord can run on a browser, don't go and take phone pictures of screens

hexed rover
#

It’s so much easier though man

#

I don’t even remember my login for discord

simple egret
#

For you sure, but not for us

hexed rover
simple egret
#

Nobody answered them

#
  • It's not readable, code is too small
lean sail
#

Literally "random point on a navmesh"

hexed rover
#

I triiiied

#

That’s why I’m here now

lean sail
#

Try harder, or try harder to read the read me. This is a waste of time

hexed rover
#

Trust me using discord is the last thing I’d want

ocean river
lean sail
#

Great another screenshot of code

hexed rover
#

Literally top ten most readable things I’ve seen today

simple egret
#

Let's not start and argue with the rules

#

Do not post screenshots of code, period

dusky token
#

Heya, I'm using this code in a GameObject's monobehaviour to make it snap to a 2d grid,

    {
        this.grid = transform.parent.GetComponent<Grid>();
        this.gridscale = transform.parent.localScale.x;

        //snap to grid
        transform.position = new Vector3(Mathf.Round(transform.position.x / this.gridscale) * this.gridscale, 
            Mathf.Round(transform.position.y / this.gridscale) * this.gridscale, 
            transform.position.z);
    }```
However, it snaps it to the point exactly in-between cells. The transform x and y values are correct on the GameObject, so I assume it has to do with the tilemap's Tile Anchor-value. However, if I set the anchor value to 0, it seems to mess with other stuff I have that uses the WorldToCell / ScreenToWorldPoint functions. I could just add `0.5*gridsize`to the x and y, but I'm worried this will cause other issues down the line. Is there a "recommended", robust or just better way to get gameobjects to snap to a grid?
hexed rover
simple egret
#

Good luck

hexed rover
#

Thanks man you were actually civil unlike my man bawsi throwing around words like psycho

lean sail
#

The behaviour described seems like it's doing what you want so im just trying to clarify

dusky token
lean sail
dusky token
unreal valley
#

Question: If I setup a variable to be a lambda of a function, is that like the same as setting it consistantly in the Update Method or no?

public int AttackDamage => SetAttackDamage();

vs

public int AttackDamage { get; private set; }

private void Update()
{
    AttackDamage = SetAttackDamage();
}

private int SetAttackDamage() {...}

leaden ice
#

it's the same as

public int AttackDamage {
  get {
    return SetAttackDamage();
  }
}```
lean sail
#

Your AttackDamage is also just a getter in the first one

leaden ice
#

Doing AttackDamage = SetAttackDamage(); in Update is definitely not a good idea

#

for many reasons

#

also this "SetAttackDamage" function seems poorly named

#

it seems to be retrieving something, rather than setting something

unreal valley
#

I was thinking about having an Event be called when anything is changed that will make the Damage change.

leaden ice
#

it's also unclear what SetAttackDamage does

unreal valley
#
private int SetAttackDamage()
    {
        // Weapon Dmg, AttributeValue
        // Dmg = MainAttribute * 4 + SecondaryAttribute
        try
        {
            Player player = _character != null ? (Player)_character : GetComponent<Player>();

            if (player != null || player.JobSystem.CurrentJob != null)
            {
                int main = 0;
                int secondary = 0;

                List<Attribute> attributes = new List<Attribute>()
                    { ((Player)_character).Stats.TotalStrength, ((Player)_character).Stats.TotalDexterity, ((Player)_character).Stats.TotalIntelligence, ((Player)_character).Stats.TotalLuck };


                main = attributes.Find(x => x.AttributeType == player.JobSystem.CurrentJob.MainAttribute).Value;
                secondary = attributes.Find(x => x.AttributeType == player.JobSystem.CurrentJob.SecondaryAttribute)
                    .Value;

                attributes.Clear();

                float weaponMultiplier = 1.2f;
                int attValue = main * 4 + secondary;
                int damage = Mathf.RoundToInt(weaponMultiplier * attValue);

                return main > 0 ? damage : 0;
            }
        }
        catch
        {
            return 0;
        }

        return 0;
    }
leaden ice
#

kind of sounds like you have some function for calculating attack damage which is non trivial and you'd like to cache it?

unreal valley
#

Essentially sets the Damage value based on the characters Attributes. Later it will factor in weapon equipped and so on

leaden ice
#

I would do this:

bool dirty = false;

int _cachedDmg = 0;
public int AttackDamage {
  get {
    if (dirty) {
      cachedDmg = CalculateAttackDamage();
      dirty = false;
    }

    return cachedDmg;
  }
}```
#

whenever anything happens that would change the value you can set dirty = true

#

you could do that part through events if you want

#

for exmaple this could be listening to events on the player like "OnEquipmentEquipped" or something

unreal valley
#

So equip new weapon, Event triggers , sets dirty to true, then get AttackDamage

leaden ice
#

yea

#

and otherwise the calls to AttackDamage will be fast since dirty will be false

#

we will only return the cached value

unreal valley
#

So what you are saying is happening right now tho, is that every time AttackDamage is being called, its always running that Function?

leaden ice
#

well I don't know what your code looks like right now

#

If it was this:

private void Update()
{
    AttackDamage = SetAttackDamage();
}
``` then you're running the funciton every frame
#

which is also wasteful

unreal valley
#

the lambda

leaden ice
#

with the lambda the funciton will run every time you access AttackDamage yes

#

so both of your examples are running the function way more than necessary

unreal valley
#

Gotcha, makes sense. So as you suggested, caching the most recent value so it wont have to run over and over.

leaden ice
#

and just marking it as dirty whenever something changes

#

that might affect the value

sinful ginkgo
#

i have a problem, whenever i try to build an APK for my mobile game this error shows up and i get 4 long error it the console and i dont know how to fix it

leaden ice
sinful ginkgo
#

i dont understand them or how to fix them

unreal valley
#

@leaden ice Thanks a lot! Going to implement this now!

pure cliff
#

I'm thinking about logically how I want to handle a process where I have multiple "rounds" worth of player actions queued up, but there is an automatic trigger for the player attacking an enemy they are facing.

So there can potentially be both a "pre-round" and "post round" free attack if they both start off facing an enemy and end facing an enemy, plus a movement in between the two.

I pre-calc all rounds worth of actions and then hand them off as a sort of animation+movement queue they all individually work through.

The tricky part is keeping them all time synced, so I need to track how long the round is for the "slowest" entity (due to animation time), and slow everyone else down to keep pace

#

As an example if I have 3 enemies, 2 just walk 1 tile, third has a 1s long ability it performs, I want the other 2 to walk a bit slower and pause at their tiles for a total time of 1s so everyone "finishes" the round in sync @-@;

steady moat
pure cliff
#

I think I need to:
Step 0: allocate a dictionary of everyone's actions they will potentially do
Step 1: calculate all the moves for round n
Step 2: calculate the longest entity's move for round n
Step 3: save this set of moves + time to aforementioned dictionary
Step 4: n+1, back to Step 2 til all rounds calc'd

glacial loom
#

Hey I am making a top down shooter which will have multiple different guns, so I for simplicity's sake I have an abstract class for all guns that handles the general logic for all of 'em, problem is it seems I cannot use the Awake() method in both the abstract and the specific class meaning I cannot set general parameters and use Awake() for more per gun uses, is there any way to circumvent this or am I aproaching this completely wrong

steady moat
pure cliff
steady moat
#
protected override void Awake(){
  base.Awake();
}
pure cliff
#

Cause I ideally want to make her run faster between 2 tiles if she had an attack, and even faster if 2

glacial loom
pure cliff
#

But she may also stay stationary and just attack twice without moving @-@;

steady moat
#

You just need to calculate all the action that will be done don't you ?

#

Is it a turn by turn or not ?

pure cliff
pure cliff