#💻┃code-beginner

1 messages · Page 328 of 1

burnt vapor
#

No problem, in case you want to add it back you can try what I mentioned

#

Usually you just want to keep a file locked for as short as possible

summer shard
#

bump again

tulip glade
#

hi folks

rich egret
tulip glade
#

here i have an object that spawns enemies ,it works perfectly fine and a player attack that destroys the enemy if i hit x and he is in some radius that i choose

#

the issue is that if i kill one enemy ,other one are spowning and following me but i cant see them in game,they chase me but cant damage also

#

what can be the sollution?

willow scroll
#

The issue is thus in your array.

rich egret
willow scroll
willow scroll
rich egret
tulip glade
#

ok so i found out that this bug happens only of i kill the main one

willow scroll
tulip glade
#

i can just place him outside of the map

rich egret
willow scroll
rich egret
burnt vapor
#

What is cameraHolder? Is that the thing that jumps?

#

Do you have a video of the issue?

#

If the object "jumps" then I get the idea you are bobbing the wrong thing

tropic notch
#

hey guys, I'm super new to unity and i've just completed this tutorial https://www.kodeco.com/980-introduction-to-unity-scripting/page/5 now i'm trying to create a death/win message but getting this error can anyone help me identify what the issue is?

cosmic dagger
tropic notch
cosmic dagger
#

within the parentheses are the line number then the column . . .

#

check the tutorial again to see what they wrote for that line . . .

#

you should see a difference . . .

strong token
burnt vapor
#

String is namespace'd

#

And a bad way to write strings

#

For beginners at least

cosmic dagger
#

ahh, they were so close to finding it . . .

tropic notch
#

sorry guys i literally just copy pasted it lol

#

thanks so much for your help

cosmic dagger
tropic notch
#

it's actually an application task for a higher education lol

burnt vapor
#

Yes, 90% of online tutorials are from pretend programmers sadly

cosmic dagger
#

can't believe they actually wrote that . . .

burnt vapor
#

Ah, higher education consists of 100% pretend programmers in that case

cosmic dagger
#

hopefully they fixed it during the remainder of the tutorial . . .

burnt vapor
#

You're better off following an actual C# tutorial

strong token
tropic notch
#

thanks again that fixed it deadpool_heart

cosmic dagger
tropic notch
#

I will! But I of course delayed the application until the last day so i'm rushing through it peeposhy

willow scroll
#

I need a break.

dusty mauve
#

Can anyone help me? Im trying to install unity but it keeps validating

paper sable
ruby python
#

[System.Serializable] ((I think))

keen dew
#

Interfaces can't be serialized

ruby python
#

My bad, I missed that lol.

burnt vapor
dusty mauve
fossil tree
#

hi my problem is the next i make a "game of life" and have a panel with a button start for laucnh my game but when i click on my button that click on my game object behind the panel

summer shard
#

and the object is attached to cameraHolder, and the main camera's position is being updated to cameraHolder

tranquil hollow
#

!code

eternal falconBOT
wooden minnow
#

why is this erroring?

short hazel
#

You cannot use ref here because .gameObject is a property that doesn't use ref returns

#

Not sure why you'd need ref in that method, classes are passed by reference already

wooden minnow
short hazel
#

Change how? That method only gets a component on it, it does not re-assign the variable

wooden minnow
#

it does reassign a variable?

#

the fontsize

short hazel
#

On the TextMeshPro component yes, not on the GameObject

short hazel
#

Again, classes are passed by reference so the font size change will have an effect without re-assigning to the original object

wooden minnow
#

?code

#

that is not the command

sick ocean
#

why its not working

using System.Collections.Generic;
using UnityEngine;

public class Score : MonoBehaviour
{
    public int score = 0;
    private void InTriggerEnter2D(BoxCollider2D other)
    {
        if (other.CompareTag("Player"))
        {

            score++;

        }
    }

    
    private void Update()
    {
     Debug.Log(score);
    }







}
wooden minnow
#

is the object a trigger?

summer shard
wooden minnow
#

also isnt it On?

#

yeah it is on i wasnt crazy

short hazel
#

A configured code editor will highlight this method differently when it's recognized by Unity. With VS, the name will be in blue and the "Unity Message" indicator will appear above the name.

#

!ide

eternal falconBOT
short hazel
#

Do that if you haven't yet

willow scroll
sick ocean
#

Thanks

summer shard
# summer shard it's the thing that holds the camera and moves up and down and here's the video ...

bump

    void HandleBobbing() {
        if (!canMove) return;
        if (Mathf.Abs(_rb.velocity.x) > 0.1f || Mathf.Abs(_rb.velocity.z) > 0.1f) {
            _bobTimer += Time.deltaTime * (isSprinting ? sprintBobSpeed : walkBobSpeed);
            cameraHolder.localPosition = new Vector3(
                cameraHolder.localPosition.x,
                _defaultCameraY + Mathf.Sin(_bobTimer) * (isSprinting ? sprintBobAmount : walkBobAmount),
                cameraHolder.localPosition.z
                );
        }
        else {
            cameraHolder.localPosition = new Vector3(cameraHolder.localPosition.x, _defaultCameraY,
                cameraHolder.localPosition.z);
        }
    }
tranquil hollow
#
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public float Speed;
    public float JumpForce;
    private Rigidbody2D rig;

    // Start is called before the first update
    void Start()
    {
        rig = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        Move();
    }

    void Move()
    {
        Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
        transform.position += movement * Time.deltaTime * Speed;
    }

    void Jump()
    {        if (Input.GetKeyDown("Space"))
        {
            rig.AddForce(Vector2.up * JumpForce, ForceMode2D.Impulse);
        }
    }
}


short hazel
#

You're not calling Jump() anywhere here

#

It's declared, but not used

tranquil hollow
#

oh

#

how can i fix it?

