#💻┃code-beginner

1 messages · Page 183 of 1

cunning rapids
#

My bad

meager sentinel
#

How does ToggleRadgoll work?

rich adder
#

but it goes back to idle and real quick into attack

meager sentinel
#

i just saw a tutorial of unity radgolls and i dont understand why it dont gets recognized to me

rich adder
#

that sounds like a custom thing

rare basin
#

looks like a custom class

#

from the tutorial you've watched

rich adder
#

Ragdoll methods are not a thing

meager sentinel
scarlet skiff
#

should the else if allow collision again?

rich adder
#

I make the same ones for my ragdoll lol

scarlet skiff
wintry quarry
meager sentinel
scarlet skiff
#

this is how it suppsoed to look

scarlet skiff
wintry quarry
#

if there's no collision anymore, that won't be happening anymore

scarlet skiff
#

or maybe it does collide for one frame, but it works fine

#

hmm i see

wintry quarry
scarlet skiff
wintry quarry
#

and set up layer based collisions

scarlet skiff
#

but then i have to keep track what goes in which layer

#

if i can handle each case in code, i can be more sure aboitu stuff

rare basin
#

you can change layers via code

wintry quarry
scarlet skiff
#

i know but like for example the fireball, the player and the archer.

player and archer should interact
player and fireball should interact
player and reflected fireball should not interact
archer and reflected fireball should interact^

now imagine u have a few others thing too, how would u keep track of which layer is for what

wintry quarry
#

when the archer shoots, the fireball starts in the EnemyProjectile layer
When the player reflects it, it moves to the PlayerProjectile layer

#

EnemyProjectiles interact with the player and not with enemies
PlayerProjectiles interact with enemies and not with the player

scarlet skiff
#

🧐

wintry quarry
#

so now the only thing you have to do in the shield code is:

void OnCollisionEnter2D(Collision2D collision) {
  if (/* collided object is a projectile we can reflect*/) {
    GameObject projectile = collision.collider.gameObject;
    projectile.layer = MyLayerHelper.PlayerProjectileLayer;

    // code to actually reflect the projectile direction here
  }
}```
uncut dune
#

I searched it and I didnt get a few things

honest trench
#
        {
            transform.position = new Vector3(Player.position.x, Player.position.y, Player.position.z);
            transform.parent = Player.transform;
            Hammer.SetActive(false);
            isEquipped = true;
        }```
I want to make it so you can pick up the ball (what the script is on) and drop it, i need a bool to tell if the object is equipped or not, which is the isEquipped. its set to false at the beginning of the game. when i dont have the isEquipped part in the if statement, code works fine, but when i have it in, it doesnt work. I put a debug log in the if statement to see if it fires and it doesnt. anyone know why?
wintry quarry
#
transform.position = new Vector3(Player.position.x, Player.position.y, Player.position.z);```
Can just be:
```cs
transform.position = Player.position;```
rare basin
uncut dune
uncut dune
#

how to use them

scarlet skiff
#

getting the nullReference error again with the player.playersPosition 🙁

honest trench
#

thanks

wintry quarry
#

it's identical

rare basin
wintry quarry
honest trench
#

ooh okay

wintry quarry
#

isEquipped = false ASSIGNS it to false

honest trench
#

let me try that

wintry quarry
#

it doesn't check if it's false

honest trench
#

oh okay i see

wintry quarry
#

&& is more efficient

#

it will skip the second check entirely if the first one already is false

honest trench
#

alright well the !isEquipped work

uncut dune
# rare basin Google it

Im doing it, just asking should the interfaces be made in the powerup script or a seperate script, and should it be on the scene or not?

rare basin
#

You can have a power up mono behaviour

#

That implements IPowerup interface

#

And when you collide with IPowerup just trigger PerformPowerup() interface method

#

And each of your power up could have different implementation

uncut dune
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class PowerUps : MonoBehaviour
{
    [SerializeField]UnityEvent powerup;
    public PlayerHealthSystem playerHealthSystem;

    void Start()
    {
        playerHealthSystem = FindObjectOfType<PlayerHealthSystem>();
    }


    void Update()
    {
        
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        if(other.gameObject.CompareTag("Player"))
        {
            powerup.Invoke();
            Destroy(gameObject);
        }
    }

}

can I keep this as base for it?

rare basin
#

You can have HealrhPowerup, DamagePowerup etc

#

Sure

uncut dune
#

ok so inside this code I would create an interface

rare basin
#

No

#

You implement the interface in that class

rich adder
#

perhaps they dont know what interface does lol

rare basin
#

They said they Googled it

#

So I assume they know

uncut dune
rare basin
uncut dune
#

okok

scarlet skiff
#

omg the reflected fireball STILL wont destroy the archer

honest trench
#
        {
            transform.position = Balla.position;
            transform.parent = Balla.transform;
            Hammer.SetActive(false);
            isEquipped = true;
        }
        if (isEquipped == true && Input.GetKeyDown("e"))
        {
            transform.position = new Vector3(Player.position.x, 2, Player.position.y);
            transform.parent = null;
            Hammer.SetActive(true);
            isEquipped = false;
        }```
So the top if statement works, lets you pick up the ball as intented, but when i put the bottom if statement in, which should let you drop the ball and re-equip the hammer you can no longer pick up the ball, any idea why?
#

i apologize for asking loads of questions that probably have simple answers im just kinda not good at this LMAO

jovial sandal
#

if (Input.GetKey(KeyCode.LeftControl))
{
Vector3 downwardThrust = Vector3.down * verticalSpeed * Time.deltaTime;
transform.Translate(downwardThrust);
} does some1 know why i go down with scroll wheel if i add this piece?

rich adder
jovial sandal
rich adder
jovial sandal
#

but it does

rich adder
jovial sandal
#

but it does

scarlet skiff
#

it doesnt reach the debug...

rich adder
#

we can go in circles all day

uncut dune
# rich adder perhaps they dont know what interface does lol

I just didnt understand how this will make it work, Ive seen interfaces are good to call the same function from even if its on different scripts. But Im just trying to call a method from a script that is in the scene by a script that is a prefab. I could just make a switch case and list all the functions called depending on the type of powerup. But I think that something like a unity event would be more organised so I didnt need to make the powerup script too full.

rich adder
wintry quarry
rare basin
#

Or the first if is executed

wintry quarry
#

or OnCollisionEnter2D isn't running at all

jovial sandal
rich adder
eternal falconBOT
rich adder
#

Also you should've mentioned that verticalSpeed gets adjusted by GetAxis

#

although don't think scroll wheel at all affects that

honest trench
#

question: if i post a question and no one answers about how long should i wait until its society acceptable to ask again

#

cuz i dont want to be that guy who spams my question 20 times waiting for an answer

rich adder
rich adder
summer stump
honest trench
#

well its long off the screen so

wintry quarry
#

you are setting isEquipped = true

honest trench
#

how do i fix that

wintry quarry
#

which causes the second if to run immediately

#

use else

scarlet skiff
rich adder
#

not the component

honest trench
#

ight let me try that

jovial sandal
scarlet skiff
wintry quarry
# honest trench how do i fix that

I would restructure the code like this:

if (Input.GetKeyDown("e")) {
    if (isEquipped) {
        transform.position = new Vector3(Player.position.x, 2, Player.position.y);
        transform.parent = null;
        Hammer.SetActive(true);
        isEquipped = false;
    }
    else if (distanceToPlayer.magnitude <= PickupRange) {
        transform.position = Balla.position;
        transform.parent = Balla.transform;
        Hammer.SetActive(false);
        isEquipped = true;
    }
}```
rich adder
uncut dune
honest trench
#

okay thanks

visual hedge
#

faced one problem where:

        for (int i = 0; i < StatusList.Count; i++)
        {  
            if (StatusList[i].duration == 0)  
                StatusList.Remove(StatusList[i]);    
        }

After removing that StatusList[i] the list is getting smaller and well... that kinda screws the purpose.
How do I actually remove all expired items from the list without screwing up?

wintry quarry
scarlet skiff
honest trench
#

okay i have an issue but ill try to fix it myself first

rich adder
honest trench
#

ill come back if i cant solve it LOL

terse osprey
#

Why is this code not able to get these game objects into the array

wintry quarry
rich adder
terse osprey
#

any way to make this work on disabled objects?

rich adder
#

Dont use names man

#

that is flimsy

#

af

rich adder
wintry quarry
#

GameObject.find is trashy in general

wintry quarry
#
foreach (Transform child in dropsParent.transform) {
  // whatever
}```
terse osprey
#

the issue is that my character with the script spawns so instantiates mid game

rich adder
#

if you really need runtime just find a "holder" object that has them in an array

wintry quarry
rich adder
#

like PraetorBlue suggested

#

but I would still Opt for a Component find instead of name

#

if you ever changed names your whole system breaks

#

Drops dropsParent = FindObjectOfType<Drops>();

visual hedge
honest trench
#
        {
            if (isEquipped)
            {
                transform.position = new Vector3(Player.position.x, 2, Player.position.y);
                transform.parent = null;
                Hammer.SetActive(true);
                isEquipped = false;
            }
            else if (distanceToPlayer.magnitude <= PickupRange)
            {
                transform.position = Balla.position;
                transform.parent = Balla.transform;
                Hammer.SetActive(false);
                isEquipped = true;
            }
        }```
alright i cant figure this out so basically it all works, but when i drop the ball instead of dropping at the players feet like it should, it drops at its original spawn point when you start the game. the player gameobject is correctly assigned in the inspector btw
#

the player variable is correctly assigned in the inspector

#

player gameobject i mean

terse osprey
#

I have gotten a little comnfused due to my inexperience so ill go do some research on the things you guys suggested, thanyouuu

wintry quarry
visual hedge
#

I will try though

rich adder
#

So you find the object that holds all your drops in a list

#

its more solid to look for a Component(Script) than a name of an object

scarlet skiff
#

ok so it doesnt even count the collision with the fireball, even tho its on the same layer as the energyball

visual hedge
scarlet skiff
#

archer script

#

fireball

#

the layer changes correctly, i checked that

#

by pausing the game

wintry quarry
scarlet skiff
#

after its reflected

scarlet skiff
wintry quarry
scarlet skiff
#

sorry still not following

wintry quarry
#

Ok I think I might be blind

rich adder
honest trench
rich adder
scarlet skiff
#

well there isnt in the script

#

i had removed it

rich adder
honest trench
#

i want it to spawn on the players feet basically

#

so same x, same z, but on the ground

rich adder
#

using 2 seems too arbitrary

#

also iirc thats worldpos

ivory bobcat
honest trench
#

like just make a gameobject at the players feet and spawn it there?

#

yeah probable

rich adder
#

easier Imo than magic number guess

honest trench
#

should i record a video to show

rich adder
#

I assume transform.position = new Vector3(Player.position.x, 2, Player.position.y);

honest trench
#

1st if statement is the dropping, the 2nd is the picking it up

#

the 1st isnt working

honest trench
#

i just dont know why or how to solve it

rich adder
#

you put y instead of Z

honest trench
#

oh you right LMAO

#

i am moronic

scarlet skiff
honest trench
#

i fixed that but it still isnt working

#

here ill record a video

ivory bobcat
#

Log the players position and see if it's the expected position.
If it's correct, consider setting the parent before changing the position.

rich adder
honest trench
honest trench
#

it spawns at 0, 0.71, 0

#

okay yeah the debug is correct

rich adder
honest trench
#

i put the parent line before the position line im still getting the same issue

rich adder
#

or just unparent first

ivory bobcat
#

Does it match the inspector position for the ball?

#

Show where/how you logged

honest trench
#

oh no it doesnt

#

the balls positions stays at 0, 0.71, 0

#

Debug.Log(Player.transform.position); i just put that in update

#
        {
            if (isEquipped)
            {
                transform.parent = null;
                transform.localPosition = new Vector3(Player.position.x, 0.71f, Player.position.z);
                Hammer.SetActive(true);
                isEquipped = false;
            }
            else if (distanceToPlayer.magnitude <= PickupRange)
            {
                transform.position = Balla.position;
                transform.parent = Balla.transform;
                Hammer.SetActive(false);
                isEquipped = true;
            }
        }```
i put the parent line before and i made it localPosition
wintry quarry
honest trench
#

but the ball position doesnt actually change it just becomes a child of the player (when picking it up i mean)

ivory bobcat
#
            if (isEquipped)
            {
                Debug.Log($"Initial: Ball position {transform.position}, Player position {Player.position}");
                transform.position = new Vector3(Player.position.x, 2, Player.position.y);
                Debug.Log($"Changed: Ball position {transform.position}");
                transform.parent = null;
                Debug.Log($"Unparented: Ball position {transform.position}");
                Hammer.SetActive(true);
                isEquipped = false;
            }```
wintry quarry
ivory bobcat
#

I think they aren't using physics.

#

Just placing the item on the ground.

rich adder
#

time to do it then xD

honest trench
wintry quarry
#

Anyway if you want it at the player's foot position just do that:

transform.position = new Vector3(Player.position.x, 0, Player.position.z);```
honest trench
rich adder
#

or also my suggestion to just make a transform just for a drop spot

#

ez mode

honest trench
#

im gonna try that hold on

#

give me like 5 minutes ill let yall know if that works

ivory bobcat
rich adder
#

yup exactly what I thought earlier

honest trench
ivory bobcat
honest trench
#

yeah sure one secx

#

sex

#

ooh wait okay nvm they do

#

when i dropped the ball i got this

#

so that would suggest the ball is going to where it should...

#

but its not

rocky canyon
#

same position in the world

ivory bobcat
#

I think you're missing a $ with the first log message

rocky canyon
#

im always missing $

honest trench
#

oh let me put that in

honest trench
ivory bobcat
#

Can you show an image of your code? (that if statement)

honest trench
#

an image or do u just want me to send it

ivory bobcat
#

I'm curious why the second log doesn't have the same values as the first, relative to ball/player.

