#šŸ’»ā”ƒcode-beginner

1 messages Ā· Page 178 of 1

thorn holly
#

Is there like a general c# alternative to coroutines to make a method occur over multiple frames?

swift crag
#

the concept can be implemented anywhere, mind you

#

coroutines are basically just...

stuck palm
#

is there a way to check if an application has been opened for the first time? like i want to set playerpref defaults or volume defaults or something

ripe shard
#

IEnumerator is C#, iterating them automatically is a Unity thing.

rich adder
#

bingo

swift crag
#
List<IEnumerator> stuffToCheck;

void CalledRegularly() {
  foreach (var item in stuffToCheck)
    item.MoveNext();
}
#

it also needs to remove items that are exhausted, but that's the idea

faint sluice
#

Like getint with default value 0 and after first open set that int to 1

swift crag
#

it has a defaultValue argument

#

so just make that the default value you want

faint sluice
#

Oh yeah, getkey also works

swift crag
#

then your game will wind up saving the prefs later

stuck palm
swift crag
#

and bam, you've got default values saved

stuck palm
#

idk if u told me this

swift crag
#

some of my singleton monobehaviours live in DontDestroyOnLoad :p

#

i was just working on that a minute ago, actually

#

I have per-scene singletons that handle a single game session

#

and then eternal singletons that handle the whole play session

gleaming wagon
#

!code

eternal falconBOT
gleaming wagon
stuck palm
swift crag
gleaming wagon
#

it cant find score even though its public

swift crag
#

you can't access a static field through a specific instance

rich adder
#

static hell

swift crag
#

either make the field non-static or don't reference a specific ScoreScript

rich adder
#

avoid static for this

queen adder
#

someone can help? with my code? i need to show checkpoints sequentially when you collide with them

swift crag
#

I'd rather have a static reference to the ScoreScript than a bunch of static fields on the ScoreScript

queen adder
gleaming wagon
queen adder
#

can we play with sprite editor via code? I want to move each square 16 pixels to the right

#

cant reslice cuz animations already linked to them 🄹

gleaming wagon
swift crag
#

A static field is not attached to a specific object. It's stored in the class itself.

rare basin
#

i feel like we're doing circles

#

you should watch some basic c# & unity tutorials

#

kinda hard to explain things to you

swift crag
queen adder
rich adder
eternal falconBOT
queen adder
#

no, why is not full

#

wait

#

here

rich adder
queen adder
rich adder
frank needle
#

thats how my peewee brain thinks this could work if you aint found a solution

rich adder
queen adder
rare basin
#

what do you mean by appear

rich adder
#

its the same thing

queen adder
rich adder
#

maybe stop letting gpt write your code it be easier for you to explain the problem

rare basin
#

oh no, another chat-gpt enjoyer?

rich adder
#

this time in spanish !

rare basin
#

even better šŸ˜„

languid spire
#

Portuguese

queen adder
#

for example, when you collide with the first checkpoint, the second checkpoint appears, and so on with all those that are in the parent

buoyant knot
#

is this man really coding with chatGPT?

rare basin
#

looks like it

buoyant knot
#

my father keeps lecturing me about how great it is for coding

rare basin
rich adder
buoyant knot
#

and then we have every single example to the contrary lmao

rich adder
#

its not that diffcult

#

the GPT code you sent its overcomplicated

#

and doesnt work

#

learn how to use Arrays

#

scrolling through index of checkpoints shouldbe easy as that

queen adder
buoyant knot
#

every time I tell him chatGPT isn’t good for coding, he just tells me I haven’t used it enough myself

rich adder
buoyant knot
#

arguing with a brick wall would be more productive

rare basin
buoyant knot
rare basin
rich adder
buoyant knot
#

not even. but he’s very tech saavy

rich adder
#

no arguing in a few years it will be capable of some interesting stuff but 4.0 aint it yet

rare basin
#

it has insane potential

#

for the future

rich adder
#

easier for the art ones to get better since that art doesn't require logic systems xD

faint sluice
#

Even with art it's just blatant most of the time

buoyant knot
#

he got his PhD in network engineering before it was a real discipline, and he’s been THE tech guy since the 80’s

rare basin
faint sluice
#

All you have to do is look at lining/lighting and FINGERS

rich adder
rare basin
#

yup

rich adder
#

the influx in code questions that are gpt is becoming rampant

#

I dont think it was this bad a few years back was it on this discord

buoyant knot
#

part of my father’s PhD thesis was based on passwords being way stronger if they were multiple words. like baddog being a potent password

rare basin
#

yea it's very common lately in here

faint sluice
#

Isn't there like a rule in here that prohibits helping with chatgpt written code? I could swear I've read that somewhere

buoyant knot
#

that wasn’t the whole thing, but it was a pretty big discovery at the time

rare basin
#

but 50% of newcomers never read the rules

#

or more

rich adder
#

just says dont Post AI answers or question that are unverified

#

doesn't specifically say you can't help fix once you find its AI code, not that I'd want to

rare basin
#

well helping someone who has chat-gpt generated code is completely pointless

#

as he doesnt even understand the code in most cases

rich adder
#

we just need a dump AI-Coding channel

buoyant knot
#

the story goes that he was TAing for a class (I assume in cryptography), and challenged students to beat the standard password-brute force algorithm. It was based on Dictionary brute force.
It defeated everyone’s password easily, and the moral of the lecture was supposed to be that passwords are not safe.

rich adder
#

all the GPT fetishers can hang out there

ripe shard
buoyant knot
#

some smartass kid walks up, puts in a two word password, and everything comes to a grinding halt

#

several years later, degree

#

tldr he basically studied weaknesses in dictionary attacks

thorn holly
#

Alright, so I’m trying to grasp the concepts of async await but this is really difficult for me to understand lol. So say I have a function. I want this function to execute some code. Then, I want it to wait for player input. Then, I want it to execute more code. I’m assuming for the ā€œwait for player inputā€ thing to work, I’d have to use async await, but I don’t really understand how I would go about using it. I also understand that using a coroutine would be better for this situation, I’m just trying to grasp the general concept of async await with this hypothetical.

rare basin
#

WaitUntil()

rich adder
#

true

thorn holly
#

Yes, I know, I’m just trying to understand the concept of async await.

rich adder
#

WaitUntil(()=> Input.anyKey) iirc

rare basin
buoyant knot
#

the benefit of coroutines is that it is easy to wait into specific points of unity’s event functions, in terms of timing

#

like WaitForFixedUpdate(), WaitForEndOfFrame(), null…

rare basin
thorn holly
#

Yeah, I get that, this is just a hypothetical and I’m trying to figure out how async await works

rare basin
# thorn holly Yeah, I get that, this is just a hypothetical and I’m trying to figure out how a...

The C# async / await workflow can simplify your code and give you more granular control over your game in Unity.

Learn how to convert your current coroutine workflow, what a task is, how to run sequential and synchronous code and how to return data from an asynchronous function.

UniTask: https://github.com/Cysharp/UniTask (Provides an efficien...

ā–¶ Play video
#

that helped me a lot

rich adder
buoyant knot
#

i have no actual experience on it, but my undersranding is that async just runs separare from main thread

