#💻┃code-beginner

1 messages · Page 438 of 1

elder kite
#

Yep

#

Still doesn’t work

worthy vault
#

hi

dry igloo
#

I have a question about deltaTime, just to make sure I got it right :
I should multiply a speed by deltaTime
but I shouldn't multiply a jump force by deltaTime

is that correct ?

languid spire
dry igloo
ionic zephyr
#

Hy guys, why is my UI disordered when I enter maximized screen?

languid spire
muted narwhal
#

How'd I get cursor position? I tried
var mouseWorldPosition = Camera.main.ScreenToWorldPoint(Mouse.current.position.ReadValue());, but that isn't working

ionic zephyr
#

Does it have to do with the canvas scaler?

marble hemlock
#

i think this goes here?
do objects from blender automatically have a collider or do i have to set that up?

languid spire
#

and, no, it is not a code question

marble hemlock
#

oh

#

which channel is best

languid spire
marble hemlock
#

thank you

muted narwhal
primal aurora
#

thats how you do it with the old input system

stark girder
#
public class HandIKCrawlSolver : MonoBehaviour
{
    [SerializeField]
    private Transform body;
    [SerializeField]
    private float footPacing;

    private Vector3 newPos;

    [SerializeField]
    private LayerMask isGround;
    // Update is called once per frame
    void Update()
    {
        Ray ray = new Ray(transform.position,Vector3.down);
        if (Physics.Raycast(ray, out RaycastHit hitInfo, 10, isGround))
        {
            if ((transform.position - hitInfo.point).magnitude >= footPacing)
            {
                transform.position = hitInfo.point;
                newPos = hitInfo.point;
            }
            Debug.Log(hitInfo.point);
        }
    }
}```
I want to make it look like crawling but cant figure out how to fix the hand to the ground before next step
muted narwhal
#

It's supposed to place item GO on cursor's position, but it's just goes to somewhere in the corner

wintry quarry
#

You mean Debug.Log?

muted narwhal
#

A custom class and method of mine

wintry quarry
#

Anyway world position and canvas position aren't the same thing, under most circumstances

#

What are the canvas settings

#

And what are the settings for the parent

muted narwhal
wintry quarry
#

World space isn't involved

hushed hinge
muted narwhal
zenith cypress
muted narwhal
#

Already tried ScreenToWorldPoint

#

still the same situation

zenith cypress
#

You didn't give it a z depth

muted narwhal
#

oh?

zenith cypress
#

Look at the doc example

muted narwhal
#

already tried like that.

#

still same

polar acorn
# muted narwhal already tried like that.

Let's try getting a bit more info:

Vector3 screnPoint = new Vector3(mousePos.x, mousePos.y, Camera.main.nearClipPlane));
Vector3 worldPoint = Camera.main.ScreenToWorldPoint(screenPoint);
Debug.Log($"Translating screen point for camera at {Camera.main.transform.position} - Screen Point: {screenPoint} - World Point {worldPoint}");
muted narwhal
#

Looks like there's something with this line

#

(don't mind that's it commented)

#

Without this line it's actually works more promising

#

I'm not sure what's wrong tho?

eternal falconBOT
muted narwhal
hushed hinge
cosmic quail
polar acorn
cosmic quail
#

oh 😵‍💫

hushed hinge
# cosmic quail damn thats a long thread. whats the question?

well they said that the issue is writting (new data) that creating a new one with no data and loading a value from it, since i am having a problem with it that saving the number of the ui text from the level select scene to make a number go up, and i need to do something that LoadData are being called

primal trench
#

how would i split a string at a specifc character index instead of a character
like for example
instead of
split at a
it's
split at character 5

rich adder
#

strings are just array of chars

#

so use index

primal trench
rich adder
cosmic quail
hushed hinge
#

at first the numbers worked before that a number changes up when i touched a muon object, but not anymore after this

steel stirrup
#

You need to separate out your UI code from your backend

rich adder
#

thats because its a combination of different people they pasted code together from

cosmic quail
rich adder
#

they refuse to actually go back n redo it properly, they rather just scotch taping it together

steel stirrup
#

The only things that are lost on scene load (assuming non-additive and not using DontDestroyOnLoad) are monobehaviors

#

So just store your game state in a regular c# object

#

and use monos to display it in the appropriate scene

rich adder
#

"how do i do that"

#

yea goodluck with that one

summer stump
#

If all monobehaviours that reference the poco are destroyed, it will be gc'd
Where do you propose to reference the poco if not using additive or ddol?

rich adder
#

You need a mono to run a poco constructor anywhere..

#

if the class is static thats another thing (but those dont have constructors so)

steel stirrup
polar acorn
cosmic quail
#

oh ok

steel stirrup
#

You probably have a scene (or rolled into splash) where you load the first sets of assets that you need, just initialize things then

steel stirrup
#

also [runtimeinitializeonload]

summer stump
rich adder
#

completely unrelated to OPs issue though

steel stirrup
summer stump
#

Unless you want to spend the couple weeks holding their hand getting them set up for it

steel stirrup
#

I'm just very confused by the idea that you need to use monobehaviors to store data

#

That's absolutely insane to me

rich adder
steel stirrup
rich adder
#

you don't need to use MB to store anything , no one is saying that

rich adder
summer stump
steel stirrup
#

I really do not get the logic in your initial statement

summer stump
rich adder
#

you're going off on some other shit

steel stirrup
rich adder
summer stump
hushed hinge
summer stump
hushed hinge
#

oh

muted narwhal
#

When instantiating an object, it has really small size in rect transform (can't even see it), compared to original GO. How can I fix that?

rich adder
muted narwhal
#

it's the same size as canvas

hushed hinge
# hushed hinge oh

the text worked before with changing the nnumber up, but ever since the instance... the number doesn't change up anymore, and i did showed in a recent screenshot in the thread...

rich adder
#

you should def not want that

muted narwhal
#

What's the problem?

rich adder
#

canvas isn't at scale 1,1,1 is it..

muted narwhal
#

it is

primal trench
#

hey dumb questin, what does .Clone do?

rich adder
#

_dragParent

polar acorn
steel stirrup
muted narwhal
primal trench
muted narwhal
#

size of it isn't changing

muted narwhal
#

only width and height

#

what's the problem?

steel stirrup
analog moon
#

can someone help me out

steel stirrup
hushed hinge
steel stirrup
analog moon
rich adder
#

that is not the problem @hushed hinge

#

You're running a method you're not supposed to inside the initilizer

steel stirrup
# analog moon what is that?

you have an array of menu objects, show your menu class since all of the errors are from trying to access things in that class

muted narwhal
#

I think I know how to fix it?

hushed hinge
wintry quarry
muted narwhal
#

what anchoring has to weight and height wtf

#

I've already setted it up

analog moon
#

@steel stirrup this is my menu scrpt

rich adder
steel stirrup
#

your array is Menu[]

#

that class is menu

rich adder
analog moon
#

ohhhh

steel stirrup
#

yeah look at the top of your menumanager script

#

youre using unityeditor

#

because that's probably

analog moon
#

thanks tho

hushed hinge
hushed hinge
#

and counter seems to be not calling muoncounter since i've jsut the debug.log for it
like
if (muonCounter == null)
{
Debug.LogError("MuonCounter not being found");
}
else
{
muonCounter.UpdateText();
Debug.Log("number go up");
}

ever since the instance...

signal owl
wintry quarry
#

also any other errors

#

that's just an "AggregateException" which is a grouping of other errors

#

without showign the full message we can't tell anything

signal owl
#

Sorry mate, thats the full one

rich adder
wintry quarry
ionic zephyr
#

why do the objects in my UI get desorganized when I maximize screen?

wintry quarry
steel stirrup
wintry quarry
#

it won't be an error

#

just a normal log

signal owl
#

thats what i see

rich adder
#

ahh firebase..

wintry quarry
#

do you have logs hidden? (Can't tell because I can't see the top right of your console)

signal owl
#

these?

#

Sorry im new to Unity

wintry quarry
#

You can add a Debug.Log($"The error type is {authError}");

#

that may help a little

signal owl
#

Sec

#

Is that a command to get more knowledge about errors in unity?

wintry quarry
#

if it's just an internal exception on their server side then you should reach out to google - that indicates a problem on their server

wintry quarry
#

printing the error code

#

it's not anything to do with Unity other than the use of Debug.Log

#

Just printing the result of this which is in your code already
AuthError authError = (AuthError)firebaseException.ErrorCode;

rich adder
#

Firebase is crap, the unity integration sucks
go with Mongo or even Unity's own storage is getting good

signal owl
hushed hinge
signal owl
#

So you say i should switch to another one?

rich adder
paper sable
#

my player only jumps if my jump force is a big value, why does it do that? this is my jump code

private void Jump(InputAction.CallbackContext ctx) {
        if (jumpsLeft > 0) {
            rb.velocity = Vector3.zero;
            
            rb.AddForce(Vector3.up * jumpForce);
            
            jumpsLeft--;
            jumpTimer = 0;
        }
    }
signal owl
#

is mongodb easier to setup

rich adder
#

I can tell you even Mongodb has proper drivers for Unity

#

Unity has its own solution also called Unity Cloud Save

summer stump
glad rune
#

anyone knows why it only displays 3 and 1. supposed to also show 2. when i try it with countdown on 6 it goes 6,4,2,1

#
{
    StartCoroutine(CountdownUI());
}

IEnumerator CountdownUI()
{
    while (Countdown > 0)
    {
        CountdownText.text = Countdown.ToString();
        yield return new WaitForSeconds(1f);
        Countdown -= 1;
    }

    yield return new WaitForSeconds(1f);
    logic.CountdownFin();


}
eternal falconBOT
summer stump
glad rune
#

nope

#

just set it to 3

hushed hinge
summer stump
#

That has nothing to do with the issue

primal trench
#

how would i get a component of a object by index?

summer stump
signal owl
#

@rich adder Do your maybe have a tutorial on how to setup Mongo or Unitys db, or how to create the authentication

primal trench
steel stirrup
summer stump
hushed hinge
paper sable
steel stirrup
#

someone should add dark mode to the tutorial

summer stump
hushed hinge
#

idk, sometimes when i am getting anxious about something, i couldn't think clearly on what Im' doing...

rich adder
gentle vortex
#

how and why did this randomly start appearing

steel stirrup
wintry quarry
hushed hinge
summer stump
summer stump
primal trench
summer stump
#

Not using the way I wrote it
There is another overload that does, but I prefer the generic overload (and you should too)

gentle vortex
#

yeah thanks chat

rich adder
polar acorn
hushed hinge
primal trench
#

huh?

#

im using the generic version

summer stump
#

That is not the generic version

wintry quarry
polar acorn
#

It's not a parameter, it's a type

primal trench
#

oh im stuopid]

#

sorry

polar acorn
#

first example, not second

primal trench
#

i read to fast and skipped the parenthesis and <>

#

im dumb >_<

#

sorry!

summer stump
#

Don't call yourself dumb

rich adder
summer stump
#

For one, it is SUPER annoying when people do that.
For two, you are just learning

primal trench
#

i dont like being annoying

hushed hinge
rich adder
# signal owl On your youtube channel?

for Unity Cloud Save yeah the older one, Trying to cover the new addition they did now you can save General data as well (gamedata) not just player data with C# (before it was only JS)

#

what are you looking to store exactly ?

signal owl
#

First of all, everything for authentification, then character data, like gold, hp, dmg, stats and stuff

#

rpg game

rich adder
#

well auth goes without saying when storing to db..

#

the auth is really easy to get goin in unity

#

email / password or just oAuth like google/ apple etc.

rich adder
#

then yes go with Unity cloud save

signal owl
#

Alright thanks, i will do so

signal owl
#

Ah thanks

gentle vortex
#

using your usual first person capsule character (and capsule collider), how can i get the angle of collision between said collider and the floor/sloop bellow

wintry quarry
#

every game is different

#

it would be more productive to show us your setup

gentle vortex
#

no the capsule is the usual thing here not the player
give me a second

wintry quarry
gentle vortex
#

alright

#

oh just to make sure im not being stupid, "normal" here refers to a vector3 with those -1 to 1 angles for multiplying with other vectors

wintry quarry
#

You're thinking of Quaternions probably?

gentle vortex
#

oh right

#

why did i decide to move my project from godot to unity

wintry quarry
#

No idea but normal vectors would be a concept in any game engine

#

Vector math is common to all game dev

rich adder
#

facts! thank you quake modding and source engine for teaching this valuable lesson

wintry quarry
#

Maybe with the notable exception of text based adventures on DOS

languid spire
rich adder
#

🧑‍✈️

narrow matrix
#

soooo hi all!!! anyone got that easy guide for setting neovim as your editor in unity on linux (popos)?

rich adder
#

also not really a coding question , more of a niche thing

summer stump
narrow matrix
# rich adder google

yup been doing that one all morning. thanks. can you suggest a better channel?

rich adder
languid spire
rich adder
#

VScode is fine on linux works great

#

I use it on Mint

narrow matrix
summer stump
#

Please stop.

#

We get it

rich adder
#

you dont have to fiddle with omnisharp anymore since the Unity plugin came out

narrow matrix
narrow matrix
#

yup been there

#

don't sweat it @rich adder i retract my question

rich adder
#

cool. best of luck mate

cedar zenith
#

Hey guys, I was wondering if anyone here could help me out with an issue or is this the wrong channel?

topaz ice
cedar zenith
#

Well, basically I was following a tutorial I saw online on making a 2d game but now my projectile attacks no longer show up(they’re invisible)

topaz ice
#

I'm pretty much "new" to unity, So I can't quite help, But I'm just waiting for everyone to finish thier own things

patent junco
#

I tried almost everything but I couldn't figure it out, can you help me?

wintry quarry
topaz ice
eager spindle
cedar zenith
cedar zenith
topaz ice
cedar zenith
topaz ice
#

alr

cedar zenith
#

In part 8 he showed the fix needed but when I tried that it didn’t work

topaz ice
#

I skipped around and all I saw was him making a chainsaw and changing the layers

topaz ice
#

in there

#

I reccomend check that out (maybe)

cedar zenith
#

The thing is that the attack projectiles are in my hierarchy as prefabs, layer set as foreground and everything necessary from the video

#

But still isn’t working

#

😭

topaz ice
#

like don't set the projectiles user layers 6 and the background 7

#

I dunno just making numbers

cedar zenith
#

According to the tutorial, I set the layer to foreground

#

Which should mean it’s above whatever I set as the background

#

I even tried removing said background but it’s still invisible

topaz ice
#

In this episode we'll add invulnerability frames to our health system after the player takes damage and fix a couple issues as well.

➤ Starting Project: https://github.com/nickbota/Unity-Platformer-Episode-7
➤ Complete Project: https://github.com/nickbota/Unity-Platformer-Episode-8

Consider supporting the channel on Patreon:
➤ Patreon: https:/...

▶ Play video
topaz ice
#

(on the chainsaw)

cedar zenith
#

Ah. We are talking about the fireballs right?

topaz ice
ionic zephyr
#

I dont get what the anchors have to do with my UI moving wherever it wants when maximized screen

rich adder
#

also not a code question

cedar zenith
topaz ice
#

to enable it

cedar zenith
topaz ice
cedar zenith
# topaz ice

So I tried ticking it but when I press play, it just I ticks

cedar zenith
#

Checking the box I mean

#

Like ✔️

topaz ice
#

AFK doggys begging for food

topaz ice
#

back

topaz ice
#

Check if its on in Inspector

cedar zenith
topaz ice
rich adder
topaz ice
cedar zenith
# topaz ice Its off

When I turn it on and press play, it just for whatever reason turns off automatically

cedar zenith
rich adder
#

then you have a script doing it

topaz ice
cedar zenith
rich adder
#

you have a reference to that ? thats the only way it would turn off by itself in playmode

cedar zenith
#

I’m new to the whole unity thing so I have no idea if I’m going to be honest 😓

#

Anyone know how I can like, make it not a prefab?

#

Was working fine when it wasn’t a prefab tbh

topaz ice
#

like someone made it for you before, Or you followed a tutorial 1-1 in every way

cedar zenith
#

Well I made the assets and animations and scripts myself. It only turned into a prefab after I put it in some folder

rich adder
#

oh maybe its not a prefab and the icon just looks different on light mode

#

usually its not filled

cedar zenith
#

Right lemme change to dark mode

cedar zenith
rich adder
topaz ice
topaz ice
cedar zenith
topaz ice
cedar zenith
rich adder
#

but the icon was dead give away

topaz ice
rich adder
hushed hinge
#

as long imma make art designs for my game to take a tiny break from it

topaz ice
cedar zenith
topaz ice
cedar zenith
#

It……doesn’t work

rich adder
topaz ice
rich adder
#

just make sure check mark is on.

round mirage
#

Why my bool variable animation end dont change (my variable is public , for call the function i use the event key in the animator)

eternal falconBOT
rich adder
#

you were told already how to share code @round mirage

round mirage
#

ohhh

cedar zenith
topaz ice
#

@cedar zenith do you think you'll get this problem as a core memory that you wont mess up again when you learn what the problem was?

topaz ice
round mirage
#
      {
        PlayerAnim.SetBool("isDrinking", true);
        StartCoroutine(DrinkTime());
      } 
rich adder
#

show that one

cedar zenith
rich adder
cedar zenith
topaz ice
round mirage
#
    {
        animationEnd = true;
        StartCoroutine(EndTimer());   
    }
    IEnumerator EndTimer()
    {
        yield return new WaitForSeconds(2);
        animationEnd = false;
    }
topaz ice
#

turn it on enemy lol

#

I dunno I'd rather just give you to enemy

#

it wasn't that. but still

rich adder
cedar zenith
round mirage
hushed hinge
topaz ice
rich adder
cedar zenith
#

I’m just gonna make a enemy layer then brb

#

I’M NEVER TOUCHING THIS SOFTWARE AGAIN AFTER MY ASSIGNMENT

topaz ice
rich adder
#

you still havent explained the original issue

cedar zenith
hushed hinge
rich adder
cedar zenith
cedar zenith
topaz ice
# hushed hinge i don't get about you saying using it as an escape?

Well I'm stupid when I make games and I can't make anything a habit, I always accidently find work arounds of starting habits, and one of them was to just do anything else but scripting, until I just didn't have anything left but to script it, and cancelled the whole thing cuz... skill issue.

round mirage
#

at the end of my animation the animation event is supposed to start and then set animation end on true my coroutine start wait 2 seconds and set animation end to false (when animation end is set to true i cant play again my animation)

cedar zenith
#

Thanks @rich adder and @topaz ice for your help

topaz ice
#

aw

topaz ice
cedar zenith
#

😭

fossil ether
#

does anybody know some resources that talk about procedurally animated spiders? I have a working procedurally animated spider but it gets messed up when i try to make it walk on surfaces with steep slopes.

I think I need to cast some horizontal rays to check for obstacles in front since I'm only casting downwards rays from above every foot but I'm not sure what to do

hushed hinge
topaz ice
rich adder
eternal falconBOT
gentle vortex
#

so i made this to make my player interact with slopes properly, as in; gaining upward momentum from quick movement up a slope, but it has it's jank, movedir.y still increases while going down and the player doesn't stick to the slope, any ways to fix that (or another way to do what this code does)? i can't think of any

cedar zenith
round mirage
rich adder
topaz ice
# fossil ether does anybody know some resources that talk about procedurally animated spiders? ...

you're reminding me of this video

It has something that moves fast like a spider and its also procedurally animated in some sort of way.
If thats what you meant you could check it out

https://www.youtube.com/watch?v=KPoeNZZ6H4s

It's been a while since the last video hasn't it? I've made quite a bit of progress since the last update, and since one of the things I worked on was some procedurally animated characters, I decided to make a video about the subject. In particular, this video highlights the entire process from initial motivation, to the technical design, techni...

▶ Play video
#

not a tutorial

#

but he talks alot about the math

fossil ether
fossil ether
rich adder
topaz ice
#

or smth

fossil ether
#

ah alright

topaz ice
#

anyway after like idk 1 hour I can ask about my problem lol-

#

float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;

Debug.Log(mouseX);

Constantly prints 0 and maybe goes up a very small bit. (for 1 messege)
Is it like a project setting problem or something?

I also do
Cursor.visible = false;
Not sure if it'll do anything though.

MouseY works. fine.

#

I'm making a first person thing...

#

and its only detecting the mouseY not mouseX

rich adder
round mirage
# rich adder this isnt the whole script
{
    private Outline outline;
    private Rigidbody Potionrb;
    private Animator PlayerAnim;
    private GameObject Player;
    private GameObject Parent;
    private GameObject Hand;
    private TextMeshProUGUI PickUptxt;
    public float distanceFromPlayer;
    private GameManager gameManager;
    private bool Near = false;
    private bool CanTake = false;
    public bool InHand = false;
    private BoxCollider PotionCollide;
    private PlayPop playPop;
    public Vector3 PotionPos;
    void Start()
    {
        gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
        Parent = GameObject.Find("ParentOfEntities");
        Hand = GameObject.Find("Hand");
        PotionCollide = GetComponent<BoxCollider>();
        Potionrb = GetComponent<Rigidbody>();
        Player = GameObject.Find("Player");
        playPop = Player.GetComponent<PlayPop>();
        PlayerAnim = Player.GetComponent<Animator>();
        outline = GetComponent<Outline>();
        outline.enabled = false;
        PickUptxt = GameObject.Find("PickUpTXT").GetComponent<TextMeshProUGUI>();
    }
    void Update()
    {
        if (Hand.transform.childCount > 1)
        {
           gameManager.ManageTake = true;
            InHand = false;
            Potionrb.isKinematic = false;
            PotionCollide.enabled = true;
            gameObject.transform.SetParent(Parent.transform, true);
        }
        ```