honest trench
#
        {
            if (isEquipped)
            {
                Debug.Log($"Initial: Ball position {transform.position}, Player position {Player.position}");
                transform.position = new Vector3(Player.position.x, 2, Player.position.y);
                Debug.Log($"Changed: Ball position {transform.position}");
                transform.parent = null;
                Debug.Log($"Unparented: Ball position {transform.position}");
                Hammer.SetActive(true);
                isEquipped = false;
            }
            else if (distanceToPlayer.magnitude <= PickupRange)
            {
                transform.position = Balla.position;
                transform.parent = Balla.transform;
                Hammer.SetActive(false);
                isEquipped = true;
            }
        }```
heres the whole thing
ivory bobcat
#

Ah, y = 2. Okay, that's fine. Why'd the z value differ though?

honest trench
#

i really just dont understand why this code isnt working tbh

rich adder
honest trench
#

even if i put a transform at the players feet that still wouldnt work right? becausei would set the ball to that transform but since that transform is just always on the player the same issue would be present

ivory bobcat
rich adder
#

oh they did the same mistake as earlier lol

honest trench
#

yeah i fixed that

rich adder
#

dont send old code then

honest trench
#

because i copied that from someone else who copied it from my earlier code

#

yeah mb

rich adder
#

we need Updated script

rich adder
#

because from the video it didnt seem so

ivory bobcat
#

Show the inspector

honest trench
rich adder
honest trench
ivory bobcat
#

Is Player, the player object in the scene?

honest trench
rich adder
#

and does it always spawn it at the same spot ? even if wrong ? or does it move if player moves

ivory bobcat
#

As of right now, it looks like you're just parenting/unparenting the object.

honest trench
rich adder
#

could be pivot issue

#

of the ball

ivory bobcat
#

With no displacement done at all.

honest trench
#

yep always spawns at same spot

honest trench
#

to put the ball at that position

rich adder
honest trench
rich adder
honest trench
#

do you want me to send a new video or sum

scarlet skiff
#

how could the if statement not be true if the fireball 100% has a fireball component

ivory bobcat
#
            if (isEquipped)
            {
                Debug.Log($"Click me to see the Ball highlighted: {name}", this);
                Debug.Log($"Click me to see the Player highlighted: {Player.name}", Player);
                transform.position = new Vector3(Player.position.x, 2, Player.position.z);
                transform.parent = null;
                Hammer.SetActive(true);
                isEquipped = false;
            }```Try this and see which objects are highlighted
rich adder
#

inspector + hierarchy

honest trench
scarlet skiff
scarlet skiff
honest trench
ivory bobcat
# honest trench