thorn holly
ripe shard
rare basin
buoyant knot
#

so it could run in a different thread

#

but doesn’t need to

rich adder
#

which why if you do UI stuff you usually get error

ripe shard
rich adder
#

most UI run on main thread, so some framework you try to chaning UI in async and it spits error

buoyant knot
#

i mean, duh. But the question is when it runs

#

like if you do A, async B, C. B might be before or after C. But i don’t know enough

elder osprey
#

Hello, this is my first time using the built in character controller in unity. Currently I am having trouble with making the player jump when pressing the bind. Here is my script: https://hastebin.com/share/bodufewiqu.csharp.

willow torrent
#

hi sorry to interrupt but does anyone know how to collaborate with someone on a game?

buoyant knot
willow torrent
buoyant knot
#

I also made a separate class for player contact state, for things like grounding, touching left/right wall, etc. Because otherwise this shit gets real messy, really fast

#

just trust me on that

rich adder
#

there's plenty of tutorials on it + unity. make sure you use Unity .gitignore
I need to make a better one lol https://youtu.be/5IxUElilf2M
adding a collaborator is just as easy you do it on the website

buoyant knot
#

the fewer things going on inside your player movement class, the easier your life will be

elder osprey
swift crag
#

Ah, verticalMove is probably going down forever

#

Consider setting it to 0 if isGrounded is true on the character controller.

elder osprey
buoyant knot
#

you probably want a different class to have access to this object to modify it

faint sluice
swift crag
#

you should generally tell us what's wrong, yes (:

buoyant knot
#

so I have TileCollision (my game is based on tilemaps), which has OnCollision etc. Whenever I get collisions, I modify the contents of the current ContactState

candid gorge
#

Hey guys, could someone help me please? I dont know exactly why my character is falling like this when on the equator of a planet, this is the script that moves it:

{
    if(!UseCustomGravity)
    {
        gravDir = (attractor.transform.position - transform.position).normalized;
        rb.AddForce(gravDir * gravForce);
    }

    else
    {
        gravDir = gravDir.normalized;
        rb.AddForce(gravDir * gravForce * Time.deltaTime, ForceMode.VelocityChange);
    }

    transform.rotation = Quaternion.FromToRotation(transform.up, -gravDir) * transform.rotation;

    Debug.DrawRay(transform.position, gravDir * gravForce, Color.red);
}```
elder osprey
swift crag
buoyant knot
#

I actually have ContactStateManager, which contains 2 ContactState objects. One for this frame, and one for last frame. Because there are a LOT of times where you want to compare this vs last frame. ContactStateManager just holds a reference to this frame and last frame’s contact state. Every frame, it deletes last frame’s contact state, and moves this frame’s contact state to be last frame state. This way we can start populating the current state.

swift crag
#

this is drifting pretty far away from Stick's question

ivory bobcat
candid gorge
# swift crag is `UseCustomGravity` turning on and off?

Custom gravity is a bool that changes between an attractor point and a manual vector for the gravity. This is the script of the editor:

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

[CustomEditor(typeof(Gravity))]
public class GravityEditor : Editor
{
    public override void OnInspectorGUI()
    {
        Gravity grav = (Gravity)target;

        grav.UseCustomGravity = EditorGUILayout.Toggle("Use Custom Gravity", grav.UseCustomGravity);
        grav.gravForce = EditorGUILayout.FloatField("Gravity Force Value", grav.gravForce);

        if (grav.UseCustomGravity)
        {
            grav.gravDir = EditorGUILayout.Vector3Field("Custom Gravity Direction", grav.gravDir);
        }

        else
        {
            grav.attractor = EditorGUILayout.ObjectField(grav.attractor, typeof(GameObject), true) as GameObject;
        }
    }
}```
buoyant knot
#

i’m just giving him separate advice that might help him stay organized. I royally fucked up my player movment script when I started, and it looked kind of like stick’s. I wasted weeks refactoring to sort everything back out, to be able to add features.

#

I want to save him the struggle that I went through

#

@elder osprey

swift crag
#

it just looks like gravity is very weak

#

and you're moving up and down

queen adder
#

if you have multiple scripts using FixedUpdate, how do you know in which order they will execute

swift crag
#

you shouldn't care about the order

summer stump
queen adder
#

gotcha

swift crag
#

Different classes can have different update orders

faint sluice
swift crag
#

but I really do not enjoy relying on that

#

What are you trying to do?

candid gorge
# swift crag also, what's the problem, exactly?

My main problem is that my jumping script doesnt work on the equator of the planet, and I think it has something to do with the gravity since it also works fine on the poles but doesnt on the sides. In this video you can see it better:

swift crag
#

it looks like the jump is always going in the +Y world direction

candid gorge
#

yeah it looks like that but idk why, this is the script that does it:

{
    //Vector3 jumpForces = rb.velocity;

    if (grounded)
    {
        //jumpForces.y = jumpForce;
        rb.AddForce(transform.up * jumpForce);
    }
    //rb.AddRelativeForce(jumpForces + transform.up, ForceMode.VelocityChange);
    //rb.velocity = jumpForces; //+ transform.up;
}```
elder osprey
candid gorge
#

its just this part rb.AddForce(transform.up * jumpForce);

#

the other lines are other things I tried and doesnt work

swift crag
swift crag
#

so transform.up would be...double-transformed into world space, basically

#

AddForce(transform.up * jumpForce) is wrong, but it's in the right direction

elder osprey
swift crag
#

It should be rb.AddForce(transform.up * jumpForce, ForceMode.Impulse)

#

it's an instantaneous change in momentum, not a steady force

faint sluice
swift crag
candid gorge
swift crag
swift crag
candid gorge
#

the direction is transform.up

#

it should work right?

swift crag
#

Yes. I'm just pointing out that your force mode was wrong for a jump.

#

This won't fix your problem. It's just something you should fix while you're looking at it.

candid gorge
#

yeah it still dont work

swift crag
#

ForceMode.Impulse means "change the momentum by this much"
The default, ForceMode.Force means "apply this much steady force"

candid gorge
#

I still dont get why it isnt working, i think its the gravity script the problem but idk

swift crag
#

That could explain why it's kinda...going up and down

swift crag
#

consider setting the rigidbody's rotation directly instead -- rb.rotation = ...

#

I don't know how it stores momentum internally. If it's in local space, then this would make a fair bit of sense

candid gorge
swift crag
#

rb.velocity is world-space, but who knows if that's how it the info is actually stored

candid gorge
#

mm okey, im going to try that and see

faint sluice
#

Ye

warm anvil
#

I seem to mostly get an issue with my IDE not being linked to Unity especially when I create a new project. As you can see the Debug.Log has no hover and is normal text so it has no knowledge of Unity it seems. So if anyone especially on a Mac knows more about the right procedures I appreciate your insight.

I'm running on a Mac with Visual Studio Code and Unity 2022.3.4f1 [for silicon]

I'd like to inquire if there are certain steps you need to take with registering your IDE (in this case Visual Studio Code) and/or in each project you create you need to install the Visual Studio Code package - but I'll pause on that question/answer for now

gleaming wagon
swift crag
#

!ide

eternal falconBOT
swift crag
#

Follow the instructions for VS Code.

warm anvil
#

Thanks Fen!

swift crag
#

your External Tools screen should look more like this after removing the old package and installing the Visual Studio Editor package

thorn holly
#

so i'm trying to make this basic async/await code that just logs something, waits for the player to press space, then logs something else. It logs the first thing, but pressing space doesn't do anything. Did I use async/await wrong?

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

public class AsyncStuff : MonoBehaviour
{
    // Start is called before the first frame update
    public bool onOrOff = false;
    void Start()
    {
        DoTheAsyncStuff();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            onOrOff = true;
        }
    }

    public async void DoTheAsyncStuff()
    {
        Debug.Log("Started");
        await new Task(() =>
        {
            while (!onOrOff)
            {

            }
        });

        Debug.Log("Finished");
    }   
}
queen adder
swift crag
#

that doesn't tell me what you're trying to accomplish

#

only how you've tried to solve your problem

#

what are you trying to make your game do?

wintry quarry
wary olive
#

Would that not need to be in Update?

wintry quarry
#

Why would we want to introduce Update here?

wary olive
#

How is it gonna get when he puts a key down

wintry quarry
#

That's what cs while (true) { if (Input.GetKeyDown(KeyCode.Space)) break; await Awaitable.NextFrameAsync(); } is for

thorn holly
wintry quarry
#

so yes

wary olive
#

Oh right but that would lock him into that function and loop with that script, would a Boolean as a check and having it in update not make more sense?

#

Depends what he is doing I guess

wintry quarry
candid gorge
thorn holly
#

so say I awaited a function instead of Awaitable.NextFrameAsync(), what would that do?

#

in the same analogy thing

wintry quarry
warm anvil
# swift crag your External Tools screen should look more like this after removing the old pac...

Thanks @swift crag . Towards the end of the instructions, I had everything completed. Restarted both Unity and VS Code, opened my code but the Debug.Log statement was still a plain cyan color. I could hover over items such as Update() and tell it was referencing some Unity knowledge; however, when I removed the Debug.Log line and began to retype it, then and only then did it change color. Any idea why it was just oblivious? Thanks!

swift crag
#

Maybe your player controller is storing your velocity in local space or something

thorn holly
swift crag
candid gorge
swift crag
#

quit VSCode, hit "Regenerate project files" in the External Tools window, and then double click a script asset to reopen VSCode

wintry quarry
#

the rest of the code in the async function will not run

#

It runs in order top to bottom

thorn holly
warm anvil
wintry quarry
#

If the function is small/fast enough, then that's fine

thorn holly
wintry quarry
#

if it's something you need to do over multiple frames, you need a coroutine or async

wintry quarry
#

synchronous (normal) functions stop the whole game engine

thorn holly
#

ah, so everything else continues, but the async function stops

wintry quarry
#

yes

thorn holly
#

so the async function is in its own little timeline thingy

wintry quarry
#

I suppose you can think of it that way

thorn holly
#

Async: into the awaitverse

rich adder
#

async can be become its own hell quick

#

use wisely šŸ™‚

thorn holly
spare umbra
#

I want a smoother landing like in Cluster Truck. How can I implement it in Unity?

rich adder
#

you'd have to describe

wintry quarry
#

you can't just new up a Task and await it

#

The task wasn't even Start()ed

#

also if you DID start that task it would freeze unity because it will run on the main thread

#

unless you ran it on a background thread

candid gorge
# swift crag Maybe your player controller is storing your velocity in local space or somethin...

My problem is within these lines, I've tried disabling this function and the player falls normally, now I dont really know what is the problem tho.

{
    Vector3 currentVelocity = rb.velocity;
    Vector3 targetVelocity = new Vector3(move.x, 0f, move.y);
    targetVelocity *= crouching ? crouchSpeed : (sprinting ? sprintSpeed : speed);

    targetVelocity = transform.TransformDirection(targetVelocity);

    Vector3 velocityChange = (targetVelocity - currentVelocity);
    velocityChange = new Vector3(velocityChange.x, 0f, velocityChange.z);

    Vector3.ClampMagnitude(velocityChange, maxForce);

    rb.AddForce(velocityChange, ForceMode.VelocityChange);
}```
spare umbra
#

It's very hard to describe it

#

You need to see

swift crag
#

it's that game where you jump from semitruck to semitruck

spare umbra
#

yeah

swift crag
#

and the trucks are all in various states of violent motion

spare umbra
#

Basicly I want the camera to continue going down when the player lands and smoothly go up to the right position

wintry quarry
#

Actually it might have worked if you started the task before awaiting it (because i think it will run on a different thread), but a spinloop like this is very inefficient. It will basically peg one of your CPUs at 100% until you press the key@thorn holly

rich adder
faint sluice
rich adder
rich adder
#

or like Dotween