short hazel
#

Call Jump() in Update like you do for Move()

tranquil hollow
#

ok

#

dont worked

summer shard
#

increase your jump force

tranquil hollow
short hazel
#

It won't work because you move the transform in void Move(). This conflicts with moving using a Rigidbody

#

Use the Rigidbody in both

tranquil hollow
#

ok

#

can i send a print here?

short hazel
#

What?

tranquil hollow
#

about the error that appeared

short hazel
#

Yes if you have an error you should post it here

tranquil hollow
short hazel
#

Yep it's correct, there is no key on your keyboard labeled as "Jump"

#

Why didn't you keep "Space" like you had before?

tranquil hollow
#

it worked

#

tyms guys

tranquil hollow
summer shard
# tranquil hollow but when i spam space i can infinite jump

add on collision enter 2d method, check if collider is layer "ground" (which u must create) and if it is, set private bool _grounded variable to true and on collision end do the same but set _grounded to false, and check if _grounded == true in jump method

tranquil hollow
#

ok

icy junco
#

what is a good way of making your own ui elemants

frosty hound
icy junco
#

thx

paper sable
#

how can i make a rect transform be anchored to left through code? the ancoredPosition field of the RectTransform class should be a vector2

paper sable
wintry quarry
#

myRectTransform.anchorMin = new Vector2(0, 0); for example

#

It's the same as setting the anchors (min and max) in the inspector:

maiden niche
#

i dont know why but i keep getting these errors and i dont understand why

cosmic dagger
maiden niche
cosmic dagger
#

look for the reference variable on each of those lines. that variable is null (does not have a value assigned). make sure you assign those variables a value before attempting to use them . . .

maiden niche
#

they should be assigned tho

cosmic dagger
#

obviously, they're not, or the error would not be there . . .

maiden niche
icy junco
#

is it usefull to use scriptableobjects in inventory when making a survival game?

cosmic dagger
maiden niche
maiden niche
#

like remove them

cosmic dagger
cosmic dagger
# maiden niche like remove them

you receive the errors, so somewhere in your code the value is removed. i have no idea where as it's your code. you need to log the value of those null variables or use the debugger to see where they get removed . . .

#

first, you need to find out which variables are null . . .

maiden niche
cosmic dagger
oak epoch
#

Dumb question: how do I fetch the actual length of an animation clip in my project?
AnimationClip.Length & the editor tab return 1.500, but the Animation windows show 1.150 (at the final 45th frame).
From what I tried the 1.150 is the "correct" one, but I don't see how I'm supposed to get it.

keen dew
#

AnimationClip.Length is in seconds but the animation window shows seconds:frames

summer shard
#

how can i get cloned button child like textmeshpro or image

keen dew
#

at 30 fps 1:15 is 1 second 15 frames (=1.5 seconds)

swift crag
summer shard
#

yea

swift crag
#

if so, the ideal thing to do would be to make a component that references the components you need

#
public class MyButton : MonoBehaviour {
  public TMP_Text text;
  public Image img;
}
#

stick that on the prefab root and reference the prefab as a MyButton

#

now you can do...

MyButton instance = Instantiate(buttonPrefab);
instance.text.text = "Hello";
#

The less nice alternative is to just use GetComponentInChildren to grab a TMP_Text from the newly created instance.

#

This can cause problems if you later decide to add more text components.

oak epoch
swift crag
#

I spent an hour or two figuring out a bug where I got the wrong component with GetComponentInChildren after adding an extra renderer to something

swift crag
wintry quarry
swift crag
#
public class InputActionIconPart : MonoBehaviour
{
    [SerializeField] TMP_Text label;
    [SerializeField] Image image;
    [SerializeField] Image fillImage;

    // actual logic down here
}

This used to just be a bunch of public fields

#

Then I rewrote it so that the fields are private and you interact with it through methods

elfin thicket
#

hi, is anyone familliar with the game "crisis response"? im trying to do a reskin on it like other mods but i dont know how

swift crag
#

this isn't a modding server

elfin thicket
#

oh

#

fuck

iron steeple
#

im stuck on this part of the code which is making a player teleported through a trigger which when player get hit by this hitbox it would teleport but it would just teleport however i wanted some to be a trap teleporter that just move the player back a couple x axis away from the teleporter

 
public class Player : MonoBehaviour
{
    Rigidbody rb;
    float speed = 10f;
    public Transform PlayerPos; 
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        Vector3 Teleported = new Vector3(10, 0, 0);
    }

    void Update()
    {
        
        Vector3 movement = new Vector3(speed, rb.velocity.y, 0);
        rb.velocity = movement;

    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Teleporters")
        {
            transform.position = PlayerPos.position -- Teleported.position;
        

        }
    }
}



#

i forgot to remove the -- to -

deft grail
wintry quarry
#

wherever you declare a variable, it's only usable within that scope

#

(a scope is basically anything confined by a { } )

deft grail
#

also you wouldnt access it by Teleported.position but instead just Teleported since its already a Vector3

iron steeple
wintry quarry
#

it's more efficient

iron steeple
#

can you explain the different

#

actually its just

#

changing == into .compare

cosmic dagger
#

check Best Practices from the pins . . .

wintry quarry
#

CompareTag does the comparison on the native side, and doesn't allocate any managed memory.

ruby python
#

While that conversation is going on, is there a list/guide or some documentation on what allocates managed memory etc? I've been thinking about the garbage collection side of stuff more recently (as anything I make has a tendency to 'stutter' every few seconds due to the garbarge collection lol.)

wintry quarry
ruby python
#

Aah okay, interesting.

quick pollen
#

hey! so I'm trying to create a vector3 direction which points towards a gameObject called target. How can I do that?
rotationPoint = Vector3.RotateTowards(transform.rotation.eulerAngles, target.position, speed, 0f);
I have this but it just rotates it in an undesired direction