I have reason to believe whatever you've referenced as Player doesn't move...
Assuming that you've referenced an unmoving object, let's opt to just drop the ball where it is rather than where this "player" is.cs if (isEquipped) { var position = transform.position; position.y = 2; transform.position = position; transform.SetParent(null, true);//Do not change the current position Hammer.SetActive(true); isEquipped = false; }

honest trench
#

alright but the player is moving

#

i tried the code it still just goes back to its starting location

ivory bobcat
ivory bobcat
#

Do you've got another script moving the ball?

#

Show the entire script

honest trench
honest trench
#

the entire thing

scarlet skiff
#

before the if statment, ye?

honest trench
#

wiat im dumb

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

public class BallPickup : MonoBehaviour
{
    public GameObject PickupText;
    public GameObject Hammer;
    public Transform hammer;
    public Transform Balla;
    public Transform Player;
    public float PickupRange = 5;
    public bool isEquipped = false;
   
    // Start is called before the first frame update
    void Awake()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
        
        Vector3 distanceToPlayer = Balla.position - transform.position;
        if (distanceToPlayer.magnitude <= PickupRange && transform.parent != Balla.transform)
        {
            PickupText.SetActive(true);
        }
        else { PickupText.SetActive(false); }
        if (Input.GetKeyDown("e"))
        {
            if (isEquipped)
            {
                var position = transform.position;
                position.y = 2;
                transform.position = position;
                transform.SetParent(null, true);//Do not change the current position
                Hammer.SetActive(true);
                isEquipped = false;
            }
            else if (distanceToPlayer.magnitude <= PickupRange)
            {
                transform.position = Balla.position;
                transform.parent = Balla.transform;
                Hammer.SetActive(false);
                isEquipped = true;
            }
        }

       

    }
}```
#

okay there

scarlet skiff
#

bro use pastemod

honest trench
scarlet skiff
#

!code

eternal falconBOT
ivory bobcat
#

Use one of the links below to paste large code blocks

scarlet skiff
honest trench
ivory bobcat
#

Save, then paste the link here.

honest trench
#

alright there

#

sent it

scarlet skiff
#

cuz one for the fireball doesnt pop up

#

just for the other collisions

ivory bobcat
#

If this script is on the object hit by the fireball, docs Debug.Log($"We were hit by: {collision.gameObject.name}", collision.collider);

scarlet skiff
#

yea

honest trench
scarlet skiff
#

it doesnt hit the fireball

ivory bobcat
scarlet skiff
#

yes

ivory bobcat
honest trench
#

the only other code relation to the ball is a ball attack animation

#

should i send my movement script or something?

rich adder
#

ohboy..

rich adder
rich adder
honest trench
#

oh

ivory bobcat
#

Show us your logs @scarlet skiff

honest trench
rich adder
honest trench
#

yes

rich adder
#

then there is your answer

honest trench
#

the animation moves the ball forward and back

#

i dont understand how that could be messing with the other code

rich adder
#

Animator is overriding the property for position

honest trench
#

o... kay?

rich adder
#

you can untick it if you want

scarlet skiff
honest trench
rich adder
#

Write Defaults

scarlet skiff
#

no fireballs

honest trench
#

okay i unticked that on the animation state in the animator

honest trench
#

still having the same problem where the ball doesnt drop by the players feet

ivory bobcat
# scarlet skiff no fireballs

So it isn't that your Fireball doesn't have it's component. It's that you are never hitting the Fireball to begin with

swift crag
#

all it does is change whether it goes back to the original value or keep the existing value

rich adder
swift crag
#

The animator will write to every single property that any animation clip in any of its states control.

#

It doesn't "give them up"

rich adder
#

but animator is def overriding their position

scarlet skiff
#

here is the firebal lprefsb with component..

#

and even if i switch to the fireball tag instead.. same thing..

#

it doesnt even register the fireball for osme reason..

rich adder
honest trench
#

yep ill try it

#

you are correct that fixes it

#

it drops by my feet

ivory bobcat
# scarlet skiff no its not that

There were no logs that said you were hit by the Fireball. If you cannot be hit or have not been hit by the Fireball, you'll not get any physics messages.

honest trench
#

now ofc the melee animation doesnt play

ivory bobcat
#

The else if statement isn't ever true because the Fireball never hit you.

honest trench
#

so how can i make it so the animator doesnt override the position

rich adder
#

and enable when you need it again

honest trench
#

is there not an easier way?

rich adder
#

thought that was pretty easy lol

honest trench
#

i mean it is but

#

idk i just feel like there should be some built in way to do that

rich adder
honest trench
#

alright well that works

#

thank you all for the help

scarlet skiff
honest trench
#

:)

ivory bobcat
polar acorn
scarlet skiff
#

and made it layer based instead

ivory bobcat
#

It's to do with your setup.

how could the if statement not be true if the fireball 100% has a fireball component
The above was an X/Y question where the problem isn't that the object 100% has the component but rather that no collision is occurring at all.

scarlet skiff
#

and penta checked if the layers for the player and the fireball can interact

polar acorn
scarlet skiff
ivory bobcat
scarlet skiff
# scarlet skiff

archer is on Enemies and fireball changes to Player Projectiles

ivory bobcat
#

And the player's inspector?

scarlet skiff
#

i think the player is unrelated in this but

polar acorn
#

their servers seem to be having a fit at the moment

limpid shoal
#

Hello I have an issue with my script that caused an error in my console. So basically my goal was to make a gun pick up system where there are two guns, one a prop gun that will just be staying on the ground waiting for the player to collide with it and a real pistol that is alredy a child of the player but will only work and appear when the player touches the fake/prop gun. And when I was making the if statement where if space is pressed and the real gun game object is set active (so it appears in the player) it will shoot, else it will not shoot. But I got an error saying that "Operator '&&' cannot be applied to operands of type 'bool' and 'void' " knowing rn that it doesnt work I am looking for an alternative way to achieve what I wanted from the start, so could somebody help?

the script:

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;

public class GunEquip : MonoBehaviour
{
    public GameObject propPistol;
    public GameObject Pistol;
    public bool showRealPewPew;

    void Start()
    {
        Pistol.gameObject.SetActive(false);
        propPistol.gameObject.SetActive(true);
    }

    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space) && Pistol.gameObject.SetActive(true))
        {
            Shooting();
        }
        else
        {
            NoShooting();
        }
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Pistol")
        {
            PickUp();
        }
    }

    public void PickUp()
    {
        Pistol.gameObject.SetActive(true);
        Destroy(propPistol);
    }

    public void Shooting()
    {

    }

    public void NoShooting()
    {

    }
}
eternal falconBOT
polar acorn
# scarlet skiff https://gdl.space/ujoqepolok.cs

Okay, so, the fireball starts on the Enemy Projectile layer, meaning it is not going to interact with Enemy. When the player reflects it, it becomes a Player Projectile and reverses direction, which should allow it to hit the Enemy, but it is not. Is that the gist of what's going on?

polar acorn
polar acorn
# scarlet skiff yes

Let's see if it's the layers causing the problems. Re-enable the Enemy Projectile collisions with Enemy, and in the section where you check for the Fireball script, instead of destroying things, add this log:

Debug.Log($"{gameObject.name} has been hit by {collision.gameObject.name} on layer {LayerMask.LayerToName(collision.gameObject.layer)}",this);

It should fire off a message when you first fire the projectile, and then another one when it's reflected back. If there are logs, then your issue is with layer management. If there are no logs, your issue is with colliders.

limpid shoal
rich adder
#

you should def configure your IDE first before anything

limpid shoal
#

ok

scarlet skiff
#

aight so now i run da game

polar acorn
#

Yep

stuck palm
#

I have code that is meant to stop the particle system when a certain condition is met, but for some reason my sprint particles are just playing endlessly, even when the print is happening

scarlet skiff
#

dam still diesnt interact with the fireball

#

what the hell could i have possibly forgotten/done wrong 😭

polar acorn
#

Show the colliders and rigidbodies on this object and the fireball

scarlet skiff
#

there r logs, just no fireball logs

polar acorn
#

the layers were working fine

#

meaning the issue is with the colliders

scarlet skiff
#

fireball

#

omg

#

i think i might know

polar acorn
#

Hm, neither are triggers, both are dynamic rigidbodies, both have 2D colliders

#

Are they at the same Z position?

scarlet skiff
#

both should spawn at z 0

#

nothing ijn the codethat changed z pos

#

yup jus tdouble cheked

#

all z0

grave forge
#

heeelp

#

Assets\pickle.cs(7,12): error CS0246: The type or namespace name 'PlayerBase' could not be found (are you missing a using directive or an assembly reference?)

slender nymph
#

do you have a type called PlayerBase

polar acorn
#

@scarlet skiff
This one might require some quick timing on the pause button (You can press Ctrl+Shift+P to pause during play mode if you need your mouse to be elsewhere for this to work)

Can you take a screenshot of your entire unity window, with the game paused, with the fireball overlapping the archer, with the fireball selected in the hierarchy and your console visible? This way I can check a whole lotta things at once for any discrepancies. I don't know what exactly I'm looking for but I might notice something

grave forge
#

wut

polar acorn
grave forge
#

umm idk

slender nymph
#

if you don't know then why are you trying to use it?

polar acorn
grave forge
#

tutorial said so

polar acorn
#

So do what the tutorial says to do

scarlet skiff
#

wait, they are at different layers, but not like the game layers, the sprite rendeder layers

#

but that shhouldnt matter, shouldnt it?

polar acorn
#

only rendering

scarlet skiff
#

ok so picture of heirchy + inspecotr while the reflected fireball is insuide the archer?

polar acorn
#

Try that whole screen thing I suggested. I don't know a specific thing to look at but maybe if I have the whole picture I can find something amiss

polar acorn
scarlet skiff
#

Dang the timing is hella hard

grave forge
#

now what?

#

Assets\pickle.cs(29,115): error CS0019: Operator '*' cannot be applied to operands of type 'Vector2' and 'double'

scarlet skiff
#

cant i just move a reflected fireball into the archer or sum

polar acorn
scarlet skiff
#

but then id have to unpause n pause

polar acorn
swift crag
#

1.23 is a literal value. Its type is double.

1.23f is a literal value. Its type is float.

#

double is more precise than float. It's also slower, so Unity uses float all over the place.

scarlet skiff
#

wiat wtffff why the hell does it turn into a is trigger???

polar acorn
#

Ah, I missed that

#

Looks like a vestige from a previous attempt to solve this problem

scarlet skiff
#

im gonna uninstall myself

polar acorn
#

I think the layer based approach is better so you can probably remove that

grave forge
#

Assets\pickle.cs(29,134): error CS1002: ; expected

polar acorn
scarlet skiff
polar acorn
grave forge
#

ide?

slender nymph
polar acorn
eternal falconBOT
grave forge
#

yea i have visual studio and no underlines

polar acorn
#

using the guide linked above

grave forge
#

where is the unity editor?

polar acorn
#

...Unity

#

the program you are making your game in

grave forge
#

ok......BUT WHERE???

polar acorn
grave forge
#

wait

#

nvm im just dum

scarlet skiff
#

bro it finally works 😭

#

thank u so much man

#

👨‍❤️‍💋‍👨

grave forge
#

welp its up to date?

#

i don't get it

honest trench
#

im having this issue where if i start the animation for swinging the hammer, pickup the ball, and then drop the ball the hammer stays in that rotation and breaks. im trying to make it so whenever you pick up the ball it sets the hammer to its correct rotation before but its just not working. any ideas on how to help?

grave forge
#

wait nvm i got it

swift crag
grave forge
#

ok jeez

honest trench
#

i was considering posting this in #🏃┃animation but i thought the solution would probably be in code so i put it here

#

if there is some option i can tick in the animator or sum lmk tho

grave forge
honest trench
#

just a couple

grave forge
#

yea an tiny bit

#

ok i finally got it to work

honest trench
#

nice

#

do u have any idea about my problemeo

dusty silo
#

Can someone explain to me how PolygonCollider2D.setPath(int, Vector2[]) works please? I don't understand how setting a different start index would change the shape.

late bobcat
late bobcat
#

ty i'll try

polar acorn
# dusty silo Can someone explain to me how `PolygonCollider2D.setPath(int, Vector2[])` works ...

https://docs.unity3d.com/ScriptReference/PolygonCollider2D.SetPath.html

A path is a cyclic sequence of line segments between points that define the outline of the polygon. Because the polygon can have holes and discontinuous parts, its shape is not necessarily defined by a single path. For example, the polygon might actually be 3 separate paths. In this case SetPath will be called 3 times, with an index of 0, 1 and 2. So index specifies which of these three collections of points are used.

It's which of the paths you want to change to the given array of vertices. If your shape is fully continuous, then the only path will be at index 0. You can change that path to whatever you want by passing in the index of 0 and the list of points that define it, in order

queen adder
# late bobcat ty i'll try

Memory Profiler was better in some of the earlier versions. U were able to see the memory block by block. But now, they removed that tab because it was really too cool feature to be continuously upgraded and bet they didn't wanted to give us that for free.

scarlet skiff
#

why wont it stop at -7

#

he not supposed to come in the -7 to 7 range

polar acorn
# scarlet skiff why wont it stop at -7

First off, you should consider using Mathf.Abs to make those checks easier to read.

Second, have you considered logging xPosition to see what the numbers end up being and if they line up with what you expect?

late bobcat
dusty silo
#

Can lambdas be used to convert an array of objects into an array of their stored information, or is that only lists?

scarlet skiff
#

aight i solved it the checks for xpos sucked

#

i suppose

if (7 < Mathf.abs(xPosition))

would be a better way?

honest trench
grave forge
#

Assets\pickle.cs(21,29): error CS0200: Property or indexer 'Vector2.up' cannot be assigned to -- it is read only

#

heeelp

polar acorn
#

You should consider actually reading your errors

#

they give you pretty good information

scarlet skiff
#

what do u call the thinie where u check a bool and use liek a question mark as a simpler if/else statment

dusty silo
#

ternary operator?

scarlet skiff
#

thanks chief

grave forge
#

i did not assign any value tf?

#

rb2d.velocity = Vector2.up = flapstrength;

teal viper
#

You're trying to assign to up which is read only

swift crag
polar acorn
swift crag
#

They are the red spikes in the Memory section.

grave forge
#

omg

#

the tutorial did it

#

why cant i

scarlet skiff
#

i dont need a "break;" here, do i?

polar acorn
#

Show the tutorial

grave forge
polar acorn
swift crag
#

that is an asterisk

#

*

polar acorn
# grave forge
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 142
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-2-05
#

Man it's actually been a while

#

like, three weeks

swift crag
#

not sure if that's what you meant to do

grave forge
#

man

swift crag
#

ah, you're playing the animation if it isn't already playing, then noting that you can't idle and breaking. i think that makes sense!

grave forge
#

ook==k someone tell me whats wrong

#

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

public class pickle: MonoBehaviour
{
public Rigidbody2D rb2d;
public BoxCollider2D boxCollider2d;
public float flapstrength;

void Start()
{
    
}

void Update()
{

    if (Input.GetKeyDown(KeyCode.Space) == true)
    {
        rb2d.velocity = Vector2.up = flapstrength;
    }
}

}

scarlet skiff
#

as for last animation, ye it sets what the current animation is basically

swift crag
#

that is not an equals sign.

polar acorn
grave forge
#

its not blurry i screenshoted it from video

swift crag
#

it's blurry enough that you misread it

polar acorn
#

and timestamp

grave forge
#

ok nvm it was * not =

#

well where my setting at?

#

uhh the flap strength

north kiln
#

Presumably you haven't saved, or have compiler errors

frigid sequoia
#

Okey, I took a really long time to answer (kinda busy sry), but I think I should do this right since you took your time to help me. I compiled the code before leaving, give it a try as you said and the documentation supports, I compiled it and tested it; it did literally nothing, don't know why, the behaviour was exactly the same. So I dediced to leave there for the time being and went out for the day. NOW I have come back and decided to test it again, it wasn't working but like it was doing nothing at all, so the issue was different, I checked the code again and... the method was empty (wtf?) Like I dunno what happened there, I rewrited it again following the guides and now it works as intended. So yeah just here to say thxs and sry for being kinda of an asshole 😄

grave forge
#

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

frigid sequoia
#

Also just to let it closed, this is how it ended

grave forge
#

game desinging more like erorr designing

polar acorn
grave forge
#

welp..its joever

teal viper
#

Somehow I came help but imagine a goose trying to code😅

polar acorn
grave forge
#

umm which class name

teal viper
#

Whichever is failing.

polar acorn
#

The file name needs to match the name of the class inside it

warped fable
#

how can i delete this?

swift crag
#

you can remove a component by right-clicking on it

warped fable
#

oh right, ty

green copper
#

if I instantiate an item using a scriptable object, and then change a variable in the scriptable object script, will that change all items using that scriptable object or just the one being changed?

rare basin
green copper
#

like, if the object is item(clone) and the data is itemdata, would item(clone).itemData.height change the variable for all itemData items or just the one

swift crag
#

References to other Unity objects are preserved.

#

They aren't recursively instantiated.

rare basin
polar acorn
#

How new?

swift crag
#

(except for references to other components in your own prefab, naturally)

swift crag
#

it was wrong for a while lol

polar acorn
#

...huh

swift crag
#

It is relatively new versions only, yeah

rare basin
#

Yea the file name doesn't have to match the class name now

#

Not sure since which version

swift crag
#

I'm guessing that, if there's only one MonoBehaviour or ScripatbleObject in the file, it just uses whatever's there

#

who knows what happens if two are present

rare basin
#

2023+

north kiln
#

The second class will not be addable by the user interface

#

and is only interactable via code

swift crag
#

makes sense

north kiln
#

Imo the old rule is a good one, but I'm glad it's not strictly enforced

#

There's little to no reason to have it another way

rare basin
#

I will stick to it anyway ig

#

Makes things cleaner

swift crag
#

allowing the names to differ does make it very obvious that Unity doesn't actually care about the C# class (other than when it needs to actually instantiate it)

#

it just cares about the script asset

wise oyster
#

Hey, I'm trying to spawn spheres randomly in a 5x5 grid, but they only spawn in a diagonal line like shown. Is my logic wrong somewhere?

grave forge
#

ook i fixed it

north kiln
swift crag
#

you call RandomGrid() exactly once

grave forge
#

i can now progress cooking

wise oyster
frigid sequoia
#

Now I am seeing a issue I did not see before, like I have an enemy with a NavMeshAgent that is meant to follow the player and the speed of it changes overtime dependeing of whatever the enemy in question is doing, the thing is, they should reach a point at which they are faster than the player and inevitabilly reach it even if the player is moving like the player speed is 10 and the enemy speed ramps from 5 to up to 15 and this is actually showing properly in the NavMeshAgent, but they never quite reach the player unless they stop, they stay literally one pixel away from colliding with it. I assume this has to do with the Stopping distance but... doesn't seem to do anything if I change so... is anything that prevents the agent to collide with its target or....

teal viper
frigid sequoia
#

Like where is he going to be next frame or something like that

teal viper
frigid sequoia
swift crag
#

Yeah, but the update order matters

#

If the enemy tries to move to the player, and then the player moves, it'll be off by one frame

#

I'd just make the enemy have a long enough reach to hit the player with a little bit of leeway

#

I do have the enemy "lead" the player a little in my game. That makes the enemy look a bit less single-minded.

teal viper
swift crag
#

I've had problems where an enemy stopped moving entirely -- it took more than one frame to decide on a path, and I was setting the destination every frame

#

oops

teal viper
#

Yeah, that's a common problem

swift crag
#

It was taking so long because the destination was unreachable

frigid sequoia
#

I mean, if it gets close enough is fine, it doesn't have to be pixel perfect, but it seems like it is stopping just outside the collision treshold, which seems like really weird

#

Maybe is a coincidence though and is something else that just happens to be set excatly at that value

frigid sequoia
swift crag
#

It tries to move as close as possible.

frigid sequoia
swift crag
#

actually, I just checked and I disabled that behavior 🫠

#

i should put it back in

#

i think it was causing weird problems when the enemy was really far away

#

it'd try to lead you by 30 seconds and just...go somewhere weird

frigid sequoia
#

Oh, nevermind, reducing the radius of obstacle avoidance seems to do the job

#

Which is weird, the player is nor an obstacle nor agent, so I don't know why they are trying to avoid as an obstacle

teal viper
frigid sequoia
amber spruce
#

how do i do cooldowns

#

like how do i make it so something can only happen if it happened more then 5 seconds ago

teal viper
amber spruce
queen adder
#

how tf do i make a boss battle lmao

#

should i use animationcontrollers

#

it seems kinda scuffed

manic crypt
teal viper
ivory bobcat
amber spruce
#

because i tried cacheing it every time the ability is used but that doesnt seem to work

#

it just never is able to be used again

#

i set timenow to Time.deltaTime should that be different

timber tide
#

make em member variables so they dont fall out of scope

timber tide
#

ye

amber spruce
#

how

timber tide
#

by making member variables ;o

amber spruce
#

yeah how do i do that

ivory bobcat
amber spruce
#

im confused on member variables how do i make one of those

ivory bobcat
#

You know those stuff up top with public, private, protected and whatnot that aren't methods?

#

Move your variable up there and it'll exist within the scope of the entire class instance

amber spruce
#

i have it up there

#
float move1lastTimeUsed;
float move2lastTimeUsed;
float move1cooldown = 3f;
float move2cooldown = 5f;
#

thats at the top

#
public void Ability1(InputAction.CallbackContext ctx)
{
    if (IsOwner)
    {
        if (ctx.performed)
        {
            if (Time.deltaTime - move1lastTimeUsed >= move1cooldown)
            {
                if (playerController.Skin == 1)
                {
                    HiddenMistSlash();
                }
                else if (playerController.Skin == 2)
                {
                    Invisible();
                }
                else if (playerController.Skin == 3)
                {
                    ShieldBash();
                }
                else if (playerController.Skin == 4)
                {
                    Subscribe();
                }
                else if (playerController.Skin == 5)
                {
                    BatterBlitz();
                }
                move1lastTimeUsed = Time.deltaTime;
                Debug.Log(move1lastTimeUsed);
            }
        }
    }
}

thats the first abilitys code

ivory bobcat
amber spruce
#

well wouldnt that mess it up if its ran at different frame rates

ivory bobcat
#

Um, the above would never happen if delta time is small

#

It's not the accumulation of deltas but the delta this frame (which is a tiny number)

teal viper
ivory bobcat
#

Normal time stamp timers would becs current = Time.time; if(current > next) { ... do stuff next = current + delay; }

amber spruce
#

works now thanks

timber tide
#

deltatime would work if you compound assign the time passed, but using real time you can just compare from previous time used

amber spruce
buoyant knot
#
  1. switch-case
  2. Enums
#
  1. wtf bro
amber spruce
#

yeah i know i do it poorly

#

but it works

buoyant knot
#

that is how you write yourself into a terrible position

timber tide
#
//deltaTime way
if (elapsedTime < cooldownDuration)
{
    elapsedTime += Time.deltaTime;
}

else
{
    DoAbility();
    elapsedTime = 0.0f;
}```
buoyant knot
#