faint sluice
thorn holly
rich adder
naive lion
#
    {
        float healSpeed = .3f;
        isHealing = true;

        if (health < maxHealth)
        {
            health = Mathf.Lerp(health, maxHealth, Time.deltaTime * healSpeed);
            ...
        }```
My lerp slows down at the end
is the issue with T not being between 1 and 0 or is it smth else
naive lion
wintry quarry
thorn holly
#

thank you

wintry quarry
elder osprey
#

Currently my IsGrounded() check is being strange, it is only true every once in a while even though I am on the ground.

wintry quarry
rich adder
elder osprey
wintry quarry
#

have you read the docs for isGrounded?

wintry quarry
#

Long story short, most people write their own grounded checks because this one is not good.

rich adder
#

yeah def go for a checksphere/box, sphere/box cast or overlap

warm anvil
#

I'm afraid I don't have the knowledge/experience to cover the missing gap. I've tried several ways to try to make what I'm sure your logic works into my code.

If you're willing to help guide me once again, I've simplied my code into a new project. Let me know if you can assist. Thanks!

rich adder
swift crag
#

foo is a boolean. it doesn't have a member named that

#

that's all

warm anvil
#

I'm pretty sure my error is where I need to put your statement before the part about bools

#

here's what I have layed out.

Input Controller script:

using UnityEngine;
using UnityEngine.InputSystem;

public class HumanoidLandInput : MonoBehaviour
{
    private InputActions _input;

    public bool BackpackActionIsPressed { get; private set; } = false;
    public bool BackpackActionIsReleased { get; private set; } = false;

    private void OnEnable()
    {
        _input = new InputActions();
        _input.HumanoidLand.Enable();

        _input.HumanoidLand.BackpackAction.started += SetBackpackAction;
        _input.HumanoidLand.BackpackAction.canceled += SetBackpackAction;
    }

    private void OnDisable()
    {
        _input.HumanoidLand.BackpackAction.started -= SetBackpackAction;
        _input.HumanoidLand.BackpackAction.canceled -= SetBackpackAction;

        _input.HumanoidLand.Disable();
    }

    private void SetBackpackAction(InputAction.CallbackContext context)
    {
        Debug.Log(context.phase);
        BackpackActionIsPressed = context.started;
        BackpackActionIsReleased = context.canceled;
    }
}
#

and here's basically the script on the player:

using UnityEngine;

public class Backpack : MonoBehaviour
{
    [SerializeField] private HumanoidLandInput _input;
    [SerializeField] private GameObject uiTest;

    [SerializeField] HumanoidLandInput backpackActionReference;
    public bool ToggleBackpack => _input.BackpackActionIsPressed.WasPressedThisFrame();

    // Update is called once per frame
    void Update()
    {
        if (_input.BackpackActionIsPressed)
        {
            Debug.Log("test");
            uiTest.gameObject.SetActive(true);
        }
        else
        {
            uiTest.gameObject.SetActive(false);
        }
    }
}
#

for now ignore the line on the 2nd script that reads:
public bool ToggleBackpack => _input.BackpackActionIsPressed.WasPressedThisFrame();

#

i know that's wrong

#

very sorry for the spoon-feeding

wintry quarry
#

BackpackActionIsPressed is a bool. Why are you trying to call WasPressedThisFrame on it?

swift crag
#

It may be easier to use events here. It'd look like this.

public class MyInput : MonoBehaviour {
  public event System.Action OnBackpackToggle;

  void HandleInput(InputAction.CallbackContext context) {
    OnBackpackToggle?.Invoke();
  }
  
  void OnEnable() {
    _input.HumanoidLand.BackpackAction.performed += HandleInput;
  }
  
  void OnDisable() {
    _input.HumanoidLand.BackpackAction.performed -= HandleInput;
  }
}

Anyone can now subscribe to OnBackpackToggle to have a method called when the action is performed.

buoyant knot
warm anvil
#

again, keep in mind that the Update() on the player is enabling and disabling the uiTest gameobject as I'm pushing in the button

swift crag
#

Exactly like what you're doing with _input.HumanoidLand.BackpackAction

buoyant knot
#

if I were ro delete your character controller, ContactState should have nothing break

#

PlayerMovement depends on ContactState, not the other way around

swift crag
#

you already know all that stuff

buoyant knot
#

the whole point of having a separate contact state is for the contact state to have all the variables describing contact

swift crag
#

let me show a brief example from my game...

#
using UnityEngine;
using UnityEngine.InputSystem;

public class InGameMenu : MonoBehaviour
{
    public InputActionReference menuAction;

    void OnEnable()
    {
        menuAction.action.performed += ToggleMenu;
    }

    void OnDisable()
    {
        menuAction.action.performed -= ToggleMenu;
    }

    void ToggleMenu(InputAction.CallbackContext context)
    {
        if (MenuController.activeMenuController != null)
            MenuController.activeMenuController.Hide();
        else
            MainMenu.Instance.controller.Show();
    }
}
#

an InputActionReference allows you to reference an InputAction from an input action asset

#

it does not automatically enable the action, so you'd probably want to keep your existing code in HumanoidLandInput

#

I find these to be supremely useful -- I just hand out action references as needed

#

each "thing" you can do includes an input action reference, so I can set which action performs it

rare basin
#

what if you have different input schemes?

#

pc/playstation etc

swift crag
#

not a problem at all

rare basin
#

not meaning different bindings

#

but the actual schemes

#

InputControlScheme

vast saffron
#

why does it not jump/fly up when i press spacebar?

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

public class BirdScript : MonoBehaviour
{
    public Rigidbody2D myRigidbody;
    public CircleCollider2D mycircleCollider;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            myRigidbody.velocity = Vector2.up * 10;
        }
    }
}
rare basin
#

then ig some kind of Dictionary would work

swift crag
#

those are completely invisible to me here

warm anvil
#

@swift crag I'll absorb and try - ty!

swift crag
#

I have Mouse + Keyboard and Gamepad control schemes

rare basin
#

Dictionary<PlatformEnum, InputActionAsset>

swift crag
#

but I don't care about them at all

#

they're all in one input action asset

#

I only care about those when I need to update the control hints I'm displaying

rare basin
#

if you're just making for PC then yea it'll work great ig

swift crag
#

I don't understand what you're talking about. You don't need multiple input action assets.

wintry quarry
rare basin
#

one input action asset, you can have multiple control schemes in it

swift crag
#

yes, I understand that. I have multiple control schemes.

rare basin
#

hold on let me open the project and screenshot it

thorn holly
#

Alright @wintry quarry I think I understand fsm's, so for my selection machine, I could have some states like ButtonGoingIn, ButtonBeingSelected, and ButtonGoingOut, and the I can just use transitions to switch between them, passing in different parameters for what buttons go in and what buttons go out as I go.

short hazel
#

I guess control schemes are more for input "parts" instead of platforms? Like one scheme for on foot actions, and another for when driving

swift crag
#

different bindings are associated with different control schemes

thorn holly
gentle sandal
#

hi guys i want to create a unity project that simulates human falling (tripping over,falling,slipping...) to simulate and extract data to feed it into an AI in order to help people with special needs or individiuals that have body problems (after accidents)

i want to ask if it is doable using Unity ?

swift crag
#

different input action maps can contain different input actions, which can have multiple input bindings

stuck palm
#

this code isnt running until i click a button on the Ui for some reason, then it just cuts to a differenet frame and idk why
RenderSettings.skybox.SetFloat(Rotation, Time.time * rotationSpeed);

rare basin
#

@swift crag imagine making a game for NintendoSwitch, where you have multiple usage mode (single joycon, double joycon) etc, and you have just one InputAsset (which is correct) but multiple schemes

warm anvil
#

@rare basin are you talking about this dropdown box? [All Control Schemes]

swift crag
wintry quarry
wintry quarry
vast saffron
rich adder
rare basin
#

that's why I was talking about the Dictionary

potent garnet
#

My onTriggerEnter method works, but for some reason my event doesn't invoke like it should once the OnTriggerEnter method is called

swift crag
rare basin
#

eh.. action maps have actions

swift crag
#

if some actions can't be performed by some devices, then that sounds like a design problem. input actions are supposed to be high-level ideas

vast saffron
#

i fixed it

rare basin
#

action map in scheme A doesnt have actions that are in scheme's B action mpa

polar ermine
#

hi its my second attemp in unity, does anyone know how to make player visible in front of some object and invisible behind it? (2D)

gentle sandal
vast saffron
#

it was just simple i didnt put my rigidbody in the script

swift crag
rich adder
rare basin
wintry quarry
queen adder
gentle sandal
rich adder
# polar ermine

you could either split that in 2 peices or if you have the pivot at the feet for both you can do some math to determine which one should be infront

#

like if your Y pos is larger than the tomb Y pos then show Order in layer infront

wicked thistle
#

Hello!
I managed to instantiate the objects how i wanted, but i think i require some help in figuring out how i need to link the hinge joints to one another. I want to link them counter-clockwise starting from the highlighted piece, but with what i managed to do until now, it doesn't really work and i don't know why. i am trying to achieve a closed-loop chain of hinges.

this is the code i'm using for it: https://paste.myst.rs/cooapqxl

rich adder
#

haven' worked on 2D too much, just tiles for that so I have 2 tilemaps

polar ermine
#

ill try

#

chatgpt should help tho

queen adder
swift crag
#

Ah, mimicking what Unity is doing: FixedUpdate, then the physics step

#

well, hmm, if you don't mind waiting until after Unity's own physics is done, you could use a coroutine with yield return new WaitForFixedUpdate();

ivory bobcat
frank needle
#

Hey guys, I'm trying to figure out how to handle procedral generation for my 2D rogue like game. It takes place in a city and I want each pre-made prefab to be placed in randomly, but still ahve the streets on the other prefab connect seamlessly. any ideas where i can start with this?

warm condor
#

hey, im having a problem with clamping my velocity unsing the Vector2.ClampMagnitude. My problem here is that it also, I think, clamps my verticle velocty as well instead of just the horizontal velocity. What sould I do? Here is my code:

            rb.velocity = Vector2.ClampMagnitude(rb.velocity, maxRunningSpeed);
        }```
swift crag
#

consider splitting it into two floats that you clamp independently

#

then just stick them back together

warm condor
#

how do I do that?

#

do you mean in the if statement or when I am clamping the velocity?

wintry quarry
#
Vector2 velocity = rb.velocity;
velocity.x = Mathf.Clamp(velocity.x, -maxRunningSpeed, maxRunningSpeed);
rb.velocity = velocity;```
#

or in Unity 2023+

rb.velocityX = Mathf.Clamp(rb.velocityX, -maxRunningSpeed, maxRunningSpeed);```
warm condor
#

ohhh ok, btw what is the diffrence between Mathf and Math?

wintry quarry
#

Mathf is for floats

#

Math does most things with doubles

#

Mathf was created by Unity.
Math was created by Microsoft

#

Mathf basically recreates most things in Math but with float params and return values

warm condor
#

ah alr, thanks!

potent garnet
potent nymph
#

Does anyone know what could be causing this error on WebGL builds:

RuntimeError: memory access out of bounds

However, running the build on a local server works fine. What's even weirder, it worked once on itch.io, but after loading it subsequent times I get this error

#

I tried every compression format in the player settings, as well as every "enable exceptions" option

queen adder
meager sentinel
#

Someone knows why this marks an error?

wintry quarry
#

Tldr it's incomplete

meager sentinel
#

wdym

wintry quarry
#

It needs at least one yield statement to be valid

#

for example yield break; or yield return null;

#

similar to how this is in error because there's no return statement:

int Example() {

}```
mental flame
#

Can I have an eventhandler for each enemy or is it better to not use events for many objects in a scene?

meager sentinel
#

Is there any way to make an IEnumerator go in loop

modest dust
meager sentinel
#

i place it at the end right?

modest dust
#
IEnumerator Stuff()
{
  while(condition)
  {
    // Does stuff
    yield return null;
  }
}
rich adder
#

and you can have many events, doesn't matter

stuck mango
#

I want to create characters for my game, my idea for this is to make a "character" gameObject with "IdSelector" script attached to it. In IdSelector you will choose 1 id from the whole list, and it should automatically choose correct sprite, scripts and stats. How do i do that? I need to know how can i connect public float ID to the list in character selector.

mental flame
mental flame
rich adder
potent garnet
rich adder
modest dust
stuck mango
#

How do i pass it and return the data? Im very new.

modest dust
#

By going through a C# course, if the thing you're asking about are functions and how to use them

potent garnet
stuck mango
rich adder
modest dust
#

But generally you figure out how to get the reference to the character selector from within the player in a reasonable way, you call a method from the selector, let's say selector.GetData(myID); where the return value is some kind of struct/class containing the data

rare basin
#

in general

#

and in your case especially

signal bronze
#

I need help with a script, i now how to make objects disapear when i run over them with the trigger function, but how can I create a script that knows that when i make 4 of this items disappears, it changes the scene to the victory scene. And i need that when u pass through the object a sound and a text appears. (But the text disapears like after 5 seconds)

proven mirage
#

Hey guys i was wondering if someone could help me witha rounding problem so im trying to make a flying sword for my game in unity2D and everything is working excpet when the word is flying i want it to come back it reaches its targetpoint before it reaches its maximum flight time before coming back automatically so i have this code. i know the issue is in the bottom if staement where we set the evctor directly to the target pos and since the target posis a float ik when we are usign move towards the sword will never make it exactly to the target and i know it will always be .1 off from the target so what can i do to round or check its close to the target?

 void Update()
    {
        TimeBtwnThrows -= Time.deltaTime;

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (TimeBtwnThrows <= 0 && transform.parent != null)
            {
                TargetPoint = Camera.main.ScreenToWorldPoint((Vector2)Input.mousePosition);
                transform.parent = null;
                IsFlying = true;
                
            }
        }
        
        if(IsFlying)
        {
            if(FlyTime < MaxFlyTime)
            {
                transform.position = Vector3.MoveTowards(transform.position, TargetPoint, FlySpeed * Time.deltaTime);
                FlyTime += Time.deltaTime;
            }
            else
            {
                if (FlyTime >= MaxFlyTime || transform.position == (Vector3)TargetPoint)
                {
                    
                    transform.position = Vector3.MoveTowards(transform.position, ObjHolder.position, FlySpeed * Time.deltaTime);
                }
            }

          
        }


    }```
#

Heres video

rich adder
modest dust
scarlet skiff
#

does this generate between -0.5 and 0.5? i know u gotta have an extra +1 or something

signal bronze
#

I edited the message

#

I need help with a script, i now how to make objects disapear when i run over them with the trigger function, but how can I create a script that knows that when i make 4 of this items disappears, it changes the scene to the victory scene. And i need that when u pass through the object a sound and a text appears. (But the text disapears like after 5 seconds)

#

Thats the complete one

rich adder
signal bronze
#

Like a mario coin, when i get it, a sound appears and a text too, and after getting four, i change scene to "Victory" Scene @rich adder

modest dust
rich adder
stuck mango
rare basin
#

can't be good at programming without atleast basic english

stuck mango
#

if u not going to help then dont speak up maybe!!

signal bronze
rare basin
#

you are not listening

rich adder
#

how do we check if another number equals another

#

etc

#

there are c# courses pinned in this channel

signal bronze
#

yeah i now, but im nervous because its the last thing i need to make for my game

languid spire
signal bronze
#

xd

modest dust
rich adder
signal bronze
#

3d game

rare basin
woven notch
#

im trying to make a player get stopped by a wall in a practice game im making but even after using tilemap colldiers and composite colliders nothing seems to work

#

could someone help

signal bronze
modest dust
# stuck mango alright, i will try

Either way, try to go though all of it and make sure you understand everything presented there more or less. Basics are important and you're gonna need them at every step when programming in Unity, so there are no shortcuts.

signal bronze
#

i know a bit of it but not that much

cosmic dagger
# signal bronze Whats the line of code for that

There's no one line of code but a series of events you need to do:
Create a script to track the score
Update score text to a new value
Etc.

You'll need to look at some tutorials first since you don't have any pricked or errors we can help with. There are a lot of resources for Mario clones . . .

scarlet skiff
woven notch
#

i have but it still doesnt work

#

player has the box collider and the wall has the tilemap collider

rich adder
#

you just copied

#

not a good way to make game

signal bronze
#

ik ik

rare basin
#

chat-gpt style like

signal bronze
#

im dumb but i was really excited and i didint think abt it

#

xd

rich adder
cosmic dagger
rich adder
#

do you know how to keep tracking of items destroyed ? @signal bronze

#

adding an integer ?

stuck mango
rare basin
tropic agate
#

Hi, I have a problem with boxcolliders, so basically I have a raycast based suspension, and the car center of mass isnt at the center, so when the car isnt moving, it slides back a bit, is it possible to automatically set it to the center?

modest dust
signal bronze
rich adder
#

but you can just do inventario.Cantidad++

signal bronze
#

well, the thing i dont know how to do is play a sound after u get one and to change the scene after i get four

rare basin
#

we're doing circles

rich adder
rare basin
#

it's pointless helping you

#

kinda

rich adder
#

ezz

signal bronze
rare basin
#

you can't understand the provided help

rich adder
#

You already solved the counting part, now move onto the next goal

proven mirage
#

Hey guys i was wondering if someone could help me witha rounding problem so im trying to make a flying sword for my game in unity2D and everything is working excpet when the word is flying i want it to come back it reaches its targetpoint before it reaches its maximum flight time before coming back automatically so i have this code. i know the issue is in the bottom if staement where we set the evctor directly to the target pos and since the target posis a float ik when we are usign move towards the sword will never make it exactly to the target and i know it will always be .1 off from the target so what can i do to round or check its close to the target?


 void Update()
    {
        TimeBtwnThrows -= Time.deltaTime;

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (TimeBtwnThrows <= 0 && transform.parent != null)
            {
                TargetPoint = Camera.main.ScreenToWorldPoint((Vector2)Input.mousePosition);
                transform.parent = null;
                IsFlying = true;
                
            }
        }
        
        if(IsFlying)
        {
            if(FlyTime < MaxFlyTime)
            {
                transform.position = Vector3.MoveTowards(transform.position, TargetPoint, FlySpeed * Time.deltaTime);
                FlyTime += Time.deltaTime;
            }
            else
            {
                if (FlyTime >= MaxFlyTime || transform.position == (Vector3)TargetPoint)
                {
                    
                    transform.position = Vector3.MoveTowards(transform.position, ObjHolder.position, FlySpeed * Time.deltaTime);
                }
            }

          
        }


    }```
Heres video
rich adder
#

for example

rare basin
#

so now we are teaching people how to use google, right šŸ˜„

rich adder
rich adder
modest dust
tropic agate
rare basin
potent garnet
rare basin
#

please

rich adder
nimble hinge
#

What's going on here

tropic agate
rich adder
ivory bobcat
swift crag
#

why are so many people bringing up the spam machine today?

rich adder
#

gpt is nonsense spam

rare basin
swift crag
#

i feel like i'm seeing it every half hour

nimble hinge
#

Spam? haha

rich adder
rare basin
#

shit code, shit comments to every code output

swift crag
nimble hinge
#

well i hate chatgpt

#

its subjective

swift crag
#

and they're giving me a damn headache

nimble hinge
#

i dont want it to replace us

#

i want it to fail (its all subjective)

stuck mango
rich adder
tropic agate
stuck mango
#

Btw, can i DM u? Its way easier to ask for help in ur native language.

nimble hinge
#

Im against AI powered chips personally

rare basin
#

how is that possible

rich adder
#

anyway but lets keep this channel Unity beginner coding questions,

#

this is like the 3rd time today we talking AI and its redudant lol

signal bronze
#

dont worry, ill do it by myself, looks like people is anoyed about other people asking for help in a discord chat that was made for that, have a greate day @rich adder ā¤ļø

modest dust
stuck mango
cosmic dagger
#

If you didn't learn after two years, you're doing smth wrong, and the discipline is not there . . .

rich adder
tropic agate
signal bronze
#

Ik Ik, but ill try to do it for myself witout any help, thanks anyway

rich adder
#

so you will forget it quick

rare basin
rich adder
#

new information needs repetition for brain to retain

gloomy ice
#

Hello, how to change this UI image width based on a variable?

float currentGreed = 0f;
float maxGreed = 100f;
rare basin
#

and change the fillAmount

rich adder
stuck mango
rich adder
#

if its a slider then its the theSlider.value

rare basin
stuck mango
rare basin
#

it isn't in my opinion

#

but i wish you luck

cosmic dagger
rich adder
#

and docs**

rare basin
#

and chat gpt kappa

rich adder
#

oh pls dont start

modest dust
# rare basin if you are learning for 2 years and there is 0 progress, then I'd say Unity is n...

Depends what he means by "learning". Honestly, my first year with Unity when I was younger, was just me blindly trying random tutorials and making random things. Technically I did something, but didn't learn much from that, lol. Only in the following years I began to actually learn properly. And he said he's young, so chill, young people don't think and learn in the same way adults do. He'll get there eventually if he commits to it.

thorn holly
#

My concept of learning is making a game, and then when I run into an issue or something I don’t know how to do, I get some help here, then do a bunch of research on the concepts that I learn

#

It works pretty well, I feel I’ve made decent progress

tropic agate
#

I think that is the problem when you are trying to learn Unity. You type in YouTube tutorials for ā€žHow to make character controllerā€ and you copy out the entire code. But what you should do is understand how transforms work in Unity, and have much more abilities and be able to do way more things

rich adder
#

yeah but you can't know about something until you start using it

#

thats when you should question what the component is and what you can do with it

nocturne violet
#

why does this keep randomly popping up?

cosmic dagger
nocturne violet
#

thank god

swift crag
stuck mango
#

Probably, yes

rich adder
slender nymph
cosmic dagger
nocturne violet
#

ohh ok

swift crag
#

if you just watch a course and think "ok I learned the course", you've probably missed most of the information

rare basin
swift crag
#

You need to see how something works, then do it yourself -- first in a very paint-by-numbers way, then with more freedom

#

Unity Learn tutorials encourage that kind of thing

rare basin
#

imagine going to school for 2 years in maths class and you still dont know how to substract/add numbers together

woven notch
#

can anyone see why the walls wouldnt stop the player from moving, im using rigidbody velocity

rich adder
#

repetition of what you just learned is good way to engrain it in mind

woven notch
#

ive been trying to solve it for atleast an hour now

slender nymph
woven notch
#

even when i turn is trigger off for both player and wall it doesnt change anything

#

i still walk through the walls

rare basin
#

are you moving through modyfing transform.position?

woven notch
#

nah

rare basin
#

collision matrix configured properly?

cosmic dagger
#

When I started tutorials, I typed all the code and redid the tutorial solo to ensure I knew how. You should strive to understand each line or code before you move on

The problem is, it's a slow process, and people need instant gratification or results to feel like they are doing smth . . .

scarlet skiff
#

how do i know specifically what it means?... "uknown" and "this" are not giving me that many clues

woven notch
swift crag
#

all it has is a numeric ID

#

but it can't find anything with that ID

woven notch
#

how do you change the collision matrix

rare basin
woven notch
#

alr

#

ty though

scarlet skiff
cosmic dagger
scarlet skiff
rich adder
cosmic dagger
swift crag
#

Unity's "hot reloading" can produce weird results

scarlet skiff
#

where do i go from here

rich adder
#

clear them from console and move on?

cosmic dagger
#

As long as it doesn't appear when you start the game again, you are fine. Unexpected results from reloading (as Fen pointed out) . . .

rich adder
#

you asked this earlier and got both times a yes answer

#

anything is Doable in unity with enough knowledge and patience

#

feed it into an AI
is very broad too, feed wat data?

scarlet skiff
#

alr ty

cosmic dagger
#

I don't see why not, you just need the data which isn't Unity specific . . .

gentle sandal
woven notch
rich adder
eternal falconBOT
woven notch
#

im making my game in 2d

rich adder
woven notch
#

but inside physics 2d there isnt the matrix

#

i cant see it

rich adder
#

yes there is

languid spire
rare basin
#

there certainly is

cosmic dagger
woven notch
#

nvm im just blind i didnt see the tab

woven notch
#

sorry

cosmic dagger
#

Click on them . . .

gentle sandal
gentle sandal
languid spire
#

no because there is just not enough data, you need a serious MoCap setup at the least for that kind of data fidelity

rare basin
#

did you really want to simulate injured people movement by ragdoll in unity?

gentle sandal
#

i think that i didn't explain it more clearly its way easier

languid spire
#

your model will be crap, believe me

rare basin
#

okay i got scared lol šŸ˜„

gentle sandal
languid spire
#

not gonna happen. have you ever trained even a simple ML model?

rare basin
#

then it definitelly will be crap

#

no offense but this is such advanced topic

languid spire
#

then you should know how much accurate data it needs to train. There is no way Unity can provide you with that for your purposes

gentle sandal
rare basin
#

no lol

gentle sandal
#

why?

rare basin
#

those big-scoped projects usually have insanely big budget

#

and entire team working on it

rich adder
#

budget 5$

rare basin
#

250$/hour and im all yours

#

dropping irl job

signal bronze
#

@rich adder this is what i got, ive changed some things but nothing happens when i get 4, so yeah, ill need help at the end

languid spire
#

Do you have a budget of at least 20 million USD?

gentle sandal
languid spire
#

no USD

rare basin
languid spire
#

dream on then get real

rare basin
#

also wouldnt that cause stack overflow?

slender nymph
eternal falconBOT
rare basin
#

pretty sure that will cause stackoverflow tho anyway?

rich adder
#

Oh didnt even see that

polar acorn
#

I don't even know what this magical project is because you keep deleting posts but from context you are likely in way over your head

rich adder
#

it will switch scene and hit if statement there at most with 0

slender nymph
#

probably just cause infinite recursion and lock up the thread, i don't think the stack would actually grow there

rare basin
#

hm, true

#

would that cause unity to freeze?

slender nymph
rich adder
#

Ahh yes

#

this will bork

rare basin
#

also coding in english will make more sense, especially when you want to share the code/ask for help in english server

rich adder
#

then do == inside that method, instead of manually setting the number variable for counting

frigid sequoia
#

Is there any difference between vector3.distance and vector3.magnitude?

polar acorn
#

so yes

#

They have nothing to do with each other

frigid sequoia
#

Isn't distance a magnitude?

rare basin
#

no

slender nymph
#

Vector3.Distance(a, b) is the same as (b - a).magnitude though

polar acorn
rare basin
#

magnitude is length of the vector
distance is well... distance between a and b

frosty hound
#

One is a function to get the distance between two points. The other gives you the length of an existing Vector.

slender nymph
rich adder
#

imagine that

frigid sequoia
#

I still don't see how the distance from A to B is different than the length of the path between A and B

frosty hound
#

They're the same value, they're different concepts.

#

If you create a vector between two points, the magnitude of that vector will be the same value as the distance between them.

potent echo
#

Hey, anyone know how to instantiate an prefab object and set it as a child object (of whatever object the script is in)?

gloomy ice
rare basin
#

that is such a google qusestion

#

you could google instead of asking here šŸ˜„

half patrol
#

hello fellas. beginner here. I run to this weird issue. i made a simple jump like in a code below. Issue is that if i press jump fast enough it double jumps! why is that?

`private void PlayerJump()
{
if (Input.GetButtonDown(JUMP_ANIMATION) && isGrounded)
{
isGrounded = false;

        animator.SetTrigger("TakeOff");

        playerBody.AddForce(new Vector2(0f, jumpForce), ForceMode2D.Impulse);
    }
}`
swift crag
potent echo
#

Oh sick, thanks

swift crag
#

I don't know how you're deciding if you're grounded.

half patrol
slender nymph
#

!code

eternal falconBOT
swift crag
#

that'll show you exactly when it happens

#

also log when you jump so you can see the ordering

rich adder
half patrol
rich adder
half patrol
rich adder
#

Indeed, they are part of the Physics2D class

half patrol
#

thank you sir/mam

rich adder
#

quick example

private bool IsGrounded()
{
    Collider2D groundedCol = Physics2D.OverlapBox(groundedCheckCenter.position, groundedBox.size, 0, groundedLayers);
    return groundedCol != null;
}```
swift crag
#