iron steeple
quick pollen
wintry quarry
ruby python
#

You need to create a new direction variable and assign a direction Vector3 to it

wintry quarry
#

BTW in order to use LookRotation you will have needed to calculate the direction vector already

#

since the direction vector is the first parameter to LookRotation

quick pollen
#

thank you!

#

yeah I had this inside of my Quaternion.LookRotation

cosmic dagger
wintry quarry
quick pollen
#

but I tried doing some silly shit like Vector3.RotateTowards(transform.rotation.eulerAngles, target.position - transform.position......

quick pollen
#

also, is there a way to make it so it doesn't have verticality?

wintry quarry
#

Vector3.RotateTowrads expects two direction vectors. You gave it an euler angle vector and a position vector. Neither of them are direction vectors

quick pollen
#

one sec

wintry quarry
#

direction.y = 0;

#

More generally, you can use ProjectOnPlane. But effectively for projecting on the x/z plane, you just set the y to 0

quick pollen
#

like this?

#

oh true

wintry quarry
#

no idea what rotationPoint is

quick pollen
#

dont need to construct a new vector for that

quick pollen
wintry quarry
#

If it's a direction vector it probably shouldn't be named "point"

#

point implies that it's a position

#

at least in my head

quick pollen
#

true

wintry quarry
#

Also you may or may not want to normalize this direction vector, depending on how it's being used later.

quick pollen
#

ill just rename it to targetDirection

quick pollen
#

but idk what it does exactly

wintry quarry
#

for LookRotation you don't need to normalize it

quick pollen
#

besides setting the magnitude to 1

#

which doesnt tell me too much

wintry quarry
#

but if you're using it to set a velocity or something, you would want to normalize it

quick pollen
#

i am in a different script

#

oh WAIT

#

yeaaa I get it

#

I was about to say that some projectiles sped up extremely fast

#

when i only changed the direction of it, not the speed

#

but that was probably because of not normalizing

rich egret
#

Why when I clone the object the movement script doesn't work in Unity?

quick pollen
wintry quarry
#

I didn't know there was only one!

iron steeple
#
public class Player : MonoBehaviour
{
    Rigidbody rb;
    float speed = 10f;
    public Transform PlayerPos; 
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        Vector3 Teleported = new Vector3(10, 0, 0);
    }

    void Update()
    {
        
        Vector3 movement = new Vector3(speed, rb.velocity.y, 0);
        rb.velocity = movement;

    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.CompareTag("Teleporter"))
        {
            transform.position = PlayerPos.position -- Teleported.position;
        

        }
    }

this is the revised is it better?

rich egret
polar acorn
wintry quarry
rich egret
#

!code

eternal falconBOT
wintry quarry
#

also explain if you have any errors in console when running the game etc

#

And explain what "doesn't work" means

quick pollen
#

btw is there a way to create a graph in a script?

quick pollen
#

as in serializing a graph?

#

idk how to explain

quick pollen
#

basically something like this?

rich egret
#

I think it has to do with the ground

rich adder
cinder crag
#

Quick question , how can I take a GameObject from another scene , that GameObject is my save and load system and I wanna get I from the scene it is and reference it in my main menu manager so I can load some data that I need to be loaded when I press my continue button , how can I get that SaveAndLoadingSystem gameobject that has a script on it and I wanna get that script so I can access a method I need.

iron steeple
#

because its still error

polar acorn
rich adder
iron steeple
rich egret
rich adder
rich egret
#

It probably doesn't recognize the ground.
But when I put the object itself without cloning, it works great.

rich adder
#

access either the collider

#

or body, or gameobject

west sonnet
#

I have an enemy prefab that contains scripts that control all my enemies. I want to create enemies that look different, so they use different sprites and animations, but I've just realized I don't know how to do that since they all share the same scripts?

For example, when the enemy runs, it plays a specific animation, but if another enemy which looks different runs, how could I get it to play a different animation, despite them using the same scripts?

iron steeple
polar acorn
# iron steeple

Collisions don't have CompareTag. Objects you collide wtih do

polar acorn
iron steeple
rich egret
polar acorn
west sonnet
iron steeple
rich adder
polar acorn
rich egret
polar acorn
rich adder
polar acorn
#

See if it's grounded, and if not, see why it's not

rich egret
polar acorn
quick pollen
#
        foreach(ProjectileVelocityChange changes in velocityChanges)
        {
            if(lifeTimeCT - lifeTime <= changes.startAfterSeconds) SetVelocity(changes.newVelocity);
        }```
does anyone know why SetVelocity never gets called?
lifeTimeCT is 5
lifeTime is 5 too and decreasing per second
startAfterSeconds is 2
newVelocity is 0
#

and yes I have elements in the changes array

rich egret
#

But the character is literally waving in the air

polar acorn
rich egret
polar acorn
#

Look for where you set IsGrounded to true and see what could be causing it to do that

rigid valve
#

is it possible to change this layer while playing with script like player does smth to chnage it

rich egret
rich egret
rigid valve
#

which I used to create the ground basically I want to uopdate the ground texture

cinder crag
polar acorn
#

When a scene isn't loaded, nothing in it exists at all

rich adder
quick pollen
#

why is this a thing and how can I work around it?

polar acorn
#

So in order to reference anything from another scene it needs to be put somewhere that does exist all the time. Either a DDOL, or a file on the hard drive, etc.

rigid valve
polar acorn
rich adder
#

eg

cinder crag
quick pollen
polar acorn
quick pollen
#

and again, isnt there a way to create a graph?

#

like how theres velocity over lifetime in unity's particle system?

#

and u can set a graph there?

polar acorn
cinder crag
rigid valve
rich adder
#

its not trivial

#

there is no way to shortcut your way through these problems sometimes

quick pollen
#

is there seriously no such thing as?

#

and yknow have it like this

rich adder
#

AnimationCurve?

quick pollen
#

maybe?

#

oh shit yea it is

rich adder
#

yup its basically that and custom inspector

quick pollen
#

but how can I use it exactly?

#

shit thanks

#

ill try to use this somehow

#

idk how

#

like I want the time variable to be controlled by something else

rich adder
#

thats totally fine

rigid valve
quick pollen
#

basically what I want is like
at second 0 have the velocity be 10
at second 3 have it be at 0
at second 4 have it be at 10 again

#

but idk how to do it

#

and the curve editor is kinda bad

rich adder
rich adder
quick pollen
quick pollen
#

yea i did that thats not the issue

rich adder
short hazel
#

Call Evaluate(n) to get a curve's Y value

quick pollen
#

but how can I use the values

quick pollen
#

hold up

#

so I can have SetVelocity(curve.Evaluate(lifeTimeCT - lifetime))?

native flicker
#

So i coded smt small and i get this error
error CS8773: Feature 'parameterless struct constructors' is not available in C# 9.0. Please use language version 10.0 or greater.
How could i change the language version? or does smb have a alternative to this ```C#
struct EnemyData {
public EnemyData() {
EnemyPosition = position;
NodeIndex = nodeidex;
Health = hp;
}

