#πŸ’»β”ƒcode-beginner

1 messages Β· Page 452 of 1

quick fractal
#

Good to know it's at least possible lol, thank you

raw robin
#

Hi all, looking for some code structure suggestions:

A player can pick up an item, and item ranges from [Ones you can throw, Ones you can shoot (i.e. a gun), Ones you can slice (i.e. a sword)...]

I have one ItemBehaviour script with all the interface that holds IThrowable IShootable...

Now the ItemBehaviour script will get length if I squeeze all the functions into one script I think, what's a better way of structuring it?

thanks

#
public class ItemBehaviour : MonoBehaviour {
    private ThrowableBehaviour throwableBehaviour;
    private ShootableBehaviour shootableBehaviour;
    private SliceableBehaviour sliceableBehaviour;

    void Start() {
        throwableBehaviour = GetComponent<ThrowableBehaviour>();
        shootableBehaviour = GetComponent<ShootableBehaviour>();
        sliceableBehaviour = GetComponent<SliceableBehaviour>();
    }

    public void PerformThrow() {
        throwableBehaviour?.Throw();
    }

    public void PerformShoot() {
        shootableBehaviour?.Shoot();
    }

    public void PerformSlice() {
        sliceableBehaviour?.Slice();
    }

Maybe something like this? So the logic for the action sits within the Behaviour script?

#

Looking at a structure like this, I almost don't need to involve any interface?

languid spire
wintry quarry
#

A mesh is not a GameObject or a component, it's an asset

#

Dyou assign it at runtime

#

And every time the mesh changes you would need to reassign it to the collider

raw robin
languid spire
raw robin
#

gotcha thanks!

short hazel
languid spire
short hazel
#

Interfaces allow inheritance, so you can make a interface IShootable : IPerformable if you want to add specific members for the more specific interface

short hazel
languid spire
#

multiple types of Performable on the same object, i.e An Axe is both Throwable and Slashable

short hazel
#

That's not in the initial spec, but if that's needed my solution won't work

languid spire
#

not criticizing your solution, it's one I use often myself, just pointing out potential drawbacks

leaden sage
#

how do i get rid of this annoying logo

languid spire
#

turn the gizmo off

leaden sage
#

i tried turn it off here but didnt work

#

do i just turn all 3d icons off?

#

that seems to work

languid spire
#

rhats on

#

open the dropdown you can select per gizmo

leaden sage
#

ahh okok, thanks

sour parrot
#

Can someone help with this issue I have, I can't seem to find a solution anywhere on YouTube or just on the internet.
I'm using a prefab called "Enemy" to spawn in a red cube guy with a gun, although, the script to control his movement needs the player's position so he can move over there. Issue is that I can't reference the player in the behaviour component in unity inspector because the player isn't inside the enemy prefab.

queen adder
#

Chat, what's "delta"?

slender nymph
#

in what context

queen adder
#

Here in my book it's in mouse input

languid spire
slender nymph
queen adder
#

if (Input.mouseScrollDelta.y > 0) {

slender nymph
#

so it's not even the mouse delta, it's the mouse's scroll delta. which is the change in the scroll wheel that frame

languid spire
#

delta generally means 'change from previously reported value'

empty gull
#

if anyone could help me realise what im doing wrong in this script thats making the gun flip wrong that would be greatly appreciated.
basically i just need the sprite to flip when you get to a certain point in the rotation.
also i know the code is not clean at all dont worry about it just wanna get this working before i clean it up

slender nymph
#

also instead of manually constructing the rotations like that (which is wrong per the link i just sent) why not just use transform.Rotate(0, 180, 0) or just flip the sprite on the sprite renderer?

empty gull
slender nymph
empty gull
wet bobcat
#

ok, so I dont think eulerAngles or

gloomy kelp
#

I'm in this problem for days right now
can I maybe update my unity version or download another admob version will this help?

slender nymph
tender stratus
#

Why cant i access a function?

#

When i press no function i see monoscript

#

then string smt

rich adder
#

it needs to be on a gameobject

tender stratus
#

Its on a button

rich adder
#

the script

#

u want function from

nova shore
#

what can i do instead of

public Keycode slot1,slot2,slot3,slot4

switch (key)
{
case(slot1):
slot1.doshit()
    break;

case(slot2):
slot2.doshit()
    break;

case(slot3):
slot3.doshit()
    break;

}
tender stratus
tender stratus
rich adder
rich adder
nova shore
tender stratus
#

But it still doesnt come up

rich adder
nova shore
#

ye ye

rich adder
polar acorn
tender stratus
#

Game object

#

transform

#

and

#

Got it now

#

It needed a capital letter

#

Thanks

rich adder
tender stratus
#

The name of the function

cosmic dagger
eternal falconBOT
rich adder
#

no it doesnt lol

tender stratus
#

It said naming violation or smt

#

Oh cause it popped up for me now

rich adder
tender stratus
#

No it didnt work before.

rich adder
#

the spelling has no relevance to if it shows up or not

tender stratus
#

The function comes up but it doesnt Do its job

rich adder
#

and what do you expect it to do vs whats happening now?

short hazel
#

The naming violation is merely a suggestion, and won't prevent your code from compiling

tender stratus
tender stratus
#

Its only purpose is to just reset the scene to its original

rich adder
#

probably isn't (or scene would reset ofc)

tender stratus
#

Its not

rich adder
#

find out why

#

is the Button hovered, clicked ? do you have Event System etc..

tender stratus
#

I couldnt tell you, Its my first ever game

rich adder
#

well start lol
you're the one at the computer with the project open

#

I can only give you pointers , I'm not telepath

tender stratus
#

Yup

rich adder
#

first step is to check your hirerchy for an Event System object

#

if you have one, run the game.
check the event system inspector, it has a bar you can uncollapse at the bottom, it will tell you exactly what you're clicking etc.

tender stratus
#

So Its a problem with the button

#

Not the code

rich adder
#

yes

#

possibly other UI covering it

tender stratus
#

No i dont think so

rich adder
#

this isn't a guessing game lol you have to debug it

tender stratus
#

System event inspector can be found where?

rich adder
tender stratus
#

yes

rich adder
#

do you know what the inspector is?

tender stratus
#

yes

rich adder
#

so what do you think the answer to

System event inspector can be found where?
is

tender stratus
#

I thought it was a seperate UI

#

its registering my Mouse clicks

rich adder
#

no Event System tells the UI what ur clicking

#

or otherway around, either way they work together

tender stratus
#

I think i may have figured it out

#

It says im On a canvas rather than a button

polar acorn
#

Show a screenshot of your full Unity window, with the hierarchy visible, and with your button selected

tender stratus
rich adder
#

You have two canvases

#

you're probably clicking the one ontop

tender stratus
#

I fixed it

tender stratus
tender wharf
#

gamers i have a question, i made a method that determinates the players position in a race based on finished laps and checkpoints. It seems to work, but sometimes it like spazzes out.

#

Checkpoint and lap progress gets tracked well

#
    public int GetPlayersPosition()
    {
        var playerPosition = 1;

        foreach (var aiPlayer in aiPlayers)
        {
            if (lapProgress[aiPlayer] > lapProgress[humanPlayer])
            {
                playerPosition += 1;
            }
            else if (lapProgress[aiPlayer] == lapProgress[humanPlayer])
            {
                if (checkpointProgress[aiPlayer] > checkpointProgress[humanPlayer])
                {
                    playerPosition += 1;
                }
                else if (checkpointProgress[aiPlayer] == checkpointProgress[humanPlayer])
                {
                    var nextCheckpointId = (checkpointProgress[humanPlayer] + 1) % checkpoints.Length;
                    var nextCheckpoint = checkpoints[nextCheckpointId];

                    var aiDistance = Vector3.SqrMagnitude(aiPlayer.transform.position - nextCheckpoint.transform.position);
                    var playerDistance = Vector3.SqrMagnitude(humanPlayer.transform.position - nextCheckpoint.transform.position);

                    if (aiDistance < playerDistance)
                    {
                        playerPosition += 1;
                    }
                }
            }
        }

        return playerPosition;
    }
#

My only guess is that I should add more checkpoints so it becomes more precise

#

or maybe there is some flaw in my logic that im not seeing

slender nymph
#

so you're just getting the raw distance from their current position to the next checkpoint. in some places they could be further back along the track but technically closer to the checkpoint, if you look at the bottom left two checkpoints around that curve and the middle two at the bottom that will be most evident there.
What I would do is instead use something like unity's Splines package, create a spline that follows the track then sample the position along that spline, then you'd also just sample the check point positions along the spline and you can get the distance from those positions along the spline

tender wharf
#

thats actually smart

#

so basically get the position on the spline thats closest to the player, then get the distance from that position to the next checkpoint

slender nymph
#

the distance from that position to the checkpoints position along the spline. the key here is calculating the distance along the spline. if you aren't doing that, then you're still just getting the raw linear distance from one point to the other

ripe flame
#

I have put this code on a trigger that the player will walk through. I want it to give a debug message every time he has collided an even number of times. (entering the room and exiting)
For whatever reason it only gives the debug message when the collisionCounter is 2. Not on 4,6,8 and so on collisions


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

public class LagerDoorTrigger : MonoBehaviour
{
    [SerializeField]
    private GameObject playerObject;
    private int collisionCounter = 0;

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == playerObject)
        {
            collisionCounter++;
            if (collisionCounter % 2 == 0)
            {
                Debug.Log("Outside");
            }
        }
        Debug.Log(collisionCounter);
    }
}
tired junco
#