topaz ice
rich adder
#

Mouse is already frameRate independent

round mirage
#
      {
        PlayerAnim.SetBool("isDrinking", true);
        StartCoroutine(DrinkTime());
      }
        distanceFromPlayer = Vector3.Distance(gameObject.transform.position, Player.transform.position);
        if (distanceFromPlayer < 4.5f)
        {
          Near = true;
        }
        else
        {
            Near = false;
        }
        if (Input.GetKeyDown(KeyCode.E) && CanTake && gameManager.ManageTake == true)
        {
            gameManager.ManageTake = false;
            InHand = true;
            PlayerAnim.SetBool("isHolding", true);
        }
        
        if (InHand)
        {
            PotionCollide.enabled = false;
            Potionrb.isKinematic = true;
            gameObject.transform.rotation = Parent.transform.rotation;
            gameObject.transform.position = Hand.transform.position;
            gameObject.transform.SetParent(Hand.transform, true);
        }
        else
        {
            gameManager.ManageTake = true;
            InHand = false;
            Potionrb.isKinematic = false;
            PotionCollide.enabled = true;
            gameObject.transform.SetParent(Parent.transform, true);
        }

       ```
rich adder
#

its not that difficult to understand the basic instructions

round mirage
#

ok

fossil ether
#

bro just sent the entire project code through discord chat lol

rich adder
#

I bet they're gonna keep it up and send the link instead of editing the messages

plucky moss
#

how do I make it that when the vent is enabled the boolean is on (what I have now) but when I press E again it disables and the boolean gets set to off?

#

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

public class freezebutton : MonoBehaviour
{
public GameObject vent;
public GameObject UI;
public bool ventOn;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void OnTriggerStay(Collider other)
{
    if(other.tag == ("Player"))
    {
        if(Input.GetKey(KeyCode.E))
        {
            vent.SetActive(true);
            ventOn = true;
        }
    }
}

}

#

this is what I have so far

eternal falconBOT
rich adder
#

use Links for large code

plucky moss
#

I'm sorry

round mirage
plucky moss
topaz ice
rich adder
plucky moss
#

gulp

topaz ice
#

Also about my problem, I'm just gonna... refollow the script

#

exactly 1-1

rich adder
languid spire
#

nothing there sets ventOn to false

plucky moss
#

ik thats what im tryna find out

round mirage
gentle vortex
#

made this to make my player interact with slopes, as in; gaining upward momentum from quick movement up a slope, but it has it's jank, it still increases while going down a slope and the player doesn't exactly stick to the slope, any ways to fix that (or another way to do what this code does)? i can't think of any
quickly going to point out that i do know why this is happening

languid spire
topaz ice
#

Its reaching. The last part (most important part) has debug.Log() printing the mouseX (which I removed the deltatime), And its constantly printing 0

rich adder
#

myb

rich adder
round mirage
topaz ice
#

Back! And I can complain more now!

#

Did the channel just die for no reason

#

He used End() on everyone ;-;

hushed hinge
rich adder
rich adder
#

why even make a static Instance if you're gonna use FindObjectOfType

#

or have a reference at all..

#

as it was told to you already .
I think you're confusing the Instance name you gave there, with what an Instance of something is

pine furnace
#

It s ok to write my input code inside fixed update?

hollow karma
#

sorry I have a question about (Debug.Log) ,it doesn't work.Can anybody help me?thanks.

rocky canyon
#

add one more.. before the if statement Debug.Log("Make sure the Collision is registered");

#

and then go from there..

#

if u get that log and not the others.. then ur tags are messed up.. and CompareTag("TagName"): is better than gameobject.tag

polar acorn
pine furnace
#

I saw someone on youtube do it inside fixedupdate

#

And it looked wrong

rocky canyon
#

ohh thats right.. OnCollisionEnter.. only happens when u enter the triggeer.. ud have time the Keypress to be perfect for it to work

polar acorn
rocky canyon
#

you'll never be able to use the input like that

primal trench
#

ok so ive been trying to figure this out for like an hour now
i have this:
SpeakerLib[CurrentDialogueFileIndex].ToString()
which prints as
!
when i do
print("!" != "!")
it prints as false
but when i do
print(SpeakerLin[CurrentDialogueFileIndex].ToString()```