    public Vector3 EnemyPosition;
    public int NodeIndex;
    public float Health;
}
quick pollen
#

what-

rich adder
quick pollen
polar acorn
quick pollen
#

u can construct a struct inside of a struct?

#

isnt that recursive?

rich adder
#

the problem is the constructor
EnemyData(Vector3 a, int b, float c)

short hazel
#

Given that position, nodeindex and hp don't exist in the context, you want to add these to the constructor's parameters

native flicker
#

ah alright ty, il try some stuff

queen adder
#

yall i just started, how do i attach the camera to a model?

rich adder
#

also not code related

queen adder
short hazel
rich adder
queen adder
#

oki

quick pollen
short hazel
#

Unity dev moment

quick pollen
#

yea i never really used C# outside of unity

#

i know it has uses in creating databases

modest dust
eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

short hazel
cinder crag
polar acorn
# cinder crag okay so i did add the ``DontDestroyOnLoad`` on the ``SaveAndLoadingSystem`` Aw...

Whenever you load a scene, it will spawn every object in that scene. DDOL moves the object to a separate persistent scene. So you load that scene again, there's still a SaveAndLoadingSystem object in that scene so it spawns. You'll need to have any extra copies of the object self-terminate if there's already one that exists.

https://gamedevbeginner.com/singletons-in-unity-the-right-way/

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

cinder crag
polar acorn
languid spire
#

Less than 1 ?

#

Also DDOL AFTER Destroy?

cinder crag
polar acorn
cinder crag
polar acorn
#

Probably better inside an else though

cinder crag
#

hmm i cahnged the less than to more than but it deletes the SaveAndLoadingSystem gameobject with the references and not the one that has empty references

rigid valve
#

why cant I color this one building

polar acorn
polar acorn
cinder crag
#

or change the references into Singletons?

polar acorn
cinder crag
#

also did this in MainMenuManager cuz it kept saying that object is not referenced or smth

polar acorn
#

You'll want to put the singleton in every scene

hollow dawn
#

my character is suppose to walk is there a solution?

polar acorn
#

so it always loads no matter where you start

rich adder
vernal valve
#

can anyone send me a player movement c+code plz

rich adder
#

google it

vernal valve
eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

vernal valve
#

they sometimes dont work

cinder crag
polar acorn
cinder crag
vernal valve
rich adder
#

just use the premade controller i sent

west sonnet
#

I want to make the camera follow the player but slightly pan depending on where the cursor is. Does anyone know how I can do this?

Is this something that would have to be done with code or can be done with Cinemachines settings?

cinder crag
# polar acorn I mean every scene

not sure if i understood it correctly, so i put the SaveAndLoadingSystem gameobject where the same name script is that has the singleton in MainMenuScene scene as well?

vernal valve
vernal valve
rich adder
summer stump
vernal valve
summer stump
#

The only difference is gonna be input

vernal valve
#

I m trying to make a horror game and some youtube videos are helpfull but I always doing something wrong so I might need to use assets for it thats why I joined discord so I could ask people about good or best assest

rich adder
vernal valve
rich adder
#

why?
just disable them,its no big deal

vernal valve
#

well I dont know much about unity thats why I asked its my first week on it

#

I mon second lesson on unity learn

rich adder
#

if ur doing unity learn why are you already trying to make character controllers ?

#

you should not be starting with such complexities

vernal valve
#

I know I wanna save some script so when I get to that part on learn I could just ctrl v it

#

is even movement that complex on unity ?

rich adder
#

that makes no sense, ur going to paste something you don't understand ofc its not gonna work

rich adder
vernal valve
#

well I coulndt find anyone on youtube explaining to a child like a explanatory

cinder crag
#

how old even are you

rich adder
cinder crag
vernal valve
cinder crag
#

what?!?!?

vernal valve
cinder crag
#

its a learning course

willow scroll
rich adder
#

Unity learn is structured to ease you into it

vernal valve
cinder crag
#

also c# course

#

do that

vernal valve
rich adder
#

learn the editor first, then code part

#

this way you know where to go and what to click

cinder crag
#

does he know c# atleast

vernal valve
rich adder
willow scroll
rich adder
#

you should start with the Essentials path

vernal valve
#

cant rememeber much to

rich adder
#

web devolobement on c+ ?

vernal valve
rich adder
#

what is C+ ?

vernal valve
#

web design is its english ?

rich adder
#

never heard of it

vernal valve
#

c^#

#

c#

rich adder
#

oh

vernal valve
#

I dont remember much

rich adder
#

then you mind as well start fresh