Hey, i tried to add System.text.json pacakge to my unityproject via editing the csproj file and running dotnet restore in terminal but this didn't work so i tried to revert it but this fucked up my entire visual studio project it says that System.Void System.Object ... is'nt defined even tough it shows these errors in vs my unity project does run

languid spire
slender nymph
ripe flame
#

Hmm how would I check that?

#

Oh I see now

#

Yup works, thanks didn't expect it to be that simple DANCE

tired junco
languid spire
tired junco
#

yes

languid spire
#

odd, screenshot the errors and post the .csproj file to a paste site

tired junco
steady yew
#

i made a 2D snowboard game and I'm using left/right arrow keys to rotate the player. I'm using torque to rotate it. The problem is i built the project and when i start the game the player rotates really slow. But it works well in studio

slender nymph
#

show code

steady yew
# slender nymph show code
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    [SerializeField] float torqueAmount = 1f;
    [SerializeField] float boostSpeed = 25f;
    [SerializeField] float baseSpeed = 17.5f;

    bool canMove = true;

    Rigidbody2D rb2d;
    SurfaceEffector2D surfaceEffector2D;

    // Start is called before the first frame update
    void Start()
    {
        rb2d = GetComponent<Rigidbody2D>();
        surfaceEffector2D = FindObjectOfType<SurfaceEffector2D>();
    }

    // Update is called once per frame
    void Update()
    {
        if (canMove == true)
        {
            RotatePlayer();
            RespondToBoost();
        }
    }

    public void DisableControllers()
    {
        canMove = false;
    }

    void RespondToBoost()
    {
        if (Input.GetKey(KeyCode.UpArrow))
        {
            surfaceEffector2D.speed = boostSpeed;
        }

        else
        
        {
            surfaceEffector2D.speed = baseSpeed;
        }
    }

    void RotatePlayer()
    {
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            rb2d.AddTorque(torqueAmount);
        }

        else if (Input.GetKey(KeyCode.RightArrow))
        {
            rb2d.AddTorque(-torqueAmount);
        }
    }
}
#

this is my controller script

plain dagger
#

I think you need to put the physics code in FixedUpdate

slender nymph
eternal falconBOT
slender nymph
#

and yes, apply physics in FixedUpdate rather than Update

plain dagger
#

ye, this'll cause it to be frame independant so it won't change how fast it's turning based on the framerate

steady yew
#

ok thank you! lemme try

umbral bough
#

Hi, I sent this code yesterday that makes no sense to me, I would really appreciate somebody explaining what's going on.
These 2 should behave exactly the same(from my understanding):

    public static Camera Camera => Instance._camera ?? (Instance._camera = Camera.main);
    public static Camera Camera => Instance._camera == null ? Instance._camera = Camera.main : Instance._camera;

Yet, 1st one results in a ton of null ref errors while the second one works flawlessly.
They are in the same script, same position(literally one above the other) and I even use the same piece of code for my time manager which just works:

    public static TimeManager TimeManager =>
        Instance._timeManager ?? (Instance._timeManager = GO.GetOrAddComponent<TimeManager>());

According to ai and a person on this server(asked the same thing yesterday), it should work the same, yet it doesn't.
Thanks in advance!

slender nymph
#

did you read the error message?

steady yew
slender nymph
#

you build it again

steady yew
#

πŸ‘

wintry quarry
umbral bough
wintry quarry
#

you have been warned

umbral bough
#

Is there a reason why it works with the TimeManager(just a regular mb script) and not with Camera?
Like does camera have something specific going on in the background?
I am just curious.

raw token
umbral bough
#

Interesting, how come TimeManager works then?
Is Camera inheriting from something other than MonoBehaviour?

cosmic dagger
steady yew
umbral bough
#

I see, I guess that would probably explain it, thanks a lot!

cosmic dagger
#

Though, ultimately, it derives from Object . . .

sour parrot
languid spire
slender nymph
sour parrot
#

its not that it wasnt clear i just didnt understand it all that well, when i typed in instance.Initialise(_target); into my code i got an error message

slender nymph
#

ah yes "an error message"
but i'm gonna go ahead and assume you didn't bother creating an Initialise method that takes a parameter on the type you were attempting to initialize?

sour parrot
#

'GameObject' does not contain a definition for 'Initialise' and no accessible extension method 'Initialise' accepting a first argument of type 'GameObject' could be found

slender nymph
#

right so you were actually using the incorrect type

sour parrot
#

as you can probably tell, im new to unity so everything i take in that isnt "write this variable here" goes over my head

slender nymph
#

there is almost never a need to make a variable a GameObject type. use the type of component you actually care about

slender nymph
sour parrot
#

rawdogging it 😍

cosmic dagger
steady yew
#

guys when i start my game my sound effects and particle systems starts on their own why?

cosmic dagger
languid spire
#

Play On Awake ?

steady yew
slender nymph
sour parrot
#

ok man chill, i'd feel like i learn less if i sat at my screen reading for ages and not just going in and learning practically

#

thank you for helping though

steady yew
slender nymph
sour parrot
#

🀫 this is the first time i've asked for help with programming in years

#

maybe you're right though but i wouldnt enjoy reading tutorials the whole time

tawdry rock
#

Help, how can i save and load a gameobject rotation?
this is my save:

rotation[0] = myPlayer.transform.rotation.x;
rotation[1] = myPlayer.transform.rotation.y;
rotation[2] = myPlayer.transform.rotation.z;```
This is how i try to load:
```Vector3 myRotation;
myRotation.x = data.rotation[0];
myRotation.y = data.rotation[1];
myRotation.z = data.rotation[2];
thePlayer.transform.rotation = Quaternion.Euler(myRotation);```
slender nymph
#

but also what are you even using to save this data? it may be possible to just store the quaternion directly

wintry quarry
tawdry rock
#

but if i don't do quaternion i get error

wintry quarry
tawdry rock
#

thePlayer.transform.rotation = myRotation; Cannot implicitly convert type 'UnityEngine.Vector3' to 'UnityEngine.Quaternion'

slender nymph
#

again, transform.rotation is a quaternion

wintry quarry
#

why would you try to put a Vector3 into a Quaternion field

slender nymph
#

that part wasn't even the issue. the issue was the first part where you store the data

wintry quarry
#

well... both are the issue

tawdry rock
wintry quarry
#

they're incompatible

#

you have to be consistent

slender nymph
wintry quarry
#

sure, or if they restored it as a quaternion (and stored it as one)

#

they jsut have to pick one

slender nymph
#

well we don't even know if they can store the quaternion because they elected to ignore the question about how they are actually saving the data πŸ€·β€β™‚οΈ

#

or i suppose they could probably make the array larger. but honestly an array for this seems absolutely pointless either way

wintry quarry
#

well presumably if that mechanism can handle a float[3] it can handle a float[4]

#

but yeah

ionic zephyr
#

In a 2D top-down view game is it better to use a OverlapBox than a Circle?

#

When attacking

slender nymph
#

use whichever shape makes the most sense for whatever you are doing. there is no "better"

summer stump
#

It depends on the shape you want

ionic zephyr
#

And how can I make my character, in that same view, face the way I am moving

#

in terms of the transform

#

I have a movement vector, how can I make the transfor "look" that way

slender nymph
#

assign either the transform.up or transform.right to the direction of movement (depending on what direction it faces with no rotation applied)

cosmic dagger
eager spindle
#

InteractableObject and Interact To Progress both inherit from Monobehaviour, why can I only disable InteractableObject?

slender nymph
#

it doesn't have any methods that would be affected by being disabled so it just doesn't render the checkbox for it (this was changed in unity 6 i believe)

#

even if it did render the checkbox, there's nothing that would be affected by its enabled state

cedar mirage
#

why is my collider not lined up with my actual circle gameobject

#

i keep having to resort to using offset

#

to get it lined up

#

is there any way to fix this simply?

slender nymph
#

where is the code question

cedar mirage
#

my bad didnt realize i was in the scripting section

#

which channel would this best be for?

#

unity talk is fine?

slender nymph
#

christ are you ever going to stop with the constant barrage of messages because you don't know how to finish a thought before sending a message?

cedar mirage
#

ohhhh lol you're that person, funny

ocean arch
#

I have an error:

#

Assertion failed on expression: 'SUCCEEDED(hr)'

#

does anyone know what this could mean?

slender nymph
eager spindle
#

Very interesting implementation

slender nymph
#

sure, but like is there any reason you need to disable that specific component?

raw token
eager spindle
ocean arch
slender nymph
#

you can still set its enabled property in code even if the checkbox isn't there, but that still won't make anything at all happen if there's nothing that will actually be affected by being disabled

slender nymph
eager spindle
#

oh wait I was disabling the wrong component πŸ˜„

raw token
ocean arch
ocean arch
eager spindle
#

My workflow would be made much more convenient if I could operate with two prefabs open at the same time, but even when starting a new Game tab opening a prefab controls all Game tabs
Any way I can work on multiple prefabs at the same time?

ocean arch
#

LTS

molten dock
empty gull
#

trying to get a weapon pickup system working, and my player simply isn't colliding with the weapon pickup on the floor.
the player has a rigid body, both the player and the weapon pickup have colliders - the weapon pickup collider has 'is trigger' on - and i've checked that the layers they are both on can collide with eachother in the physics matrix
i have also tried using OnTriggerEnter2D instead of OnCollisionEnter2D and neither work for me, currently all i need is for the 'canPickUp' bool to be checked when i move into the weapon pickup collider

rich adder
slender nymph
#

i would also strongly recommend against using Collison/Trigger messages for interaction systems. use a physics query like an OverlapCircle instead and you can have all of the relevant detection code in Update on a single object so you not only don't miss input (like what is clearly happening here) but also so you don't have a hundred different objects always checking for something that can be checked from one central location

empty gull
empty gull
queen adder
#

I don't know if i read it right but if you gonna use ontriggerenter both objects needs to have a trigger hitbox (What i know) I was wrong

slender nymph
#

incorrect, at least one must have isTrigger on. but both can have it enabled

queen adder
#

Oh sorry my bad, Also a noobie

slender nymph
#

the page i linked goes over that kind of information

fickle stump
#

!code

eternal falconBOT
fickle stump
#

Hey, I'm currently trying to turn on one light after the other on a path.
For now I can turn them on, but I'm having a mistake somewhere where the lights aren't turning on one after the other, but all at once.

slender nymph
#

that loop completes in a single frame. you'll want to extract the loop into a coroutine and yield for your desired time each iteration so they enable one at a time

fickle stump
#

Hm I never worked with coroutines

#

thats gonna be interessting

raw token
wintry quarry
dusk bloom
#

i have question, i dont have idea why playerdatainstance dissapears after i start game> any clue why it dissapears from its field after i start game

ivory bobcat
dusk bloom
#

oh sorry then, (so im not beginner anymore? notlikethis )

slender nymph
#

if it isn't related to the code though, then definitely not appropriate for this channel as this is a code channel

errant pilot
#

Guys i have a raycast that stop working when i add a collider to the object, how can i fix it?

summer stump
errant pilot
#

ill send the code

summer stump
# errant pilot

Put some debug logs in. Which condition fails? I am guessing the collider.transform is not the player_transform

errant pilot
#

its hitting its own collider

summer stump
errant pilot
summer stump
errant pilot
modern oxide
#

Hi guys! I'm making a VR game and I'm using the XR interaction Toolkit. I was wondering how I could make a grenade? I've tried but I can't get it to work

raw token
rocky canyon
#

not sure how vr hand controls work.. but u need to pass on velocity to the grenade

#

(sphere w/ rb)

modern oxide
modern oxide
raw token
# modern oxide well, I guess getting it to detect when it should go off, like it only going off...

If you mean "go off" as in explode, you could just use a normal OnCollisionEnter() event to detect impact and explode. The hands could be omitted from triggering the collision via layers.

For the actual explosion, you might have the grenade instantiate a prefab encapsulating the relevant effects - particles, audio, and maybe using a physics query to detect rigidbodies nearby and apply an AddExplosionForce()

(one of many possibilities πŸ‘€)

rocky canyon
#

ya, shouldnt be interacting with hands once released

empty gull
#

when instantiating a prefab it loses some scripts and gameobjects, i know this is intended but i need to know how to add those back into the prefab upon instantiation in the script, heres the code so far, any help is appreciated ty

crisp token
#

why cant I make an abstract method static / is there something else with similar functionality

empty gull
empty gull
rocky canyon
#

use that to then grab components /and or set up other values once instantiated

raw token
crisp token
modest dust
modest dust
mint remnant
#

you could always create a singleton

crisp token
#

highest possible reference

empty gull
modest dust
raw token
#

On a bit of a tangent, I think you can define an interface with static members, but then it might make a mess of inheritance... I'm assuming a parent and child class cannot both implement the same interface, because that would make an inheritance graph rather than a tree/chain? πŸ€” (brain fart)

Edit: shower thought. Pay me no heed - I'll play πŸ‘€

Edit edit_v2_final_final.doc: ewww

crisp token
#

well not highest but the same way they do it for casting

modest dust
#

You call a static method on class-level, not instance-level

#

MyClassName.StaticMethod

#

If it's abstract, you can call it from the base class which declares it

#

From there it makes no sense which implementing class to choose

crisp token
#

oh yeah, nvm then

#

forgot about that part

empty gull
rocky canyon
#

get component just grabs the script using <Type> soo it'd be whatever your player script was.cs

modern oxide
#

Using Unity.XR, how do I find my controllers using roles?

rocky canyon
#

many different ways to do it.

        PrefabScript prefabScript = instantiatedPrefab.GetComponent<PrefabScript>();```