if you know you are doing it poorly, do better

amber spruce
#

if it aint broke dont fix it

buoyant knot
#

have you ever heard of refactoring?

#

it’s literally redoing something that isn’t broken.

amber spruce
#

if i ever do smth like this again i would use enums or switch-case as i now have learned about them but i dont really have the time to change something that is working fine for what i need it for

timber tide
#

it's w/e, but your ide will convert it to switch for you if you right click on the statement and convert it automatically

#

and even further into a pattern matching statement

#

which offers not actual improvement but looks cleaner

amber spruce
#

yeah thats why i decided not to change how im currently doing it because for no actualy improvements its not worth the time changing it when i could be doing other stuff

#

im not saying i would do it the way im doing it now again i would definitly change to another way but i just dont have the time to change my current way

timber tide
#

im saying it will do it for you though since you've got it set up in a way that it will

amber spruce
#
if (move2lastTimeUsed < move2cooldown)
{
    move2lastTimeUsed += Time.deltaTime;
}

else
{
    if (playerController.Skin == 1)
    {
        Dash();
    }
    else if (playerController.Skin == 2)
    {
        WizardDash();
    }
    else if (playerController.Skin == 3)
    {
        SwordSlash();
    }
    else if (playerController.Skin == 4)
    {
        Like();
    }
    else if (playerController.Skin == 5)
    {
        SyrupySplatdown();
    }
    move2lastTimeUsed = 0.0f;
}
timber tide
#