vernal valve
#

and as much as I got it is quite different then what we are tought

willow scroll
rich adder
#

its the same language

#

only the specific framework api changes

summer shard
#

why my add listener doesn't work bruhhhh

    private void LoadPosts() {
        foreach (WikiPost post in WikiPosts) {
            if (post.Day > day) continue;
            GameObject button = Instantiate(buttonPrefab, postsContent.transform);
            PostButton buttonScript = button.GetComponent<PostButton>();
            if (!buttonScript) continue;
            buttonScript.title.text = post.PostTitle;
            buttonScript.profilePicture.sprite = Sprite.Create(post.PostCreator.ProfilePicture,
                new Rect(0, 0, post.Photo.width, post.Photo.height), new Vector2(0.5f, 0.5f), 100f);
            button.GetComponent<Button>().onClick.RemoveAllListeners();
            button.GetComponent<Button>().onClick.AddListener(() => {Debug.Log("gowanowndoawdio");});
        }
    }
vernal valve
vernal valve
rich adder
summer shard
willow scroll
wintry quarry
summer shard
wintry quarry
#

Changing tint etc?

vernal valve
rich adder
willow scroll
summer stump
willow scroll
#

Go learn it first.

vernal valve
rich adder
#

i do web dev all the time in c# the same exact types are used

summer stump
#

And pretty much every language has those

vernal valve
#

what comes before c# on web dev

summer shard
vernal valve
#

might be java

willow scroll
vernal valve
#

what is the one called with <html>

rich adder
#

java still has same types

willow scroll
summer shard
vernal valve
#

what comes after that one on advance

summer shard
vernal valve
#

css

willow scroll
vernal valve
#

dangit

rich adder
#

anyway none of this is related to Unity or beginnner

#

just do the courses

vernal valve
#

now I have to learn c#

#

man

#

😦

rich adder
#

if you want to dev in unity yes

summer shard
vernal valve
#

I just wanna make a horror game doesnt matter if its made with free assest or codes

#

is it possble for me to make one while learning c#

#

I will be using assests

rich adder
vernal valve
#

like enemy ai fps controller and stuff

summer shard
rich adder
#

it will probably take a few months

#

or more

#

depends how you learn, and how motivated u are to learn

summer shard
vernal valve
#

I mean rather than waiting to make the game while learning c# I wanna make one with assest then I can make it complete version with codes later this way I can test myself and see if I m proceeding

rich adder
summer stump
summer stump
#

If you find it boring, so what, just do it

summer shard
rich adder
#

its gonna be crap

vernal valve
# summer stump Just do learn.unity pathways

I m doing it also I search on google or youtube but people are either skipping some parts guessing you know what they do or using their old scripts to fasten thing wich teaches nothing

rich adder
#

until you get better with time

vernal valve
summer stump
vernal valve
rich adder
#

its normal

vernal valve
#

its like hide and seek

rich adder
vernal valve
#

but inevitable :d

rich adder
cinder crag
vernal valve
#

any suggestions on how to learn c# rather than unity learn I wil keep going with it but reading is not my thing sometimes so

#

any youtubers or webpages ?

rich adder
summer shard
summer stump
rich adder
summer stump
#

You are gonna have to read most solutions, so you should get used to it now

rich adder
#

@summer shard if so and ur not hitting breakpoint then no wonder its not subscribing

summer shard
summer shard
vernal valve
#

thats not cause I dont like it it cause of my eyes the more I read the more words scramble on my eyes eventually either I have to stop reading or change the background and font color

rich adder
#

if the breakpoint hits, you will see the Hammer icon

summer shard
#

it's a war crime

summer shard
#

but it didn't hit the debug

#

after i clicked

rich adder
summer shard
#

they arent

rich adder
#

and thats the correct button?

summer shard
#

yup

wintry quarry
#

what makes you sure?

summer shard
#

it shows up in the game, and there's no other variables called "button" in this script

#

wait i think it doesn't work

#

it should change the title text but it's still _desc

#

sooo, it does print the "load" and "change title" logs but doesn't change them?

        foreach (WikiPost post in WikiPosts) {
            if (post.Day > day) continue;
            GameObject button = Instantiate(buttonPrefab, postsContent.transform);
            PostButton buttonScript = button.GetComponent<PostButton>();
            Debug.Log("load");
            if (!buttonScript) continue;
            Debug.Log("change title");
            buttonScript.title.text = post.PostTitle;
            buttonScript.profilePicture.sprite = Sprite.Create(post.PostCreator.ProfilePicture,
                new Rect(0, 0, post.Photo.width, post.Photo.height), new Vector2(0.5f, 0.5f), 100f);
            button.GetComponent<Button>().onClick.RemoveAllListeners();
            button.GetComponent<Button>().onClick.AddListener(() => {Debug.Log("gowanowndoawdio");});
        }
rich adder
quick pollen
#

is there no way to edit AnimationCurves using some file or smth?

#

like this is obnoxious to work with

rich adder
quick pollen
#

thats what I do yea

rich adder
#

but yeah not the best curve window out there

quick pollen
#

but its impossible to see the curves

quick pollen
#

like i cant zoom in only vertically

rich adder
#

wdym zoom only vertically

short hazel
#

It's very faint but both horizontal and vertical scrollbars have special areas at their extremities you can drag to zoom in

summer shard
#

idk if that's what u meant

rich adder
# summer shard

you know , technically you already have a script there you can link the button directly in that script

#

PostButton can just have field for Button and subscribe it there

summer shard
summer shard
#

like wikipost is the argument to open post, and this is it's class

public class WikiPost {
    public string PostTitle;
    public string PostDescription;
    public WikiUser PostCreator;
    public Texture2D Photo;
    public WikiComment[] PostComments;
    public int Day;