note that this could, itself, let you jump many times if you mash quickly

#

until you get far enough off the ground, this will say that you're grounded

#

this let you jump to the moon in Doom Eternal

candid gorge
#

Is there a way to prevent rigidbodies from irregular jumping? I've managed to do it directly tweaking the velocities instead of adding forces but I can't manage to make it local to the player transform so it doesnt really work for me. This is what I have right now

rich adder
#

weird, works fine on mine

#

Ah I think I see what you mean

swift crag
vale karma
#

What am I missing here to create movement?

using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerScript : MonoBehaviour
{

    //this field with contain the actions wrapper instance
    PlayerControls actions;

    void Awake()
    {
        // instantiate the actions wrapper class
        actions = new PlayerControls();


    }

    // Update is called once per frame
    void Update()
    {
        // the update loop polls the "move" action value each frame
        Vector2 moveVector = actions.Player.Move.ReadValue<Vector2>();
    }

    void OnEnable()
    {
        actions.Player.Enable();
    }

    void OnDisable()
    {
        actions.Player.Disable();
    }
}
swift crag
#

well, you don't actually do anything with moveVector...

swift crag
#

you compute it and then throw it out

vale karma
#

lol okay, i had movement going for a while and didnt understand what I copied, so Im going thru Unity documentation to learn exactly how its done