you cant use deltatime here

#

if you're doing it by the input system because it doesnt exist in update

#

so you have to check by previously used time

amber spruce
#

ok

timber tide
#

well, you can use it but you must append the delta value inside of update, because in this case you're only incrementing values whenever you press the key

fierce geode
#

What's the most popular way to apply a turning force to a 3d character, like if they're moving fast in one direction that any additional acceleration in another direction will only turn them gradually so you need to apply an extra force to rotate them to that direction?

amber spruce
#

i mean i dont have a option to change the fps so i dont think it really changes much

#

right or will it matter

fierce geode
#

my current idea is to use a vector dot product to check if the current velocity vector is pointing in the same direction as the players input and then multiple the current acceleration by the difference between the two angles.

summer stump
fierce geode
#

Actually since the dot product equals 1 when the vectors are alligned, I should be multiplying it by 1-dot product

amber spruce
summer stump
sullen canyon
#

I want sorting Y pos for my top-down game, it's affected to canvas UI element ?

buoyant knot
timber tide
#

UI is sorted by render queue only

#

or rather how it's positioned in the hierarchy

north kiln
#

if they're enums why is this all just using unreadable numbers

#

I love it when my type is 3

nimble apex
#

lol

#

this is more like a draft now

#

there are tons of rules that i need to think of

