#💻┃code-beginner

1 messages · Page 322 of 1

shell sorrel
#

types either only exist in code, or have a GUID provided by a meta file

#

so its fine to rename

#

just if its a MB or SO make sure the filename matches as well as meta

hexed terrace
shell sorrel
#

yeah same with rider

#

just mentioning since i have no clue what people use or if its properly setup

#

rider is pretty good for unity refactors, it will auto add needed attributes, and can even refactor stuff inside the scenes and asset and prefab files

wild veldt
#

Hello, i'm working on a project where at one point i need to be able to store and load different shapes for a polygon collider.
When my player switches from different states i need its hurtbox (a polygon collider) to change shape accordingly.
What would be your best solution to do it ?

shell sorrel
karmic kindle
#

Thank you very much!

shell sorrel
#

make a object that has multiple colliders on child objects and turn those objects on and off in code as needed

#

way simpler then trying to modify collider at runtime

rare basin
#
  • change the mesh when needed
wild veldt
wild veldt
#

it's called on each update

shell sorrel
#

why would you do it on each update, instead of just when the target changes

wild veldt
#

i mean yes it will work but is it optimal ?

shell sorrel
#

would worry just about making things work

#

but my point was something is setting target, so why not have the logic that sets target handle this isntead doing it in update

scenic saffron
#

How can i only use everything in Update while my Player is alive so i don't get a error Message when it dies?
Code:

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

public class Distance : MonoBehaviour
{
    public Rigidbody2D rb2D;
    public GameObject Player;
    public Transform PlayerPosition;
    public Transform Blackhole;
    float distance;
    private Vector3 Atraction;
    public float Gravety = 1000;
    

    void Start()
    {
        Player = GameObject.FindWithTag("Player");
        PlayerPosition = Player.transform;
        rb2D = Player.GetComponent<Rigidbody2D>();
    }

    void Update()
    {
        distance = Vector2.Distance(PlayerPosition.position, Blackhole.position);
        
        //Debug.Log(distance);
        
        Vector3 direction = Blackhole.position - PlayerPosition.position;

        direction.Normalize();

        //Debug.Log("Direction from object1 to object2: " + direction);

        Atraction = (direction / (distance / 2)) * Gravety * Time.deltaTime;
        rb2D.AddForce(Atraction);
    }
}
shell sorrel
#

just null check player at the start of Update and return early

#

if (Player == null) return;

scenic saffron
#

ok thx

#

works fine thx

old heath
#

Update on my enemy AI script: the issue with the different AI modes has been resolved (Update is now spelled correctly), but the speed issue still remains. Code: https://hastebin.com/share/ihunavowim.csharp

#

!code

eternal falconBOT
boreal dove
#

Player character behind and in front of objects

final kestrel
#

Hey guys. What does it mean when yield return null lets say for example. Waits for next update? I do not seem to understand how updates work and I do not even know what to look for on the internet. Can anyone point me to the right direction so I can do some research?

wintry quarry
summer stump
#

Looks like it runs immediately after update does, interesting

final kestrel
#

So If I am getting 60 frames per seconds. It calls the update 60 times?

wintry quarry
#

Update runs once per frame

#

So of course, yea

final kestrel
#

So what do you actually mean when it waits one frame?

#

Speaking about the yield return null

wintry quarry
#

I mean the code on the next line doesn't run until the next frame

#

I mean it literally

summer stump
ruby ember
#

does anyone know how to make record script?

example you survived 5 minutes and you get new record part (first image) and saves time