#

now all its public variables are methods are accessible like prefabScript.ReferenceA = ... ;

#

or prefabScript.DoFunctionA();

steep rose
#

would cancelling inputs be a good way to limit speed on a rigidbody? (just WASD)

rocky canyon
#

sounds awful, and odd

#

just limit its actual speed lol

summer stump
steep rose
rocky canyon
#

ya, weird phrasing lol. ignoring inputs over a limit is just basic clamping

steep rose
#

my code in my main script got all messed up because unity autosaved and i didnt have a backup when it did

summer stump
#

So if moving "left" at the max speed, just don't add speed when pressing A. But if you press D, then decrease that velocity

steep rose
#

so now i have to redo everything

rocky canyon
#

unity autosaves now? πŸ‘€

summer stump
steep rose
summer stump
steep rose
#

i would like to

#

i just dont know how

summer stump
rocky canyon
#

well do.. !git

#

!vc ?

eternal falconBOT
#
Using version control in Unity

Unity Version Control

git Git

Get the latest .gitignore file from here. It should be placed at the root of your Unity project directory.

rocky canyon
#

there we go

summer stump
#

It is dead easy. There is no reason not to

rocky canyon
#

its pretty easy within the backup, change, pull/push, aspect of it all

steep rose
#

version control seems very useful and would have probably saved me a couple times πŸ˜…

#

i will get on it

rocky canyon
#

one of my harddrives just gave-out last month..

#

it was an awful ordeal. but knowing atleast some of my projects were on VC made it not as bad

#

ruining a scene is 1 thing.. losing a project or two.. pretty much ties ur hands to using version control, if ur half-sane

modern oxide
#

How do I fix this? I can't find what varible the XR controllers are

#

so I can't make a varible for it

empty gull
slender nymph
graceful crystal
#

any idea why it's not recognising this as a variable for player?

slender nymph
slender nymph
modern oxide
slender nymph
#

well what are you actually trying to do with that line then?

modern oxide
#

also if grip is too

slender nymph
#

and have you looked at the documentation to see how you might do that? or have you gone and looked at ancient tutorials that use methods that have been obsolete for years?

steep rose
modern oxide
slender nymph
#

what doc did you look at

steep rose
slender nymph
#

github is pretty much the industry standard. use it

steep rose
queen adder
#

I miss omnisharp checking my whole project for syntax error when I press F8 :<

slender nymph
queen adder
#

what code intelligence server does unity call the one they uses now?

slender nymph
#

but when using the xr interaction toolkit, shouldn't you just be using the input system for input? like that's literally a requirement for that package

slender nymph
queen adder
#

really?

teal viper
eternal falconBOT
slender nymph
empty gull
queen adder
slender nymph
#

the C# DevKit just installs relevant c# extensions. omnisharp is part of the C# extension and likely always will be

queen adder
steep rose
#

i started a thread so it doesnt get messy here

modern oxide
slender nymph
#

it doesn't even matter if it did because that method is still obsolete

modern oxide
#

oh its been replaced with Characteristics

teal viper
quartz beacon
#

hello i'm completely new to unity and c# and i have an audio source component attached to a gameobject and i just want to trigger the sound through code. how can i target the audio source and play the sound?

graceful crystal
#

thank you tho ❀️

slender nymph
#

those are entirely unrelated things

sage folio
#

this might have an issue not relating to the script, but when i build the project the player can't move, they player can fall but there is no movement, although its fine when playing in the editor, this is a first person 3D project
https://gdl.space/kopilikixo.cpp

rich adder
#

you probably got rid of the extra script with unassigned reference

solemn fractal
#

Hi friends.. I am getting an error on line 39 here.. it says: You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
The other class looks like this as you can see in the SS. why that doesnt work?

deft grail
#

AreaOfAttack is a MonoBehaviour

rich adder
solemn fractal
#

I always did like that. Not sure why I cant do it.

#

Always used new Classname()M

deft grail
rich adder
#

you should not new a MB

deft grail
#

so you didnt do that always, because its impossible

summer stump
deft grail
#

it was either empty, or a ScriptableObject or something, like the error suggest you can fix it like that

rich adder
#

couldn't even new a SO

#

they got confused for sure aint no way lol

summer stump
#

You CAN new a gameobject. I'm assuming it was maybe that?

deft grail
summer stump
#

I mean, an MB is a component. How can a MB exist outside of a gameobject?

solemn fractal
#

Understood. Thank you guys.

rich adder
solemn fractal
#

Already fixed here. Thank you all

#

I have so much difficulty with null reference.. the day that I learn how to master this.. I think I will speed up my games progress 1000%. Just a comment. πŸ˜›

rich adder
tardy needle
#

Anyone knows how can I serialize a script inside a component? I would like to inside the inspector be able to chose the 3 public atributes of health. Is it possible to do this?

slender nymph
#

does Health have a reason to inherit from MonoBehaviour? if no, then don't make it a MB. if yes, then the only way you'd be able to do that is to write a custom inspector that will then write to the serialized fields stored on the reference assigned to your PlayerManager

toxic frigate
#

hello all, im not sure how to phrase my question correctly so please clarify if there is confusion: when i exit a scene and load up a main menu scene and then load up the first scene again, nothing works, why is that and how can i fix it

here is the main menu loading line
cs UnityEngine.SceneManagement.SceneManager.LoadScene("mainmenu");

native hill
#

does anyone have a tutorial about row and collums, im trying to make a summoning script that spawns objects behind u in rows

slender nymph
toxic frigate
#

oh jeez you're right

#

thank you so much

tardy needle
toxic frigate
#

this is like the third time you've helped me lol how do i give you karma

slender nymph
solemn fractal
summer stump
tardy needle
#

I see, for the Health script monobehaviour isnt needed, but my other scripts will

summer stump
#

If you want it to be a direct component, then you need it to be a MonoBehaviour. If it is just data, it does not have to be

tardy needle
summer stump
tardy needle
#

Okay thanks

slender nymph
hallow sun
#

Question about building a .exe
Does it always need the folders? It always makes a BurstDebug, Data, MonoBleedingEdge, and a dll.
Do i need to upload all of these to share my game? Unreal does a similar thing idk if im missing a setting.

slender nymph
#

