#archived-code-general

1 messages · Page 124 of 1

boreal kelp
#

Sorry if im unclear english is not my native language :c Im trying to do a button for each key. Like : Forward : w, Left: a etc. and rebind each of them without calling the other keys

heady iris
#

so you want to be able to rebind "W" to do something else

#

and still have "A", "S", and "D" be part of the movement composite

boreal kelp
#

Yup

heady iris
#

i've never touched input rebinding, so i don't have any advice, unfortunately

boreal kelp
#

oh okok no problem :))

gray mural
#

it's like if and else if

boreal kelp
#

yes

gray mural
#

Composite:

// you can press all 4 in Update for example
if (W) ...
if (S) ...
if (A) ...
if (D) ...

Non-composite:

if (W) ...
else if (S) ...
else if (A) ...
else if (D) ...
boreal kelp
#

okok

#

so how am i supposed to still have them composites but have them rebind separately?

gray mural
#

I do not get

boreal kelp
#

like i saw tutorials where they rebind all of the keys at the same time

#

like one button and then rebind wasd in the same time

stark jacinth
#

transform.forward = -camera.transform.position; worked

#

thanks

gray mural
#

or isPartOfComposite

boreal kelp
#

yes but i dont want that

gray mural
boreal kelp
#

im so sorry i dont know how to explain

gray mural
#

write in your own language and then translate into English

heady iris
#

you're making the flashlight point in the direction from the camera to the center of the world

#

what's wrong with transform.forward = camera.transform.forward?

boreal kelp
# gray mural if you cannot explain - I cannot answer

ok so i saw it in a tutorial because i was trying to rebind my keys. And then i saw that they did the wasd that way wich is not what i wanted to do. I wanted to do it separately so i tried to find something like that, wich i didnt find. So im trying to ask peoples here because i dont know where i can get help

gray mural
boreal kelp
#

And the main question is : Im trying to have one button for each keys of wasd and not one to rebind all of them at the same time

#

but because its composite it doesnt work and i dont know why

gray mural
#

or I don't understand something?

boreal kelp
#

because its in vertical and horizontal axes and we need them together to work

gray mural
boreal kelp
#

yes but if i do that i will still have to do ws and ad on a single button

#

like one button for ws

#

and one for ad

heady iris
#

Up is a binding, as is ZQSD-WASD

#

it sounds like you need to rebind Up

#

rather than trying to rebind ZQSD-WASD

boreal kelp
#

is it possible to make the wasd not composite without losing the fact that i can do horizontal movement?

gray mural
heady iris
#

well, doesn't that just kick the can down the road

#

you still have composites

boreal kelp
#

my bad not horizontal diagonal *

heady iris
#

you'd just put the two inputs together in your code.

gray mural
heady iris
#

to make sure we're all on the same page here

#

the problem is that, when you try to rebind a composite binding, you have to rebind all of the parts of the composite at once?

gray mural
boreal kelp
#

like is it possible to not do a composite at all and still do diagonal (like if i press w and a at the same time)

heady iris
#

i.e. if you try to rebind your movement input, you have to set the Up, Down, Left, and Right keys

gray mural
boreal kelp
#

i dont want composites at all

heady iris
#

i don't think anyone here is on the same page right now

gray mural
gray mural
boreal kelp
#

im sorry let me be clear

#

so in this situation

gray mural
#

you should explain what you wanna do

boreal kelp
#

to rebind my keys

#

and not do duplicates

gray mural
#

explain with if, if else, else maybe?
i will come in a few minutes

boreal kelp
#

okok

heady iris
#

no, explain with a description of what the game does

#

that will be more useful.

prime sinew
#

You guys should make a thread

boreal kelp
#

okok

#

yeah im all for it im sorry for spamming a little :c

heady iris
boreal kelp
#

oh i didnt see there is a input system channel

#

im sorry

boreal kelp
static matrix
#

which quality setting does the editor use? Is it the same as PC standalone

heady iris
#

it should be whatever is highlighted in the Quality menu

static matrix
#

okay

dim umbra
#

How would I make it so that code runs when an object interacts with the solid part of a platformEffecter2D? Using onCollisionEnter2D still registers even when the object just passes through and doesn't actually collide with the solid part.

static matrix
#

can I use Render Pipeline Assets if Im not using the standard pipeline?

heady iris
#

the scriptable render pielines used those, yes

static matrix
#

no I mean

#

If i am using the standard pipeline

#

sorry mispoke

#

if im not using any special pipeline

heady iris
#

then no, because you're not using a scriptable render pipeline

static matrix
#

because it looks like it gives me the option

#

but im not using SRP

heady iris
#

right, there are no scriptable render pipeline settings, 'cos you aren't using a scriptable render pipeline

static matrix
#

ah
but I cant create one?

heady iris
#

well, no, because you aren't using a scriptable render pipeline...

#

the settings menu always shows that, AFAIK

static matrix
#

ah

#

ok

winged tiger
#

Hey I wrote something like

public static void Change(Vector3 pos, int amount)
    {
        Terrain ter = Terrain.activeTerrain;
        TerrainData terrainData = ter.terrainData;
        
        Vector3 converted = ConvertWordCor2TerrCor(pos);
        int x, y;
        y = (int)converted.x;
        x = (int)converted.z;

        int[,]  prev = map;
        map[x, y] = amount;

        // Assign the modified map back.
        terrainData.SetDetailLayer(0, 0, 0, map);
    }

It sets detail on terrain, but now I need to set not only one point but points surrounding too, and additionaly return a 1 if the detail map changed (is diffrent than was before). Can anyone help? I have no idea how to do it honestly

ivory pasture
#

how do i stop a running coroutine?

potent sleet
heady iris
#

el goog

ivory pasture
#

i did not realize you have to make it a var to use that function

#

thanks though

heady iris
#

it's not that you're makign the coroutine "a var"

#

you're saving the result of calling StartCoroutine

#

and then using that to stop the coroutine later

#

that's all

ivory pasture
#

alright, thank you

limber agate
#

why do the wood logs show up in the scene view but not the game view

potent sleet
#

not code question btw

limber agate
#

ur right it isnt

#

but yeah the z was -14

lethal tusk
#

I want to understand how saving on a json file works in unity instead o just memorizing it, what i understand so far is usually you make a class with all variables you want to save like health, score etc. Then you make an object out of that class and save it. For loading you can load data from the file to the object.
Did i understand it right? or Im missing something.

potent sleet
#

pretty much

lethal tusk
#

cool thanks

gray mural
#

much better though

static matrix
#

So the thing that seems to be causing all the lag is Semaphore.WaitForSignal

lethal tusk
gray mural
static matrix
#

its following this pattern where it does a bunch of things, waits 50 ms, and then does all the rendering

#

like this

#

deos anyone know why it is waiting?

lethal tusk
gray mural
static matrix
#

or what it is waiting for?

potent sleet
gray mural
lethal tusk
#

yeah right now im using it to store my score, much easier to use. but not fleixable at all.

potent sleet
#

PlayerPrefs lives in your registries and it sucks being ported across versions

lethal tusk
# gray mural json?

no PlayerPref, right now Im converting it to json based system cuz the game is getting bigger

potent sleet
lethal tusk
#

POCO?

potent sleet
#

"Plain Old CLR/Class Objects"

#