you survived like lower than 5 minutes you get your time (your time is the time you survived but you didn't get a record) and has best time the record you made

final kestrel
#

Isnt it like a second

deft grail
ruby ember
deft grail
summer stump
# final kestrel Yeah

A frame is a loop, it contains everything that needs to happen in the game. (Simplified almost to being incorrect)

It is NOT a second or any specific amount of time

wintry quarry
# final kestrel Isnt it like a second

A frame is basically a still Image of your game. Every frame the game draws a new image on the screen. By drawing lots of images really quickly, the game appears to be animated

#

Same concept as a cartoon or TV show

summer stump
#

All the stuff that needs to render and is written in update happens in a frame. The next frame will wait as long as necessary for the previous frame to complete

ruby ember
deft grail
#

so is the code you sent your code? or from a tutorial or something

ruby ember
final kestrel
deft grail
summer stump
ruby ember
deft grail
final kestrel
wintry quarry
#

It always affects the logic

#

It waits one frame

ruby ember
final kestrel
#

All right I'm probably not understanding something. I will do some research. Thanks a lot for your time!

wintry quarry
#

I feel you're still not understanding what a frame is

summer stump
deft grail
deft grail
ruby ember
hollow dawn
#

when i use unity remote why does it lag so much on my phone?

deft grail
hollow dawn
ruby ember
deft grail
quaint anchor
#

hello, im looking for a way to display my player's health on screen using a bar, how would I go about doing that, I've defined a health bar in the main player script just confused how to display that on the screen itself

deft grail
#

you would do this in the else statement which is when you dont get a best time

ruby ember
#

or another "if"?

deft grail
#

you either get a new record or you dont

#

new record > display new best
you dont beat record > display current time and display best time

ruby ember
#

i think like this right? (your time)

deft grail
#

and in the else statement you write code

ruby ember
# deft grail just keep this code?

i forgot to say

i got new record but when i play with lower record it dosen't appear new record or your time when i save the code like that

deft grail
# ruby ember
float minutes
float seconds
if(besttime...)
{
    newRecord = true;
    StartCoroutine
    besTime.text = ...
    setFloatBestTime...
}
else
{
    newRecord = false;
    currentTime.text = minutes and seconds
}
boreal dove
#

Im doing a game in a 3D engine but with 2D sprites. I did a camera with cinemachine which is fixed around my player character, and all the deco objects are always looking to the camera. but now i want, if im standing in front of a deco object the player shall be in front but if i walk behind the object, the object shall be in front. I watched some videos to do so, even in 3D with 2D sprites just like mine but i dont get it working and i dont know what im doing wrong. Can someone help me with that ?

deft grail
eternal falconBOT
boreal dove
final kestrel
summer stump
#

That is the point of coroutines generally. To spread logic over multiple frames or even seconds

#

Or until some event has occured

final kestrel
#

Frame in this context just means the game loop right? Like renders the image gets the input and moves the player etc?

boreal dove
summer stump
final kestrel
#

All right I will keep looking at that one. Thanks a lot for the answers again! Appreciate it.

lofty dome
#

i did everything and also added scrpti but this door is not opening

deft grail
#

might be better playing an animation also instead

lofty dome
#

i tried with animation it just makes it worse idk how to implement it since i just begun like 2 days in unity

#

oh wait i got it

#

no worries

#

thanks a lot

stuck palm
#

Strange bug, the custom physics calculations that I prepared seem to break down on lower fps

#

Collisions are not working as they shouls

edgy prism
#

Hello, Im trying to implement pausing in my game since I have coroutines running basically all the time I tried setting Time.timeScale to 0 the problem is with my Unpause coroutine

IEnumerator UnpauseCoroutine()
    {
        countdownImage.gameObject.SetActive(true);
        countdownImage.sprite = countdownSprites[0];

        yield return new WaitForSeconds(1f);

        countdownImage.sprite = countdownSprites[1];

        yield return new WaitForSeconds(1f);

        countdownImage.sprite = countdownSprites[2];

        yield return new WaitForSeconds(1f);

        countdownImage.gameObject.SetActive(false);
        state = GameState.Playing;
        Time.timeScale = 1f;
    }

Since im using WaitForSeconds with timeScale set to 0 the second never passes. Is using Time.timeScale good practice in the first place and if so how would I fix my coroutine

edgy prism
summer stump
edgy prism
stuck palm
#
private void Start()
    {
        pi = GetComponent<PlayerInput>();
        PlayerInputController[] piclist = FindObjectsOfType<PlayerInputController>();

        ID = piclist.Length;

        markerStart?.Invoke(ID, this);
        
        DontDestroyOnLoad(gameObject);
    }

Right now i have it so when this object is created it self sets the ID to the player count. this system breaks down when player 1 leaves while player 2 is still there for example. when they join back, they take overp layer 2 and break the game logic. how can i fix this

burnt lichen
#

I've had an issue with some code basically it is meant to find the nearest object with the food tag and store it as a Vector3 but it doesn't run at all prob bcs im iterating through every object here is the code:

Not related to jam but I've had an issue with some code(unity) basically it is meant to find the nearest object with the food tag and store it as a Vector3 but it doesn't run at all prob bcs im iterating through every object here is the code:

ruby ember
summer stump
ruby python
willow scroll
#

If there's a case, when the GetTime key doesn't exist in PlayerPrefs, consider using the method's 2nd parameter, float defaultValue.

bestTimeText.SetText(PlayerPrefs.GetFloat("GetTime", newBestTime)); // or simply 0f
stuck palm
#

can arrays have a null value

willow scroll
willow scroll
#

Say, you have an array of GameObjects, and suddently, the GameObject with the index 2 is destroyed. The array[2] is null.

#

It works with any enumerables of any reference-types

wintry quarry
#

Please note the difference between the variable referencing the array itself, and the values in the array

willow scroll
wintry quarry
#

The array reference itself can be null. And if it's an array of reference types, then each element can individually be null

#

any time you have a reference-type variable, it can be null.

willow scroll
#

So, "can arrays be null" / "can arrays have a null value". Pretty confusing to me

wintry quarry
#

Yes those are two separate questions, and it's unclear which @stuck palm was asking.

#

Note of course that objects themselves are never "null". Null is a particular value a reference -typed variable can have.
it just means the variable isn't pointing to any actual object

polar acorn
long coral
#

Hey everyone, does anyone know why I'm unable to pass a GameObject through my scripts? I've set up all the info on a scriptable object and then I'm passing that through to a manager class.
When I try and pass that on and instantiate the GameObject, I'm getting the error:
ArgumentException: Object of type 'UnityEngine.Object' cannot be converted to type 'UnityEngine.GameObject'.

It's specifically calling out the 'InitialiseMonster' method as the problem. Here is my code:

public class MonsterBase : ScriptableObject
{
    public string monsterName;
    public string monsterDescription;
    public MonsterStage monsterStage;
    public int health;
    public int maxHealth;
    public int mana;
    public int maxMana;
    public int startingWeight;
    public GameObject monsterModel;
    public ScriptableObject nextEvolution;
}

////////////////////// New class ///////////////////
private void SetMonsterStats(MonsterBase monsterBase)
        {
            monsterName = monsterBase.monsterName;
            monsterDescription = monsterBase.monsterDescription;
            monsterStage = monsterBase.monsterStage;
            monsterHealth = monsterBase.health;
            monsterMaxHealth = monsterBase.maxHealth;
            monsterMana = monsterBase.maxHealth;
            monsterMaxMana = monsterBase.maxMana;
            monsterStartingWeight = monsterBase.startingWeight;
            monsterModel = monsterBase.monsterModel;

            InitialiseMonster(monsterModel);
        }
wintry quarry
#

you'd have to look at the filename/line number of the error to know where

#

The code you shared doesn't have enough context (nor did you share the error details) to know exactly what the problem is beyond that.

polar acorn
#

Notably: A Scriptable Object is not a GameObject

wintry quarry
#

All GameObjects are Objects, but not all Objects are GameObjects

long coral
#

I think I've fixed it the s ript was listening for an event which sent an object and that was inteferring with the variable and then the method

#

Thanks for your help

stuck palm
wintry quarry
#

if it's an array of reference types, then yes

polar acorn
wintry quarry
#

if it's an array of value types, then no

#

There's nothign special about the values being in an array

stuck palm
wintry quarry
#

no

stuck palm
#

Okay

wintry quarry
#

If it's a type that's normally nullable, then it's also nullable in an array, and vice versa

#

the array changes nothing about that

willow scroll
polar acorn
#

/r/inclusiveor

willow scroll
stuck palm
#

Strange question, but can you create your own value type? Making your own class is a reference type if my knowledge serves me right, but can you make your own kind of int or something like that?

wintry quarry
#

of course

stuck palm
#

Or like a bool or a string or something

wintry quarry
#

strings are reference types

stuck palm
stuck palm
wintry quarry
#

Yes you should

willow scroll
wintry quarry
#

bool is a struct

#

but yes it's a builtin type

stuck palm
#

They're purple on my IDE so I thought it was a value type LOL

quick pollen
#

whats the best function to use when I want smth to happen when I instantiate the gameobject that the script is on?

quick pollen
#

cool, thought so but I saw "OnDestroy" and thought theres an "OnInstantiate" or smth, thanks!

#

or "OnLoad"

stuck palm
#

I think that's similar

#

It's what I use for some things

quick pollen
wintry quarry
#

Awake is most like "OnInstantiate"

#

OnEnable gets called too, but it will also get called again if you disable and re-enable it

stuck palm
quick pollen
#

cuz technically the object doesnt get enabled cuz the prefab im copying is enabled by default

quick pollen
#

oh cool

willow scroll
wintry quarry
#

Start happens like a whole frame later

#

Awake will have run by the time Instantiate returns

#

(as will OnEnable)

willow scroll
quick pollen
#

also how can I move smth using rigidbody without causing issues

#

I mainly use charactercontrollers so i kinda forgot

#

i dont want to just edit the velocity

stuck palm
willow scroll
quick pollen
#

maybe moveposition?

willow scroll
quick pollen
willow scroll
ivory bobcat
ivory bobcat
ruby ember
wintry quarry
ivory bobcat
willow scroll
# quick pollen maybe moveposition?

MovePosition is usually not too realistic and will definitely move the Rigidbody to the desired position. If you want the character to e.g. not go through the wall, use velocity or AddForce

willow scroll
#

Oh, I haven't mentioned the error

#

I forgot to convert float to string.

#

Add the .ToString method after the GetFloat

willow scroll
#

Alright

polar acorn
willow scroll
willow scroll
ruby ember
willow scroll
#

I have already told you what to do

polar acorn
willow scroll
#

ToString is a method, use parentheses.

ivory bobcat
#

Looks like the ide is already configured. There's a lack of the very basics.

lofty dome
#

the textbox is disappearing but it doesnot detect e click

#

im trying to make a dialogue box when i click the robot

willow scroll
ivory bobcat
#

Were there any console logs?

gaunt ice
#

!ide
your vscode tells you to install the extension

eternal falconBOT
gaunt ice
#

also update wont be executed on disabled object

summer stump
willow scroll
#

I thought they were trying to click on the text.

#

And I thought by "e" was meant "the"

lofty dome
lofty dome
ivory bobcat
summer stump
#

Figured it out in the other server. That script is on tbe same object they are disabling

gaunt ice
#

you need to have a configured ide to ask for help

boreal hare
#

Hello

#

How to make the Frame per second will smooth fast and goes slow

#

Target frame rate

willow scroll
ruby ember
ruby ember
willow scroll
boreal hare
#

Ok edit the Target Frame rate

willow scroll
ruby ember
quaint anchor
#

Just a quick question, how would I go about creating a score counter that goes up every single time an enemy dies,

wintry quarry
#

have the enemy class call a function on the singleton when it dies

willow scroll
quaint anchor
quaint anchor
#

this is currently the enemy death script and i tried to use a void Score function that would incriment the score by 50

wintry quarry
#

I don't see anything in this code that is calling out to a singleton score manager object.

quaint anchor
#

and the score going out

wintry quarry
#

that's just your damage and death logic

willow scroll
verbal dome
#

What do you want it to show?

quaint anchor
quaint anchor
willow scroll
willow scroll
#

If you want to actually kill the enemy, you'd usually use the Destroy method

Destroy(gameObject); // assuming the script is on the enemy
quaint anchor
wintry quarry
quaint anchor
#

what is a singleton ?

quaint anchor
#

let me change that now

wintry quarry
willow scroll
quaint anchor
wintry quarry
#

Are you playing with the console window open?

#

You should not ignore errors

quaint anchor
#

no there was no error in the console window

wintry quarry
#

Then what you are saying makes no sense

#

I bet there was an error

quaint anchor
#

apologies there is an error

wintry quarry
#

Exactly

quaint anchor
#

it only appears after the enemy is hit

wintry quarry
#

exactly

#

use a singleton

#

this will solve your problem

#

Turn the script that tracks the score into a singleton

#

google "Unity Singleton pattern"

quaint anchor
#

the script that trakcs the score is part of the main player script though

#

should i just make it its own script ?

wintry quarry
#

Doesn't make a difference

#

But yes

#

you should definitely make it its own script

#

Each script should only have a single responsibility

quaint anchor
#

okay let me do that then

wintry quarry
#

otherwise your code will be spaghetti

willow scroll
quaint anchor
wintry quarry
#

simpleton 😆

#

The UI would be a separate thing entirely

willow scroll
wintry quarry
#

It can read the data from the singleton

#

ideally, using events, but that's a little more advanced, so you could just have the singleton reference the UI and update it, or use Update from the UI script

quaint anchor
#

apologies caps lock

#

im a bit confused about actually implementing the singleton

#

i created a seperate score script

#

but am i supposed to remove the reference from teh enemy script

#

because currently I use this line in the enemy script to reference the score value

#

so that I can update the counter from the enemy script when it dies

willow scroll
wintry quarry
quaint anchor
#

use the singleton in the enemy script ?

willow scroll
wintry quarry
quaint anchor
#

or is the singleton its own script ?

wintry quarry
#

the score script should be a singleton

#

the enemy script should interact with the score script singleton

quaint anchor
#

right

#

oaky

#

so i copy pasted the singleton into the score script

wintry quarry
#

Good - now add the rest of the score stuff you need.

#

Also fix the name

quaint anchor
#

oh yeah it should be score not singleton

#

okay i added the float for the score counter

wintry quarry
#

Now from any other script you can do Score.instance.ScoreCounter to access that ScoreCounter float

willow scroll
# quaint anchor use the singleton in the enemy script ?

Alright, I would say so:

  • Enemy should be a script assigned to every enemy in your game
  • Sigleton is a generic class, created in a separate script
  • ScoreManager is a class, derived from the Singleton
public class ScoreManager : Singleton<ScoreManager>
  • Every time something happens with the Enemy, e.g. it collides with something, the score should be updated using the method in the ScoreManager.
ScoreManager.Instance.AddScore(1);
  • ScoreManager should manage all the variables like score and scoreText, which should be updated in the AddScore method
quaint anchor
#

okay i got it

#

so in the enemy die section i can now just add the Score.ScoreCounter line

wintry quarry
#

sure

#

sashok is recommending a bit of a "cleaner" more robust approach

#

It's probably better practice, but will be a bit more complex for you to start with

quaint anchor
#

yeah it does sound a bit more complex

languid spire
#

Score.instance.ScoreCounter

wintry quarry
#

Yes that my bad^

quaint anchor
#

does that look right ?

wintry quarry
#

no

willow scroll
polar acorn
# quaint anchor

So you want to set the score counter to 50 when this object dies?

wintry quarry
#

what you're doing right now is just setting it to 50

quaint anchor
#

oh okay

wintry quarry
#

= +50f means "set it to positive 50"

#

+= 50F means "set it to whatever it is right now plus 50"

quaint anchor
#

that was a mistype

#

i didnt even realise that

#

thank you

#

okay now thats set up am i able to ust display the score as part of the UI ?

willow scroll
quaint anchor
#

ah wait when testing, i am recieving the same error as before

willow scroll
#

Make sure you have the TMP_Text serialized in your manager class

quaint anchor
willow scroll
quaint anchor
#

it is the line i just added

polar acorn
# quaint anchor

Did you actually put an instance of Score in the scene somewhere

quaint anchor
#

ah wait that might be the issue

#

its because its not being referenced anymore

#

score is just a script its not tied to anything at the moment

#

i have this object that is the TMP for score

willow scroll
quaint anchor
#

should i put the script under that

willow scroll
#

You really shouldn't

#

Consider creating an empty GameObject like, what I usually call it, #ScriptsHolder

quaint anchor
#

right

willow scroll
#

You may call it like ScoreManager etc.

quaint anchor
#

and then i added score to that

willow scroll
#

That's right

#

You have to serialize the TMP_Text to store the text in your Score script

#

Which you then assign to your score text

quaint anchor
#

so in the score script itself is where i have to reference the TMP SCORE and then update it

quaint anchor
#

okay

#

so would i do get object ?

willow scroll
#

You simply serialize it using the SerializeField attribute

quaint anchor
#

in the code is there like a command that i can reference the tmp object

willow scroll
quaint anchor
#

oh okay

#

sorry i am new to unity i am just slightly confused on the code

willow scroll
#

And I would highly recommend to create a method in the Score script, which manages both setting the score and updating the text when parameter passed isn't 0

willow scroll
quaint anchor
#

😭

willow scroll
#

Oh, sorry, that was a typo, lol

#

"I'm not blaming you"

willow scroll
quaint anchor
#

no im a bit confused what to write after SerializeField

#

i wrote score

#

not sure if thats right

willow scroll
#

The SerializeField is the attribute, which should be written in []

#

The score's type is TMP_Text

quaint anchor
#

so that ?

willow scroll
#

So,

[Attribute] accessModifier type name;
willow scroll
quaint anchor
willow scroll
quaint anchor
#

ah there we go

#

now it shows up on the script

willow scroll
# quaint anchor

Yes, that's already right. But you should usually put the access modifier to readability

#

I would recommend putting private before TMP_Text

#

(Even though it's already private by default)

quaint anchor
#

gotcha

#

i created a different tmp thats empty

#

so that it can update that text

willow scroll
#

Drag it to the scoreText

quaint anchor
#

done that

willow scroll
# quaint anchor

Additionally, we use thisCaseToSeparateTheWordsForThisKindOfNames

quaint anchor
#

oh yeah woopsite

willow scroll
quaint anchor
#

after that then how do i actually update the text itself with the value ?

#

do i have to convert the float to string

willow scroll
#

I would first consider creating a method in the Score class.

#

Consider naming it like AddScore

quaint anchor
willow scroll
#

And it should have a parameter, guess, float is what you use.

willow scroll
# quaint anchor

Consider adding an access modifier before the method's return type (which is void and returns nothing)

#

(Although an access modifier isn't important)

willow scroll
quaint anchor
#

oh okay

#

so public

willow scroll
#

Yes, that's the right conclusion

willow scroll
quaint anchor
willow scroll
quaint anchor
#

i am a bit confused

modest dust
# quaint anchor

It would probably be wise to also rename #ScriptHolder GameObject to something more meaningful, such as ScoreHandler, to avoid any confusion later on

willow scroll
summer stump
slender nymph
# quaint anchor

you should consider going through some basic c# courses so you understand the syntax of the language and how to correctly structure and write your code

quaint anchor
#

i am typically used to using GMS langauge not C#

willow scroll
quaint anchor
#

right

slender nymph
quaint anchor
#

as the text is for a score counter

#

so im just using float to track the score

willow scroll
slender nymph
summer stump
#

For how much score to add

Unless it is always a set amount I guess

willow scroll
modest dust
#

Like, "UI Handlers" or anything

quaint anchor
summer stump
slender nymph
willow scroll
dusky zenith
summer stump
quaint anchor
polar acorn
#

it's not a condition

willow scroll
dusky zenith
#

It seems like that AddScore is just being called to me, why is it completely wrong lol

summer stump
slender nymph
summer stump
#

They replaced the method declaration with that

dusky zenith
polar acorn
quaint anchor
ivory bobcat
#

Relative to indentation and the curly brace, they probably had try to define it like a method where instead they're wanting to make a statement call.

quaint anchor
#

decided to use C# because using python for games or any game related thing was way too slow and inefficent

modest dust
dusky zenith
quaint anchor
willow scroll
slender nymph
quaint anchor
summer stump
timber tide
#

my snake game I made in pygame begs to differ

#

totally running that at 200+ fps

slender nymph
ruby ember
willow scroll
ruby ember
quaint anchor
slender nymph
#

then you certainly don't have enough time to finish it considering you don't even know how to write a method

ivory bobcat
summer stump
quaint anchor
willow scroll
slender nymph
quaint anchor
#

i watched videos on basics like movement and handling stuff i intended to put in my game and the rest was just done by trial and error

willow scroll
quaint anchor
dusky zenith
willow scroll
ivory bobcat
quaint anchor
#

i am just strying to implement what you were saying before

#

then i shall look through C# tutorials

willow scroll
slender nymph
#

"i just want to do this one thing. then i super pinky promise that i'll go learn the basics. i promise"

willow scroll
quaint anchor
#

my bad for being on a time crunch i guess

willow scroll
#

How long time have you even had for the whole project?

ivory bobcat
quaint anchor
#

roughly a week or so

quaint anchor
willow scroll
quaint anchor
#

it is due at midnight for me

willow scroll
#

I would have had 30 minutes, had it been me

ivory bobcat
#

I'm assuming with the inferred lack of basics and squiggly line, this implied you had called the statement in an inappropriate scope.

slender nymph
dusky zenith
quaint anchor
quick pollen
#

how can I move an object forward using AddForce?

quaint anchor
#

it benefits me more long term to actually understand unity and c# as thats whats used at the university i am attending in september

willow scroll
quick pollen
quaint anchor
#

all its doing currently is setting up the scorecounter variable that can be accessed by other scripts and updated, using a singleton it creates an instance of the script that can also be changed from any other script and accessed

willow scroll
#

The method should

    1. Update the score
_score += value;
    1. Update the text
scoreText.SetText(_score.ToString());

Don't forget to first check whether the value is 0 to increase the performance.
The method should be called whenever you want in the Enemy class.
Is this all? Yes.

ivory bobcat
quick pollen
#

nvm im stupid, rb.AddForce(transform.forward, ForceMode.Impulse); was it all along
....i used Vector3.forward........

ivory bobcat
#

If you're just looking for code, there are examples in the docs

quaint anchor
# dusky zenith Nice 🙂

i am very aware of what i am coding and understand it after i implement it, its just that when it comes to implementing things i am not sure the specifics of how to do so always

dusky zenith
#

No problem

quaint anchor
#

or will it be something like 1 or 0

#

i created the public method

willow scroll
quaint anchor
#

im just confused as to where the value is being taken i wouldve assumed it wouldve just been as simple as having like a variable defined at the top and then just adding to that via a method in another script

ivory bobcat
willow scroll
quaint anchor
#

oaky so im using ScoreCounter then in the paramater

#

since thats the value i want to display

#

on the text

#

right

ivory bobcat
#
//Somewhere in Start()
AddScore(5f);//Usecase```
slender nymph
willow scroll
quaint anchor
dusky zenith
#

the parameter is value, public void AddScore(float value) the parameter is a float and it's called value

quaint anchor
#

right that makes more sense

willow scroll
modest dust
willow scroll
quaint anchor
#

but i assumed that'd be handled as a part an enemy script not here

willow scroll
#

Corrected.

modest dust
#

Point 2 is still wrong

dusky zenith
quaint anchor
#

i adjusted the variable names a bit to refelct what im using

dusky zenith
#

This is good now

ivory bobcat
#
[SerializeField] private float _score;
public float Score
{
    get => _score;
    set
    {
        _score += value
        scoreText.SetText(_score.ToString());
    }
}```
willow scroll
#

Thank you

quaint anchor
willow scroll
dusky zenith
#

Well now that you have an addscore function

#

You should use that

willow scroll
quaint anchor
#

okay so change ScoreCounter to AddScore

#

wait no

#

oh wait that was right

willow scroll
dusky zenith
#

Yes now it's right

willow scroll
#

Also you may consider creating a variable from this 50

modest dust
#

And make ScoreCounter private for good measure

quaint anchor
modest dust
#

since it neither needs to be public nor serialized

willow scroll
quaint anchor
willow scroll
quaint anchor
#

okay nevermind i was wrong then

quaint anchor
#

is that right

willow scroll
quaint anchor
#

oh yes right

#

and delete

#

the

#

Score Counter

wintry quarry
#

or you could switch to it

#

but you're in a weird hybrid mode right now

#

but the function alone was fine for now

willow scroll
dusky zenith
# quaint anchor

Also the name of the variable is the same as the class, which could bring up some issues

#

Property

quaint anchor
#

i changed the

modest dust
quaint anchor
#

stuff

wintry quarry
#

idk this property is just complicating things

quaint anchor
#

wait i forgot to change Score

wintry quarry
#

and isn't really needed right now

willow scroll
wintry quarry
#

It's not complicated for someone who knows what they're doing but that does not include @quaint anchor

quaint anchor
#

appreciate it

willow scroll
quaint anchor
#

i added the property and changed the float name to ScoreAlt to avoid confusion

willow scroll
quaint anchor
#

Score is the same as the class

#

Score

#

since i named the script Score

willow scroll
#

Having a variable and a property for the same class with different names is what indeed gives you the confusion

quaint anchor
#

so it was flagging it as an error since the name was the same as the class it was enclosed in

rocky canyon
#

ide didn't like it

quaint anchor
#

yes

#

that being said though this means it should now work right

willow scroll
quaint anchor
willow scroll
#

The property is supposed to be called Score. The class should be called like.. ScoreManager..?

quaint anchor
rocky canyon
#

is scoreText assigned?

quaint anchor
willow scroll
quaint anchor
#

wait no what

#

it disappeared

willow scroll
willow scroll
# quaint anchor

Because you renamed it from scoretext to scoreText.
The field stores its value by the name, that's why changing its name makes it lose the value.

quaint anchor
#

okay its working now

rocky canyon
#

odd..

quaint anchor
#

my score finally incriments

willow scroll
#

Yey!

quaint anchor
#

i am very happy that worked

#

thank you very much for your help

#

i will now go and do some unity lessons

willow scroll
quaint anchor
#

so i can finish the rest of this code

willow scroll
rocky canyon
summer stump
final glade
#

Hello,
I am trying to replicate this animation on unity using gizmos and lerp. I figured out on how to do the center sphere animation, the problem lies with the others and their movement any recommendations?
Thanks!

wintry quarry
#

math

#

IDK - my recommendation is focus on each individual piece one at a time

final glade
wintry quarry
#

Mostly just looks like a bunch of sine functions and such

#

or just moving in a circle of increasing/decreasing radius

#

You'd have to analyze how each thing is moving ¯_(ツ)_/¯. If you can play it in slow motion that may help

tawny bolt
ruby ember
#

it worked but the thing to fix is the timer

#

counter

main anchor
#

what does this error mean?

#

heres the full error, sorry

summer stump
open vine
#

is there any reason why this piece of code wouldn't work?

#

ik that the code actually runs from the debug.log but it doesn't actually work when I check it out in the inspector

polar acorn
#

Whether or not it stays enabled is another matter, but if the log happens then it's definitely enabling it

open vine
#

ooh okay that makes a lot of sense

#

just to make sure if a script has a DontDestroyOnLoad then even though it enters a new scene it will redo the start and awake methods right?

open vine
#

the only thing that I have that disables the script is disabling it in the start method, but it won't run again when changing to a new scene?

polar acorn
willow scroll
# ruby ember

The delays before your messages are insane.
As I have mentioned in my previous response, parse the string as you've done it before.

open vine
#

mb i shouldve made it clearer. The code i showed is an event that runs the moment a scene is changed. So i think its running before the start method, and the start method ends up disabling it again.

polar acorn
rich mountain
#

to destroy a game object

destroy.gameObject();
#

Is that correct>?

rich mountain
#

thanks!

languid spire
#

no, does it not occur to you to go and read the documentation?

rich mountain
#

i couldnt find the docs

ruby ember
polar acorn
willow scroll
willow scroll
stuck palm
#
private void RegisterPlayer(PlayerInputController player)
    {
        print("adding " + player);
        players.Add(player);
        player.ID = players.Count;  
        markerStart?.Invoke(player.ID, player);
    }

i'm getting the stuff in the console, but in play mode the list doesnt update. players is a list of type PlayerInputControllre

wintry quarry
ruby ember
stuck palm
#

the list in the right where it says players has nothing in it

wintry quarry
# stuck palm

Maybe that's not the list your code has a reference to

polar acorn
wintry quarry
#

How and where are you calling RegisterPlayer?

stuck palm
wintry quarry
#

How is that set up?

stuck palm
#

there is only one characterselectmanager

#

in the scene

wintry quarry
#

Maybe you're not referencing the one in the scene

#

maybe you're referencing a prefab or something

tawny bolt
wintry quarry
#

When I'm asking "how and where" I'm kind of looking for code

stuck palm
#

PlayerInputController emits sendRegister on awake

wintry quarry
#

so it's likely adding it and immediately removing it

stuck palm
#

ohhhh

#

thats probably it

#

i didnt even notice that

wintry quarry
#

Adding a log to Unregister would have been my next suggestion

#

(if I knew it existed)

stuck palm
#

mb i should have provided more context

abstract finch
#

Is there an easier way to write this offset position out?
Vector3 offset;
Vector3 positionWithOffset = transform.position + (transform.right * offset.x) +(transform.up * offset.y) + (transform.forward * _offset.z);

wintry quarry
#

or:

Vector3 positionWithOffset = transform.position + transform.rotation * offset;```
#

The former takes your object's scale into account.
The latter does not.

abstract finch
#

awesome thank you!

rich mountain
#

Anyone know why my text is not showing up ingame?
it shows up in saying it should show in my debug log but in game it doesnt show

public class HudController : MonoBehaviour
{
    public static HudController instance;
    public void Awake()
    {
        instance = this;
    }

    [SerializeField] TMP_Text interactionText;

    public void EnableInteractionText(String text) 
    {
        interactionText.text = text + ("F");
        interactionText.gameObject.SetActive(true);
    }

    public void DisableInteractionText()
        {
           interactionText.gameObject.SetActive(false);
        }
}
polar acorn
rich mountain
#
    void SetNewCurrentInteractable(Interactable newInteractable)
    {
        currentInteractable = newInteractable;
        currentInteractable.EnableOutline();
        HudController.instance.EnableInteractionText(currentInteractable.message);
    }

    void DisableCurrentInteractable()
    {
        HudController.instance.DisableInteractionText();
        if (currentInteractable)
        {
            currentInteractable.DisableOutline();
            currentInteractable = null;
        }
    }
}
polar acorn
rich mountain
#

wym what calls it?

#

like the tmp?

polar acorn
#

I mean what calls this function

#

Are you sure it's running at all

rich mountain
#

yeah i used a debug log and it runs it but it just doesnt show up

polar acorn
#

Where did you log

rich mountain
#

under

interactionText.gameObject.SetActive(true);

and

interactionText.gameObject.SetActive(false);
#

also under

HudController.instance.DisableInteractionText();
polar acorn
#

Make sure that it's not deactivating it after the activate

rich mountain
#

I believe it is, the debug log only pops up once when its set to active but the DisableInteractionText debug log is always going

#

lemme run it again with Collapse and see

polar acorn
polar acorn
rich mountain
#
   void SetNewCurrentInteractable(Interactable newInteractable)
    {
        currentInteractable = newInteractable;
        currentInteractable.EnableOutline();
        HudController.instance.EnableInteractionText(currentInteractable.message);
        Debug.Log("Text ON");
    }

    void DisableCurrentInteractable()
    {
        HudController.instance.DisableInteractionText();
        Debug.Log("Text Off");
        if (currentInteractable)
        {
            currentInteractable.DisableOutline();
            currentInteractable = null;
        }
    }
}

So im getting the "Text Off" constantly even without looking at the object
but im getting the "Text On" Once while looking at object

#
    public void EnableInteractionText(String text) 
    {
        interactionText.text = text + ("F");
        interactionText.gameObject.SetActive(true);
        Debug.Log("Enabling Text");
    }

    public void DisableInteractionText()
        {
           interactionText.gameObject.SetActive(false);
           Debug.Log("Deleting Text");
        }
}
#