#

it prints as true

rich adder
polar acorn
primal trench
pine furnace
hollow karma
polar acorn
primal trench
polar acorn
polar acorn
# primal trench

Change your log:

Debug.Log($"[{SpeakerLib[CurrentDialogueFileIndex].ToString()}], length: {SpeakerLib[CurrentDialogueFileIndex].ToString().Length}");
hushed hinge
#

but he gave it a thumbs up in the screenshot

#

should i remove
muonCounter = FindObjectOfType<MuonCounter>();?

polar acorn
#

You have a carriage return in your string

primal trench
polar acorn
#

two characters so that there's a line break regardless of which OS is viewing it

primal trench
polar acorn
#

That's why there's three characters in the string

primal trench
#

is there a way to write that as a string?

polar acorn
#

.Trim()

#

Remove whitespace

primal trench
#

so i'd do

#

SpeakerLib[CurrentDialogueFileIndex].ToString().Trim()

polar acorn
#

That should work. Pretty sure C# trim gets rid of newline characters

primal trench
#

let's see

polar acorn
#

Make sure you add the trim to the debug log to see if it's properly removing it

rich adder
hushed hinge
rich adder
#

but yes you are blindly copy and pasting and this will happen until you learn to apply a bit of your own critical thinking to what you're trying to accomplish