public class ImAPoco{ }

static matrix
#

where is multithread rendering in player settings
I cant find it

potent sleet
lethal tusk
#

oh got it

static matrix
#

is there like an "Advanced Settings" Button

#

I cant seem to find this

potent sleet
#

these aren't code specific questions @static matrix

static matrix
#

ok then where do i go

potent sleet
static matrix
#

ok then

jaunty sleet
#

I am trying to save the initial position of touches so I can calculate which direction the user is swiping, if they are swiping. I am saving them in a dictionary with the touch as they key, but when it tries to access the touch it says that it doesn't exist. Does anyone know why this could be? Here is my code https://wtools.io/paste-code/bNxl

#

You can use objects like a touch as the key for a dictionary right?

tawny mountain
#

Anyone have an idea on this

gray mural
tawny mountain
gray mural
#

once it's position equals or is more than something...

tawny mountain
heady iris
#

quaternion x/y/z/w values are NOT euler angles

#

they are the four components of the quaternion

#

you want .eulerAngles

gray mural
heady iris
#

transform.rotation.z is the third component of the quaternion, not the rotation around the Z axis. transform.eulerAngles.z is the appropriate value.

gray mural
heady iris
#

that code is not correct.

gray mural
tawny mountain
heady iris
#

that isn't a z position, for sure...

#

that's an angle

lethal tusk
#

how can I clear a json file? can I just do this:

string json = JsonUtility.ToJson("");
File.WriteAllText(path + fileName, json);

gray mural
lethal tusk
#

thanks

gray mural
lethal tusk
gray mural
lethal tusk
ivory pasture
#

webgl build just shows nothing with universal rp 🤦

gray mural
gray mural
lethal tusk
gray mural
tawny mountain
# gray mural what's the problem here? ```cs if (transform.eulerAngles.z >= smth) { // wha...

ok , sorry had to tend to my chickens ... the first script is suposed to overide the rigidbody 2d physics, the second script is the seesaw object where I call it when seesaw z rotation = 25
https://pastebin.com/AxZ5H9LM
https://pastebin.com/W4jCFjNP

ivory pasture
gray mural
lethal tusk
gray mural
tawny mountain
lethal tusk
#

I wasn't sure, and It wasn't the best solution

#

yours is better

gray mural
tawny mountain
#

Its an object on the seesaw

#

The tennis ball falls and the cannon ball arc's up and to the right ( as normal physics will allow )

#

I want it to go up and to the left .. opposite of natural physics ( red circles in above image )

gray mural
#

maybe you can draw it?

#

with lines

heady iris
#

mess with the masses

gray mural
heady iris
#

oh, I see

gray mural
#

yes, you wanna...

tawny mountain
gray mural
#

in case black ball won't collide with that tube

tawny mountain
#

No the first black ball goes up and to the right

tawny mountain
#

Tennis ball falls and launches the cannon ball the opposite of the black arrows

tawny mountain
#

thats what I get normally

gray mural
#

I don't think changing physics is a good idea

tawny mountain
#

my acrprojectile script shjould over ride that

gray mural
#

do something with your scene

#

or maybe that's because of that tube?

#

The easiest way might just be to take full control. On the correctly timed press, disable the RigidBody and the Collider. Then just move it yourself to the target location. It's really hard to get precise control over a RigidBody -- every FixedUpdate(), it might be picking up force from collisions, and there can be many FixedUpdate() calls between Update() calls.

tawny mountain
real ivy
#

HI :p

#

i'm studing inverse kinematics for some time, but idk how to render it

#

for a single leg creature i used linerenderer

#

but now i have 6 legs

#

im using FABRIK in my IK

heady iris
#

six linerenderers?

real ivy
real ivy
#

in other simulation i did a jointRenderer script with one linerenderer for each joint

#

but it seems to be very expensive for the computer to render

heady iris
#

the docs suggest using separate renderers for separate lines

#

i wouldn't think six lines would be too bad!

real ivy
lyric nest
#

i know this is a bad explanation but: is there a way for me to create an array of "conditions" (ie script variable here) that can be accessed and then be used by another script? kind of like the condition menu from the animator but for c#

heady iris
heady iris
#

Do you just want to create a list of dropdowns?

lyric nest
#

not really? more like a list of script variables but from other scripts

heady iris
#

describe what you want to do

#

not "have an array of conditions"

#

what are you creating?

lyric nest
#

ok so basically i have a door that i want to open but only when all switches are turned on. i was thinking the best way to do this is to have the door reference the switch scripts of each switch and see if they are on or not.

heady iris
#

ah, ok

#

referencing arbitrary variables on other components isn't really practical -- that'd involve reflection

#

since you'd be able to get any variable from any component, pretty much

#

sounds like you have a much more narrow use-case, though

#

i think the neatest way to do this is to just have a list of Switch objects

#

where Switch is the component on the switches

#

you can then access their "on" field

#

if you want to make it more general (maybe there are switches and locks and pressure plates), you could instead have the various devices reference the door

meager sigil
heady iris
#

yes, if you've rotated around all three axes, then the result may be non-intuitive

#

for an object that is only rotating around the Z axis, the interpretation is correct

woven matrix
#

hey guys help me out, I am using rendure texture to make a scope of a camera, but in game the result is a bit darker can some one help me out with this?

ashen yoke
#

you have any post processing?

woven matrix
#

nope

leaden ice
#

You're probably using the standard shader which is lit

#

This also isn't a code question

woven matrix
#

sorry my bad I am used to only ask code questions

#

it was automatic

#

-.-

real ivy
#

i use a prefab of the leg segments

#

this prefab rotate towards the target point

#

and i can say my brain is very big

tender lark
#

Yall know how to get SetActive functions to work on an Image

#

Instead of gameObject only

gray mural
tender lark
#

what???!!

#

Public image example

#

example.gameObject.SetActive(false)

#

@gray mural like this?

gray mural
#

you should set its gameObject component to false

tender lark
#

thank you

#

it's so damn siple yet far

gray mural
#

GameObject.SetActive

#

should be used with GameObject then

heady iris
#

only game objects are activated or deactivated

#

Behaviors can be enabled and disabled.

primal wind
#

If you wanna get technical you could make a class that implements a Enable() method

#

But i think it's useless for most things

heady iris
#

well, I mean, you can make any method you want!

ashen yoke
#

wrong

#
        void 9999()
        {
        }
heady iris
ashen yoke
#

c# sucks

heady iris
#

cirnophobic

woven matrix
#

hey guys how can I get a angle from -90 to 90 relative to a transform and a target?

#

I am not understanding how

#

I am using cs Vector3 targetDirection = target - transform.position; float angle = Vector3.Angle(transform.forward, targetDirection); float clampedAngle = Mathf.Clamp(angle, -90f, 90f);
but the values allways come positive

#

even if the target is above or below the transform

heady iris
#

you want SignedAngle

woven matrix
candid moon
#

Hello I am having an issue where an npc in my game is supposed to sit down after reaching a table, and for some reason there is a velocity applied right after sitting down
I am not sure where that velocity is coming from
https://medal.tv/games/requested/clips/1dLBD8DtHi_90E/d1337SjgfblD?invite=cr-MSxsd20sMjYzNjQxOTcs