Same with this one

polar acorn
#

Because it's getting deactivated every frame

rich mountain
#

so ill need to only delete when i look away

polar acorn
#

Yes

rich mountain
#

How would i do that?

#

Using a if statement?

#

or would i just need to move the disabler to another spot

polar acorn
#

You never actually told me what calls these functions so I can't answer that

rich mountain
#

EnableInteractionText

#
public class HudController : MonoBehaviour
{
    public static HudController instance;
    public void Awake()
    {
        instance = this;
    }

    [SerializeField] TMP_Text interactionText;
#

Also i deleted both functions that delete the text and still the text doesnt show up

polar acorn
#

So, you have nothing disabling it, and the text doesn't appear?

rich mountain
#

yeah

polar acorn
#

Does it still log, and does it log the value you expect

rich mountain
#

Yes it logs the value i expect

polar acorn
#

Either the thing you're looking at isn't interactionText or something else is setting it afterwards

stiff fjord
#

hey if i wanted it so when i click a ui button such as a picture of a couch it allows me to place a peice of couch in a 2d environment top down i understand the logic of it i dont understand how i would go about coding it imt rying to make my first proper game ive made about 20 short platformers this game is basically each time you click play a new procedually generated cottage entior is made and you decorate the empty house

deft grail
#

you would attatch that to a method which would instantiate/activate a sprite or game object which would be the highlight of the couch

stiff fjord
#

im mainly looking for pointers on how to place the object down only on a tilemap with "floor" layer i shouldve been more clear srry

deft grail
stiff fjord
#

it isnt placed in the tilemap layer but i dont want it so the couch can be placed on a wall its hard to explain let me gets some images

#

so i want to try make it when i click if the player has the furniture hovered over a wall or in a void it will reject the placement but if its hovered over the floor it will accept

deft grail
stiff fjord
#

ok ill get back to the discord when ive completed that

rich mountain
#
public class PlayerInteraction : MonoBehaviour
{