candid gorge
eternal falconBOT
signal bronze
#

now i have this, but it doesnt work @rich adder

rare basin
#

because you are not calling DestroyObject() anywhere

#

also as already menitoned

#

this will cause your Unity to freeze

signal bronze
#

why?

#

it should load the scene named as Victory

rare basin
#

infinite calling

signal bronze
#

and how can i make it to be finite

rare basin
#

it loads scene called Victoria then triggers a function that is calling a scene called Victoria then triggers a function that is calling a scene called Victoriathen triggers a function that is calling a scene called Victoria

#

infnite amount of times

north kiln
#

that function is an infinite loop, but good thing is you also never call that function from the outside, so it does absolutely nothing either

signal bronze
#

ok i understand

#

would it work like this?

north kiln
#

Yes, though you have to question why you've made a function at all if it's only one line long and it's local
Also, because you've put it inside another function you cannot use access modifiers (ie. public)

signal bronze
#

so only void?

#

and

rare basin
#

you lack basic c# knowledge

signal bronze
#

how can i make that when i got the 4 items it changes scenes?

rare basin
#

if(got 4 items)
{
ChangeScene();
}

signal bronze
#

like, what should i change here

rare basin
#

and you just made a local function

summer stump
rare basin
#

that's not the desired behaviour i guess