#

annnnnd this code is in a switch case , so its not hard to reference it lol

eternal needle
#

seems odd that this is in a switch and you still need to check values like this

gaunt ice
#

If the loop continue if bet result is not 3 6 7 so why you check if the bet result is 1 or 2

north kiln
#

I hate this

#

make some functions so it's clear what any of this even means

timber tide
#

should label your stuff more

north kiln
#

betResult.type.IsWhatever() instead of checking like this

#

and abstract away this crap

timber tide
#

use enums instead of explicitly binding values to represent some references and whatnot

gaunt ice
#

Also (a and b) or b is b

fierce geode
vale karma
#

I got an issue with the camera and the player body not syncing up correctly when turning. Ive troubleshooted it down to this block of code. What math do i have wrong here? (the camera is not a child object of the player)

 public void OnLook(InputAction.CallbackContext context)
{  
    view = context.ReadValue<Vector2>();
    yRotation += view.x * 0.1f * sensX;
    xRotation -= view.y * 0.1f * sensY;
    xRotation = Mathf.Clamp(xRotation, -45f, 45f);

    cameraPosition.localEulerAngles = new Vector3(xRotation, yRotation, 0f);

    playerRotation = new Vector3(0f, yRotation, 0f);
    Quaternion deltaRotation = Quaternion.Euler(playerRotation * Time.fixedDeltaTime);
    rb.MoveRotation(rb.rotation * deltaRotation);
} 
teal viper
#

I think I gave you a suggestion how to change it yesterday. Did you give it a try?

vale karma
#

i did yesterday, and i believe we changed transform.Rotate() to rb.MoveRotation bc it is a smooth movement between rotation vectors

teal viper
#

I can see some other issues too. Like calling MoveRotation from an input callback instead of fixed update.

vale karma
#

i changed that a second ago, i am now just being a bit destructive trying to find out whats goin on

queen adder
#

ok so im coding for the first time in microsoft visual studio, and there are some errors in my movement script, and i would like help fixing

teal viper
teal viper
queen adder
#

those are the ones with the red underline right

vale karma
#

ohhh yea i think i got distracted and ended up goin to bed, so your saying instead of rb.MoveRotation(rb.rotation * deltaRotation); I should calculate rb.rotation * deltaRotation seperately?

teal viper
#

What's the rotation * deltaRotation even for? Can you explain the intention behind it?

teal viper
vale karma
#

yea its incredibly hard to follow, rb.rotation * deltaRotation is basically multiplying the Y rotation of the input to Time.fixedDeltaTime. Then that has to be a quaternion to go into MoveRotation.

#

im about to just restart the entire script. I keep changing it anyways

teal viper
#

It's not just hard to follow, it makes little sense to me in the first place.

vale karma
#

hahahaha

teal viper
#

Like, can you explain the logic step by step?

vale karma
#

yea i know about the components, what they do mostly, but then its "how do i put this together? ill watch a vid on it" and they have the worst code... but your already 20 minutes in and i dont really know a different way of rotating the camera and player with the new input system..

#

the documentation has some good examples, but i think i used the moveRotation example unity had and it was the rotation * deltaRotation stuff, with the quaternion

teal viper
vale karma
#

your right, its just a vector2 i can split with .x and .y

#

okay so mapping the input is fine, so my problem is with rotations in general lol

teal viper
vale karma
#

is rotation velocity the difference from the first call to the second?

teal viper
#

If you want to use the final rotation(which is correct in this case), you need to feed it into move rotation directly(after converting to a quaternion), instead of doing any math on it.

teal viper
#

There's even a comment describing what the code does.

Rotating around y axis, 100 deg/sec

Which is not exactly what you want. You should use the example as a reference to understand the API, not apply it to your code directly.

vale karma
#

ohh yea, i changed that to the YRotation

#

so I was using the YRotation as a degree per second

teal viper
#

Yes.

vale karma
#

so i just need to set it to deltaRotation?

#

nope, i got some more learnin to do

teal viper
#

No. Start simpler. What does MoveRotation method take?

vale karma
#

a Quaternion 😄

teal viper
#

Not the type. What does it represent?

vale karma
#

a vector3?

teal viper
#

No. It's in the docs. Just read it.

vale karma
#

the new rotation for the RigidBody 😮

teal viper
#

Yes.

#

And what in your code represents the new rotation(desired rotation)?

vale karma
#

yRotation?

#

dad please dont be disappointed im trying XD

teal viper
#

This only represents the rotation on the Y axis.

vale karma
#

playerRotation

teal viper
#

Correct

vale karma
#

do i have to worry about Time.fixedDeltaTime with the MoveRotation or the playerRotation?

teal viper
#

What do you think?

#

Remember what parameter it takes?

vale karma
#

i would think no because its not moving the player... but im not sure if i have to calculate it beforehand.. but seeing the MoveRotation method doesnt take the Time.fixedDeltaTime function i guess no?

#

also i know the new input system normalizes the movement already, I didnt know if it dealt with the time or not

teal viper
#

Think simpler. What does MoveRotation do?

vale karma
#

rotates the rb

#

ohh hey i fixed it somewhat,

#
rb.MoveRotation(deltaRotation);```
#

it can now move in the right direction and rotate correctly, but it still doesnt constantly update the direction im moving in until i click w again

#

oh yay its all working now, thanks mr dlich

teal viper
vale karma
#

nothin, i just copied most of the document

teal viper
#

It's not nothing. As long as it serves a purpose in your code, it does represent something.

#

What does it represent?

vale karma
#

i renamed it playerRot, as in MoveRotation(Quaternion rot)

teal viper
#

Good. Naming your methods and variables correctly is very important, both to assist you in understanding your code and even more so when you ask other people for help and share code with them.

vale karma
#

i want to optimize it to look like the old input system unity asset that has the fps for you

#

like i have code that "just works" that looks like

yRotation += view.x * 0.1f * sensX;
xRotation -= view.y * 0.1f * sensY;```
teal viper
#

Okay?

#

Not sure I understand what you're trying to say.
But I'd get rid of that 0.1f magic number in there.

vale karma
#

idk what that means or how the math is correct when doing -= or +=.

summer stump
#

Why even have it? You already have sensitivity

vale karma
#

i think i had it set in the thousands or something rediculous

summer stump
#

The minus equals is to make the view not inverted

summer stump
#

By removing the 0.1, you can avoid that

vale karma
#

its at 1 sens rn and super fast

summer stump
vale karma
#

then you have to be more precise when changing it in the editor

#

so like .01 i could then have a sensitivity on a menu reasonable from 0-10 or something

limber barn
#

Does anyone know how to make it so when a particle touches an object with a tag it runs a method that’s inside of the object it touched

worthy veldt
#

i have output[output.Length - 1] = element; line and editor says that it can be simplified to output[^1] = element; i want to use it but i fear ill forget about it, what is this ^1 called ?

#