private void CustomerSit(GameObject sitPos)
    {



        transform.position = sitPos.transform.position;
        print(transform.localRotation);

        Rigidbody rigidbody = GetComponent<Rigidbody>();

        transform.localRotation = Quaternion.Euler(0, 0, 0);
        transform.rotation = Quaternion.Euler(0, 0, 0);
        rigidbody.velocity = Vector3.zero;
        rigidbody.constraints = RigidbodyConstraints.FreezeAll;
        print(transform.localRotation);
        Animation customerSitAnim = GetComponentInChildren<Animation>();

        animator.SetBool("isOrdering", true);



        ChooseRandomItem();

        sitting = true;
    }```

Watch Bug Help 12/6/23 and millions of other Requested videos on Medal, the largest Game Clip Platform.

▶ Play video
soft shard
#

Could you give an example of how you intend to use this system, maybe with pseudo code? I dont think I fully understand your goal with it

soft shard
candid moon
#

unfortunately didn't work thank you for trying though ^^

earnest gazelle
#

I have implemented undo/redo for my tools, the key is ctrl+z and ctrl+y. The problem is that the undo/redo keys are the same as undo/redo unity. What do you suggest?
Change shortcut? is there any way to use ctrl+z, ctrl+y for my tools without conflicting?

leaden ice
#

Why not integrate your undo/redo into Unity's undo system

earnest gazelle
#

It is in runtime.

#

I think it should exist an api to stop undo functionality

#

Undo.IncrementCurrentGroup();
Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
but I think it is better to use different shortcuts

steady moat
#

What you actually want ? What is the end goal ?

charred dust
#

Is there a way to make interface variables show in the inspector (Serializable?)

heady iris
#

no, since they don't derive from UnityEngine.Object and aren't one of the other types that can be serialized

#

you probably want to make an abstract class that derives from MonoBehaviour and implements the interface

#

it's definitely a pain-point

charred dust
heady iris
#

actually, can you point me to an example of that?

charred dust
#

me?

heady iris
#

no, sim

charred dust
#

oh

heady iris
#

I guess you can make an Object field and then just check that you put a valid object in?

#

(i.e. one with the right interface)

charred dust
#

sounds like a lot of extra work imo. Ig I'll just put that variable in my self without a interface.

steady moat
#

Like Odin

#

Things like do a function on button, restrict string value base on condition, bitmask field, etc.

#

And, we have the possibility to show any variable/function.

heady iris
#

right, but how would you do this specific thing?

#

i.e. exposing an interface field in the inspector

leaden ice
steady moat
heady iris
#

ah, I see

steady moat
#

For the part of retreiving/exposing an interface, you can use Reflection + Attribut.

heady iris
#

so you'd show an Object field and then make sure whatever you put it in matches the interface?

#

i know i've seen something like that before

steady moat
#

You can do that for sure, but I do not see what it is gonna do with exposing paramters of an interface.

heady iris
#

parameters of an interface?

steady moat
#

I was thinking more something like MonoBehaviour : IInterface and expose the value of the function inside.

#

Result*

heady iris
#

maybe we're thinking of different things here...

#

i am thinking of letting you reference anything that implements an interface

#

(more likely, reference any unity object implementing an interface)

steady moat
#
public interface IInterface {
  [Inspect] string GetValue();
}

public class MyBehaviour : MonoBehaviour, IInterface {

}

[CustomEditor(typeof(MonoBehaviour))]
public class MyBehaviourEditor : Editor 
{
  public override void OnInspectorGUI()
  {
     //Do reflection things there
     //Draw the field
     DrawDefaultInspector()
  }
}
heady iris
#

ah, so you're talking about drawing extra things in the inspector from an interface field

#

okay, different thing

heady iris
#

so that if I had, say:

public interface IFoo {
  public void Foo();
}

public class FooClass : MonoBehaviour, IFoo {
  public void Foo() { Debug.Log("Foo"); }
}

public class FooClassRedux : ScriptableObject, IFoo {
  public void Foo() { Debug.Log("Bar"); }
}

public class SomeComponent : MonoBehaviour {
  public IFoo myFoo;
}
#

i could drag in either a FooClass or a FooClassRedux and both would fit in that myFoo field

lethal tusk
#

when we make a script unity generate some stuff in a file called Assembly-CSharp.csproj
which is an xml file if im not mistaken which filled with a lot of info. Is there a way to change its default values so whenever that file is created use some other data instead of its default data?

heady iris
#

why?

steady moat
#

Not a place for such things. Also, how many hours did you put into it ?

heady iris
drowsy heron
#

ok

#

bruh

heady iris
#

although i'm not even sure what the point of this is

steady moat
drowsy heron
lethal tusk
# heady iris why?

because whenever it generate the file, for taget net framework version it uses 4.7.1 by defualt by for some reason i have net frame work 4.8.1. And targeting the wrong version makes my auto correct not work while im writing code

heady iris
#

ah, I had a similar problem once

drowsy heron
#

honestly I'm extremely frustrated to spend all the time explaining the error and explaining how such a thing has to work within the game, and it's amazing how gpt can't solve a simple problem in the coding and ends up causing more problems in the place

simple egret
#

Unity has full control over your project file (csproj extension) you should not modify it manually

heady iris
lethal tusk
#

oh

drowsy heron
tacit dawn
#

A little question, is it the same to write:

public class Entity : MonoBehaviour, ITarget
{
  public void DealDamage(uint amount, DamageType damageType, uint numberOfHits, bool ignoreShield, bool ignoreArmor) {//effect}
}

and

public class Entity : MonoBehaviour, ITarget
{
  void ITarget.DealDamage(uint amount, DamageType damageType, uint numberOfHits, bool ignoreShield, bool ignoreArmor) {//effect}
}

With this as the interface:

public interface ITarget
{
    void DealDamage(uint amount, DamageType damageType, uint numberOfHits=1, bool ignoreShield=false, bool ignoreArmor=false);
#

like does it change anything in term of access?

heady iris
#

pretty sure the second one is an error

#

the default access modifier for interface members appears to be public

#

you can do protected, but that's a bit weird...I think that demands explicit interface implementation?

tacit dawn
rich leaf
#

Hey I have a question regarding movement with the rigid body of a character. Right now, My movement script looks like

#

void NormalMovement(Vector3 movementDirection)
    {

        // Calculate the movement amount based on the current speed


        // Translate the player's position based on the movement direction and amount
        Vector3 newPosition = transform.position + movementDirection * currentSpeed * Time.fixedDeltaTime;
        playerRb.MovePosition(newPosition);

        Debug.Log(movementDirection);

        // Rotate the player to face the movement direction
        if (movementDirection != Vector3.zero)
        {
            Quaternion targetRotation = Quaternion.LookRotation(movementDirection);
            transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);

            // Play correct animation
            if(currentSpeed == sprintSpeed)
            {
                this.GetComponent<PlayerAnimationHandler>().Player_Ani_Sprinting();

            }
            else if (currentSpeed == walkSpeed)
            {
                this.GetComponent<PlayerAnimationHandler>().Player_Ani_Walking();
            }
            else
            {
                this.GetComponent<PlayerAnimationHandler>().Player_Ani_Jogging();
            }
        }

        // if not moving, play idle animation
        else
        {
            this.GetComponent<PlayerAnimationHandler>().Player_Ani_Idle();
        }
        
    }
#

Where the movementDirection is calculated in the FixedUpdate(), which is also where this movement code is called:

  void FixedUpdate()
    {


        #region Normal Movement
        if (normalMovement)
        {
            // Check if the player is running or walking
            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            {
                currentSpeed = sprintSpeed;
            }

            else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
            {
                currentSpeed = walkSpeed;
            }
            else
                currentSpeed = jogSpeed;

            // Calculate the movement direction based on arrow keys or WASD
            Vector3 moveDirection = Vector3.zero;

            if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
                moveDirection += Vector3.forward;

            if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
                moveDirection += Vector3.right;

            if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
                moveDirection += Vector3.back;

            if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
                moveDirection += Vector3.left;

            // Normalize the movement direction if it's not zero
            if (moveDirection != Vector3.zero)
            {
                moveDirection.Normalize();
            }

            // Move the player
            NormalMovement(moveDirection);

        }
        #endregion
#

The issue is it seems like the player needs time to "charge" before it starts moving. I can see that the movementDirection vector is properly being calculated. However, it takes a few seconds of holding my key down for my player to begin moving. Additionally, once it starts moving in a specific direction, there is no delay in continuing to move that direction. ie if my character finally begins to move after holding W, i can let go of W and hold it again and it will instantly begin moving again. However, if I try to move in a different direction, I will have to wait for it to "charge"
I dont think this is a code issue as it calculates the movementDirection properly as well as working as intended once the player finally begins to move. Is this an issue with the rigidbody setup?

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.

rich leaf
#

my code is formatted

lean sail
#

read the code command

swift falcon
#

Large Code Blocks

leaden ice
#

You didn't share your Rigidbody setup so hard to comment on that

rich leaf
leaden ice
#

But since you're using MovePosition it's unlikely

rich leaf
#

The vector that is being inputed into MovePosition is what I expect to see, and the debug message prints the same vector when the player is stuck vs when the player is not stuck

#

Is this some sort of issue with the mass of the player? the drag?

lean sail
#

mass only has an effect on forces added to it, and your player has no drag from your screenshot

rich leaf
#

Why is it when "isKinematic" is disabled, the movement is perfectly responsive (but jittery)?

leaden ice
#

As mentioned above I think this is probably an issue with your other components

rich leaf
#

What could effect the rigid body?

leaden ice
#

Any of your other components

#

Whatever animation thing you're using is a good bet

rich leaf
#

How can the animations affect the rigid body?

#

When those animation things are commented out it still persists

lean sail
#

there are a lot of things that can make it jittery, tbh i dont really know why u have a kinematic rigidbody with rotation frozen on each axis to begin with

#

Even a desync between camera and player can make it look jittery, while the player is moving perfectly fine

rich leaf
#

My point is that the code is by turning off the isKinematic it shows that the inputs are being handled properly. I'm not sure why my player needs to hold down a key continuously for a few seconds before it moves. And when i let go and press the same key, it continues to move. However, if the direction vector changes, it takes a few seconds again

wind palm
# rich leaf My point is that the code is by turning off the isKinematic it shows that the in...

Off the top of my head I can explain why it moves after release (albeit it shouldn't be much), however the delay doesn't make too much sense to me.

You're using MovePosition
https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html

Rigidbody.MovePosition moves a Rigidbody and complies with the interpolation settings. When Rigidbody interpolation is enabled, Rigidbody.MovePosition creates a smooth transition between frames. Unity moves a Rigidbody in each FixedUpdate call.
#

However, based on your code, could you not just use Unity's default CharacterController to avoid these issues?

lethal tusk
#

There is a thing in python called Dictionary which allow you to save 2 data for each thing you put in like this:
"Name" : "Alex", "Age" : 20 etc
Kind of like a json file.
Is there anything like that in c# so i can store some data?

latent latch
#

yeah, a dictionary

lethal tusk
#

oh

#

so they have the same name>

rich leaf
#

yeah\

lethal tusk
#

then how you define it?

quartz folio
#

Though that just looks like a class with variables as there's different types as values

lethal tusk
#

can't I define it like this somehow ["Name" : "Alex", ...]

rich leaf
#

        newDictionary.Add(30, gameObject1);
        newDictionary.Add(31, gameObject2);
        newDictionary.Add(32, gameObject3);
        newDictionary.Add(33, gameObject4);```