the only folder you don't need and should always delete is the one that literally has "DoNotShip" in its name. the others are absolutely necessary

crisp token
#

are you guys talking about version control? i really need to look into that

slender nymph
#

no, but you should be using some sort of version control. i personally recommend and use git, but unity's version control package is decent from what i've heard

crisp token
#

Does that back up your entire asset folder or just code

slender nymph
#

you commit what you want to your repository

crisp token
#

So git can store all kinds of files? That’s cool

solemn fractal
#

Hi guys.. I have a situation here. I want the player to attack enemies if he enter this area. If I put on the variable to attack only in 1 unity so float areaOfAttack = 1; It will attack correctly in 1 square unity. But the scale of my circle is 2.1 I want it to be always the circle area. And I do not want to use collision to check this.. any fix for that other than using collision 2d?

slender nymph
crisp token
#

Is the purpose of git to create a copy essentially in case unity files get corrupted? I’m just not sure what the main concern is

slender nymph
#

no, it's to track changes to your files so you can revert those changes, work with others, and as a bonus hosting the repo on a remote repository serves as a backup for the files

crisp token
#

Ok, thanks I’ll go do that

verbal dome
solemn fractal
solemn fractal
#

HI guys when I try to use the Console.Writeline nothing appears on console.. any ideas?

solemn fractal
#

Amazing, that worked. Thank you.

summer stump
crisp token
#

can I pass a bool by reference?

summer stump
ivory bobcat
crisp token
#

i dont even know if this is going to work but im trying to call a coroutine from a different script and have that coroutine pause and resume only when the method in which it was called is run again

ivory bobcat
#

Pass a reference of the object that owns the bool

crisp token
#

as in the script?

ivory bobcat
#

Coroutines won't take ref parameters.

summer stump
slender nymph
#

can't pass ref parameters to the coroutine so that will be the best option. or pass a func that returns the state of that bool and use WaitUntil

crisp token
#

i thought you cant do that with monobehavior?

summer stump
#

Pass a reference to it? Of course you can

crisp token
#

ah I got you, thanks

#

like this right?