primal trench
hushed hinge
# rich adder if you already using MuonCounter static Instance there is literally no point of ...

if i remove private MuonCounter muonCounter; then the underline with the muonCounter in
if (muonCounter == null)
{
Debug.LogError("MuonCounter not being found");
}
else
{
MuonCounter.Instance.UpdateText();
Debug.Log("number go up");
}

would have a red underline, and even if i remove that and keep MuonCounter.Instance.UpdateText(); it would be an error when i start the gaem and go in a stage scene, wouldn't it?

...imma try

stark perch
#

@rich adder can you help me with that code

rich adder
#

people use the physics no friction material but I think its a poor band aid, good way to fix it just raycasting and making sure you are not blocked when moving forward otherwise dont apply velocity that way

rich adder
#

why even null check on something you dont need

hushed hinge
#

yes

rich adder
#

Instance is assigned in the other script you dont need to null check the field

#

just dont call this before that assigment in awake/start

#
if(MuonCounter.Instance)
MuonCounter.Instance.UpdateText();``` at most..
#

and even thats overkill..if you have good design these arent generally needed

stark perch
#

i thi good

rich adder
stark perch
#

now you jsut can't moe when you're grounded

rich adder
#

dont apply velocity if you're blocked

#

same check you do for grounded you do it for infront of you

#

also why are yuo only moving horizontal if not grounded.

stark perch
#

it's not just if stuff is infront of you, literally if i just jump with nothing around me i go into the ground and then get placed back

rich adder
hushed hinge
rich adder
#

also why are you manually applying gravity that way

rich adder
hushed hinge
rich adder
#

like I said its totally overkill but thats what you would check if you changed the original if statement from field you had

#

get it?

#

Instance is the script already

hushed hinge
rich adder
#

if you already did it then verify it works

hushed hinge
#

well.... i don't know if it works since the number is still not changing up when i touched a muon gameobjecti in the other scene

hushed hinge
stark perch
#

@rich adder i changed it to using unity's default gravity but it's still happening

stark perch
#

why is it going into the ground

rich adder
hushed hinge
rich adder
hushed hinge
#

i just wanted that the counter number can be able to go up when you touch a muon object and not staying at 0, especially when you exit the game

stark perch
rich adder
#

you just end up writing a lot of spaghetti code because you just copy and pasting everyones code

rich adder
#

or do jump with AddForce instead of .velocity
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);

#

i never used .velocity for jump so idk

polar acorn
# hushed hinge i just wanted that the counter number can be able to go up when you touch a muon...

This is the last I'm going to give you so pay close attention.

  1. Create a Singleton that has variables for the counters.
  2. Your UI should reference the instance of the singleton to know what number to display.
  3. Whenever you touch a "muon object", increase that variable in the singleton instance.
  4. Whenever you need to save or load, write those variables to disk or read them back to change the variables on the singleton instance.

This is the entire process. Boom. Scene-persisting saveable data.

Learn the pros & cons of using singletons in Unity, and decide for yourself if they can help you to develop your game more easily.

stark perch
#

neither works

rich adder
stark perch
#

both things yo uwrote

#

continous or force doesn't work

rich adder
stark perch
#

ForceMode@D

#

rb.AddForce(Vector3.up * jumpForce, ForceMode2D.Impulse);

rich adder
buoyant schooner
#

I've got an issue where my input script for my player character is getting big, any suggestions on how I could improve this?

hushed hinge
#
  1. I did made a singleton in MuonCounter
  2. the number which should change is _amountMuons
barren dagger
#

hello...

rich adder
silver lagoon
#

I want to call this value 'ListIndex' from the script cui. PotionList is used fine without error, but the code says ListIndex doesn't exist. Why is this happening and how can I fix this?

summer stump
polar acorn
summer stump
#

Share code properly. Are these two images from the same class even?

silver lagoon
#

No to both questions

summer stump
#

via cui
And see how you did NOT do that with ListIndex?

rich adder
silver lagoon
twin bolt
#

Their is a child in ItemHand

rich adder
stark perch
#

@rich adder why is it not working

rich adder
stark perch
#

is it maybe because of the physics scale again

rich adder
# stark perch

show the gizmos in scene during playmode, select the player and place Game view side by side with Scene view

polar acorn
rich adder
rich adder
#

is that the actual one you referenced?

twin bolt
#

yes

polar acorn
stark perch
twin bolt
rich adder
#

try Continuous like I said earlier and you said you changed it..

stark perch
#

ok i will but i changed it back agfter nothing changed

rich adder
twin bolt
#

Yep i found it. @polar acorn @rich adder

stark perch
#

what more

rich adder
stark perch
#

box

rich adder
#

I see it says its a tilemap ? You should not have a box collider

stark perch
stark perch
rich adder
stark perch
#

well how do you do it

rich adder
stark perch
#

where do i add the component

rich adder
stark perch
#

i added it now it's fully filled

#

how do i make it so some are filled and some aren't

rich adder
#

wdym fully filled?

stark perch
#

every tiule on the map has a collider

rich adder
#

put the ones you dont want colliders on separate tilemap without collider

#

play around with order in layer to do between background and foreground

stark perch
#

i did it

#

and oit still does the same thing

#

like when i jump

#

and i ow get stuck at the edges of tiles sometimes

rich adder
# stark perch

add the composite collider also like i told you beofore

#

and checkmark the Used By Composite on the tilemap collider

#

if it adds rigidbody make sure its static

stark perch
#

now i just fall from the floor

#

i checked used by composite i tried setting the rigidbody on my player to static but it does nothing

rich adder
stark perch
#

and where does it add a rigidbody

barren dagger
polar acorn
hushed hinge
#

how's this progress? i have been looking at the tutorial

hushed hinge
frosty hound
alpine dew
#

So, does anyone know how I can make use of either the invoke method or an enumerator to delay the conclusion of a static script?

#

I've tried passing in a reference to the class since IEnumerator is a MonoBehavior method

#

but that doesn't seem to want to work

cosmic dagger
alpine dew
#

it doesn't?

#

so can I just include the coroutine in the static function?

cosmic dagger
hushed hinge
alpine dew
cosmic dagger
alpine dew
#
public static void WarpMap(string map, int sp = 1, bool isDefaultAudio = true)
    {
        Debug.Log("================================================================");
        Debug.Log("(Menu Controller) WarpMap instantiated.");
        
        playerInput.enabled = false;
        playerCamera.SetActive(false);
        playerCapsule.SetActive(false);

        if (isDefaultAudio)
        {
            AudioSource source = MenuController.sourceA;
            source.PlayOneShot(source.clip);
        }

        fadeOut.SetActive(true);
        instance.StartCoroutine(DelayLoadScene());
        MenuController.isTransition = true;
    }

    IEnumerator DelayLoadScene()
    {
        yield return new WaitForSeconds(1.5f);

        GlobalVariables.SP_School_Side_A = 6;
        SceneManager.LoadScene(3);
    }
#

DelayLoadScene isn't accessible because of the aformentooned MonoBehavior exclusivity, in this script's scope

#

so I first tried defining it as a private instance of the class and then sending it through the function as one of its arguments but it didn't take too kindly to that concept and was still acting like I didn't give it a reference

cedar bone
#

I've been scratching my head from this simple problem. For some reason, my gun keeps moving around for no reason, even though I have no script on it, and my character controller only moves it once to (0, 0, 0) local position.

cedar bone
#

but I never change its position anywhere else

#

and it keeps changing for no reason

hushed hinge
summer stump
#

Why you made a class called Singleton is beyond me. But that was never the suggestion

cosmic dagger
alpine dew
#

it's in the same script

#

also for the last part I corrected it to public accessibility

hushed hinge
cosmic dagger
alpine dew
#

the error is claiming that it doesn't have an object reference even though I called it from the class itself

summer stump
alpine dew
cosmic dagger
slender nymph
alpine dew
#

hm, okay I'll try something else then

#

Alright making it a public static instance of the class allowed me to use it

#

which I probably should have figured but it slipped my mind

#

thanks guys

tight kayak
#

Hi, I am completely new to Unity and coding in general. I purchased an asset of this game template I thought would be interesting to build upon. But I literally cannot even figure out how to change the art.

The most confusing is what the globe thing and the "Main" thing at the bottom right corner is. I believe that's the place I need to focus on to get my own art to replace the existing stuff.

Tutorials on this are somehow hard to find on YouTube.

Please point me in the right direction thank you 😦

polar acorn
#

You'd probably want to make a copy of the material and use a different texture if you want to change it

hushed hinge
eternal needle
summer stump
summer stump
hushed hinge
tight kayak
tight kayak
#

see I changed the banner of the dog to a fish tank

#

but why is that specific corner of the .png image being called to that specific banner like that, where do I decide on Unity how that happens?

eternal needle
#

Still isnt a coding issue

polar acorn
tight kayak
#

o my bad u mean i'm not supposed to post this here?

tight kayak
hushed hinge
#

i've been reading the tutorial

#

but yet..

#

since both MuonCounter and Counter have instances...

#

Your UI should reference the instance of the singleton to know what number to display.

Whenever you touch a "muon object", increase that variable in the singleton instance.

Whenever you need to save or load, write those variables to disk or read them back to change the variables on the singleton instance.
.... i don't know if these are left to do...

teal viper
#

Read your code and see for yourself

hushed hinge
#

I am struggling with it... that that with my ui should reference the instance of the singletong to know what number to display, the number to display should be _amountMuons...

polar acorn
#

Put a script on it

#

that reads _amountMuons

#

and sets the text to that

hushed hinge
teal viper
#

If you already have script that does that, then use it

hushed hinge
hushed hinge
#

ok..

Whenever you touch a "muon object", increase that variable in the singleton instance.

the muon object have also tag names like "Muon1" "Muon2" and "Muon3" so that it can tell which objects it is

#

but.... it worked before the instance thing, but not anymore...

mint remnant
#

have you tried peppering debug log calls all over to track the flow of your code?

mint remnant
#

Well unless you know how to actively use the debugger to follow the flow, you're going to need more than one debug log statement to figure out what you think is happening vs. what is really happening

#

and it wouldn't hurt to sketch out a mini flow chart ahead of this so you have what you expect to happen in what order ahead of time

hushed hinge
#

a mini flow chart?

mint remnant
summer stump
hushed hinge
mint remnant
#

Um, don't increment it inside hte debug log!

mint remnant
# cedar bone Can someone help me out here

Your gun is parented to the player, yet you mention a Pickup() method, which I must have issed seeing, but does it re-position the gun when picked up reletive to hte player?

hushed hinge
mint remnant
hushed hinge
#

i never heard of Increment before

raw token
# cedar bone Can someone help me out here

Looks to me like your CameraPos object may be ending up in a whacky location... Share screenshots of the inspectors for Player and CameraPos after things go awry.

Also, send large blocks of !code like that in an external site as described by Dyno 👇. The Discord code file embeds kind of suck

eternal falconBOT
rocky canyon
#

the word increment?

#

means to add to..

#

_amountMuons++; <- this increments _amountMuons by 1 each time its run

summer stump
north oar
#

im trying to make a simple flappy bird game but my pipes are moving at different speeds even though i have the top pipe as a child of the bottom one. ```public class Pipes : MonoBehaviour
{
// Start is called before the first frame update

[SerializeField] GameObject prefab;
void Start()
{

}
private void Update()
{
    if (transform.position.x > -10)
    {
        transform.position = new Vector3(transform.position.x - 0.05f, transform.position.y);
    }
    else
    {
        Destroy(gameObject);
    }
}
public void SpawnPipes()
{
    Instantiate(prefab, new Vector3(10f, Random.Range(-3f, -8f)), Quaternion.identity);
}

}```

rocky canyon
#

wait.. so u have a pipe inside a pipe?

#

and that pipe also has a pipe script?

north oar
#

yes..

rocky canyon
#

that would be my guess.... the pipe inside the other pipe is moving twice as fast

north oar
#

i wasnt sure how to attach the other pipe to the first one

raw token
north oar
#

yeah tahts what its doing

rocky canyon
#

mmhmm so u shouldnt do that

north oar
#

so should i just remove the pipe script in the child?

rocky canyon
#

yes, it'd still move the same speed as the parent pipe
Actually. you'd have to see if that works.. b/c of things like ur destroy method

cosmic dagger
#

That sounds painful . . .

hushed hinge
north oar
#

another question so id put the SpawnPipes() in a loop to make them infinitely spawn but how do i set time inbetween spawns?

rocky canyon
#

look up coroutines

hushed hinge
frosty hound
#

@hushed hinge This is your official last caution about this before you start receiving warnings. Make a thread, use the thread, do not come out of that thread. You've been at this same thing for two days now, and we're not going to sit through another of you occupying this channel.

mint remnant
# hushed hinge then...

to be honest, nevre hearing of increment before, you're going to struggle a lot trying to do much of a game. I'd consider stepping back to learn some programming basics first

rocky canyon
#

ive seen a few posts so far.. i feel like they skipped a week or two worth of learning

#

bought a motorcycle before learning to ride a bicycle kinda thing

north oar
hushed hinge
summer stump
hushed hinge
#

oh

spiral glen
#

is there a way to get the size of an object in any way related to box colliders?

rocky canyon
#

absolutely

spiral glen
#

could you perhaps enlighten me please

rocky canyon
#

boxCollider.size;

spiral glen
#

❤️

#

is it possible to get a boxcollider from an object or do I need to save the boxcolliders seperately?

rocky canyon
#

GetComponent<BoxCollider>();

spiral glen
#

awesome

rocky canyon
#

just GetComponent if its on the same object

spiral glen
#

it is

raw token
#

In a very strict interpretation of SOLID/Dependency Inversion Principal, is it permissible/reasonable to have multiple layers of abstraction between concrete objects? That is, interfaces/abstract classes implementing/extending other interfaces/abstract classes?

My gut feeling is that this is wrong, but I can't quite put my finger on why... Like I'm extending the contract between the higher- and lower-level objects with the lower-level objects' implementation details

#

Though, I guess if an abstract class is the abstraction, then you're already including lower-level objects' implementation details... maybe it's fine 🤔

eternal fiber
#

im new and dont know anything but what im confused on is what do i download to start coding c#?

mint remnant
#

I'd ask, does it impede my ability to properly add unit test?

raw token
mint remnant
eternal falconBOT
eternal fiber
alpine dew
# alpine dew ```cs public static void WarpMap(string map, int sp = 1, bool isDefaultAudio = t...

This is a kind of followup to my earlier post and problem, I more or less made it work, but despite the instance of the class being a static member and also the function that uses this reference is static, but for some reason it seems like it loses its reference at some point and returns null, that or it never got one in the first place.

public static void WarpMap(string map, int sp = 0)
    {
        Debug.Log("================================================================");
        Debug.Log("(Menu Controller) WarpMap instantiated.");

        instance.StartCoroutine(DelayLoadScene());

        IEnumerator DelayLoadScene()
        {
            yield return new WaitForSeconds(1.5f);

            GlobalVariables.SP = sp;
            SceneManager.LoadScene(map);
        }
polar acorn
alpine dew
#

I was told you can use a coroutine inside a function

#

Idk if it's good practice

#

instance is defined here

public class MenuController : MonoBehaviour
{
    public static MenuController instance;
mint remnant
#

didn't know C# even allowed you to declare a function within one, weird

alpine dew
#

well it's more like a MonoBehavior method by proxy

polar acorn
alpine dew
#

You're gonna have to elaborate on that

#

actually I think I know what you mean

polar acorn
rocky canyon
#

@summer stump i just can't anymore

summer stump
alpine dew
#

My initial understanding was that it would store the reference as is

summer stump
polar acorn
rocky canyon
#

most things don't assign themselves to anything

polar acorn
#

How is it supposed to know which MenuController the variable holds

alpine dew
#

well you can't use this inside static methods to refer to the script object

rocky canyon
#

ints and numbers and stuff do.. typically zero

polar acorn
#

There is no this

alpine dew
#

alright then what do you suggest?

polar acorn
alpine dew
#

Does it have to be specific?

rocky canyon
#

needs to be of the same type atleast..

polar acorn
#

Well, if you want to refer to a specific object it's probably a good idea to set it to that object

#

Not gonna do you much good if you set it to a different object

summer stump
alpine dew
#

I don't know if I even need all that, my intentions are to delay a function's ending slightly, but to do that with an enumerator from what all I've managed to gather, you need to pass in an instance of MonoBehavior

polar acorn
alpine dew
#

I think you're right about that

polar acorn
#

Question: Why is this function static at all

alpine dew
#

I need it to be accessible from another class

frigid schooner
#

I have a question

alpine dew
#

so I can call a function from it?

polar acorn
#

why not just put the coroutine in that other class

frigid schooner
#

can playerprefs be accessed from any object and any script?

polar acorn
#

Absolutely nothing about this uses any sort of references in this class

alpine dew
#

because the class doesn't handle any of the stuff the delay is needed for, it's all handled by the function

polar acorn
#

Just put this coroutine in the function you're trying to call it in

#

And then start it there

polar acorn
#

and put it

#

in the class that calls it

frigid schooner
#

the most annoying part about references is to drag the stuff into the boxes

#

player prefs saves a lot of time not having to do that

alpine dew
#

forget about the coroutines, do you know if any other delay option works in a static method?

polar acorn
summer stump
alpine dew
polar acorn
summer stump
#

It is fairly important
It is basically the crux of tbe entire issue

polar acorn
#

Just put the damn function in the class that uses it

#

you're already abusing static to avoid referencing

#

why not just do neither

rocky canyon
#
    private void OnGUI() {
           Utils.RealtimeDebug(msg, offset, textSize, textColor, screenSize); // <--- static non-mono class (w/ functions reliant on OnGUI)
    }``` is this okay tho?, the coroutine comments up above got me thinkin
#

When i was making this.. i tried to just call it in start or something.. but got errors saying certain things from within that static class needed OnGUI.. so i fixed it by just calling it inside a OnGUI instead, (b/c i couldn't wrap the main function in OnGUI b/c its not a monobehaviour)

quick fractal
#

I'm trying to disable shadows as an option on a directional light, would this be all I need?

#

Having shadows enabled doubles the tri count from 20M to 40M so it'd be nice to be able to disable that

rocky canyon
quick fractal
quick fractal
wintry quarry
#

Then you don't need Update at all

rocky canyon
#

ur ide isnt working correctly

#

shadow shoulda spit a red error at u

quick fractal
#

I'm not editing in Unity, that's probably why

#

Just a separate project I'll use an asmdef to link to unity

rocky canyon
#

ahh ok

quick fractal
#

Seems like shadows won't work, which dll would that be in if you know?

#

(I assume I'm missing a reference)

#

It normally says but not this time I guess

rocky canyon
#

lol, not a clue.. Light is in UnityEngine; i guess

quick fractal
#

That's annoying 😬

polar acorn
rocky canyon
#

u need a reference to a light yes

quick fractal
#

I'm referencing every UnityEngine DLL I've got access to

quick fractal
#

That was working fine

rocky canyon
#

ahh ok

quick fractal
rocky canyon
#

use just Light then

#

covers all types of lights i think

quick fractal
#

Thanks

summer stump
polar acorn
#

It does exist, and it's a boolean, you have to set it to something

quick fractal
#

Well

#

Not with the shadows

summer stump
rocky canyon
#

weird Light is shadows

quick fractal
#

But, that's been added

rocky canyon
#

and DLights are shadow

alpine dew
rocky canyon
#

i didnt notice u were using a DirectionLight <>

polar acorn
rocky canyon
#

@quick fractal still works the same if u use Light.shadows = ..

alpine dew
#

it's a protected override void that's part of an Interactable class I have

rocky canyon
#

so use whichever one u want i guess

quick fractal
#

Looks that way, thanks <3

#

This truly is the most complex script anyone has ever written

polar acorn
alpine dew
#
protected override void Interact()
    {
        Debug.Log("Interaction (" + gameObject.name + ")");

        if (isDoor)
        {
            var GameObject fadeOut = MenuController.fadeOut;
            fadeOut.SetActive(true);
            MenuController.isTransition = true

            MenuController.WarpMap(mapString, spawnPosition, isDefaultSound);
        }
tidal trellis
#

Trying to run Unity Essentials Project, but I am getting this TMPro cannot be found error. As a result other errors like TextMeshProUGUI could not be found. Using Unity version 2022.3.39f1 . Any idea how can I get these defined?

summer stump
quick fractal
#

I return with more questions, is something up with my script that's causing the references to not show up?

#

Oh wait.. Might be missing that serializable thing

#

Been a while since I did anything with editor scripts

steep walrus
#

im following a tutorial and I want to add on a little bit by deleting some of the game objects. I have the object in as a prefab it seems as I imported it as an .fbx from blender but when I try to use the "Destroy(Easy);" the Easy party gets underlined red and says it doesnt exist in that context

tidal trellis
summer stump
#

It is TextMeshPro

#

And you are not looking in the "in project" section, right?

tidal trellis
quick fractal
cedar bone
tidal trellis
summer stump
summer stump
# tidal trellis

In Project is only things that are in your project. So all that shows is that you do not have TextMeshPro in your project

rocky canyon
polar acorn
#

So put the IEnumerator in this class

quick fractal
polar acorn
#

and have fadeOut start it

alpine dew
#

hm okay okay

raw token
# quick fractal Oh wait.. Might be missing that serializable thing

Unity won't serialize statics, and it looks like DirectionalLight might be an unserializable struct... But since it's a struct (value type), even it were originally declared to be serializable, it would be a unique instance of data rather than a reference to some other data which already exists 👀

I think you might want a Light instead

quick fractal
rocky canyon
#

Yea lmao

cedar bone
#

The actual pistol