    public WikiPost(string title, string description, WikiUser postCreator, Texture2D postPhoto, [CanBeNull] WikiComment[] comments, int day) {
        this.PostTitle = title;
        this.PostDescription = description;
        this.PostCreator = postCreator;
        this.Photo = postPhoto;
        this.PostComments = comments;
        this.Day = day;
    }
}
rich adder
summer shard
#

wait omfg im so dumb, im so sorry, there was another panel over the original posts panel, which the button was supposed to go to and i was clicking the wrong button, that's why it didn't change it's title and all

rich adder
#

:\

vital hinge
#

Hello, im having an issue with my moving background. It works until the player dies then it just stops. I'm using this script for the moving background:|

`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ScrollBackground : MonoBehaviour
{
[SerializeField] private RawImage _img;
[SerializeField] private float _x, _y;

void Update()
{
    _img.uvRect = new Rect(_img.uvRect.position + new Vector2(_x, _y) * Time.deltaTime, _img.uvRect.size);
}

}`

rocky canyon
#

theres nothing about the player in this code block

vital hinge
rocky canyon
#

meaning unless you've tied it to the player some how.. it shouldn't matter about the player..

polar acorn
# vital hinge no, on the bg

So nothing on this has to do with the player. If the player dying breaks this script, it's because of something the player is doing, not this one

#

Do you get any errors

vital hinge
rocky canyon
#

check the inspector when it breaks..

#

is the scrolling script still present.. and enabled?

vital hinge
#

yea

#

nothing seems to be broken

#

could it be just a unity bug? Maybe restarting it will help?

polar acorn
#

Log _img.uvRect after you set it

vital hinge
#

wait what?

#

what does that mean

polar acorn
#

Log the value of the thing you set

#

after you set it

#

So you can see what it's set to

vital hinge
#

I still dont get it, sry I know close to nothing about code

#

but could the problem be linked to time.deltatime?

polar acorn
rich adder
cosmic quail
vital hinge
#

mb

rich adder
#

Debug is the class

vital hinge
#

the debug is working

#

it keeps updating

cinder crag
vital hinge
polar acorn
cosmic quail
#

Time.deltaTime is 0 then isnt it

rocky canyon
#

if timescale is 0, yes deltaTIme is also 0

vital hinge
#

yea I guess, I removed the time.timescale and now everything works perfectly

cinder crag
vital hinge
rocky canyon
#

probably could just use a bool to tell what code to run instead of setting a global value to 0

polar acorn
rocky canyon
#