ivory bobcat
#
public IEnumerator MyCoroutine(MyScript myScript)
{
    while(myScript.myBool)
    {
        //do stuff
        yield return null;
    }
}```
crisp token
#

I cant believe i didnt know you could pass Monobehaviors as objects

#

a whole world has oppened up to me

summer stump
#

MBs ARE objects, to be clear

crisp token
#

this whole time I had been using GetComponent<>

#

so I thought you could only do it from other monobehaviors

summer stump
#

UnityEngine.Object > Component > Behaviour > MonoBehaviour

modern oxide
#

How can I get VR controller input using Unity XR? I've been trying to figure it out but I just can't

modern oxide
#

oh yeah thanks

cosmic dagger
crisp token
cosmic dagger
native hill
#

wheree is the site to paste stuff!

cosmic dagger
eternal falconBOT
native hill
#

i found it, thank you

summer stump
#

Wait, ide?

native hill
#

no, i have my ide

cosmic dagger
summer stump
cosmic dagger
#

oh shit, you right. it was !code

eternal falconBOT
native hill
cosmic dagger
#

i knew that . . . 🫠

summer stump
#

Do you know how to use the debugger? I would put a breakpoint in and check values at runtime

eternal needle
#

did you debug what those values are? unless you changed them in inspector
0 * anything = 0

#

transform.position - (CurrentRow * RowDistance * transform.forward) - (CurrentCollum * RowDistance * transform.right)
=> transform.position - 0 vector - 0 vector

native hill
eternal needle
#

well dont just randomly change stuff

summer stump
eternal needle
#

this should be used for something, did you use AI to make this code?

native hill
#

oh alright, ill do that

native hill
summer stump
#

I recommend against that

eternal needle
#

well you shouldnt, as you have no idea what this code is doing

native hill
eternal needle
#

and yet here we are

native hill
#

yeah πŸ’”

#

ill try debugging it right now

mint remnant
#

maybe we can get chatgpt to join the discord and when it sees code it wrote it can chime in, hey I wrote that code, let me help you fix it

native hill
#

it didntntntn helppp!!!

#

my computer is so slow im sobbing

#

is Debug.Log(SpawnPositon); enough for trying to debug it?

teal viper
native hill
#

i tried understanding it before i wrote it

#

my code is super buggy, i think im just gonna rewrite it without ai thank you guys

summer stump
#

But what did the log say?

eternal needle
# native hill is ```Debug.Log(SpawnPositon);``` enough for trying to debug it?

i did also point out one likely problem above. you should debug what the difference is between the transform.position and spawnposition is, since your issue is that they're spawning ontop. Then you debug further with possibly the results of CurrentRow * RowDistance * transform.forward or CurrentCollum * RowDistance * transform.right

native hill
# summer stump Not the best

i pressed space four times and i got (-5.07, 1.17, -0.54) four times, it stopped spawning at me cause the values i changed in the code didnt change in the inspector for some reason so i just changed it there

native hill
#

after CurrentColumn goes back to zero it goes infront of the first clone spawned

#

i got it to work, thank you guys

queen adder
#

I just wasted like 2 hours because I was trying to hit a box collider (not 2D) with a 2D raycast

#

fml

#

no medicine for stupidity

mint remnant
#

Debug.Drawline my raycasts if at all in question

summer stump
oak elk
#

hi, does anyone know how to make unity "refresh" my compiler errors after i fixed them in vs code (so that i can start play mode)?

#

for example i acidentally write nonexistent variable "radius" instead of just putting a number , and it caused a compiler error, but after i fixed it unity hasnt caught on that i fixed it already, and i have to restart the engine every time it happens

ivory bobcat
#

Did you save the script?

oak elk
#

yeah i saved it in vscode

raw token
#

Unity should be watching those files and recompiling/reloading the domain automatically πŸ‘€

ivory bobcat
#

Did you change the Unity configuration to not auto compile?

oak elk
#

lemme check wait

#

oh it works hahaha

#

it was disabled

#

thanks lolo

umbral rock
#

im following a tutorial to make subway surfers and i came across a line of code called Math.Lerp, i know what it does, so u give a minimum value and a maximum value and then a starting value to the third and he is gonna randomly choose a number between the min and max right? so i understand that but i dont know what the tutorial is doing, i'll send u a photo of the line of code

#

the minimum is x but x doesnt have any value in this whole block of code

#

He just put a variable on top like this, Private float x; is this default on 0?

#

and he is using the lerp to determine the animation time to dodge i think but i wonder why he is using lerp? because it'll chose a random value between the min and max so wont this effect the animation because its a random number every time?

eternal needle
#

also most of this tutorial code looks horrible

umbral rock
#

Hmmm, but why does he uses lerp? so i know its for the animation but isnt the random number gonna affect the animation or something?

#

i dont understand why u should use lerp for animating

eternal needle
#

not sure what random number you're talking about

#

the only part that controls the animation is the .Play call, nothing else affects your animation itself

umbral rock
#

Well, the math.lerp is chosing a random number between the x and the NewXPos right? and what is the Time.deltatime*Speeddodge then? thats the random number right? or?

languid spire
#

why random? where do you get that from?

eternal needle
#

lerp is a linear interpolation between A and B, at value T where t is between 0,1

umbral rock
#

oh its a loop?

eternal needle
#

not at all

umbral rock
#

so value T cant be 2?

#

But why does this guy uses this?

eternal needle
#

well, the code is shit but they're also not using a value over 1

languid spire
#

basically, because he doesn't know what he is doing

umbral rock
#

Well yeah i understand that but i just wanna know why he does uses it and how it works

languid spire
#

he probably learned his Unity code from Brackeys tutorials which are full of this kind of shit

eternal needle
#

they are using it incorrectly, and we cannot tell you why

umbral rock
#

it works tho so? i just want to understand what it does in this case? so he choses a min and max value, then he does the time.deltatime* speeddodge?

#

is this to determine his position in wich lane he is? because subway surfers has 3 lanes i guess?

languid spire
#

so Lerp is normally
current = min,max,t where t changes
what he is doing is
current = current, max, t where current is changing and t is static

umbral rock
#

ok yeah, thanks for that i now understand how it works but i still cant fully understand why he uses it? its somemthing used for moving the character i think? but why would he use that lol?

#

whats the thought behind that

#

because x will always be slightly different no? bcs the time.deltatime will constantly be slightly different

languid spire
#

basically to make a framerate indepentant value of x to modify the position by

languid spire
umbral rock
#

and not the time.deltatime? because thats not always the same right?

umbral rock
languid spire
umbral rock
languid spire
#

you adjust by framerate becauuse you do not want your movement to be fast on fast computers and slow on slow computers, you want it the same on both

umbral rock
#

aaah ok i know why he does it, so he moves the character the at the same speed always on every pc/phone etc... and the x value is always different based on how fast your computer is? but one thing i still not understand is, u say the value of lerp is always between 0,1 but time.deltatime * dodgespeed is always higher than 1 right? dodgespeed in this case is 10f

#

or is time.deltatime a really low number?

languid spire
#

no, it is always less than 1

umbral rock
#

huh? is it bcs time.deltatime is a number like 0.000....

#

or?

languid spire
#

think about deltatime on a pc running at 200FPS it is 1 / 200. On a phone running at 30FPS it is 1 / 30

umbral rock
#

aah and *10 it'll never be higher then 1

#

and if u have 1 fps (;

languid spire
#

your game is shit and no one will even play it

umbral rock
#

Lmao ok ok

#

thank u very much for the help, i appreciate it alot, i atleast know what it does and why he uses it

languid spire
#

As bawsi said, this is horrible code so don't take it as 'this is the way it should be done'

eternal needle
umbral rock
languid spire
umbral rock
errant pilot
eternal needle
vernal bone
#

hello
i need to make a "pause game" system for my game, looking for implementation
I'm trying to make all parts of the game to be dependant on internal "pause" flag, rather than using Time.timeScale.
Is it a good implementation, or is there another way? Because i feel like Time.timeScale may not be the best solution, because it can influence more than just gameplay i.e. menus and such

supple wasp
#

People how can I have this code?

short hazel
eternal needle
#

At the bare minimum you would have to recreate your own values for timescale, deltaTime, etc, just to have a simple working version. And even then you need to handle rigidbodies somehow

vernal bone
#

i understand that it can be bothersome, i just don't know how bad of a practice this is

eternal needle
#

Its an option on the animator

vernal bone
#

oh

upper tide
#

Do I have to initialize all variable default values like I would in C++ to avoid UB?

vernal bone
#

so using timeScale for a pause is, like, one of the best solutions?

upper tide
short hazel
upper tide
#

ayeay

strong harness
#

I have a problem, hit count is zero when the game is paused, time scale is set to zero but when the cursor position is on the gameobject and I resume the game and afterwards pause it again, it would be OK!

 var ray = _cameraCollection.Main.ScreenPointToRay(_inputController.CursorPosition);
            var hitCount = Physics2D.GetRayIntersectionNonAlloc(ray, _results, distance, layerMask);

It is in update routine.

I mean the problem is when the game is paused and I hover on a gameobject. It cannot return it but if I resume and pause, it is OK

eternal needle
eternal needle
vernal bone
upper tide
eternal needle
#

It's been too long since I've done c++, I dont remember tbh

upper tide
#

I shall google then

queen adder
#

put in editor folder, rightclick a script you wrote, and select autograb components, automatically fills any field for you :3 (if it thing is in the gameobject and/or child )

ivory bobcat
#

You mean component fields?

upper tide
#

How come I don't need to do the whole = new List<>... thing? I thought ref types were initialized null

eternal needle
eternal needle
upper tide
#

Ohhh that's what it means

ivory bobcat
#

Yeah, it wouldn't be nice for external dependencies (component references that would be from other objects)

upper tide
languid spire
queen adder
upper tide
ivory bobcat
#

I never use find ||- unless I'm writing code for others or am in need of mad automation||

upper tide
#

Also was wondering if there was a container in C# supporting both lifo and fifo

eternal needle
languid spire
queen adder
#

all find bad, with bytypes being worst

ivory bobcat
eternal needle
upper tide
languid spire
upper tide
dry tendon
#

Why is this not working??

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

public class ButtonActions : MonoBehaviour
{
[SerializeField] private UIDocument uiDocument;

void EnterFactory ()
{
    Debug.Log("Entering factory");
    
    VisualTreeAsset newAsset = Load<VisualTreeAsset>("UI/UXML Docs/GameHUD");

    if (newAsset != null)
    {
        uiDocument.visualTreeAsset = newAsset;
    }
    else
    {
        Debug.LogError("VisualTreeAsset not found at the specified path.");
    }
}

void MoreFactoryInfo ()
{
    Debug.Log("Opening more info screen");
}
    
void FactoryTutorial ()
{
    Debug.Log("Starting tutorial");
}

}

languid spire
#

also !code

eternal falconBOT
eager spindle
#

the name Load does not exist in the current context

dry tendon
languid spire
magic panther
eternal needle
magic panther
#

what do you mean

magic panther
#

im stupid

#

wrong variable

dry tendon
# languid spire your code will not even compile, fix that first

Better like this?

void EnterFactory ()
{
Debug.Log("Entering factory");

    VisualTreeAsset newAsset = Resources.Load<VisualTreeAsset>("UI/UXML Docs/GameHUD");

    if (newAsset != null)
    {
        uiDocument.visualTreeAsset = newAsset;
    }
    else
    {
        Debug.LogError("VisualTreeAsset not found at the specified path.");
    }
}

Sorry for the format... I'm just doing it on my mobile phone

eternal needle
#

Why are you coding on your phone?
Write it on your computer, then see if it compiles

dry tendon
#

No, no hehe, I dont have enough connection to open discord on my pc hehe, I already have opened unity there

ivory bobcat
languid spire
dry tendon
languid spire
eager spindle
#

oh nvm thats solved

languid spire
dry tendon
eager spindle
#

Resources.Load finds stuff in the Resources folder.

Calling Resources.LoadAll<Objective>("objectives") will go to Resources/objectives, find all objects that are objectives and return an array of it.

glossy turtle
#

ok havent seen the previous code nevermind.

languid spire
eager spindle
#

yep so in your Assets folder create this

#

then dump all your uxml files in there

glossy turtle
dry tendon
#

Thank you all, lemme take a look at docs and try it again πŸ™‚

dry tendon
#

I'll try to update the path

languid spire
dry tendon
#
    void EnterFactory ()
    {
        Debug.Log("Entering factory");
        
        VisualTreeAsset newAsset = Resources.Load<VisualTreeAsset>("Assets/Resources/GameHUD");

        if (newAsset != null)
        {
            uiDocument.visualTreeAsset = newAsset;
        }
        else
        {
            Debug.LogError("VisualTreeAsset not found at the specified path.");
        }
    }```