lethal tusk
rich leaf
#

you can use anything as the key/result

lethal tusk
#

nice ty

rich leaf
#

that example just uses integers as the key and gameobjects as the result

lethal tusk
#

got it

quartz folio
#

If you wanted any type of data you would use object, but that's not a great way of programming, instead you would just use a class or something that's actually defined:

class Person
{
  public string Name;
  public int Age;
}
...
var alex = new Person
{
  Name = "Alex",
  Age = 20
};```
lethal tusk
#

oh that is a Dictionary?!

quartz folio
#

No

lethal tusk
#

I have one like that in my code, I want a Dictionary inside of it

vague jolt
#

if I run this code

File.WriteAllText(Application.dataPath + "/save.json", save);

Where is the file supposed to be once the game is builded ?
Here ? Becasue I can't find it.

vague jolt
quartz folio
#

!api

vague jolt
tawny elkBOT
vague jolt
#

i mean here

quartz folio
#

Why not just look at the docs, which tell you where Application.dataPath is.

lethal tusk
vague jolt
#

Win/Linux player: <path to executablename_Data folder> (note that most Linux installations will be case-sensitive!)
this is what is says but in the data folder there is not save file

broken fractal
#

Factorio 😧

lethal tusk
vague jolt
quartz folio
vague jolt
#

i hate how the game does not behave the same in editor and once builded

quartz folio
#

You should check that it runs via logging or the debugger, as it should be that folder

vague jolt
#

how do i do that ?

quartz folio
#

Either connect the debugger to a development build and use breakpoints

vague jolt
#

any way i am really confused by a thing, are unity games just the files in the folder you build the game or there is something else ?

wind palm
vague jolt
quartz folio
#

Because player prefs are not in the folder

#

and generally people save to the persistent data path, not the data path.

wind palm
vague jolt
#

that is just leaving files in my computer without me knowing

quartz folio
#

Welcome to Windows

wind palm
#

That's not really a windows problem.

#

I guess permissions could be an issue perhaps.

quartz folio
#

Windows is very permissive about where programs put files

lethal tusk
vague jolt
#

Debug.Log("The script Save File generator is running");
When i run the builded version is this getting printed in a file ?

quartz folio
rich leaf
lethal tusk
#

replace the result with another data

rich leaf
#

if you want a new result then just add a new entry

quartz folio
#

dictionary[key] = value

lethal tusk
lethal tusk
rich leaf
#

are you trying to replace the value at runtime?

lethal tusk
#

yes

vague jolt
#

so the logs say
FileNotFoundException: Could not find file "C:\Users\edora\OneDrive\Desktop\Simulation\Factorio Logic Simulator_Data\save.json"

So i guess that the function that generates the file is never started because another script is trying to get the file first blocking everything else?

#

should i make the function that generates the file in the void start of the script ?

quartz folio
#

Or, check if it exists before you try to use it

bold terrace
#

I dont know if this is a bug in Unity or not, but I have merged 2 different strings (nameString and descriptionString) and added it to the TextMeshProUGUI component. However the name and the description are overrided.

This is basically what I have done:
string newString = nameString + descriptionString
TextMeshProUGUI textComponent.text = newString

vague jolt
vague jolt
#

no i correct my self

#

i have no idea what is that

bold terrace
vague jolt
#

have you tried increasing the text area?

#

maiby there is not enoght space

bold terrace
wind palm
#

I was thinking there's an invisible "new line" like \r, that wasn't handled correctly

vague jolt
#

only thing that comes to my mind is to fix those two red error, they problablyu don0t matter but maiby they do

#

some one had the same problem

#

and was the \r

bold terrace
#

Seems to be my issue, where does the \r come from?

wind palm
bold terrace
vague jolt
wind palm
#

Usually lines in files end with \r\n which would support all platforms

bold terrace
#

Thanks everyone, I should be able to fix it now

leaden ice
#

Linux uses \n alone

wind palm
#

_>

lean sail
#

using \n alone should just be fine

dusk apex
#

Would be the constraint, if it matters

leaden ice
wind palm
lean sail
#

pretty sure if u write line1\nline2\r\nline3 to a file you'll still get all on its own lines

wind palm
#

The sauce

fading trail
#

should i make a voxel engine via using a 2D array noiseMap and then evaluating the height based on an AnimationCurve or use an array that gets all dimensions of the map and then store that

#

or should I use the first for the surface and the latter for the underground

lyric moon
#

anyone know how i can get a sort of 'device position' for my mobile game, i want it so walking IRL walks in game

lean sail
sharp root
#

Anyone know how i can play Admob ads in my mobile game at random times?
Interstitial btw

cobalt apex
#

Hey does anyone have any experience with optimization of behaviour trees? Running into an issue where the number of active behaviour trees are actively starting to hurt the performance. Currenly i'm storing the running nodes by the ID of the subject(simple int) for the behaviour in a sorted dictionary, but somehow it does not seem like a great performance gain over a regular Dictionary. Any pointers to points of optimization would be appreciated!

steady moat
wet condor
#

helo im looking for a helping material what i wnat to do is hide my varibles if my bol is true.
E.g 3 varibles Lock, Name, Password.
if my lock varible is true then idont want to shoe my name and pass varible i know it can be done using custom editor but i cant find the right material to do so

nocturne sierra
#

has anyone ever tried coding a programm for the hololens (using MRTK) in unity version 2019, where a cube spawns in front of u and u can do stuff like make it bounce via gravity and physical material? maybe additional speech input? we need sth like that for a school project and I was just wondering

lunar anvil
#

https://gdl.space/vepinitaho.cs I spawn Objects but sometimes they collide with each other and then they fly out of row how can I change that? ( the Objects are moving forwards)

spiral robin
#

I want this to activate the outline component on a raycasted object and then disable it when no longer raycasted. But it doesn't seem to be working

leaden ice
#

You're only doing anything when the Raycast hits

#

What about when the Raycast doesn't hit anything?

#

You need to handle that case

swift falcon
#

Hello, I am having some issues exporting my android game, can anyone help?

spiral robin
swift falcon
#

It's just the first time that I'm making an android game so I don't know how to use it

#

Oh but I have a different question

swift falcon
#

Most videos say that I need to use Unity Remote 5, but I can't find it on the play store

heady iris
#

the manual links to the application on the play store

placid summit
#

General OOP question - if you have a vehicle base class say and you override with a car class, a tank class etc. Is it valid to put an enum or something in the base class as a fast type check, to avoid doing endless if vehicle is car, if vehicle is tank etc? when you only have the vehicle class to hand? I dont know what cost type checks incur...

#

actually C# pattern matching seems to make it redundant 'is' is fast and you can even switch on class type

leaden ice
steady moat
#

If you show what you are actually trying to do, we might be able to give some suggestion.

placid summit
#

Yes I agree with you 2, it is a sign of poor design in most cases...

#

It was because I have a filter class with huge variation in inputs depending on type - the UI needs to change based on that. So it is not like I am calling a Move() or DoWork() function, I have to get full type info to setup the UI

leaden ice
#

Can't have a SetupUI() function?

#

I'll agree it's sometimes more convenient to use the switch

steady moat
placid summit
#

well one way anyway

dim plover
#

Hello everyone, anyone come up to very long compile problem today ?

leaden ice
#

Just as long as you understand what's going on, I'll not shame you for it lol

placid summit
#

ah I'm not sure I will ever reach C# perfection - but if it works in the end it may be the best I can do eh. If anyone has suggestions on bibles for best code tips...

steady moat
placid summit
#

but actually the UI bit is combined - ideally I guess TankUI->Tank CarUI->Car would be better

steady moat
#

There is two things here:
UI contract. (What other people see and can do on the UI)
UI capacities. (What can be done in the UI)

#

In your UI, you can have the capacities to show ammo by example.

#

However, only the TankUI will do the drawing of the ammo.

placid summit
#

yeah my vehicle stuff was an example but that is the point - one class type can have a very different UI, while still being a vehicle

steady moat
#

You give the capacities to show Ammo, show Speed, show Durability. However, only the TankUI will actual make the call to those functionnality

placid summit
#

yes, I always make it work, just not always in the best way - if you have any reference to this kind of "capacities and contract" method let me know

urban marsh
#

Hello everyone !
Is there a quick way to add the 60 scripts that are in a folder to a prefab ? (other than clicking 60 times "add script" in the inspector)

leaden ice
#

But 60 is a lot of components for one object

steady moat
#

Also, the reference I gave might not be good actually, it is more the formal approach than the design approach of designing by contract.

#

It tries to solve the question: How to make a bugless program where what we want is more how to design functionnalities in isolation, with the usage of interface. Maybe something like mocking in Unit Test is more close to what I actually refer. (You do not need the implementation of an interface to write a test)

placid summit
#

well formal/correct approach vs getting-it-done is a delicate balance. If the code gets too bad you waste time refactoring, if you take too long trying to make it the best, you never get it written!

dawn nebula
#

Apparently turning OFF a collider in a trigger will call OnTriggerExit, but turning ON a collider in a trigger will not call OnTriggerEnter

#

that's odd

steady moat
heady iris
#

gonna implement my game in Ada

#

a verifiably correct cookie clicker clone

weary marlin
#

what is the correct way to initialize the first object after setting up the bindings in the installer?

#

the following produces a warning:

#
        public override void InstallBindings()
        {
            this.Container
                .BindFactory<TileBehaviour, TileBehaviour.Factory>()
                .FromComponentInNewPrefab(this.tilePrefab);

            this.Container
                .BindFactory<WallPartBehaviour, WallPartBehaviour.Factory>()
                .FromNewComponentOnNewGameObject();
        
            this.Container
                .Bind<WallBehaviour>()
                .FromNewComponentOnNewGameObject()
                .AsTransient();
            
            this.Container.Resolve<WallBehaviour>().CreateWall();
        }
#

Zenject Warning: It is bad practice to call Inject/Resolve/Instantiate before all the Installers have completed! This is important to ensure that all bindings have properly been installed in case they are needed when injecting/instantiating/resolving. Detected when operating on type 'WallBehaviour'. If you don't care about this, you can disable this warning by setting flag 'ZenjectSettings.DisplayWarningWhenResolvingDuringInstall' to false (see docs for details on ZenjectSettings).

#

like ok i get its bad practice but what is the good practice

#

i could circumvent this with .NonLazy() but i dont want to move business logic into the constructor

cursive bridge
#

I’m new to unity so I have this hell of a easy question. I made a square and want it to move, how do I code that? I know I can just go search it up in YouTube but could I also get an explanation of how it works? I want to know what each text means in the code in case I want to change it oater or use it again. Anybody? rosathink

steady moat
cursive bridge
steady moat
#

If you want a description of what the fuction/line does, you can ask in #💻┃code-beginner. However, you will understand even better by searching on Google.

steady moat
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/

cursive hollow
#

Is there a way to increase gravity onto rigidbodys? My character controller jumps are too floaty rn

gray vessel
#

What is the limitation of the new keyword? In the docs it says that override extends and new replaces, which makes sense, except you can very easily do this:

class foo {
  protected virtual void action1() 
    {
        Debug.log("Action")
    }
}

class overrideFoo : foo {
  protected override void action1() 
    {
        Debug.log("Action2")
        base.action1()
    }
}
class newFoo : foo {
  protected new void action1() 
    {
        Debug.log("Action2")
        base.action1()
    }
}``` and get exactly the same results
heady iris
#