perhaps if i know more ill be able to recall it later

teal viper
vale karma
#

dont worry i got it lookin nicee

#

gotta move jumpforce oops

vale karma
#

does scale matter when dealing with rigidbodies? im trying to crouch

grave forge
#

bro unity wont work tf

#

i agree but it dosent do anything

rich adder
grave forge
#

understandable have an nice day

#

heeeelp

polar acorn
#

with what

grave forge
#

oops wrong server

vale karma
#

how do i make the character not get stuck on the edge of a platform?

#

i tried a physical material and it works somewhat i think, but it still is an issue

vale karma
#

im not sure, probably the raycast thinking its the ground

teal viper
vale karma
#

yea its not the top priority atm, i can live with it

#

rn im tryin to fix this weird ghost code

teal viper
vale karma
#

in the inspector, you can see that sprinting changes the Move Speed from 2 to 3, But crouching does everything it needs to BUT change the move speed

#

i can even debug the speed in the If statements and it changes accordingly, just not the actual speed fsr

teal viper
#

I don't see anything changing aside from the bools in that video.🤷‍♂️

vale karma
#

this shows it better

#

im thinking now that the code for the crouch method is sound, but whatever is actually moving the player isnt updating the moveSpeed variable?

vale karma
#

also are you impressed with my super mega ultra fps controller?

teal viper
vale karma
#

ill have to lookup a video on some debugging, all i know is strings and sometimes values

teal viper
tepid summit
#

ok,

vale karma
#

hahaha are you talking about not using : and ? or because the else if is unnecessary?

tepid summit
#

arguably simple question coming up,

#

but tf is a ghost code

vale karma
#

idk, a new term

tepid summit
#

code that compiles and doesnt work?

tepid summit
vale karma
#

everything that seems to show that its working, but still doesnt lol

#

it just kinda poofs

teal viper
tepid summit
#

here ill reply to it

tepid summit
vale karma
#

i wonder who

tepid summit
#

oh

#

hey

teal viper
#

Ah, they just come up with a name for it.

vale karma
#

isnt there some kind of phase or enum i could code to do this instead of coding out each method in a different way?

tepid summit
#

yeah that makes sense

vale karma
#

i forgot what its called

teal viper
#

What are you referring to?

vale karma
teal viper
#

Explain in words please.

tepid summit
#

check for a key press and change the speed on the press

vale karma
#

no the MovementState. stuff

teal viper
#

Assuming you want only one state active at the same time, a state machine with enums is a good option, yeah.

vale karma
#

well heck i kind of already made one

#

the isCrouched, spritning and walking

teal viper
#

Except that they don't represent one state and prone to bugs.

vale karma
#

what gives it away

teal viper
#

If you have one variable for the current state, you physically can't be in 2 states, which makes it easier to debug.

tepid summit
vale karma
tepid summit
#

oh ok

vale karma
#

dude how many times am i gonna have to alter this script

tepid summit
#

trust me,

#

at least 14 more times

vale karma
#

at least it makes me feel better you guys been thru this

tepid summit
#

plus another 3 for every 2 changes

teal viper
gilded elm
#

Hello, I wanted to know, I am making my game in VR like PC building Simulator, I placed my objects in the right place, except that I always have the elements in red and blue as in the photo and I wanted to know if it Is this an option to check or not?

It seems to me it's a box to uncheck in the preview but I don't know where it is.

vale karma
#

Ive been really just learning absolutely everything about movement, and got fed up for not konwing how to do it myself, I started this script yesturday

tepid summit
vale karma
#

hahaha i thought he was looking down in a pond reflection but also into the top of a house

tepid summit
#

damn

vale karma
#

then i saw the hands then i was like oh its vr and thats a navigation dot

teal viper
gilded elm
vale karma
#

you have to SetActive(gameobject, false) when the trigger is hit

tepid summit
#

no

#

gameObject.SetActive(false)

vale karma
#

^what he said

tepid summit
#

ty

gilded elm
vale karma
tepid summit
#

Unity moment

gilded elm
teal viper
vale karma
#

yea i doubt ill get close to making money out of this, at least for another 10 years

teal viper
#

Though I do enjoy debugging. You learn to do it at some point. It's like a puzzle game. Food for the brain.

vale karma
tepid summit
#

you should learn to "stop"

#

youll get burnout

#

trust me, it sucks

vale karma
#

i got adhd i do it with everything

tepid summit
#

fair enough

vale karma
#

ill take care of myself today, thanks for the help guys

tepid summit
#

i have reason to believe i have autism (getting tested soon), and i tend to do the same

tepid summit
#

now go have fun

hybrid tapir
#

public void amountThatIsActive(Values values)
{

}

why doesnt that appear in a button onclick

tepid summit
#

what

#

oh

hybrid tapir
#

forgot to mention Values is an enum

#

its already bad enough that the inspector only supports a void with one parameter

#

😭

tepid summit
#

can you send the whole script

#

with three of these ` on bioth ends

hybrid tapir
#

ill do it tmrw i decided to gtb after i asked thinking you would just know lol

#

like turned the pc off and everything

tepid summit
#

damn

#

ok

hybrid tapir
#

the script literally has a public enum with 8 options and that void statement i didnt do anything else with it

tepid summit
#

having the whole script would really help with debugging

hybrid tapir
#

ok

gilded elm
tepid summit
#

so filter it to remove the preview instead

gilded elm
#

filter? how to do that?

polar acorn
grave forge
#

guys if 2 colliders touch without scripts will they just collide?

polar acorn
grave forge
#

cool

#

now i can be even lazier!

tepid summit
#

is there something like a Rigidbody.GravityScale

#

or something along those lines

jovial sandal
#

i love ur name @tepid summit

tepid summit
#

ty

#

ur names also cool

gilded elm
tepid summit
#

yeah but like for scripting

gilded elm
#

I'm in VR so I only have the XR Plugin scripts (XR Socket interactor, XR Grab interable)

#

and the XR Interaction Manager

tepid summit
#

ok

gilded elm
#

and I try to look on the internet or even settings but I can't find

tepid summit
#

i dont work with vr so i cant help you

#

also theres a vr specific channel if you want to try there

gilded elm
tepid summit
#

im pretty sure

gilded elm
#

I thank you for your help all the same

tepid summit
#

ok

hybrid tapir
#

is there a specific way to use enums in void params?

ivory bobcat
#

What do you mean by void params?

earnest atlas
#

void params, next gen of params

gaunt ice
#

Void=nothing hence void param=no param?

#

Btw void is the type name

#

I think you mean method

tepid summit
#

is there a big difference between lerp and slerp? if so, what is it

tall storm
tepid summit
#

oh ok

#

so slerp is more like spherical lerp

#

like a conjunction

nimble apex
#

to be very simple. with a quite bad example

#

lerp : movement like when u take an elevator
slerp : if you jump off a cliff irl

trail heart
#

Rather imagine traveling around a circle or a sphere

tepid summit
tepid summit
#
        {
            Debug.Log("Running");
        }
        else
        {
            Debug.Log("Walking");
        }```
The Running Debug only works on the time you first press shift, id like it stay as you hold the key
trail heart