languid spire
#

you really did not read the Resources.Load docs did you

dry tendon
# languid spire you really did not read the Resources.Load docs did you

oh, my bad! is it like this? ```csharp
void EnterFactory ()
{
Debug.Log("Entering factory");

    VisualTreeAsset newAsset = Resources.Load<VisualTreeAsset>("GameHUD");

    if (newAsset != null)
    {
        uiDocument.visualTreeAsset = newAsset;
    }
    else
    {
        Debug.LogError("VisualTreeAsset not found at the specified path.");
    }
}```
languid spire
#

yes

dry tendon
# languid spire yes

then, how could i load the uxml from a different folder without using Resouces one?

languid spire
#

you cannot other than using an asset bundel or addressable

#

but you can have multiple Resources folders and they can have sub folders

dry tendon
languid spire
#

that depends on your use case, if the asset is included in the build then Resources.Load is your only option other than a direct reference

dry tendon
languid spire
#

no, you only want stuff in Resources that you will load with Resources.Load

dry tendon
languid spire
#

Or you make a folder Assets/UI/UIXML DOcs/Resources and move the stuff you want rto load into that

#

Resources does not have to be directly under Assets

dry tendon
#

That's definetly my answer πŸ™‚

#

And to load it it would be the same code?

languid spire
#

yes

dry tendon
#

And if I had two resources folder, how would unity know which one I'm refering to?

languid spire
#

Magic, just dont use the same asset name in multiple Resources folders

teal viper
languid spire
dry tendon
#

Lovely, so, thanks for you help! I'll read more docs before asking it here πŸ™‚

dry tendon
teal viper
#

Sadly, magic doesn't exist.

#

Santa doesn't exist either btw.

languid spire
#

wdym, I do it every day and, btw, you have not seen my beard, long and white

winter tinsel
#

i guess doing nothing for 364 days makes you acquire hobbies

bright oxide
#

hello, is it possible to bind button scaling to length of the text?

ripe shard
bright oxide
#

Thanks

queen adder
#

IBeginDragHandler, IDragHandler and IEndDragHandler acts like IPointerDownHandler, IPointerMoveHandler and IPointerUpHandler. Is it normal behaviour? I thought it should get called when there is a drag going on

silk night
queen adder
silk night
#

Hmm weird, have never seen one fire and the other doesnt, usually they dont work at all when there is a problem πŸ˜„

sweet sierra
#

Ik I asked this earlier but... kinda stuck. How can I access the Text Child of "CoinsAmount" button?

Finding and Accessing the ScoreCount child was easy because there was only one. But out of three buttons, I don't think I can easily reference the text inside the score

silk night
#

Just make a public field with TMP_Text as type and drag your Text Element into it in the inspector

delicate portal
#

With this piece of code I'm creating three lines in a triangle from the player, but...

#

Doesn't matter where the player is, it always points into one place

sweet sierra
#

I was doing that earlier but for every level, will that be "effective"?

#

For now I only have 6 levels though

silk night
#

You can create a level template that has the important stuff already linked and create copies or even prefab variants of it

sweet sierra
#

Interesting. Thank you! πŸ™Œ

keen needle
delicate portal
#

Why is Vector3.forward pointing down??

keen needle
#

probably for * 0.4

silk night
delicate portal
#

No, its just a wider radius

delicate portal
keen needle
#

What is he supposed to do?

delicate portal
#

Well, if the enemy is in the 'Defend' state, he'll go to one of the 3 line's end.

#

But this way, its just in 1 place

#

Added a vector that adds to the other, but its still in 1 place

keen needle
#

If you want it to move to where the line ends you can use SetDestination, but it will go straight

steep rose
#

use the actual player transform

delicate portal
delicate portal
steep rose
#

Player.Transform.forward

delicate portal
#

I use that

steep rose
#

not vector3.forward

delicate portal
steep rose
#

show me Hierarchy of player

#

what what it has on it

#

if the player doesnt rotate, the debug will never rotate with it

delicate portal
#

The rotation is good

steep rose
#

also check what player is in your code and check if is actually is a transform

delicate portal
#

It is I checked.

#

The problem is not with the rotation. It is with the position.

#

The lines should move with the player indicating its forward position.

steep rose
#

thats its direction

#

not position

delicate portal
#

But I might have to just add the player's position vector to the end?

steep rose
#

can i see the Hierarchy and not cropped out

delicate portal
steep rose
#

thats the inspector

delicate portal
#

I kind of got it

#

I made an offset indicating the player's position excluding y, and then adding it to the end position of the line

stiff abyss
wintry quarry
#

They're the same prefab presumably

#

and your code here is guarding against having more than one object spawned from the same prefab

wintry quarry
#

You're also modifying the prefab's rotation here which is a bad idea:

obj.transform.rotation = RandomRotation```
#

i.e.:

                GameObject instance = Instantiate(obj, SpawnPosition, obj.transform.rotation = RandomRotation);

Should change to:

                GameObject instance = Instantiate(obj, SpawnPosition, RandomRotation);
wintry quarry
#

if you want to actually track spawned objects per prefab you would need a Dictionary<GameObject, List<GameObject>> and then you could theoretically limit it to some number N of spawned obejcts per prefab if you want (with some additional code)

#

but right now your code is limiting to one object per prefab

fair thorn
#

guys how do i approach a big project that i want to replicate

rich adder
#

this is very vague

#

replicate what exactly?
also is it code? cause this is code channel

fair thorn
#

like i want to create a replica of a level from zelda

#

and i have a example small project in github that my guide sent me

#

for learning practically

rich adder
#

so whats the problem ?

fair thorn
#

I dont know where to start

#

its like what part should i focus first

#

cause like its hard to know where to start like what thing

rich adder
#

it really depends how much you know about unity & code

fair thorn
#

like the scripts

rich adder
#

making a game is no easy task , lots of different systems in play together

fair thorn
rich adder
#

break down bigger problems into smaller ones easier to solve

fair thorn
#

I know design patterns,codes,etc etc

#

yea i have tried breaking them down

#

its just where do i start

rich adder
fair thorn
#

form game manager or

#

player

fair thorn
rich adder
#

get things in motion you will worry less

fair thorn
#

aah okay

#

i will try to

#

i was confused in wheather to code the manager first

rich adder
#

thinking too much leads to "paralysis by analysis"

fair thorn
#

or the player

#

by i know

#

πŸ˜…

#

thats what happeninng to me

rich adder
#

when that happens to me I just start chipping at it , as πŸ§€ as that is, it works

#

starting anything at all gives your project "momentum"

#

from there to me just snowballs , I dont even think about it anymore and just churn out code

fair thorn
#

what you mean chipping

#

🀣

rich adder
fair thorn
#

yea i mean thats a good way of thinking

rocky canyon
#

well, subtractive art anyway.. for additive you could say the first glob of paint on the painting

ionic zephyr
#

Hi, I have a problem with my tools and weapons. All of my tools and weapons are SOΒ΄s which have different stats, however one of them is Durability. I want to know how to remove the object from my inventory whenever it breaks. The problem is that when I reduce de Durability counter with each hit, I am reducing the SO stat so I am facing the problem that I might have to create a new class of tool that has a durability float and add that specific class into a different List on the Inventory Manager, is there another way to solve this?

wintry quarry
#

And current durability doesn't belong on the SO but on a runtime instance

ionic zephyr
wintry quarry
#

No

#

Only max should be on the so

#

Current should be elsewhere

polar acorn
ionic zephyr
polar acorn
ionic zephyr
#

so I should have ToolData and Tool Object, ResourceData and ResourceObject for example?

#

even if they dont belong in the Overworld

polar acorn
#

It doesn't need to be a MonoBehaviour, but there should be a "Not ScriptableObject" class you can pass around and modify that represents that specific thing in the game

ionic zephyr
#

Okay, thanks a lot for this help

sweet sierra
#

Kinda new to coroutines and delays but... I can't see any delay even after this

sweet sierra
#

I just need a delay in the loop πŸ˜‚

#

So to kinda create an animation

rich adder
#

so you put the loop in the coroutine

#

Starting a Coroutine doesn't NOT delay the current function

sweet sierra
#

Like this?

rich adder
#

it starts an "async"-like function, as it runs "on the side" (technically isn't but its very fast)

rich adder
sweet sierra
#

Reading that rn

#

So... from what I've read sooo far... The coroutine repeats every X number of seconds or frames?

rich adder
#

right now it does the loop. Starts a new coroutine, waits for time and does nothing.

#

you're not using it correctly

sweet sierra
#

Quick Question... do coroutines run until stopped?

#

Or just once?

rich adder
#

they only run once unless you put an infinite loop inside

#

(one that doesn't hang)

rough hill
#

My character is doing some crazy stuff when moving towards the camera. I am using cinemachine but how is the character blocked by the camera?

sweet sierra
#

Ok ok. I'll read more the doc and then implement it. Thank you sooo much!

rich adder
#

they are a bit more practical

sweet sierra
#

Got it

#

Oohh yess... I can see the difference

rich adder
prisma salmon
#

Hey guys! I want to make a top-down 2D world map like you're playing Risk or something that lets you select individual parts of nations on a map, but I can't find any tutorials that teach me how to make something like that. I'm an absolute noob at game coding so any help/tutorials you could send would be really appreciated

#

World Map Strategy Kit 2 is the closest thing to what I'm looking for, but I don't have 100 dollars to spend and I want to make everything myself if possible.

rocky canyon
#

you can use OnMouse events to detect for clicks and stuff on 2d sprites for example..

#

just need to create some buttons that look like different pieces of the level

rich adder
#

can also raycast onto a texture to find exact coordinate you're on , match the color to specific regions or something like that

#

maybe use SVGs for the shapes?

rocky canyon
#

yeap, could do that.

worthy tundra
#

gonna make my first ever FSM, wish me luck

rough hill
languid spire
rocky canyon
worthy tundra
# rocky canyon good luck

gonna keep it simple:
one FMS "brain" script that can change between states, let other scripts inherit from it, and one state template script which is going to be a scriptable object, other states can inherit from it

prisma salmon
#

Thanks, guys- I also found a good tutorial, too

sweet sierra
rocky canyon
#

you mean the tweening UI elements or the player animation? the playeranimation is glitchy..

rich adder
rocky canyon
sweet sierra
rocky canyon
#

its just missing a keyframe or so it appears

#

the loop back to the start is glitching

rich adder
#

yeah player animations needs bit of work, maybe copy the last frames and invert them

rocky canyon
#

it should be really close to instant.. (players hate waiting for stuff for no reason)

rough hill
sweet sierra
rocky canyon
#

most button type animations should be between 100-500ms good rule of thumb

#

almost instant.. but not exactly

rocky canyon
#

i tend to use AngleAxis alot for things like cameras

worthy tundra
slender nymph
#

This isn't really about the code itself, but it is FSM not FMS, Finite State Machine.

keen dew
#

Finite Mate Stachine

worthy tundra
eager spindle
#

finite at freddy

mystic dawn
#

Hello there! has anyone worked with custom css and html for itch.io pages before? im looking to ask about adding some custom html classes or id to edit specific elements in my pages, has anyone done some of this before?

rich adder
mystic dawn
#

oh sorry is there a channel for game page related stuff?

slender nymph
#

closest would be #1157336089242112090
but you're more likely to get a response in a more general game dev server or somewhere specific to web dev/html+css

mystic dawn
#

yeah i guess something like web related servers would be useful! haha there's really not much documentation on itch page customization from what i've searched

steel hull
#

real simple question why do we multiply the sensitivity with time.deltatime when making a mouse looking function

slender nymph
#

you're not supposed to. people teaching you to do that are wrong because mouse input is already frame rate independent

steel hull
#

I knew it

#

thank you all

#

one more question tho

#

what are quaternions

#

I've been trying to find that out for tha past 3 hours

slender nymph
#

it's a 4 axis structure to represent complex rotations. you don't really need to understand them, there are helper functions that let you use euler angles which are the angles you are already familiar with

steel hull
#

thankss

wintry quarry
#

just like a Color is a data type that holds a color

#

Quaternion would have been better named in the API as "Rotation" simply

slender nymph
#

I feel like if they'd done that there would be even more people improperly using their members as euler angles. at least with the data type being called quaternion it's easier to look up what they actually are and see that they are not expressed in euler angles so fewer people abuse them

wintry quarry
#

I feel like it's hard for that to happen more than it doesnow

worthy tundra
eager spindle
worthy tundra
#

whereas with quaternion, beginners can look it up and see this image, realize that its something more complex that they should tackle once they have more experience

eager spindle
#

netlify/vercel lets you deploy your unity app quickly as it doesnt have a size limit, you can then embed the netlify/vercel PWA into a github page

#

that's how im doing it rn

#

would never pay for netlify/vercel but they're a good free option ig

mystic dawn
eager spindle
#

are you able to embed a custom page into itch?

#

if so embedding a custom github page could work out

steel hull
#

I just installed unity

#

please

rocky canyon
wintry quarry
eager spindle
wintry quarry
#

and it's easy

eager spindle
#

i posted a visualisation of each type of rotations a while back give me a sec

steel hull
slender nymph
wintry quarry
#

People scare beginners away with the "4 dimensional" nonsense and really Quaternions are easy when you just ignore that stuff

#

and use the API

worthy tundra
half egret
rocky canyon
#

i think everyone besides math majors.. just use quaternions..

#

don't need to understand em to use em lol

mint remnant
#

Go look up quaternions and transformations from a 1977 PDF from NASA, there's like 12 different matricies to create a quaternion πŸ˜›

half egret
#

Honestly when it comes to quaternions, I just tell people to get a basic understanding of gimbal lock and that's it

#

There are a lot of handy visualizations out there

rocky canyon
steel hull
#

what does clamp exactly do like limit?

wintry quarry
#

it returns a value between the clamp min and max

rocky canyon
#

returns a number closets to teh limit it falls in

steel hull
#

oh so if its over the max it returns the max

wintry quarry
#

yes

steel hull
#

right?

#

nicee thanks

eager spindle
#
float Clamp(float value, float min, float max) {
  if(value < min) return min;
  if(value > max) return max;
  return value
}
#

minor spelling mistake

steel hull
#

I am learning πŸ˜„

steel hull
#

Its easy for me to understand most of these because I was originally a roblox developer but I feel like unity is much better

#

not to reach users but in any other way

rocky canyon
#

lol, unity is a game engine

#

roblox is a game πŸ˜›

steel hull
steel hull