#💻┃code-beginner

1 messages · Page 251 of 1

keen bramble
#

What would be a good beginner game to make

red scarab
#

makes sense, but I assumed it was capped to 60fps so I didnt expect such a dramatic change in force requirements

wintry quarry
red scarab
#

yea I thought I did lmfao

wintry quarry
#

regardless you want to use Fixed so it's consistent

red scarab
#

ofc

summer stump
ivory bobcat
#

If you find yourself fighting/modifying the rigid body physics system too often, consider using non physics or kinematic rb. Oftentimes, it's easier to implement your own gravity than to fight friction/sliding and forces applied to your target - which will happen if your game isn't a ragdoll/roll-a-ball or physics simulator. Unfortunately, rigid body physics is extremely popular, so you'll be losing a lot of support if you're intending to use Character Controller or roll your own (kinematic/Transform)

wind raptor
#

I have a question about best practices with coroutines. I'm writing a function to crossfade between two audio clips in my audio manager script. I'm planning to have a coroutine to handle the fading out of one clip/source and the fading in of another, but I'd rather the calls to the audio manager not require the caller to start the coroutine. Is it common practice to have a public function like ChangeClip and a private coroutine called internally called something like _ChangeClip? Or how do others handle things like that?

As an aside, does the caller of a coroutine "own" that coroutine? As in, who would need to call StopAllCourtines() in order to halt it? The caller, or the script on which it was called?

ivory bobcat
#

You'll need rb physics for complicated physics behaviors though, unless you're wanting/willing to implement those yourself.

modern smelt
#

was thinking to far

ivory bobcat
#

I was referring to reducing or limiting your current velocity on button release. You'll probably not want to completely abandon forces and doing so probably still won't work the way you would entirely expect it to - you probably wouldn't want to be assigning the vertical velocity a positive value or zero if you aren't grounded/flying etc

modern smelt
#

i finnaly just apply a vector in started and another one in canceled

modern smelt
brazen canyon
#

Hey guys
I have this class.
In this class there's a bool variable and I made a property to get set it.
And in the Awake method I set this bool to true
Does this mean that the property is set to true too ?

swift crag
#

You didn't use the property at all.

#