#

you made a void inside a void

rare basin
#

yes finally

#

now call that function you made

#

also are you increasing Cantidad whatever it is anywhere?

slender nymph
#

DestroyObject is never being called too

rare basin
#

perhaps you wanted to use OnDestroy unity method?

signal bronze
#

srry for my low english lvl

rare basin
#

as i said 2 hours ago

#

you cannot get help

#

because you lack very basic c# knowledge

slender nymph
signal bronze
#

is this correct? I dont think so

slender nymph
#

i have no idea what your intention is with this code so i have no idea if that is going to do what you want

rare basin
#

that will cause to load the scene multiple times

slender nymph
#

it shouldn't. it will call LoadScene then the next frame will load the scene

rare basin
#

ow didn't know that

#

i thought its loading scenes asynchronusly

#

so if the scene is kinda big it would take some time

rich adder
#

nowhere did I put Update() there xD

signal bronze
#

this

rich adder
signal bronze
#

i think im having a stroke between understanding the english + trying to do this

signal bronze
rich adder
#

you should only be calling this method OnTrigger

signal bronze
#

no

meager steeple
#

i copied a youtube tutorial for a resolution dropdown which should display resolutions only with the refresh rate the monitor is set at. but it doesnt work for some reason

rich adder
#

nested function

#