it affects the behavior when you have a variable whose compile-time type is of a parent class

#

and whose run-time type is actually a child class

#

with new, the run-time type is ignored. you just get the method on the parent class.

#

with override, the run-time type is used. you get the method on the child class.

#

so:

#
foo x = new overrideFoo();
x.action1(); // calls overrideFoo's implementation
foo y = new newFoo();
y.action1(): // calls foo's implementation
cursive bridge
# steady moat !learn

I’m trying to male a third person game, what tutorial would you recommend me mate?

heady iris
#

you need to learn unity.

#

follow the tutorial tracks on Unity Learn.

gray vessel
#

thank you for that

#

That's a subtle but important distinction I guess

heady iris
#

basically, virtual methods allow for polymorphic behavior, since you can override them

#

non-virtual methods do not

late mango
#

Hi everyone

#

I'm kind of lost on a project. How would I make it so I can rotate an object around another one following the mouse?

tacit sedge
#
{ ...}
bool isGrounded()
{
float ExtraHeight = .03f;
RaycastHit2D raycastHit2D = Physics2D.BoxCast(Col.bounds.center, Col.bounds.size, 0f, Vector2.down, ExtraHeight, LayerMask);
return raycastHit2D.collider !=null;
}```
I'm using this code for my 2D Jumping. However, I can't figure out how to make it so you can only jump when on the floor. Players can still jump on walls. I have LayerMask attatched to the tilemap I'm using for the collidable objects.
heady iris
late mango
#

No

mental rover
late mango
#

When I move the mouse I would like to rotate the object around another one

heady iris
#

then I don't know what that means

#

maybe you can make a visual example?

wind palm
late mango
#

That king of thing

#

But without having to clicking

#

Something like that

#

The object rotate to match the mouse angle compared to the object it's orbiting on

wind palm
#

Ah yes, I see.

late mango
#

But it stays focuse on the object

#

I know rotate around makes it rotate around the object but I don't see how we can match the mouse angle

wind palm
#
  1. So you need to get the mouse position in world space.
  2. Get the direction from the object thats being orbited, based on the mouse's position.
  3. Multiply that by the distance you want the object to be from the object thats being orbited and set that as the new position
tacit sedge
late mango
#

But I can just fix it by setting the z to the difference between the camera and the object

mental rover
late mango
#

I mean it wouldn't point to the object it's orbiting on anymore

tacit sedge
wind palm
late mango
#

Ok I'll try that

#

I'll report back to you 🙂

heady iris
# late mango

okay, so the object follows the mouse and points at a target

heady iris
#

er, not quite

#

targetObject.transform.position - transform.position

#

you can also use transform.LookAt(targetObject.transform.position)

wind palm
late mango
#

targetObject.transform.position - transform.position?

heady iris
#

Yes.

#

If you add that vector to your position, you get the target's position

#

Therefore, it is a vector pointing to the target

late mango
#

Oh I see

heady iris
#

target - source + source = target!

#

in general, to get a vector between two things, just compute to - from

wind palm
#

Unity compile times are driving me insane!

warm stratus
#

Hey, this line
controlEditor.obstaclesObject[indexOfRight].name.StartsWith("barrier")
does this error:
StackOverflowException: The requested operation caused a stack overflow.
UnityEngine.Object.get_name () (at <ba783288ca164d3099898a8819fcec1c>:0)

someone knows why?

wind palm
#

What is obstaclesObject a GameObject?

warm stratus
wind palm
#

I wouldn't have expected name to cause a stackoverflow.

warm stratus
wind palm
warm stratus
#

but something good is that the error is everytime

warm stratus
wind palm
#

That screenshot doesn't show much xD

warm stratus
wind palm
#

Ah! That'll do it.

warm stratus
#

and what s the limit?

fervent furnace
#

depends on stack size

late mango
wind palm
#

I'm not sure it has a definitive size. But you really aught to not toy with it!

fervent furnace
#

and memory usage each function call

wind palm
#

Where possible avoid nesting methods.

late mango
#

Now I just have to constraint the movement

#

So it's always at the same distance from the object

warm stratus
wind palm
#

Usually you can rework this into a do { } while(); or a while() { } loop

wind palm
warm stratus
wind palm
warm stratus
#

ok it works fine now

gray mural
#
public delegate char OnValidateInput(string text, int charIndex, char addedChar);

This method (from TMP_InputField) is happened when player presses the button

public OnValidateInput onValidateInput 
{
    get 
    { 
        return m_OnValidateInput; 
    } 
    set 
    { 
        SetPropertyUtility.SetClass(ref m_OnValidateInput, value); 
    } 
}

I am really bad in those delegates, but how does Unity know that it should execute this method, when I press key button?
Because I cannot find it anywhere. And yes, it should be somewhere in the code I guess ?

wind palm
#

Is it not specified in the inspector?

gray mural
heady iris
#

context please: what class is this defined in?

gray mural
heady iris
#

is this a MonoBehaviour you wrote? does it implement any interfaces?

gray mural
#

This method (from TMP_InputField) is happened when player presses the button

#

in TMP_InputField

heady iris
#

i am having trouble following you

gray mural
heady iris
#

then m_OnValidateInput is a delegate that gets invoked when input is provided

heady iris
#

the input field decides when to do that

wind palm
#

I would have thought it was added here:

It could have been done through code)

gray mural
potent sleet
#

this wont work
you need to do AddListener

heady iris
#

it responds to input being provided by invoking the delegate

wind palm
gray mural
heady iris
#

i do not understand where your confusion is coming from

gray mural
#

I have debugged it

heady iris
#

the input field invokes the various delegates when the right conditions are met

#

that's very normal

potent sleet
wind palm
#

If you're certain it isn't done in the inspector, just find all usages of the delegate name.

#

It'll have to be declared somewhere >_>

gray mural
potent sleet
#

that makes no sense

heady iris
#

does TextMeshPro give you source files, or does it give you a DLL

heady iris
#

if it's the latter, you ain't seeing it

gray mural
gray mural
gray mural
#

because you cannot type in TMP

wind palm
# gray mural It cannot be

Where TMP makes that call will be inside TMP.

What will be in your code is where you do AddListener(myDelegate)

#

OR it is defined in the inspector

potent sleet
#

is there something particular about it or is this like an XY problem ?

#

nothing special about delagate event

gray mural
gray mural
#

I cannot do that

potent sleet
#

what for tho?

heady iris
gray mural
#

I am trying to make my own InputField to solve XY problem we were talking with other people in #archived-code-advanced. But I have lack of knowledge in Events, delegates and other (everything actually). So I am investigating original TMP_InputField to incerase my knowladge and be able to do the same things.
That's why I need to know how those delegates are used, I guess ??

heady iris
#

The source is not provided.

wind palm
gray mural
heady iris
#

i can tell you that it looks something like this...

#
void SomeFunctionThatChecksForInput() {
  bool changed = /* something */
  if (changed)
    if (onValidateInput != null)
      onValidateInput(newText, /* other args */);
#

that's it

gray mural
gray mural
heady iris
gray mural
heady iris
#

if you're just asking "how do I use delegates"? that's a relatively simple problem

gray mural
potent sleet
#

InputField class is 5000 lines

gray mural
potent sleet
#

holy shit

gray mural
gray mural
potent sleet
wind palm
#

!!!

potent sleet
potent sleet
#

like what tells InputField this character has changed on the field

#

yes?

heady iris
#

here's slightly more detail

wind palm
heady iris
#

it checks if the new text equals the old text

#

if not, it calls OnValidateInput for every single character

#

mildly terrifying

wind palm
potent sleet
#

neat

gray mural
potent sleet
#

they are custom class that inherit event

wind palm
potent sleet
#

is true TMP_InputField class is literally in Library Package Cache

#

looking at it now

gray mural
heady iris
#

this is the implementation of TextMeshPro

#

if it's not in there, it does not exist

gray mural
#

in File Explorer even more comfortable I would say ??

potent sleet
#

look when you "insert" new char

#

it does all this

#

etc.

#

all the implementations are here

gray mural
wind palm
#

That was a wild ride.

potent sleet
#

so what exactly you're confuse on

#

you keep mentioning about keycode tho lol

#

line 1700

#

has all the keycodes

gray mural
gray mural
heady summit
#

!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.

potent sleet
#

if you look at the new input system is the same thing

fiery geyser
#

i'm trying to use JsonUtility to read a json file, but it is ignoring my JsonProperty tag

gray mural
potent sleet
#

how do you know?

gray mural
potent sleet
#

if you use OnMove(InputValue value) on the new input system you'd see the same thing

#

for example

#

on new input system "Messages"

gray mural
potent sleet
#

I mean it can still recieve the event without the reference

heady iris
#

Delegates can interfere with static analysis.

#

It's no longer obvious where an invocation takes you.

#

(which is why they're so useful in the first place)

gray mural
#

and that's probably my initial question🤔

potent sleet
#

injected somehow

#

voodoo

wind palm
#

Dun dun dun

weary quiver
#

Hello, can you guys help me with a problem? I am trying to compare the value I get from the game, with a number ( here 0.5 ), but somehow this doesnt work. In the Debug.Log I can see the number updating without a problem but somehow when I try to compare them, it is not working.

potent sleet
weary quiver
#

The Method is on a button that I've made, and thats what I meant, if I press the button I always get a debug.log but the if question is not working.

potent sleet
weary quiver
#

that one is working fine

potent sleet
#

Debug.Log(Index.Value)

weary quiver
#

so I know the button works at least

potent sleet
#

before if

#

maybe you're looking / linked the wrong Finger class

#

!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.

idle oxide
#

oh sry

weary quiver
potent sleet
#

yu got a shitone of errors

#

maybe thats why its not working as intended lol

weary quiver
#

yeah because two of the fingers arent connected

potent sleet
#

errors = odd behavior

#

fix the errors first

weary quiver
# potent sleet errors = odd behavior

Does this have anything to do with the comparision: NullReferenceException: Object reference not set to an instance of an object. RPS_Game.Update () (at Assets/Game_Itself/RPS_Game.cs:19

potent sleet
#

lol

fervent furnace
#

all errors will result on some unpredictable flows of program....

potent sleet
#

literally can't reach the rest of the lines @weary quiver

#

code goes from top line to bottom

#

if something is broken in middle it wont keep going

#

other scripts May work but this one wont

idle oxide
#

So I tried creating a Mario style jump (the longer you hold space the higher the player jumps. But when I run my code and I press space my whole unity editor just freezes and I can't interact with anything. Code: https://gdl.space/azekecadoc.cpp
Thanks in advance!
Ps: I hope this question format is correct

heady iris
#

while (Input.GetKey(KeyCode.Space) && midJump)

#

this will never change

#

if Update never returns, then the game is stuck.

#

Sounds like you need a coroutine.

fervent furnace
#

the engine cannot change other stuffs including reading the keyboard input during this while loop

weary quiver
weary quiver
#

Debug.Log("Index: " + Index.Value.ToString());

potent sleet
#

also sounds likea band-aid fix if you don't know the true cause

weary quiver
#

This one here

potent sleet
#

like so t:RPS_Game

#

tell me if you find copies with missing inspector fields

#

Index is null somehow..

weary quiver
#

that's everything I get

#

oh

#

I have it on the canvas

#

and there are missing stuff

potent sleet
weary quiver
#

And also I put it on the button

#

And there is nothing

potent sleet
#

that'll do it

weary quiver
#

would it break something, if I put all the other fingers "scripts" on the button?

#

or it will work just fine

#

I mean like fill the spaces out

potent sleet
#

not really a good way to do it but should work fine

#

you only need 1 script no?

#

don't put scripts in UI elements tho

#

it's bad practice imo

weary quiver
#

oh

#

I wanted to like be able to play the game from the start of the button so yeah

potent sleet
radiant marten
#

forgot about that channel thanks

potent sleet
sleek stream
potent sleet
#

make a gameobject that is literally just ScriptsManager or something, holds your important scripts

sleek stream
#

its works in level 1 but not 2

weary quiver
#

okey

potent sleet
sleek stream
#

how do i unpasue it

#

oh ye

heady iris
#

you probably have Error Pause enabled in the console

potent sleet
sleek stream
#

thanks bro

fervent furnace
#

have you enable error paused?

sleek stream
#

wait

potent sleet
#

open the Console tab

sleek stream
#

works now ty

#

i turned it off

potent sleet
#

no..

#

thats not a fix..

sleek stream
#

wdym

potent sleet
#

you have to fix the actual error thats pausing it

#

now ur just putting a bandaid over a gushing artery

fervent furnace
#

no, if it pauses, then the scripts have errors needed to be fix

sleek stream
#

its a useless error

heady iris
heady iris
potent sleet
sleek stream
#

because i deleted my moving platform but the script is still somewhere

#

its harmless

potent sleet
#

so find the script

sleek stream
potent sleet
#

it tells you which one it is throwing

sleek stream
#

did it

#

no errors now

potent sleet
#

😔 try not to ignore errors

sleek stream
dense falcon
#

any idea why I get these errors when trying to build an asset bundle?

#
        private void BuildHUD()
        {
            var hudBundle = new AssetBundleBuild
            {
                assetBundleName = _manifest.Name + ".hud",
                assetNames = new[] { _hudAssetPath, _manifestPath }
            };

            const string localOutputPath = "SpectatorHUD/Build Output";
            var outputPath = Path.Combine(Application.dataPath, localOutputPath);

            Directory.CreateDirectory(outputPath);

            BuildPipeline.BuildAssetBundles(Path.Combine("Assets", localOutputPath), new[] { hudBundle },
                BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
            
            EditorUtility.RevealInFinder(outputPath);
        }
potent sleet
dense falcon
#

so preprocess?

potent sleet
#

put it in the editor folder no?

idle oxide
#

when I press space the player gains infinite velocity even tho the if requirement isn't satisfied. I can't figure out what causes this https://hatebin.com/jvckmqywuz

potent sleet
#

also GetKey gets called a bunch of times even if you tap it once

dense falcon
idle oxide
dense falcon
#

¯_(ツ)_/¯

idle oxide
#

Like it logs it's false but it keeps adding velocity

fervent furnace
#

what is the mass of rigidbody

#

also, you can reference the transform of player

heady iris
#

that is going to be framerate-dependent

idle oxide
#

is there anything better than an impuls?

heady iris
#

what are you tryign to do here?

#

accelerate the player gradually?

#

or give the player a 'kick' that gets them moving instantly?

idle oxide
#

so hold down space for higher jump

#

Also I fixed it

#

It just isn't smooth sadly

heady iris
#

I would suggest starting with a big impulse

#

to instantly get you flying upwards

#

then add a continuous force

#
void OnJump() {
  rb.AddForce(Vector3.up, ForceMode2D.Impulse);
}

void FixedUpdate() {
  if (jumpHeld) {
    rb.AddForce(Vector3.up);
  }
}
#

something like that

gray mural
#

Does anyone know why this code throws StackOverflow error?

private new void Start()
{
    LookForEvent();
}

private void LookForEvent()
{
    StartCoroutine(LookForEventCoroutine());

    IEnumerator LookForEventCoroutine()
    {
        // yield return _waitForEvent;
        yield return new WaitUntil(() => Event.PopEvent(_currentEvent));

        while (Event.PopEvent(_currentEvent))
        {
            print("Event is popped or whatsoever");
        }
    }

    LookForEvent();
}
somber nacelle
#

the LookForEvent method calls itself

gray mural
#

that was dump

gray mural
# somber nacelle the LookForEvent method calls itself

thank you, this one works ok now

private void LookForEvent()
{
    StartCoroutine(LookForEventCoroutine());

    IEnumerator LookForEventCoroutine()
    {
        // yield return _waitForEvent;
        yield return new WaitUntil(() => Event.PopEvent(_currentEvent));

        while (Event.PopEvent(_currentEvent))
        {
            print("Event is popped or whatsoever");
        }

        StartCoroutine(LookForEventCoroutine());
    }
}
somber nacelle
#

you could also just use a while loop in the coroutine instead of starting the coroutine recursively like that

weary quiver
#

How can I play these animation using Code? Like I made an closed animatio for the entire hand, and I made a mask for each state I want, and I want to basically be able to play the specific animation where I want.

naive swallow
#

I've got a situation where "time" can be non-linear (you can scrub through playback to get the state of something at a specific time) and I want an animation to be starting at some point in time after when it should start. I have the timestamp of when an animation should have started, I have the current time stamp, and I have the name of the animation that should be playing at this point in the timeline. I need to play that animation at the proper normalized time to where it would be at that timestamp. Easy enough to find what that normalized time is, it's the InverseLerp of the current timestamp minus the start time from the clip's duration.

Only problem: How do I get the duration of a clip by name? I can get the current state info, but entering the state, getting the info, then getting the length from that in order to play that animation again from a new start point seems clunky and awful, and usually with Animator controls that means I'm doing something the hard way.

steady moat
steady moat
tacit sedge
gray mural
#
private float GetClipLength(Animator animator, string clipName)
{
    foreach (AnimationClip clip in animator.runtimeAnimatorController.animationClips)
    {
        if (clip.name == clipName)
            return clip.Length;
    }
}
mental rover
#

you've found that it's returning true when you think it shouldn't be

#

so that result is not null, so what is it?

#

that's the question to ask yourself and find out

tacit sedge
# mental rover so that result is not null, so what is it?

I've found that it's printing null when nothing is touching the object attatched to this code, and printing UnityEngine.CompositeCollider2D when colliding with any object, but the problem is that it's returning not null even when the object isn't below it.
i.e, the player can jump when against a wall, floor, and ceiling, not only when on the floor.

fast rune
#

Hello everyone, I need help with my gun
My gun is doing a weird 360 movement to follow the cursor and it flips as the player moves left and right
could someone help me?

#

if the idea is to seperate the gun from the player, the gun would be floating

mental rover
tacit sedge
mental rover
#

that's the direction the box travels in, but how large is the box?

dawn nebula
#

Is there a way to have multiple 2D sprites n the same Z, define an order for them, and have it so this order is maintained when you look "behind" the sprite?

#

Like the order is reversed.

#

Cause you flipped the sprite around.

fast rune
#

what do you mean?
I didn't understand sorry

gray mural
#

test it

dawn nebula
#

lagging?

gray mural
#

yes, lagging

#

they gonna change their positions

dawn nebula
#

do you mean Z-fighting?

gray mural
#

and crawl on each other

tacit sedge
gray mural
gray mural
#

I guess it should be in 2D too, in 3D for sure though

fast rune
gray mural
#

I do not see any problems though

tacit sedge
fast rune
gray mural
fast rune
#

it is correct, but the way it follows it is not correct

gray mural
fast rune
# gray mural what's incorrect?

https://www.youtube.com/watch?v=NKF-FkDzE-s
take this video for example, skip to the end and look at how his gun follows the cursor
I can't use his script because I have my own shooting script

Consider donating to help me keep this channel and website alive : https://paypal.me/supportTheGameGuy 💖

or Support me on Patreon : https://www.patreon.com/the_game_guy

In this video im gonna show you how to fire 2d gun and also add effects to make it look cooler, And add a recoil to our gun to add a nice feel to it.

In this tutorial i will ...

▶ Play video
gray mural
#

it's shaking a bit, yes

#

that's one more method

fast rune
# gray mural yes, what's wrong?

his is not rotating in like a 360 way, mine is like out of position and isn't rotating correctly
with the gun being flipped when the player moves left and right

gray mural
#

kinda

if (transform.eulerAngles.y <= 30f && transform.eulerAnger.y >= 60f)
{
    // just then you gonna rotate it
}
#

and just do not flip the gun with the player

#

I cannot help you anymore, I need to sleep, good luck

tacit sedge
#

does anyone know what syntax I have to use to define the size for the boxcast?

tacit sedge
#

I'm trying to define it using Vector2(1,1) but that's not working

latent latch
#

2D boxcast?

tacit sedge
#

yeah

tacit sedge
lean sail
#

the declaration tells u exactly what syntax (you mean parameters?) it uses

twin hull
#

syntax?

tacit sedge
#

it says Vector2 size, but when I try Vector2(1,1) it doesnt work

heady iris
#

yes, because that's not how you make a Vector2...

#
var vec2 = new Vector2(1,2);
#

you must construct the Vector2

twin hull
#

construct the struct :>

#

and you don't have to cache it but if you're using same thing repeatedly then it's probably worth doing that