    public float playerReach = 3f;
    Interactable currentInteractable;
    void Update()
    {
        CheckInteraction();
        if (Input.GetKeyDown(KeyCode.F) && currentInteractable != null)
        {
            currentInteractable.Interact();
            Debug.Log("You pressed F on it");
        }
    }

    void CheckInteraction()
    {
        RaycastHit hit;
        Ray ray  = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
        if (Physics.Raycast(ray, out hit, playerReach))
        {
            if(hit.collider.tag == "Interactable")
            {
                Interactable newInteractable = hit.collider.GetComponent<Interactable>();
                if (currentInteractable && newInteractable != currentInteractable)
                {
                    currentInteractable.DisableOutline();
                }

                if (newInteractable.enabled)
                {
                    SetNewCurrentInteractable(newInteractable);
                }
                else 
                {
                    DisableCurrentInteractable();
                }
            }
            else 
            {
                DisableCurrentInteractable();
            }
        }
        else 
        {
            DisableCurrentInteractable();
        }
    }

    void SetNewCurrentInteractable(Interactable newInteractable)
    {
        currentInteractable = newInteractable;
        currentInteractable.EnableOutline();
        HudController.instance.EnableInteractionText(currentInteractable.message);
        Debug.Log("Text ON");
    }

    void DisableCurrentInteractable()
    {
        if (currentInteractable)
        {
            currentInteractable.DisableOutline();
            currentInteractable = null;
        }
//        HudController.instance.DisableInteractionText();
 //       Debug.Log("Text Off");
    }
}

#

Is the interaction script

polar acorn
rich mountain
#

i dont see what could be changing it if the only thing that deletes it is commented and there is no interactable things besides the one im looking at

polar acorn
#

So if something else isn't changing it, then the thing you're looking at isn't interactionText

rich mountain
#

wym the thing im looking at?
Like the object?

polar acorn
#

The thing you're expecting to display the text

#

You've logged interactionText.text. If that logs what you expect it to, and there's a text thing you are looking at that doesn't, then those are not the same object

polar acorn
rich mountain
#

Yeah

polar acorn
#

Assuming everything else you've told me is true

rich mountain
#

how can it not be interactionText

polar acorn
#

Show that

polar acorn
#

Okay, now, click on that. What object highlights in the hierarchy?

polar acorn
polar acorn
#

Since this is interactionText, and your log shows that interactionText.text is what you expect it to be when you expect it to be that, then something else is changing it

rich mountain
#

It logs correctly in the console

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

public class HudController : MonoBehaviour
{
    public static HudController instance;
    public void Awake()
    {
        instance = this;
    }