if(gameRunning){ // do all ur stuff }

#

then u can toggle that bool in the player class when it dies

cinder crag
polar acorn
#

that singleton should not reference any components on anything

#

other things should get and set data from the singleton

cosmic quail
rocky canyon
#

and then you would have that in the first scene of urs.. and if u apply DDOL to it.. and it will stick around in all ur scenes

cinder crag
polar acorn
#

Other things modify that struct through the singleton

harsh silo
#

Apologies if this is the wrong thread but I don't really see a general questions section. Are there any work arounds to when an imported asset is rotated wrong? My script to shoot it is not working properly because the arrow facing in a "flying" position will be going via the Y axis

vital hinge
harsh silo
#

ofc I can rotate it but that still prevents it from shooting along the z axis in its proper orientation

rocky canyon
#

a work-around is to use an empty container.. w/ the object as a child object.. (orientate the child object to face the right direction in reference to the parent)

#

and then use the parent object (as the main object)

short hazel
#

Or shoot towards transform.up instead of transform.forward

rocky canyon
#

^ a third solution

harsh silo
#

Awesome that's all helpful thanks guys

rocky canyon
cinder crag
wintry quarry
cinder crag
wintry quarry
#

You can/should have a static instance field for the LoadManager itself

#

you called this a "singleton" but I'm not seeing any of the usual singleton pattern aspects here

#

like an instance field etc.

cinder crag
#

so idek

wintry quarry
#

They did this:

public class Singleton : MonoBehaviour 
{
    public static Singleton instance;
}```
#

your code is not doing that

#

your code has a field of an entirely different type

#

the SaveData field should not be static

slate pendant
#

@frozen raft Please post your question here! Thank you!

wintry quarry
#

the public static LoadManager instance; should be static

#

but you don't have that at all

wintry quarry
#

but also restart it from the beginning because it's currently not rightr

cinder crag
#

i seriously dont get it ngl , i have a script and im trying to access a method from it that loads the data i need from a struct but theres references i need to make to the playerStats etc , by going with the singleton path , i dont understand how to do it since im not allowed to put a singleton where i need to make and get references but i need to have an object that is in both scenes , i cant put the SaveAndLoadingSystem in both scenes cause then i will have to put references n stuff from the player and i dont have the player in the main menu scene so idk how to go with this

polar acorn
cinder crag
rocky canyon
#

a singleton can be referenced from anywhere within the scene..

#

you can put a DontDestroyOnLoad method in the script to make it stick around in all the scenes..

#

so you'll have access to it from every scene w/ the right setup

polar acorn
cinder crag
polar acorn
rocky canyon
#

you can pass references to it when needed

cinder crag
#

So if the player health was 30 then it will load the health to be 30

rocky canyon
#

theres other methods of getting references than manually assigning them, as well

cinder crag
#

And I need the references cause those stats are on different components on the player obj

polar acorn
rocky canyon
#

^ yea, this is just a structure issue.

polar acorn
#

Imagine the data you want to pass between them is a large dodgeball. Your SaveAndLoadingSystem is in a tall tower, and the player objects are all running around in the field below it.

Does it make more sense for the players to throw the data ball up to the top of the tower, or for the tower to drop the data ball down to player?

lost anvil
cinder crag
polar acorn
#

The SaveAndLoadingSystem doesn't tell the objects its data, the objects ask it for their data

cinder crag
polar acorn
#

You'd just have other objects read that data to do things

cinder crag
#

or i could move the SaveData struct to another script and make that into a singleton then do the rest

polar acorn
#

So, as those values change in game, you'd have those objects change the corresponding value in your singleton

#

Then .Save would simply write the data to file

#

and vice-versa for Load

#

So, for example, when the player gets damaged, they'd change SaveAndLoadingSystem.instance.SaveData.health = newHealth (you might need to change your struct for a class)

#

And likewise, when a player object is created (either at the start of the game, when loading, when changing scenes, etc.) they'd set their health to SaveAndLoadingSystem.instance.SaveData.health

rocky canyon
#

everything digi is saying is 💯 truth.. heres an example of my Save method...
it has a reference to a data class where my game stores its data..
whenever I want to save my new data I just call the Save method..
all the data is there and ready to be written to the JSON save file

#

whenever something happens (player reaches a checkpoint) or the (player changes the volume settings) it automatically just updates teh stored values in the _savaData class

cinder crag
#

so i didnt need to do all of this and just save that data when needed

cinder crag
rocky canyon
#

my GameManager stores a reference to that data..
soo.. when my game boots up.. I set up all the game objects by using that reference

#

this is the asking part.. where my game objects ask for their values

mystic pike
#

so my buttons are not working, im using TMP buttons and im trying to click them and they do nothing (they where working fine yesterday) and the on click event is set up so i dont know whats going on

cinder crag
cinder crag
#

first i do smth like SaveAndLoadingSystem.instance.SaveData.health = health then save

rocky canyon
#

think maybe somethings blocking the buttons?

mystic pike
#

(yea i know single player is set to twoplayer)

rocky canyon
#

and ur image is marked as Raycast Target?

mystic pike
#

yea it is

rich adder
#

debug event system in playmode

#

the text is probably covering the buttons

mystic pike
mystic pike
rich adder
rocky canyon
#

i debugged w/o even knowing it existed for almost a year 😅

mystic pike
rich adder
mystic pike
#

this is what i get when i press single player

rich adder
mystic pike
rocky canyon
#

and you'll see the Raycast Target

#

all my text have this setting disabled.. b/c the text bar covers a good majority of the buttons

rich adder
#

ur text so wide lol

rocky canyon
#

thicc

mystic pike
rigid valve
#

I am trying to make a selection chat with npc but I cant choose the option

rich adder
rocky canyon
# mystic pike

yea, 2 things..

  1. u should disable the raycast target there..
  2. u lied to us (thats not TMPro)
rich adder
#

also just dont put Text elements above buttons
UI is always hierarchy Bottom = First

rocky canyon
#

may end up having to find dedicated asset documentation for troubleshooting..

mystic pike
rocky canyon
#

im gonna go ahead and say.. ive never used Ink.. so idk

rocky canyon
rocky canyon
#

in PS its the exact opposite.. top = top

rich adder
#

so drawn last = above

#

gpu thangs

rocky canyon
#

button order..

  • Container
    • Background (Button)
    • Text
rocky canyon
#

in photoshop its like drilling into the image.. layers come as u get to them (top down)

rich adder
#

yeah thats a good way to look at it lol

rocky canyon
#

this conversation may be relevent to u as well @rigid valve

#

make sure nothings covering the button (the text for example..) should have its Raycast target option disabled.. so u can click thru it..

#

check the EventSystem to debug what ur hitting ( during play mode )

mystic pike
#

yea @rocky canyon i switched it to TMP and it works fine

rigid valve
mystic pike
#

i feel like an idiot now

rich adder
#

btw u have a null reference

#

might wanna check that out

rigid valve
#

yeah I was trying to use mouse to select options so was updating the code

#

eaelrir I wanted to use only keyboard for seelcting options and have mouse clamped but that didnt worked out

rich adder
#

you cant select it with the mouse being locked

#

cursor has to be visible too afaik

rigid valve
#

do u know a better way to create a dialouge with options??? rn I am using ink

rich adder
#

either unlock the cursor for selections
or
there is a workaround for First Person view with locked cursor though by replacing the Input Module

#

Ink is amazing

#

its not the problem

rigid valve
#

this is my mouse code

rich adder
#

use links to post code

#

!code

eternal falconBOT
rigid valve
#

!code

eternal falconBOT
rich adder
#

this is bad for mouse btw
* Time.deltaTime

#

don't use that on mouse inputs, its already frame independent

rich adder
rigid valve
rigid valve
rich adder
rigid valve
#

I wanted this thing to work with arrow keys to nav and f to select but it wasnt working thats why I am trying mouse now still no resluts

rich adder
rich adder
rigid valve
rigid valve
#

do u have spare time I really need to fix this for college assignment

maiden niche
#

anyone got an idea why my inventory items wont stack

rich adder
rigid valve
rich adder
#

many people here are knowledgeable if I don't respond I'm sure someone will

cinder crag
rigid valve
rich adder
polar acorn
rich adder
rich adder
#

thats declaration of Savedata class

#

not the actual object

polar acorn
#

That's a class yes. Do you have a field named SaveData on your singleton

summer stump
#

That isn't even a declaration of the SaveData variable

rigid valve
summer stump
#

Just of a class that COULD be used (but apparantly isn't)

summer stump
#

"WORKKING " + choiceIndex

rich adder
#

that an int

#

if you want to debug the value add it to the string

#

"Working " + choiceIndex

summer stump
#

I believe they wanted "WORKKING" actually

rich adder
#

oh didnt see u wrote that already 😛

cinder crag
rigid valve
#

😭

rich adder
rigid valve
#

using fffff

rich adder
#

f ?

#

wat does that even mean

rigid valve
rich adder
#

you seem to have a wild misunderstanding how the Button component works

rigid valve
rich adder
#

i know but you have to do the simple stuff first, you're jumping into doing dialouge system without knowing yet how to interact with the UI lol

rigid valve
#

can I dm u if u dont mind

rich adder
#

if you have to make a seperate scene/project and strictly work on Buttons / methods through UI etc. Take that approach you slowly put everything together

#

you're learning too many things at once

rigid valve
#

have u checked my mouse code? shouldn't it get unclammped from centre when I am chatting with npc?

rich adder
#

I said that tho

#

You have to unlock the cursor and make it visible

#

otheriwse you'd need a special FPV Input Module made for locked curosr

rigid valve
#

how?? I googled it I found only this much

rich adder
#

keep it simple for now and unlock th cursor to interact with UI

rich adder
rigid valve
rich adder
#

Yeah I get it

rigid valve
#

I want it to get locked again when I leave npc

rich adder
#

so call the toggle

#

must be public to call it from another script

#

or subscribe to an event (probably too complex for you rn)

rigid valve
#

why call the toggle?

oak mist
#

I got a question for HUD implementation:

So as you can see theres a screen with some material on it to appear like there some information on it. Its static and doesnt change. I bought some animated HUD which i can customise to display health and say speed, but im not sure how / If i can implement it to the actual ship (This game will be in VR, so i see no real alternative). Any suggestions?

rich adder
#

this will keep toggling

oak mist
#

0h sorry, I thought the answer would be code based

#

where would i go for this?

rich adder
oak mist
#

snm

#

thank you

rich adder
rich adder
#

why did you do that

#

also dont send screenshots of code

rigid valve
#

to stop nonstop toggling?

rich adder
#

so you remove the entire method instead of not calling it every frame?

cinder crag
polar acorn
rigid valve
rich adder
#

you wont learn much if I tell you every single step though.

rigid valve
#

its working now with mouse finally

#

damn

#

still not working with keys tho

rich adder
rigid valve
cinder crag
polar acorn
#

And SaveData as well, actually

#

it's no longer a struct

rich adder
rich adder
cinder crag
rich adder
#

oh right

polar acorn
rigid valve
cinder crag
polar acorn
#

So you have to say which SaveAndLoadingSystem you want instance to be, and which SaveData you want SaveData to be

rich adder
rigid valve
rich adder
#

pretty sure they cover correct choices / actions

rigid valve
#

no it was only till this pokemon part

cinder crag
rigid valve
rich adder
polar acorn
#

For SaveData: This would set it to itself, how would that accomplish anything

rich adder
wet nebula
#

Hello friends 🙂 I have a question about "detection". I am making a platformer and naturally have to check collision with the floor, walls and cliffs... I am using Physics2D.OverlapBox right now to check those, one for each type of detection. Shoul I use collider triggers instead? Which one has a better performance or is it indiferent in this case?

cinder crag
regal bear
#

Hi, want to create a basic time system, not too complicated, just a clock with 0-24hours and minutes, for example after 20:00 it will be night, after 7:00 will be day. Is it that hard? I search for videos but all of these tutorials was like a lot line of code. Im not on pc now but will be soon, thats why i asking, then ill try figure it out.

cinder crag
#

smth like this for instance

polar acorn
rigid valve
rich adder
#

they cover everything you need

cinder crag
polar acorn
rich adder
#

imo the Physics class is the best method

rigid valve
wet nebula
rigid valve
#

lol I am wqatching this same guy

rich adder
#

Ever wonder how to convey your characters' thoughts or have your game talk to your player? In this tutorial, we take a look into a script tool called Inky from Inklestudios and write up a small dialogue for Phoenix wright in Unity!

Resources
Ink by Inklestudios: https://www.inklestudios.com/ink/
Brackey's Dialogue System: https://www.yout...

▶ Play video
#

iirc some stuff is newer and has more feature btw

#

check the docs for ink

cinder crag
#

so now whenever i make a change to lets say the health and maxhealth , i do smth like this?

rich adder
#

computers are very powerful these days, they can handle such things easily

wet nebula
#

@rich adder thanks a lot!

maiden niche
#

anyone got an idea why my inventory items wont stack

rich adder
cinder crag
#

lemme get u a vid rq

rich adder
rich adder
#

also if you serialized the class observe savedata in the inspector see if thats changing

polar acorn
cinder crag
rich adder
#

oof

#

you're saving the local saveData that is empty

polar acorn
cinder crag
#

now it saves

#

pog

rich adder
lost anvil
#

no sir im working on inventory

rich adder
#

holy hell
GetComponent<ChaseEffectHandler>().StartCoroutine(GetComponent<ChaseEffectHandler>().OnChaseStart());

#

just make a public mehod that calls the coroutine

lost anvil
#

👍

rich adder
#

anyway so is this only being called once ? OnChaseStart()

lost anvil
#

at the start of the chase when enemy spots player yeah, but then the hasStung bool resets OnChaseEnd and the canChaseTheme is handled in Update

#

so really the deciding factor whether it gets called is hasStung

rigid valve
#

@rich adder is are a keywork or smth

lost anvil
#

and i debugged it earlier and it was calling the chase music etc but it wasnt playing the sound

rich adder
lost anvil
#

it was im pretty sure but ill check again

rich adder
#

need to look at docs

rich adder
lost anvil
#

nope

#

definitely calls everytime

#

just doesnt play any sound on the second chase

rich adder
lost anvil
#

yeah

rich adder
#

audio source volume is up and all that in inspector on chase?

lost anvil
#

yup

cinder crag
#

so i am saving data n everything but it doesnt load it , and im confused on why

rich adder
short hazel
polar acorn
rich adder
#

from json returns data

polar acorn
#

You aren't doing anything with the result

cinder crag
#

how could i possibly do something with the result?

polar acorn
lost anvil
polar acorn
#

Right now it's fax-machine-into-shredder.gif

rich adder
lost anvil
cinder crag
polar acorn
cinder crag