Oh, that was intentional (:

#

I wouldn't say the property is "set to true"

#

Available certainly evaluates to true, thouh.

sacred reef
#

Hi, when i create a default unlit shader and create material and apply it, the object disappers.
is this intended or is something wrong with unity ?

ivory bobcat
swift crag
#

It's whoever StartCoroutine is invoked upon, indeed. The actual place you define the IEnumerator method doesn't matter.

#

(well, it doesn't matter for the sake of who owns the coroutine)

sacred reef
modern smelt
# ivory bobcat I was referring to reducing or limiting your current velocity on button release....
public void StartJump(InputAction.CallbackContext context)
    {
        
        if (context.started)
        {
            if (isGrounded)
            {Debug.Log("isGrounded");
                _jumpScheduled = true;
                jumpForceactual = jumpForce;
            }
        }

        if (context.canceled)
        {
            Debug.Log("Cancel");
            _jumpScheduled = false;
            Vector2 velUp = Vector2.zero + Vector2.down * jumpForceOnFall;
            rb.velocity = velUp;
            //rb.velocity = Vector3.down * jumpForce/2;
        }

What do you think about this ?

brazen canyon
swift crag
#

It will be true once Awake runs.

#

so, for example, if you're referencing a prefab, Awake won't have run on that object

#

and the property will return false

#

Awake runs as part of instantiation as long as the game object that SpawnPoint is on is activated

#
bool foo = spawnPrefab.Available; // false
var point = Instantiate(spawnPrefab);
bool bar = point.Available; // true
modern smelt
#

@ivory bobcat true xD

sage mirage
#

hey, guys! I am trying to load my best time and make it in format of a clock. So, how to do that right here?

{
    bestTime = PlayerPrefs.GetInt("BestTime");
    int minutes = Mathf.FloorToInt(bestTime / 60);
    int seconds = Mathf.FloorToInt(bestTime % 60);
    bestTimeText.text = "Best Time: " + bestTime;
    bestTimeText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
}```
modern smelt
#

but still the problem that i lost instantanetly my momentum and get drag to ground , how can i simulate a parabola ?

sage mirage
#

I don't know how to make that like I am displaying the best time text but I dont know how to convert that on that format

short hazel
#

If you need both, then put the Best Time: in the format string directly

#

"Best Time: {0:00}:{1:00}"

#

An alternative would be to store the time as a TimeSpan, which handles time automatically and supports formatting

#

Just noticed but your int bestTime parameter is useless because you overwrite its value on the very first instruction in that function

#

Whatever you passed there when executing the method is lost

pallid verge
#

why cant vs find playerRb?

short hazel
#

ControlGravity is static. Static methods cannot access non-static things

pallid verge
#

oh alright

#

thank you

#

what is the name of the G button because this doesnt seem to work

#

it tells me to change the input settings but i cant find them

swift crag
#

GetButton is not used for keys.

#

buttons are more abstract concepts, like "Fire"

short hazel
#

Edit > Project Settings > Input. This will search for the axis there

swift crag
swift crag
#

and both of those things would be able to make Input.GetButtonDown("Fire") return true

pallid verge
#

do these variables "Gravity", "Sensitivity" etc. matter if i want to just do something when the button is pressed?

short hazel
#

You should be using GetKeyDown instead

pallid verge
short hazel
#

Show your code, you need to pass a KeyCode value into that

pallid verge
#

a string doesnt work?

short hazel
#

It does, but the enum value provides more safety, you cannot pass a random value without it yelling at you immediately
Can't do KeyCode.fkljglkf for example, you get a compiler error

desert flume
#

anyone knows how to change the high score text programmatically?

feral oar
#

you can do stuff like
integer.ToString(); and it’ll convert the number to a string format

#

or just manually type the number, but i’m sure you want that to work dynamically so using a variable would be better

desert flume
#

ty

#

how do i save permanent data

whole isle
#

i want to add dashing to my game

#

the code been writted but idk how to add a button to it

#

i asked cahtgpt

#

and idk what to do from here

polar acorn
whole isle
#

like an input

polar acorn
#

To an input asset?

whole isle
#

ig

#

i wanna button when i press it dashes

wintry quarry
# whole isle

Well the first step I guess if you're using ChatGPT is to follow ChatGPT's instructions. You haven't followed step 1 and 2 of its instructions

polar acorn
#

How did you add all the rest of them if you have other inputs?

#

Just do that again for your dash button

whole isle
wintry quarry
#

generally but it mostly seems geared towards creating a whole new actions asset which you likely already have one of.

#

it's also only telling you how to create the action

#

not how to bind it to your code

whole isle
#

😭

wintry quarry
#

It's probably better to follow actual input system tutorials

polar acorn
#

You should probably just read the actual documentation for the Input System

wintry quarry
#

rather than asking CGPT

polar acorn
#

Then you won't need to wonder if it's done something right

polar acorn
#

you'll know it's right

whole isle
#

here my code btw

wintry quarry
#

always start with the official manual

#

RTFM

stuck jay
#

I'd only recommend using ChatGPT for summarizing Unity's docs

#

It's not reliable enough to generate tutorials on its own

void siren
#

so, I have this code, and it sorta works ig, but when the object drops below 1 health it destroys the atual object rather than the clone of the object. How would i make it destroy tthe clone instead?

wintry quarry
#

This code should basically not be running AT ALL on the "original". Since it is, you've done something wrong

void siren
#

so how would i make it destroy the clone thats being affected rather than the object?

wintry quarry
#

Most liekly rather than properly cloning things from a prefab, you're cloning things from an object in your scene

void siren
#

uh hah

#

yeah

wintry quarry
stuck jay
wintry quarry
#

But each copy will only destroy itself

wintry quarry
wintry quarry
#

they just need to make sure they're instantiating from a prefab instead of a scene object

polar acorn
void siren
#

so what should i do to make the object be a perfab

polar acorn
wintry quarry
#

Drag the object into the project window to create a prefab from it. Then delete it from the scene

void siren
#

what its supposed to do but ig i did something wrong

#

I have it

wintry quarry
#

Then have your spawner reference the prefab instead.

wintry quarry
void siren
#

ok ty

wintry quarry
#

also you probably want to delete the copy in the scene

stuck jay
# void siren wha

MyInstantiatedObject = (instantiate code here)

If (health <= 0)
{
Destroy(MyInstantiatedObject)
}

wintry quarry
#

no reason for one to be there

stuck jay
#

But yes, this isn't necessary if you use prefabs

wintry quarry
#

they would be separate objects

void siren
#

Its not letting me

stuck jay
wintry quarry
void siren
#

it gives me that red circle cursor

wintry quarry
stuck jay
#

Just make the instantiated object have its own destroy script

void siren
#

when i try to put it into this

wintry quarry
polar acorn
void siren
#

it is

wintry quarry
#

where is "this"

void siren
wintry quarry
#

more context

desert flume
#

how do i make my camera background checked

#

like chess

wintry quarry
#

stop cropping the screenshots

#

Show the full unity window

void siren
wintry quarry
#

drag the enemy prefab into that slot

void siren
#

i cant

wintry quarry
#

because that's not a prefab

#

you didn't make a prefab

#

that's just an image

void siren
#

ok so i messed up bad

polar acorn
void siren
#

i already deleted tghe object

wintry quarry
#

just ctrl z to get the enemy back in the scene and make a prefab from it as I described before

void siren
#

oh i didnt know ctrl z worked on that

whole isle
whole isle
wintry quarry
#

is this new?

void siren
#

0-0 i cant drag it into the project window because im dragging it around the scene

wintry quarry
whole isle
wintry quarry
#

not the scene window

void siren
wintry quarry
void siren
whole isle
desert flume
wintry quarry
whole isle
wintry quarry
#

click on it

#

in the project window

#

double click it actually

polar acorn
desert flume
#

Oh

void siren
#

now the script for the enemies isnt working

polar acorn
#

This seems like you just want to put a texture on something or put an image behind something

desert flume
#

yeah thats more of a unity question i think

void siren
#

they dont move or anything

whole isle
wintry quarry
polar acorn
#

they mean the project window

wintry quarry
#

that would be where assets live

polar acorn
#

the window labeled project

#

the window created specifically to hold project files

#

that window

whole isle
polar acorn
wintry quarry
#

but it's very likely open already

whole isle
wintry quarry
#

are you trolling me sir

whole isle
#

omg lool mb

#

sorry

polar acorn
wintry quarry
#

Well to be fair

polar acorn
#

why would they mean rendering if they said general

wintry quarry
#

directionally...

#

Rendering is under General

#

🥹

whole isle
#

then i click project

wintry quarry
#

mhmmm

#

then you look at the project window

#

and find your asset

#

and open it

#

assuming you created one

#

if you didn't create one, you create one now

#

If this is a premade project, there will already be one... somewhere

whole isle
#

im sorry but im actually baffled

#

i press project and nothing happend

wintry quarry
#

Yeah because the project window is probably open already

polar acorn
#

as we said

#

now go look at it

wintry quarry
#

it's the one that has all your assets in it

#

It says "Project" at the top of it

polar acorn
#

the one labeled "Project"

whole isle
#

this?

void siren
#

the script for the enemy wont work now, i need this player transform thing in here for it to work but when i delete the enemy object it wont let me put the player into the player transform thing

#

that was probably a bad explanation

whole isle
polar acorn
#

prefabs cannot refer to objects in scene

void siren
#

how would i do thast

void siren
wintry quarry
#

it's probably this:

polar acorn
whole isle
whole isle
#

Omg im so slow

polar acorn
void siren
#

gives me the red circle with a line going through it looking cursor

whole isle
polar acorn
whole isle
polar acorn
#

In code, set the variable after you spawn it

wintry quarry
#

I don't think you have an input actions asset yet

void siren
#

beginner D:

whole isle
polar acorn
void siren
wintry quarry
polar acorn
void siren
#

yeah

polar acorn
void siren
#

not in unity i dont think

polar acorn
#
void siren
#

isnt it just blahblah = moreblahbalh

#

with a few more words like public float for number values

polar acorn
#

So set the variable on the object you instantiate, not the prefab

whole isle
#

i have this

void siren
#

whats instantiate

polar acorn
queen adder
#

i haven't really i just need like a base idea of how i would do that

whole isle
# whole isle

by any chance how would i access this and add an inpuit for dash

void siren
#

i have to be with such a pain to deal with

#

because idk what ur talking about still

polar acorn
void siren
#

im spawning them

#

with a spawner

polar acorn
#

how

void siren
#

idk

polar acorn
#

then this conversation is over

void siren
#

no

#

lets continue

polar acorn
#

I literally cannot continue further without this information and you don't know it

#

so there's nothing more to be said

#

If you don't know how you're spawning something, how am I supposed to know what you are doing

void siren
#

lemme read the code

#

1s

#

oh

#

instantiate

whole isle
#

would this be fin e

polar acorn
whole isle
#

to use as my dash

polar acorn
#

that's the old input manager

#

which one are you using

whole isle
void siren
#

so how would i make them follow me.....

polar acorn
void siren
#

and the code work

whole isle
#

i tried the thing that the person sent and my thing dosent have the thing under it

polar acorn
void siren
#

i dont understand how instantiating them has got to do with me not being able to set this

#

oh ok the conversation really is over

#

nice

#

thanks for the beginner help

swift crag
polar acorn
polar acorn
whole isle
void siren
swift crag
#

you wrote code that does this

void siren
#

no

#

actually

#

im a beginner and watched a tutorial on how to do some basic stuff and still dont understand how it works because im a beginner

#

literally started yesterday

polar acorn
#

So, how are you spawning the object whose variable you want to change

swift crag
#

Okay. But you still must have actually written code that makes the spawner work, yes?

whole isle
#

is it here

#

pls tell me is that

#

PLEASEEEEE

#

PLSDLASDOASDOSDAO

swift crag
#

stop spamming

whole isle
#

sorry

keen bramble
#

Im strugglign to find a starting point to unity, the doc has no actualy starting point

swift crag
# whole isle

this is not the input action asset. This is the PlayerInput component.

It does currently reference the input action asset, though.

keen bramble
#

!start

eternal falconBOT
#

:teacher: Unity Learn ↗

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

keen bramble
polar acorn
# void siren this

Instantiate returns a reference to the object it's made. Set that object's .player variable

whole isle
keen bramble
#

It just tells me to use premade things

feral oar
swift crag
whole isle
swift crag
void siren
#

is there like a websiter

polar acorn
void siren
#

to how insantiate woeks

swift crag
void siren
swift crag
keen bramble
#

Ok

stuck jay
polar acorn
# void siren we went over this

Right. So, store the result of Instantiate in a variable. Then set the .player variable on that variable to the object you want

void siren
#

how would i store the result of it though

stuck jay
#

Learning Unity, and programming/modelling/drawing, is all about practice

swift crag
polar acorn
whole isle
#

is it this

swift crag
#

you've created two different InputActionAsset assets

void siren
#

all i know is the absolute basics of setting a variable

swift crag
#

you named one "Player movement" and one "PlayerInputActions"

polar acorn
whole isle
#

dam so how would i resolve this

void siren
#

well i know less

wintry quarry
#

delete one

#

use the other

whole isle
#

i think one of the is usless

polar acorn
summer stump
polar acorn
#

In this case moreblahbalh is your instantiate

#

Store that in a variable

void siren
#

ok so i should write blah blah = insitiate...

polar acorn
#

then set that variable's .player to what you want

whole isle
polar acorn
swift crag
void siren
#

where in my code does it say .player? im so confused

summer stump
whole isle
swift crag
#

we can't teach you ever single aspect of programming one message at a time

polar acorn
#

That's the variable you're trying to set

#

Store the result of Instantiate in a variable

#

Set that variable's .player

#

that's the thing you're trying to do

swift crag
whole isle
wicked stratus
#

I'm working on a 2d game, but I want the ability to have a 3d object as a part of the ui- i.e. there's a robot, and the player can rotate the robot to get a better view of this. I'm not sure how to implement this- it should be able to go over ui. I haven't done anything like this before- is there a standard way of doing this, such as a secondary camera and a camera view for that?

void siren
polar acorn
void siren
#

and this is private variable?

polar acorn
#

It's a whatever you want variable

desert flume
#

does anyone know how to set the background of a unity project?

polar acorn
#

but there's no reason for it to exist outside of this function

#

so probably not a class variable

polar acorn
swift crag
void siren
#

but a variable has to start with private or public and stuff liek that

swift crag
#

No. A member may have an access modifier.

#

members being things like fields (variables declared in class) and methods (functions declared in a class)

#

Local variables are not part of a class, becaues you declare them inside of a specific function.

feral oar
#

i learned something new and it’s not even my question

swift crag
# polar acorn

EnemyController has a variable named player. player is a member (a field, specifically) of the EnemyController class.

#
public void Foo() {
  int bar = 3;
}

bar is a local variable I declared inside of Foo

#
public class MyClass : MonoBehaviour {
  public void Foo() {
    int bar = 3;
  }
}

bar doesn't exist outside of the Foo method.

Local variables should be used for things you need to temporarily store.

#

such as, for example, the enemy you just instantiated

#

you don't need to store it for a long time, so you don't put it in a field

#

you just need to hang on to it for a moment so that you can do something with it

void siren
#

so where would i store the variable for insitiate

polar acorn
keen bramble
#

Theres no template called 'Microgame'

swift crag
#

you need the 2021 LTS

#

the 2022 LTS doesn't have the microgame templates, iirc

keen bramble
#

Oh ok

void siren
polar acorn
#

You asked what .player was

#

so I showed you what it was

#

your variable named player on the object you're instantiating

void siren
#

from what you explained, all I understand on what to do is this:

clone = Instantiate(Enemy, pos, Quaternion.identity);
swift crag
#

how did you declare the Enemy field? this will be important.

#

show me the entire line where you declare it

void siren
#
private GameObject Enemy;

this?

swift crag
#

yes, although I presume it's got a [SerializeField] above it

void siren
#

Yeah

swift crag
#

You are currently referencing the prefab as a GameObject.

#

Instantiate will return a GameObject.

#

This isn't very useful, since you want to set a field on the EnemyController component on the prefab.

wintry quarry
#

Random recommendation - that should probably be named "enemyPrefab" to be clear about what it is!

swift crag
#

indeed

#

You should change that declaration to:

[SerializeField] private EnemyController enemyPrefab;
#

This will allow you to reference the EnemyController component on the prefab

#

Instantiate will return an EnemyController.

swift crag
void siren
swift crag
#

where is clone declared?

#

clearly not here, since there's no type name on that line

void siren
#

i dont know how to declare it

swift crag
#

look two lines up

void siren
#

thats what i was going to ask

swift crag
#

you declared a local variable named pos of type Vector3 there

void siren
#

Yes but its not going to be a vector

wintry quarry
#

You declare variables in C# with:
TypeName variableName;

swift crag
#

okay, but what is it going to be, then?

void siren
swift crag
#

well, what is the type of enemyPrefab?

void siren
#

EnemyController

swift crag
#

That's the type that Instantiate will return.

#

and thus that's the type you want to use

void siren
#
EnemyController clone = ...

so what will i put here

manic meadow
#

Name:Clone() prob

swift crag
#

store the result of Instantiate in the variable.

void siren
#

so there will be 2 lines with that

swift crag
#

all on one line.

void siren
swift crag
#

you've instantiated two enemies

void siren
#

so get rid of the second one

swift crag
#

correct.

#

you don't want to instantiate two enemies.

summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

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

swift crag
#

clone now stores an instance of EnemyController, so you can access any public field on it and store whatever you want in it

#

clone.foo = bar;

swift crag
# void siren

much like how you set pos.y = Random.Range(-5, 5);

void siren
#

wait so whats changed

#

i still cant put the player object into the zombies script on who to follow

swift crag
#

Yes, and you will not be doing that.

#

Prefabs can't reference scene objects.

void siren
#

So how would it follow the player

swift crag
#

someone has to give the EnemyController the player's transform

summer stump
manic meadow
swift crag
#

I am working towards the answer.

summer stump
#

It harms them

manic meadow
#

learning is the best way

summer stump
#

And it is against the rules here

void siren
swift crag
#

Do you want help?

#

If so, please humor me.

swift crag
# void siren

you have the newly instantiated EnemyController stored in the clone variable.

summer stump
#

What fen is doing is the absolute best way for them to learn

manic meadow
summer stump
wintry quarry
#

Why do these people have the same damn profile pic lol

swift crag
#

name change.

void siren
#

o.o

swift crag
#

oh, no, it is two people

#

baffling

wintry quarry
#

Or one person with two accounts

manic meadow
#

you know whats funny, is that PraetorBlue has giving 2 sentences of advice and has prob helped more

void siren
manic meadow
void siren
#

there would be no need

manic meadow
steel smelt
#

That sounds exactly like what one person with two accounts would say

tropic marten
#

quickest way to edit the line of code below to make it so that the movement is always rounded to 1 or -1?

    public void Move(InputAction.CallbackContext context)
    {
        horizontal = Mathf.RoundToInt(context.ReadValue<Vector2>().x);
    }
void siren
#

can i get help now

steel smelt
#

what

summer stump
void siren
#

yes i mean all of this nonsense to stop

summer stump
#

Yes, I do hope rain stops with their nonesense

swift crag
void siren
#

its hard to listen to fen when im being accused of two accounts O.O

swift crag
#

It's not something you instantiate after the game starts.

manic meadow
swift crag
#

Okay. So, the enemy spawner can store a reference to the player.

#
[SerializeField] private Transform playerTransform;
#

The enemies can't, because they aren't placed in the scene. They're spawned in later.

#

That's the problem.

void siren
#

so the player would also have to be a prefab?

swift crag
#

No; prefabs can reference each other, but that's not very useful here

#

The enemy could know about the player prefab

#

But that's not the actual player in the scene

swift crag
summer stump
swift crag
#
var instance = Instantiate(prefab);
instance.foo = 123;
instance.bar = "Hello";
#

e.g.

#

in your case, you need to assign clone.player

#

the enemy spawner tells the enemy about the player

void siren
#

so i would have to make a variable with the players location

summer stump
swift crag
#

You already have a variable called player that holds a Transform.

void siren
#

clone?

#

oh

summer stump
swift crag
#

The enemy spawner holds the player's Transform.

#

The enemy spawner holds the enemy prefab.

#

The enemy spawner instantiates the enemy prefab.

#

Then it gives the player's Transform to the newly spawned enemy.

#

Now the enemy knows about the player's Transform.

void siren
#

so i have that variable

#

playerTransform

#

But what would i actually do with ti

#

like how

summer stump
#

Transform has a position property

swift crag
#

particularly lines 2 and 3

summer stump
#

If the enemy has a reference to the transform of the player, it can get a constantly updated position

void siren
#

right

swift crag
#

it sets two fields on instance

#

it sets instance.foo to 123 and instance.bar to "Hello"

#

now how about this one?

#
instance.baz = myField;
void siren
#

baz?

swift crag
#

it's a made-up name

#

it has no meaning

summer stump
swift crag
void siren
#

lemme think

#

stores the data from myField

#

which im guessing is another variable

swift crag
#

Correct so far.

#

But what does it store the data into?

void siren
#

instance.baz

swift crag
#

Right.

void siren
#

baz is a variable

#

the na,e

#

name

swift crag
#

It stores myField in the baz field on instance

#

(and "variable" is perfectly valid here, too)

swift crag
#

clone.??? = ???;

void siren
#

clone.pos = playerTransform;?

#

no

swift crag
#

Almost -- clone.player = playerTransform

void siren
#

not clone.pos

swift crag
#

but otherwise, exactly (:

#

We store playerTransform into the player field of clone.

#

And since clone is our newly spawned enemy, the enemy now has a reference to the player's Transform

#

Now the enemy can figure out where the player is and chase them.

void siren
#

wouldnt that include some complicated math

summer stump
# void siren not clone.pos

Correct.
An important thing here is that if you store the position of the player, it will not UPDATE with the player.
If you store the transform component OF the player, the position WILL update

swift crag
#

well, that's a separate matter

swift crag
#

random examples from my game...

void siren
swift crag
#
gameMode = Instantiate(gameModeTemplate);
gameMode.Configure(gameModeTemplate.ConfigData);
controlHint = Instantiate(controlHintPrefab);
controlHint.Create(label, action);
root = Instantiate(configListPrefab);
root.configurable = configurable;
summer stump
#

You wouldn't have a reference to the player TO update the position without some component reference
It would just be some numbers

swift crag
#

It's just three numbers in a trenchcoat.

#

Transform is an actual unity object that's attached to a game object

void siren
#

so what do i do to make it do all of that

polar acorn
# void siren cant you just put it in void update and it will

Vector3 is what is known as a value type, meaning whenever you set a Vector3 variable, you're setting the value of it. Once it's set, it's set, and it'll always be that until you change it.
Transform is a reference type, it refers to an instance of something. A different thing could go and change values on that instance, and anything else that references that object would see those changes

void siren
#

would i have to change this?

summer stump
polar acorn
swift crag
#

If your only problem is that you couldn't reference the player's Transform, your game should be working again now.

wintry quarry
# void siren

should'nt that be rb.movePosition(rb.position + ...);

polar acorn
#

why change any of that

swift crag
#

You've got your player again.

void siren
wintry quarry
#

sure it's just... odd

#

It's probably identical

#

but it's odd

void siren
swift crag
#

First step: check your console

void siren
wintry quarry
void siren
#

ah

polar acorn
# void siren

Show the code where you set player in the spawner code

void siren
#

oh wait

#

spawner code

polar acorn
# void siren

Where do you set it on the instance you create during the game

honest vault
polar acorn
swift crag
honest vault
#

u can assign prefabs too right?

void siren
#

yeah

polar acorn
# void siren wha-

The thing several people just painstakingly explained for the past hour and a half

swift crag
void siren
#

iw ill just show the entire spawner code

swift crag
#

okay, so you don't actually do anything

honest vault
swift crag
#

you need to actually write the code

void siren
#

yeah i was asking that earlier

summer stump
polar acorn
#

You had it

#

you had the answer

#

you finally cracked it

#

and then just

#

didn't write it

void siren
#

i asked how

#

meaning

#

where

#

to put it

feral oar
#

would it be he needs to assign the value where the object gets instantiated? like
instantiatedObject.reference = blah

swift crag
polar acorn
#

you literally wrote it

potent nimbus
#

hey guys, so i have this problem when i try to use animations in my game that its not working in the code:

polar acorn
#

once you realized you used the wrong name at least

swift crag
#

you want to give the newly spawned enemy the player's Transform, yes?

rich adder
void siren
#

i dont actually think about what im writing

#

im slow

polar acorn
potent nimbus
void siren
swift crag
#

Give yourself some goddamn credit and think.

eternal falconBOT
rich adder
#

configure it

void siren
swift crag
#

There are only a few places you can even put that line of code without getting an error.

void siren
#

confusing

feral oar
#

maybe start with a smaller project bob? do something simpler where you only worry about a few parts

polar acorn
void siren
#

ok

#

let me think

polar acorn
#

where do you think you should put the line

swift crag
#

read each line of code and describe out loud what it does

void siren
#

well

#

it would have to be in here right?

swift crag
#

Correct, since that's the only place that clone exists.

void siren
#

anywhere after the enemycontroller line?

swift crag
#

That's where clone is declared, so yes.

#

You can't use a local variable before the line that declares it.

potent nimbus
void siren
#

so like that

swift crag
#

Correct.

#

Instantiate the enemy, then give it the player's transform.

void siren
#

now i get that

swift crag
#

well, did you assign playerTransform?

void siren
#

i tihnk so

polar acorn
# void siren

Did you actually assign anything to playerTransform in your spawner

swift crag
#

"think so" is insufficient

#

prove it.

polar acorn
void siren
#

i did this

swift crag
#

That does not assign anything to it

polar acorn
swift crag
#

That declares the existence of a field.

steel smelt
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

void siren
#

so what would i assign to it

swift crag
polar acorn
void siren
#

that?

void siren
polar acorn
#

what is playerTransform

steel smelt
#

I get that you're invested but at some point it becomes spoonfeeding despite all your attempts to have him reason about what he's doing

swift crag
#

surely you know how to assign a reference in the inspector

polar acorn
swift crag
void siren
#

doesnt transform store the position...

void siren
#

im running out of hope

swift crag
#

you badly need to follow some written tutorials

polar acorn
#

Literally put in a single frame of thought into it

#

it's called playerTransform

#

what do you think it should store

#

You named it that

#

You know what it should be

#

so set it to that

void siren
#

isnt transform

#

the

#

position

summer stump
#

It is a reference to a component

#

That component HAS a position PROPERTY

#

But the transform itself is not a position

void siren
#

thats what i meant

polar acorn
void siren
#

i id

#

did

summer stump
void siren
polar acorn
#

the thing you were saying was not correct

#

So, knowing this now

#

what do you think

#

the variable playerTransform should be holding

void siren
#

transform

polar acorn
#

of?

void siren
#

the player

polar acorn
#

💯 👍 🥳 party_parrot

#

So drag that in

void siren
#

but uh

#

nevermind that would just be annoying

#

i sweat to god there literally nothing in my code thats holding the players transform

#

for me to give it to playerTransform

polar acorn
#

it

#

in

#

the spawner is in the scene with the player

#

drag it in

void siren
#

yes but my code isnt even finished

#

i still have this line

polar acorn
polar acorn
void siren
#

because i dont know what to put in it

polar acorn
#

why do you have that line at all

#

drag in the variable

void siren
#

i was told

#

to

polar acorn
#

Declare the variable as public or serialized and drag in the player

void siren
#

i was asked some thing about where it was declate

polar acorn
#

like you were already doing

#

before you made the enemy into a prefab

swift crag
#

"assign" meaning to drag something into the inspector

swift crag
#

i suppose that does have a double meaning

polar acorn
void siren
#

i have said many times

#

it gives me the red circle cursor

polar acorn
#

if so, stop

void siren
#

yes it is

polar acorn
#

Why are you spawning in copies of your spawner

void siren
#

im niot

#

the spawner needs to be somewhere so the zombies can spawn on it?

swift crag
#

that has nothing to do with being a prefab.

void siren
#

no wait

#

its not

#

mixed up la words

swift crag
#

If you've dragged a spawner prefab into the scene, just assign playerTransform on the instance in the scene

void siren
#

its an object

polar acorn
#

Think before you answer god damn it

void siren
polar acorn
#

Stop just saying shit when I ask a question

#

This is like the fifth time I've asked a question and you've answered it with the exact goddamn opposite of what you're doing

#

Give it like, a single frame of brainpower, check the question, and give the actual answer

void siren
#

am i not allowed to get words confused with eachother on my second day of using unity

#

my deepest apologies

rocky canyon
#

i have a car asset i threw in my project, i and i noticed this, its for the audio i believe, to ramp up the pitch as the car accel..
my question is does this affect the entire scene? (my gut says yes) just want to confirm.. and if so.. bad asset imo

polar acorn
#

So, anyway, back to the issue. The spawner is not a prefab. So drag in the player to the variable

rocky canyon
#

setting of the fixedDeltaTime, that is..

void siren
#

WHAT DO YOU MEAN DRAG THE PLAYER THE THE VARIABLE

#

am i still in visual studio or in unity

#

tell me when you want me to switch

void siren
#

other wise i will get lost like right now

rocky canyon
#

when * you drag something * its referring to the editor

#

you don't drag things in VS

void siren
#

sometimes they use an odd selection fo words

rocky canyon
#

its the terminology that comes with the duty

#

you'll have to learn them

swift crag
#

given that you were trying to do it with the enemy prefab

void siren
#

so i get confused if they mean what theyre saying in a way that matches the dictionary definition

void siren
rocky canyon
#

imo your being abrasive.. just be humble.. we're aware you may not know certain things.. cussing and using all caps isn't very productive.. just say you dont know them

polar acorn
# void siren WHAT DO YOU MEAN DRAG THE PLAYER THE THE VARIABLE

Press the left mouse button while hovering over the player object in the hierarchy. Then, and this is important, without releasing the button, contract the muscles in your arm such that your hand moves the mouse across the table. Use the power of 𝕥𝕖𝕔𝕙𝕟𝕠𝕝𝕠𝕘𝕪 it will move the little white arrow (called a "cursor" in nerdy internet jargon) accordingly. Now, the hard part. You need to position your arm and hand in such a way that this "Cursor" overlaps with the box that describes your playerTransform variable. Then, and only then, do you release the button

rocky canyon
void siren
#

like i have said MANY times

swift crag
#

Screenshot the entire editor with the enemy spawner selected.

polar acorn
swift crag
#

The entire screen, please.

polar acorn
#

You said the spawner is not a prefab

rocky canyon
#

is you hand broken? or it doesn't allow you to drop it in the slot?

steel smelt
#

Wild guess compile error

void siren
#

oh you meant in the enemy spawner object

#

right

swift crag
#

Yes. The thing with the playerTransform on it

polar acorn
swift crag
#

Not a random unrelated object.

void siren
#

well i have one on the enemy called "player" and right next to it it says transform

polar acorn
swift crag
#

if you refuse to pay attention, your game will refuse to work

rocky canyon
#

setting fixedDeltaTime in 1 script modifies it everywhere in the project basically? am i correct in that assumption?

#

just trying to fit my foot in the door for a sec

void siren
#

yes yes im not paying attention

summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rocky canyon
#

ok, this is a dumb asset then..

feral oar
swift crag
#

you're just changing the timestep

void siren
#

CAN I JUST GET HELP... what do i do next

summer stump
polar acorn
#

in

#

the

#

player

rocky canyon
void siren
#

i will do the tutorial and leave you guys alone for a week after this

#

did

summer stump
#

Spawn literally made a gif of what to do

void siren
#

yes and I DID IT

feral oar
void siren
#

jesus christ

polar acorn
void siren
#

nothing

polar acorn
#

good

rocky canyon
polar acorn
#

we're done

void siren
#

ok THANK YOU

summer stump
void siren
#

im very sorry about uh what happened today

#

have a good day all of you

swift crag
feral oar
#

@void siren i still recommend trying to recreate a smaller game. seems like you’re taking a bigger challenge on than you’re ready for

swift crag
#

I'm actually not sure how changing deltaTime affects how often physics updates happen..

#

If it doesn't, then that code would make sense

void siren
#

this is usually the first thing i try to do

swift crag
#

10% timescale means you need to update physics 10 times as often to get the same apparent physics update rate

rocky canyon
swift crag
#

(assuming this is the case)

void siren
#

i make it harder for my self, i know

swift crag
feral oar
#

i wish you luck then. sounds like an unintuitive way to go about it to me

#

i think you’d learn faster going about it another way

void siren
void siren
#

anyways ima do the tutorial now

feral oar
#

damn homie really does just want it to be harder

rocky canyon
void siren
rocky canyon
#

disabling the TimeManager (that script i shown) breaks the car script completely.. but no compile erros

feral oar
#

lmao that sounds like progress in a sense

rocky canyon
#

i want to modifiy time values in my own scripts (for my player and game/) maybe i can integrate it INTO the script

#

that this scrip uses

#

b/c i dont feel like a wild goose hunt

#

lol

void siren
rocky canyon
#

he was talkin to me i assume

void siren
#

ah

#

mb

rocky canyon
#

you just need to do some tutorials

#

no offense.. but u should probably coming seeking help here atleast after watching/ learning for a few days

#

if not a week or so

#

we use terminology that we assume people will atleast be familiar with

#

if u dont know that terminology its gonna hinder ur progress

feral oar
void siren
#

feels good when im done

rocky canyon
#

dopamine++

void siren
#

rather than doing some boring tutorials

feral oar
#

you know you don’t need to, right? like there’s no shame in making things easier on yourself

swift crag
#

you don't get a runner's high from falling off a cliff

#

look, i'm going to be as polite as possible here

#

you are not in a position to "just figure it out"

void siren
#

I know im not

polar acorn
#

You are a toddler in a welding shop. You are just going to hurt yourself.

swift crag
#

it took well over an hour to add a few lines of code, and you repeatedly demonstrated that you have no understanding of fundamental concepts

void siren
#

usually how i learn coding languages is i just do some trial and error then do research when i want to quit

#

and it works

#

im on the research stage

swift crag
#

You cannot do this. I certainly won't be enabling it any further.

polar acorn
#

Then do that and keep us out of it

void siren
#

after all of that

#

i said im doing that like 15m ago

feral oar
#

have you tried a less frustrating approach?

void siren
feral oar
#

if its a series of getting frustrated and quitting, maybe you have an approach that is unhealthy

void siren
#

ive never quitted

#

felt like it but never done it

#

with coding

swift crag
eternal falconBOT
#

:teacher: Unity Learn ↗

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

feral oar
#

misread it. but if you want to quit so frequently, maybe you should try something different

void siren
#

first i experiment then learn

swift crag
#

I learned Unity with very few tutorials. I also happened to have at least eight years of programming experience already, plus some prior experience with game making.

#

I didn't do it because I decided I'd get brownie points

#

I did that because it was the most efficient way for me. It is clearly not the most efficient way for you.

void siren
#

i feel like im getting a life lesson here

#

but with coding

void siren
#

only putting a few hrs into it each day

rocky canyon
#

is there a debug / stats like window to monitor timescales?

feral oar
#

what languages have you leaned thus far in this way?

swift crag
rocky canyon
#

Scratch

void siren
delicate lagoon
#

I suspect "learn" is doing a lot of heavy lifting here

rocky canyon
void siren
#

i am calm...

rocky canyon
#

good, i dont wanna see no more caps

feral oar
#

fr though. what have you learned?

void siren
#

python, php, and now this

#

not alot as ofg now

rocky canyon
void siren
rocky canyon
#

i don't use OnGUI that often, and i know u do alot

swift crag
#

Here is a basic example

feral oar
#

are you fluent in these languages?

void siren
#

yes

swift crag
#
void OnGUI() {
  using (var _ = new GUILayout.VerticalScope()) {
    GUILayout.Label(gameObject.name);
    someBool = GUILayout.Toggle(someBool, "Toggle Me");
    someFloat = GUILayout.HorizontalSlider(someFloat, 0, 1);
    
    if (GUILayout.Button("Click me")) {
      Debug.Log("Clicked");
    }
  }
}
swift crag
#

GUILayout automatically positions the elements for you. GUI does not.

void siren
#

php i use on a website me and my friend are making and with python i make programs and games

feral oar
#

then the difference might be not only are you learning C#, you’re also trying to learn Unity at the same time

swift crag
#

Note that if you have several objects all trying to draw stuff at once, they'll all be overlapping

rocky canyon
#

thats fine..

#

just for debuggin..

swift crag
#

You can use GUILayout.AreaScope to create specific regions (it takes a Rect argument)

rocky canyon
#

i want to see whats going on in this asset

swift crag
#

My IMGUI debugger is one enormous OnGUI

#

It calls methods on anything that's being debugged to let them draw stuff

swift crag
feral oar
#

are you having fun? getting frustrated like you said you are?

rocky canyon
#

codes sooo counterintuitive..

#

i havent figured out what modifies the time scale bsides this script

void siren
rocky canyon
#

u shouldnt post in a channel that has 10s of thousands of people then..

#

that will happen

void siren
#

yesterday i got only 1 person helping me. today i wasnt expecting 10 people

rocky canyon
#

lol, thats fair

#

sometimes theres crickets in here.. other times its procrastination city

void siren
#

and yesterday i was actually learning from it

dusty silo
#

!code

eternal falconBOT
feral oar
#

do remember not everyone will be willing to explain a concept to you that can be learned from the beginner courses

void siren
#

clearly 10 people were willing and it was too much

feral oar
#

its great you had someone to do that for you once

#

but do not expect it

void siren
#

i had someone to do it for me once?

#

i didnt get them to write me a paragraph of code or something

feral oar
#

the other day when i’m assuming you had one person talking to you

#

i’m not saying they gave you code. but it seems they explained a principle to you

void siren
#

no

#

it was just some errors

feral oar
#

ah then thats different

swift crag
#

oh yeah, and that makes sense

#

I have a "Headless mode" for my game that turns off the camera and cranks up the timescale really high

#

When I do this, I get a ton of FixedUpdate calls per frame