    [SerializeField] TMP_Text InteractionText;

    public void EnableInteractionText(String text) 
    {
        InteractionText.text = text;
        InteractionText.gameObject.SetActive(true);
        Debug.Log(InteractionText.text);
    }

//    public void DisableInteractionText()
//        {
//           interactionText.gameObject.SetActive(false);
//           Debug.Log("Deleting Text");
//        }
}

#

This is the HUD script

#

Nothing in it changes the text

polar acorn
#

You've shown evidence that it's the correct object, and that the log is printing properly, so simple deductive reasoning shows that since it is correct at this time, something else must be making it incorrect after this runs

rich mountain
#

after it runs would be a void Awake or void start/update?

deft grail
rich mountain
#

start runs at the start same with awake correct?

deft grail
rich mountain
#

yes

rich mountain
#

the instance: = this;

queen bone
#

can someone help me ?, Im doing a arrow that points to a enemy position based on the player position and rotation but the code that i have dont work very well

        
        Vector3 FirstPoint = (Player.position - transform.position).normalized; // Direção inicial do objeto
        Vector3 LastPoint = (Inimigo.position - transform.position).normalized; // Direção final do objeto

        float angle = Vector3.Angle(FirstPoint, LastPoint);

        Quaternion PlayerRotation = Player.rotation;
        float KartYrotation = Player.eulerAngles.y;
        if (KartYrotation > 180f)
        {
            KartYrotation -= 360f;
        }
        Quaternion rightrotation = Quaternion.Euler(0f, 0f, angle - KartYrotation);