also my eyes are bleeding

#

"it doesn't work for some reason" idk maybe look at the Red Underline Error

meager steeple
#

yeah it says its not valid for this item but i dont know why and how

rich adder
signal bronze
rich adder
#

I'm sure you didn't mean to nest that inside of Start() though

meager steeple
#

ahhhh

#

thank you

rich adder
#

that is called every frame, why did you put it there..

rare basin
#

helping him since 2 hours šŸ˜„

cosmic dagger
signal bronze
rich adder
rare basin
#

lmao

signal bronze
#

Im srry, language barrier + im dumb asf

#

My family reminds that to all the time

#

xd

signal bronze
rich adder
signal bronze
rich adder
#

wtf why

#

its a method, we don't assign method

signal bronze
north kiln
#

It really seems like you should follow some tutorials before doing all this on your own

rare basin
#

we've been telling him to do that

#

since 2 hours now

#

im losing hope šŸ˜„

#

unless someone writes the code for him

signal bronze
#

sorry

rare basin
#

don't be sorry - learn

#

you could go through entire C# begginer course

rich adder
#

they just need the basics but they kinda getting it, at least they know comm between two scripts

#

sorta

rare basin
#

by the time you are here asking for help

rich adder
#

but yeah you need the C# basics

signal bronze
# rare basin don't be sorry - learn

dont have time, im 18 im in "Bachiller", in spain is like the last grade before univesity, i only have time on weekends and with luck, this next week i have 6 exams

rich adder
#

ohh thats not what we want to here then

signal bronze
#

I would love to spend 10 hours a day in this but its impossible to me

rare basin
#

you could spent that 2 hours for learning

#

no?

rich adder
#

"I dont have time" is not an excuse for not learning

#

Im doing this shite ontop of 2 fulltime jobs mate

signal bronze
rich adder
#

it comes off lazy if you say I have no time

signal bronze
signal bronze
rich adder
signal bronze
rare basin
#

constantly

#

look for solutions

signal bronze
#

ik

rare basin
#

commit, do the job

#

instead of constantly complaining

rich adder
#

ofc if you're not passionate enough about something you wont be eager to learn anyway

signal bronze
#

dont know what eager means

rich adder
#

like excited

signal bronze
#

ah okay

#

ill try to tak 1 hour every day to learn C#

#

Idk if ill be able to but ill try

#

Im srry for disturbing, have a great day and thanks for the help

vale karma
#

which method of movement is best for a realistic environment, kind of like gta style of walking around?

rare basin
#

physics based

#

if you want realistic movement type

#

and proper collision handling

vale karma
#

can i use a character controller with a player input action thing?

#

sorry im not too good at this yet

wintry quarry
vale karma
#

so does movement work without the Input manager thing if i just use the character controller? im confused

stuck mango
#

Why wont this work?
Script 1:

    public int health;

Script 2:

   public TextMeshProUGUI HPCOUNT;
   HPCOUNT.text = Toy.health.ToString();

Two scripts are connected already because first i a scriptable object and the second has a reference to it at the start of my code

vale karma
#

i just read up alot on unity about the new input system, and i wanna do it with a player input component and input action asset

frosty hound
vale karma
#

but then i coded pretty much the same thing from unity, but of course it doesnt include movement

cosmic dagger
stuck mango
paper plaza
#

what the hell?

signal bronze
#

ik dont say nun abt it, im dumb asf

#

i already said srry

paper plaza
rare basin
#

changing data in scriptable objects during runtime is not a good idea

signal bronze
#

i know, still srry for all of u trying to help me, gn

rare basin
#

unless you know what you are doing

stuck mango
#

Thank you, ill change it to maxHealth

rare basin
#

keep your health in HealthSystem class or something

#

only keep data that doesnt change in scriptable objects

#

or initial values

paper plaza
#

is there a way to bake navigation path for the ai on this mesh?

#

i don't know what to do

solemn summit
paper plaza
#

that's what im trying to do but when i click the "bake" button it does nothing @solemn summit

cosmic dagger
nocturne violet
#
            for (int i = 0; i < data.In_office.Length; i++)
            {
                if (data.In_office[i] == false)
                {
                    scary.Stop();
                    break;
                }
            }
#

does anybody know how to fix this? even when one of the arrays are true, it will stay stop

solemn summit
nocturne violet
#

oh, how do i make it where it will check everything though?

solemn summit
#

Like you want to check through all data.In_offices and if ONE of them is false do scary.Stop()?

nocturne violet
#

im trying to make it where it checks if all the arrays are false

#

and if one is not, it will not stop

cosmic dagger
nocturne violet
#

yes

eternal needle
cosmic dagger
nocturne violet
#

oh

#

ill try that, thank you

#

and then after that ill make an else statement

eternal needle
#

You dont need an else statement. That else will still be checking if any one element is false

signal bronze
#

Hi, just wanna tell u that i actually made it work, thanks for the help bro, fr thanks @rich adder ā¤ļø

nocturne violet
eternal needle
nocturne violet
#

yes it will do something different when the opposite thing happens

eternal needle
#

Else is for doing logic when the above conditions are not met. If you check for true, and then add an else statement you are just checking for false.

#

False in 1 element

nocturne violet
#

oh'

gentle sandal
#

anybody can recommend an existing ragdoll project for simulating human movement?

eternal needle
rich adder
gentle sandal
ripe shard
#

what do you even mean by simulating human movement?

#

ragdolls on their own dont simulate any kind of "realistic" movement, just constraints on joints

solemn summit
#

Like goofy active ragdoll? Ragdolling when dead/hit? Gotta have some specifics

gentle sandal
#

i guess ragdolling then

solemn summit
#

To what end, though? What' the goal?