        transform.rotation = rightrotation;
eternal falconBOT
deft grail
queen bone
#

the arrow just flip flop randomly

stiff fjord
#

you can place furniture now

deft grail
stiff fjord
#

would i do like a constant update every time it changes a square on the grid to see if its on a tilemap cell and if its not dont let the mouse move

queen bone
#

if someone can go call with me to understand better my problem I would be very grateful if you could give me some help

deft grail
deft grail
stiff fjord
deft grail
stiff fjord
#

might go with that one

#

but the game isnt relativley performance intensive eitherway

#

also how to postproccess on cinemachine?

queen bone
deft grail
stiff fjord
#

i tried but nothing shows up

#

im using a virtual camera

deft grail
stiff fjord
rich mountain
#

Very simple fix

stiff fjord
#

image 1 = pp layer
image 2 = whole scene
image 3,4 = normal camera

#

image 5 = cine

rocky canyon
#

vcam uses reg cam, u just enable it on the camera like a non-cinemachine project

#

for urp atleast, been a while since i used the built in rendering pipeline.. but was teh same way, even using the post processing stack, u did ur volume / layers and w/e and just applied that to the regular cam

stiff fjord
#

i enabled it but it still doesnt work its 2D

regal bear
#

Hello, i am very beginner, i know only basic of coding, but already experimented a lot of thing, just for hobby, i want to make a simple 3D RPG game. Can you give me a few advice, tips tricks for a beginner? Also i really like database systems, any way to handle weapons, items, monsters etc like a database? Since i want to make a singleplayer game a real database not needed, but i like that structure.

deft grail
regal bear
fierce shuttle
# regal bear Hello, i am very beginner, i know only basic of coding, but already experimented...

If you are not familiar with them already, I would look into programming patterns and code architecture, it may help with breaking your logic into steps and managing your code so it doesnt become super messy, albeit it does take some trial/error to get familiar with patterns and implement an architecture that works well with your workflow - I think ScriptableObjects are the easiest to use for data in Unity but if you wanted a more flexible solution, you could look into NoSQL databases, which are basically just local databases that dont exist on a cloud - though an RPG, even a simple one may be a bit of a big project, but also a nice genre to learn making generic and modular code in, be sure to look into source control once you get started, as youll likely need to revert changes (or just have a backup) at various points of development

rich adder
quaint anchor
#

hello i have a question, I am currently trying to make a results screen for my game that shows a couple values, i have the results screen showcasing but was wondering if there were some issues with my code, my goal is to showcase a number next to the enemies hit field that relates to a number that is divided by 50 to get the number of enemies, but for some reason it is not showing up

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

public class ResultsScreenScript : MonoBehaviour
{
    public static ResultsScreenScript instance;
    public float _score;


    //place TMP for enemies hit in here
    [SerializeField] private TMP_Text enemiesText;

    //place TMP for grade in here
    [SerializeField] private TMP_Text gradeText;
   
    void Start()
    {
        
    }

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

    public float ScoreAlt
    {
        //gets score value from _score then sets it in the addscore method
        get => _score;
        set => AddScore(value - _score);
    }

    private void Awake()
    {
        //checks if instance is relevant and functioning
        if (instance == null)
            instance = this;
    }

    public void AddScore(float value)
    {
        //displays score on TMP in game
        _score += value;
        value = value / 50;
        enemiesText.SetText(value.ToString());
    }
}
deft grail
#

did you debug.log the value and the text after changing it

quaint anchor
#

no not yet

#

let me do that now and get back to you

quaint anchor
#

nothing shows up in the console

deft grail
regal bear
quaint anchor
#

it is meant to be a passive script that is always active in the scene

deft grail
quaint anchor
#

the code i just pasted

#

its attached to an empty object

#

with just the script inside

#

it is meant to log the player's score over the course of the song and the relay back the information to them

deft grail
#

but you still need to add score for it to run

summer stump
deft grail
#

it wont just do it by itself

quaint anchor
#

addscore is called in the enemy script when it is killed

deft grail
quaint anchor
#

oh in the

deft grail
quaint anchor
deft grail
#

where do you run AddScore

#

it doesnt do it automatically

summer stump
quaint anchor
#

in both score and results screen

summer stump
quaint anchor
#

its tracking the same thing

summer stump
deft grail
quaint anchor
#

oh

summer stump
#

Having two scripts is probably causing you confusion

quaint anchor
#

that may be the issue then

#

is it better to just handle it in the one script then

deft grail
#

doesnt even make sense for it to be in more than 1

quaint anchor
#

okay ill get rid of hte one script

#

okay ive moved the field to my score script

deft grail
quaint anchor
#

just throwing it in there for grading

#

specifies to comment on code as much as possible

deft grail
quaint anchor
#

alright

#

well now that ive done that when im taking in the score do i just output it the same as addscore ?

#

i have this method

#

so i assume id just replicate that under a diff method name

#

and then do what i did before

deft grail
#

yeah

quaint anchor
#

is this fine ?

deft grail
quaint anchor
#

id like to hope so

fierce shuttle
summer stump
quaint anchor
#

i followed the same methods i did to showcase my score on screen during gameplay but for some reason it is not working now

deft grail
#

what is _score

#

what does that represent

quaint anchor
#

its a variable that holds the value of the players total points

deft grail
#

and is "points" supposed to be the amount of enemies hit

#

or is that something different

quaint anchor
#

it is but also isnt, each enemy hit is worth 50 points

#

which is why i divide points by 50 at the end on the results screen to get the actual number of enemies hit

deft grail
safe hull
#

I have a question about colliders. I have an interaction circle that detects collisions with a tilemap collider, but I noticed that my debug does not go off when i collide with a new tile while another tile currently inside the circle. I'm guessing this has to bdo wit hthe tilemap collider and all the tiles being the same collider, so I was wondering if there were any workarounds

quaint anchor
deft grail
quaint anchor
#
{
    public static Score instance;

    //keep track of the value of the score
    private float _score;

 
    [SerializeField] private TMP_Text scoreText;
    
    [SerializeField] private TMP_Text enemiesText;
   
    [SerializeField] private TMP_Text gradeText;

    public float ScoreAlt
    {
        //gets score value from _score then sets it in the addscore method
        get => _score;
        set => AddScore(value - _score);
    }

    private void Awake()
    {
        //checks if instance is relevant and functioning
        if (instance == null)
            instance = this;
    }

    public void AddScore(float value)
    {
        //displays score on TMP in game
        _score += value;
        scoreText.SetText(_score.ToString());
    }

    private void EndGame()
    {
        var value = _score / 50;
        enemiesText.SetText(value.ToString());
    }

    public void FinalGrade(float value)
    {
        //displays grade at end of the round
        if (_score >= 8000)
            enemiesText.SetText("A");
        if (_score >= 6000)
            enemiesText.SetText("B");
        if (_score >= 4000)
            enemiesText.SetText("C");
    }

}
deft grail
#

but the main thing i assume is your just nto calling any of these methods

#

they are just sitting there

deft grail
quaint anchor
#

ah right i forget to set them

#

like i did with AddScore

fierce shuttle
deft grail
#

because this isnt the same thing

quaint anchor
#

oh okay

#

i assumed it would be done the same

rich adder
deft grail
#

same with FinalGrade

quaint anchor
cosmic dagger
deft grail
quaint anchor
#

my logic for ending the game is under a different object

deft grail
quaint anchor
#

okay that makes sense

summer stump
safe hull
#

alright thanks

quaint anchor
deft grail
quaint anchor
#

when i place it in the other script it says it does not exist in the current context

quaint anchor
deft grail
#

in the middle of the script in some random place

quaint anchor
deft grail
#

show the surrounding lines

quaint anchor
#

at the top just under the class

deft grail
#

you arent declaring a variable

#

you are running code

fierce shuttle
# regal bear does nosql affect performance higher than the scriptable object? so should i sti...

Im not sure on the performance difference, though one benefit is with a database, you can access and change your games data outside of Unity, with ScriptableObjects, you can directly pass them as a reference to objects to share or clone data (such as spawning weapons with the same base stats, or playable characters), you can use either or both if your project is intended for learning, though with an RPG that usually has tons of data-driven content, a database may be easier to manage in the long run, albeit it might take more time to setup/learn

quaint anchor
#

since thats whats dealign w ending the game

deft grail
#

so if thats where it is

summer stump
deft grail
#

then thats where it should go i suppose

quaint anchor
quaint anchor
deft grail
#

whats the code

quaint anchor
deft grail
#

you are accessing it outside its own class

#

so it should be public

quaint anchor
#

okay i changed it

#

to public

#

i didnt realise it was set to private

cosmic dagger
# quaint anchor

you made it private. it can only be called within the class which created it . . .

quaint anchor
#

when trying to do the same though i get flagged w a different error for finalgrade, do i need to remove the value float from the paramater in the original script

deft grail