#💻┃code-beginner

1 messages · Page 455 of 1

solemn fractal
#

    [SerializeField] private int _enemyHealth;

    void Start(){
    }

    void Update(){  
    }
    
    private void OnTriggerEnter2D(Collider2D other) {
        if (other.CompareTag("PlayerBullet")){

            PlayerBullet playerBullet = other.GetComponent<PlayerBullet>();

            _enemyHealth -= playerBullet.PlayerBulletDamangeGetSet;

            if (_enemyHealth <= 0){
                Destroy(this.gameObject);
            }
        }
    } ```
summer stump
#

Well, _enemyHealth is private. It is not static. You seem to only be modifying it on the actual instance and not a prefab....

I am not sure what the issue is
Nothing here should affect other objects

solemn fractal
#

Yeah.. i just wanted to kill an enemy and the HP goes from 1 to 0, the enemy destroys and the other enemies are not affected. Now if I kill 1 all the other enemies also get 0 hp.

rich adder
solemn fractal
timid quartz
#

thanks for this - got it all working now! I'll make sure to put you and Navarone in the credits of my game 🙂

feral osprey
rich adder
#

checking Tag and the component instead of just doing it all one 1 like above

solemn fractal
# rich adder nah was talking about what you're doing is redundant from earlier

I tried this, but was not working and I didnt want to push it further to not bother with same question over and over. I already have a lot of issues going on to fix, and if I applied this one it would just make it harder. As I applied and it said I couldnt use it the way you wrote. So i just went back again to what I was doing

summer stump
feral osprey
#

😦

rich adder
solemn fractal
rich adder
tall lodge
#

Everything else you've shown doesn't seem to be the issue. But does your SpawnManager or the _enemyList handle destroying/removing any objects?

solemn fractal
viral hound
#

im trying to use a movement system in 2d with rigidbody using addforce forcemode.force, but its really incosistent when i test it, almost like the values are changing every time... i tried looking online and people say its because its in Update(), but im not really sure what to do.

summer stump
viral hound
#

its not

summer stump
#

And yeah, always do physics in FixedUpdate

viral hound
#

when i tried to but the same functions in fixed update its not working

#

do i have to make the values stronger?

summer stump
viral hound
#

ok let me test a bit

summer stump
#

FixedUpdate will often happen a lot less often if the games fps is fast or just normal
It is called 50 times per second ideally (but can be changed in settings)

viral hound
#

when i put in fixed update i had to make the values likes 10 times stronger than update

#

is that normal

raw token
#

That makes sense for the time-relevant force modes, I think...

tall lodge
viral hound
#

dam so if someone else ran this, will they move at different speeds depending on their frame rate?

raw token
#

If you're continuously applying a force scaled by time, it'll be relative to the physics step. So if you're applying continuous force in Update(), then you're often accumulating multiple steps worth of force into a single physics update to greater effect

summer stump
viral hound
#

wait so it does or doesnt?

summer stump
tall lodge
#

In Update it would. In FixedUpdate, it should be the same for different users

viral hound
#

ahhh ok

summer stump
#

DeltaTime is included in the AddForce calculations, so it really wouldn't in update either
But it is not stably called in Update

viral hound
#

thx 👍

tall lodge
#

Update runs once per frame. Players at a higher framerate it would run faster for. FixedUpdate runs once every fixed frame (50 per second by default) so for every user it would try and stay consistent

summer stump
#

AddForce uses deltaTime in its calculations internally, so even at different framerates it would run about the same. It would just not be as stable because it would not run at the cadence of PhysX/Box2Ds interal update

tall lodge
#

Ah neat

tall lodge
north oar
#

im like 3 weeks into learning unity and i was feeling confidnet with what i was learning at the beginnign with the basic stuff but now im watching tutorials and it just feels like im copy pasting everything without being able to understand it and its kinda stressful anyone else gone thru a similar experience?

slender nymph
drowsy oriole
#

Where do I learn code

eternal falconBOT
#

:teacher: Unity Learn ↗

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

drowsy oriole
#

Nvm

steel hull
#

but I am doing it :/

drowsy oriole
#

i am to

steel hull
#

uhm okay no offense to any worker but are unity's web servers running on a potato?

steel hull
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

steel hull
#

this is really bad

#

I am sorry but

#

the videos don't load

#

the site itself doesn't load

worthy tundra
strong harness
#

If the destination point is not on baked nav meshes, Can it return a path which the last point is the closest point on nav meshes?
Suppose there is a square or circle obstacle and the target point is the center of the square/rectangle. It should find the path without needing a change in the stopping distance

languid spire
strong harness
strong harness
#
 if (!_agent.isPathStale && _agent.pathStatus == NavMeshPathStatus.PathComplete)
            {
                if (_agent.remainingDistance > StoppingDistance + 0.01f)
                {
                    PathStatus = PathStatus.Running;
                   
                }
                else
                {
                    PathStatus = PathStatus.Completed;
#

_agent.remainingDistance is based on the last point or target point?

#

because, in my test, it can return the path correctly

languid spire
languid spire
strong harness
#

I should find the distance between the last point on the path (partial) and the closest point on the obstacle

languid spire
#

Generally I just check remaining distance and/or isStopped

#

you can also check agent position against the last position in the path

strong harness
#

I have checked, the last point on the path and also destination is not target point.

#

It is the closest point to the target point on baked nav meshes. Therefore, remaining distance is a distance from the current point to the destination point (last point on the path) not target point we have given to it

#

In the above example, the target point is the center of mass. Nav mesh agent returns path complete

#

See. The distance between the character point and target is around 1m but stopping distance is 0.05

steel hull
#

yo uhm

#

can someone help me in a vc? I need to screenshare

#

or I can just send them a video

frosty hound
#

You can send the video here and someone can help if they want, no need to bait someone into a 1:1 call.

steel hull
#

but here a video

steel hull
#

and the capsule is the body basically which is underneath the player

#

IDK what is causing this

umbral rock
#

So i have a codeblock right here and i dont know if i understand it correctly, so its used for an inventory drag and drop system and im trying to understand the code, so image.raycasttarget, is that just to scan if ur dropping the item on one of the slots? and if it drops on one of the slots then he sets the parent of that item to the itemslot? and he also does an image,raycasttarget = true; to scan if u drop the item on a slot? is that right?

wintry quarry
#

setting it true means it will receive and block UI events

#

false means it won't

steep rose
# steel hull

the rigidbody is supposed to be on the parent object, not on one of its children. also like everyone else said you are using a character controller so dont use a rigidbody, you have to choose either rigidbody or character controller they do not like eachother

#

also rigidbodies dont like you setting the transform, thats why they have applyforce

fallow galleon
#

Hey i kind of need help with unity and VS code. When i remove restricted work space most of my code turns blue.

umbral rock
# wintry quarry setting it true means it will receive and block UI events

so if u end the dragging in this case the UI events will be blocked and because of that he goes back to his traditional position? and when u begin dragging u'll tell it that UI events are possible? but why if i drag and drop on another slot the item is not attached to the new slot? is that because u set the transform.parent to his root? so it goes to the traditional slot?

fallow galleon
#

When i turn on restricted mode. My c# and unity extention gets disabled

#

But code becomes normal

steep rose
#

sounds like you need to configure your !ide

eternal falconBOT
fallow galleon
steel hull
steep rose
#

and physics

#

i do that for my player

steel hull
#

and you move the player with velocity?

#

is that correct?

steep rose
#

applyforce

#

you can move it with velocity but just dont set its transform

steel hull
#

so which one is better?

steep rose
steel hull
#

yep, no issues

#

oh

#

no need to say it

steep rose
# steel hull so which one is better?

depending on your preference and what game you are making, you choose one, if your game requires physics use the build in rigidbody, if you want to make your own physics use character controller

#

character controller requires skill to make good physics but it is worth it due to the fact you can control anything via your script

#

rigidbody's interact fully with unitys physics system

steel hull
#

yay now I need to re do my movement script

#

amazing

#

yippe

#

you said not to use transform on rigidbodies but can I rotate them with transform?

#

you know cuz the body should move with the camera

wintry quarry
#

only use the Rigidbody

steep rose
#

it goes over all of that

steel hull
#

alright thanks

#

uhm one more question wouldn't setting the velocity be the same as addforce?

umbral rock
#

So im wondering, he is using inventoryitem in this code, is this the script called inventoryitem or is it the prefab that he uses? and he gets the inventoryitem component...

steel hull
steep rose
#

give me a minute im getting pinged left right and center

steel hull
umbral rock
# wintry quarry

yes but there is an other script called inventoryitem and then he uses inventoryitem in this script, or is it the prefab called inventoryitem he uses?

wintry quarry
#

it only knows about code

#

InventoryItem refers to the InventoryItem class.

umbral rock
#

Aah and then he gets the InventoryItem component wich is the actual InventoryItem prefab?

wintry quarry
#

definitely not a prefab

steep rose
# steel hull your assistance is heavily required 🙂

either i would follow these series of tutorials and stop to where you want it
https://www.youtube.com/watch?v=f473C43s8nE&t=189s

or these series
https://www.youtube.com/watch?v=LqnPeqoJRFY

FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial

In this video I'm going to show you how to code full first person rigidbody movement. You can use this character controller as final movement for your game or build things like dashing, wallrunning or sliding on top of it.

If this tutorial has helped you in any way, I would really appreciate...

▶ Play video

Part 1 of the Rigidbody FPS Controller (w/ Wall Running) tutorial series.
Thanks for watching!

In this video, I teach you how to create basic movement. By the end of the series, you will have fps movement + wallrunning

Rigidbody FPS Controller Tutorial #1 | Basic Movement in less than 4 min

(LINKS MENTIONED IN THE VIDEO)
FixedUpdate: https://...

▶ Play video
steel hull
#

ty

umbral rock
#

well, he gets that component wich is basically the item right? and then if u drop it on a slot he sets that components parent to that slot?

#

i guess its like that?

wintry quarry
#

on the script instance of the dragged item

#

from the context of this screenshot alone I can't tell you any more than that

#

he gets that component wich is basically the item right
It's definitely a script which is meant to represent an item.

umbral rock
#

this is the inventoryitem script

#

so if i understand it correctly, this is just the dragging code and if u stop dragging then he will go back to his original parent, then the second script he made is when the item is dropped he checks if the slot is empty and if so he picks the inventoryitem component and then sets his parent to the new slot?

winter tinsel
#

how difficult would it be to make a grid inventory system?

#

like this

#

items have different sizes instead of just taking up one inventory slot

wintry quarry
steel hull
#

uhm guys what is drag

wintry quarry
#

each item just has a list of Vector2Int positions, and you just loop over allt hepositoons for overlap and bounds checks

steel hull
#

nvm got it

winter tinsel
#

ill just mark the min and max lengths and widths of the inventory so items can know where to show up lol

wintry quarry
winter tinsel
#

allright thanks

sly monolith
#

hi there, i tried to program and would like to get some examples for code in visualstudio but i cant find the preference tab anywhere can anyone help me with this?

umbral rock
sly monolith
wintry quarry
#

show screenshots

sly monolith
wintry quarry
#

it's in the Unity editor

sly monolith
#

oh🤦‍♂️

#

ty

umbral rock
#

I still dont rly understand what the component InventoryItem is? is that these things?

wintry quarry
#

you would see it in the inspector if you attached to that object

sly monolith
formal hill
#

Anyone know how I can make it so the camera rotates and goes up so the player can see something when going downhill?

My current camera code:

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

public class Camera : MonoBehaviour
{
    public GameObject Player;
    private Vector3 offset;


    // Start is called before the first frame update
    void Start()
    {
        offset = transform.position - Player.transform.position;
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = Player.transform.position + offset;
    }


    private void OnTriggerEnter(Collider other)
    {
        
    }
}

eternal falconBOT
formal hill
umbral rock
wintry quarry
#

as mentioned

umbral rock
#

yes but how does he drop the item in the slot then? he sets the transform of the inventoryitemscript to the slot transform?

wintry quarry
formal hill
wintry quarry
wintry quarry
sudden pilot
#

guys the problem ıs When ı press A and D character not turns same rotatıon Anyone know why?

formal hill
wintry quarry
steep rose
#

you should be using rotations

#

eulers or quaternions (the bane of my existance)

sudden pilot
sudden pilot
#

localScale thıng

formal hill
steep rose
sudden pilot
steep rose
#

scale has nothing to do with rotation

wintry quarry
#

you can achieve a "flip" effect with scale

#

the real question is

sudden pilot
wintry quarry
#

did you take any debugging steps for your code @sudden pilot

#

What makes you think it's not working

steep rose
#

beats me

wintry quarry
wintry quarry
sudden pilot
#

dont know why

wintry quarry
#

start debugging your code

formal hill
steep rose
#

you shouldnt give up learning something if it goes wrong

sudden pilot
#

when pressing "D" key

umbral rock
sudden pilot
#

when pressıng A key

#

and press nothıng

#

ıt says local scale X = -1 but

#

player not turns left

#

tf xd

steep rose
#

keep in mind localscale if for children of a parent

#

i believe

#

and from your script you are applying forces on the parent im guessing

#

so change it to scale

sudden pilot
#

not chıld or parent

steep rose
#

change it to scale not LocalScale

sudden pilot
errant flower
#

im having an issue:

NullReferenceException: Object reference not set to an instance of an object
OnEnterMilk.OnTriggerEnter () (at Assets/scripts/OnEnterMilk.cs:16)

NullReferenceException: Object reference not set to an instance of an object
OnEnterMilk.OnTriggerEnter () (at Assets/scripts/OnEnterMilk.cs:22)

this is OnEnterMilk.cs
and Areas.cs

wintry quarry
wintry quarry
errant flower
#

oh

#

uh i just didnt add it ;-;

wintry quarry
#

Working without line numbers is like sociopath behavior

errant flower
#

no i meant like in the screenshot lol

wintry quarry
#

Well it's hard to tell which line things are on without line numbers

errant flower
wintry quarry
#

That's the only reference being dereferenced on those lines

errant flower
#

oh

#

let me add the full screenshot

wintry quarry
#

I mean we already know what's wrong no?

#

Assign your areas reference to fix it

errant flower
#

ye but areas is a script and enemy is the same but it doesnt have an error

wintry quarry
#

I don't know what that sentence means

#

But you need to assign the reference

#

Regardless of anything else going on

wintry quarry
#

You didn't assign the areas reference

#

Also wait how would you even know?

#

The error happens before the enemy line

errant flower
#

oh

wintry quarry
#

So enemy might not be set up either

errant flower
#

ye but it shows 2 errors

#

oh wait ye

wintry quarry
#

So what?

errant flower
#

mb thx

formal hill
errant flower
wintry quarry
#

That or you need your code to check if it's assigned before using it

ripe shard
umbral rock
wintry quarry
#

It doesn't do anything else at all

wintry quarry
umbral rock
#

hmm but what code is used to make the dragged item click into the slot u want it in?

wintry quarry
#

Idk what you mean by click but it's hard for me to say having only seen very little of the code

#

Presumably something in OnEndDrag

umbral rock
#

so its an inventory system im making with drag and drop, i just dont understand wich block of codes make it position into the inventory slot?

#

for what is this code necessary?

#

its for dropping the item into the inventory slot right?

wintry quarry
#

Sure

#

This code runs on the slot you are dropping it into

umbral rock
#

Okay and that code is linked with this

wintry quarry
#

I mean it's related, sure.

#

"linked" doesn't have much of a specific meaning

umbral rock
#

yes, and when u drop it where does it tell the item to position into the inventory slot?

wintry quarry
#

It sets the parent

#

I don't know the details but I assume these are UI elements and probably the positioning itself is just handled by the RectTransform settings on the thing

umbral rock
# umbral rock Okay and that code is linked with this

if i only use this code then if i drag it on a new slot than the item goes back to its original position and not to the new slot... so the second code somehow enables the item to be positioned into the item slot

#

wich i dont quite understand...

#

he does this inventoryItem.ParentAfterDrag = transform, so i guess its this that positions the item into the slot?

wintry quarry
#

Nope

#

Again

#

It's literally just setting a field on the script

#

I don't know how many times that needs to be said

#

That field is used later

umbral rock
#

okay, but why is the code usefull then?

#

because without it it doesnt attack to the new item slot

#

its something to do with the parentafterdrop, first its = transform.parent and then on the second code he sets the parent to transform, doesnt that parent the item to the item slot? im rly trying to understand it

wintry quarry
fiery breach
#

learning how to use structs, idk what im doing. trying to set the DistanceToPlr variable, and etc

languid spire
#

foreach on a struct[] will return a COPY not the original

fiery breach
#

the monster[] is a list of all the monsters, and im trying to play a heartbeat sound if youre within the specific radius

summer stump
warm raptor
#

Hello, In a fps, what would be the best way to detect if a bullet fly close to a player, to later play a fly by sound. my bullet are actual mesh with a rb and I already tried to put a collider in trigger mode around the player, but it doesn't work because the bullets are going to fast.

umbral rock
#

isnt transform.parent the original parent and transform is to a new parent

summer stump
#

Not really sure why they do that instead of setting it to null, but I missed a lot of the conversation obviously

umbral rock
#

look

summer stump
#

transform.parent is its CURRENT parent btw, not original

umbral rock
summer stump
umbral rock
#

and then he sets the parent to transform

summer stump
umbral rock
#

is it just checking where the item is dropped and then the transform of that item slot is his parent wich makes him attach?

#

so the parent after he dragged is set to transform.parent wich is his current parent but then he sets the parent to transform wich makes him attach to the item slot i think?

summer stump
rich adder
#

use references in the inspector

summer stump
umbral rock
#

i dont know how he attaches is...

summer stump
#

Which is why you should not watch this video, and instead watch the one where he explains......

umbral rock
#

is the setparent to transform making the item attzch to the item slot?

summer stump
marble hemlock
#

Is GetKeyDown better than GetButtonDown?

Am I misunderstanding or don't they both just check for if you're holding down something?

marble hemlock
#

oof

rich adder
#

Button lets you assign your own "keyword" to specific key

#

eg "JumpKey" rather than Keycodes, some are already predefined

umbral rock
summer stump
marble hemlock
rich adder
marble hemlock
#

okay thanks

rich adder
#

like drag the player component you want inside a inpsector field for your enemy?

#

in that case just store the reference in the enemy spawner or whatever is IN the scene spawning enemies, and have that hold the reference to player and pass it on spawn

#

or make the player a singleton I suppose

marble hemlock
#

im trying to somewhat abandon game tutorials and really just study the functions in documentation, specifically ones i see a lot

#

a lot of the times they fail to explain why do they do something, or just sort of gloss over it so i just eh

rich adder
marble hemlock
#

its been a bit of a process to find things but its pretty fortunate there are a lot of resources

rich adder
#

pretty much i google anything else, most of the time you find the answers on the unity discussion

umbral rock
#

:/

#

its ofcourse the setparent

#

wich is first transform.parent

#

but then he sets it to transform... wich i dont understand

summer stump
#

That is 1) a different script 2) a field unrelated to the one in the other script

umbral rock
#

he sets the dragparent to transform right?

summer stump
pale ocean
#

hey all im watching a beginner tutorial by codemonkey and for handling movement he uses a capsulecast, what i don't understand is why the capsule cast specifically, and how he landed on the numbers for the player radius & height. can anybody explain this to me.

steep rose
#

if you have a question for a reference go to docs

#

they are your friend

#

also the Playerheight and Radius are just floats

pale ocean
#

i know, but how did he land on these numbers? what if i wanted to add my own model how would i get these numbers?

steep rose
#

he just adjusted them in game then used the numbers

#

that he found

#

also you cant add your own model into a raycast

pale ocean
#

how'd that work

#

oh

polar acorn
pale ocean
#

no i know but the capsule is meant to represent the player

pale ocean
steep rose
#

its nice to have on the spot so you dont need to go back in script every time

#

but you do you

pale ocean
#

alright then thanks

marble hemlock
#

my code functions fine but everything just shows up white so its somewhat hard to differentiate things

eternal falconBOT
marble hemlock
#

thank you

pale ocean
eternal steeple
#

would this be a correct usage of Time.deltaTime, want to make sure as i watched a video but i was still slightly confused on it?

accelerationTime += Time.deltaTime;

float accelerationFactor = accelerationCurve.Evaluate(accelerationTime);
currentVelocity = Vector3.Lerp(currentVelocity, targetVelocity, accelerationFactor * Time.deltaTime);
steep rose
# eternal steeple would this be a correct usage of ``Time.deltaTime``, want to make sure as i watc...

time.deltatime is used is a wide variety of situations, mainly being in situations that you dont want to update all your code based off the framerate your game is currently at. quake is one of the games that didnt make the game update off a in game timer and instead made the game update off of what the current framerate was, thats why it was either really fast or really slow. always be sure to check docs out for a question like this!

here is the doc below
https://docs.unity3d.com/ScriptReference/Time-deltaTime.html

#

but in short, yes it looks to me for it to be correct
edit: I did not see the other time.deltatime, i am blind

steep rose
#

you almost gave me a heart attack 😅

#

i was questioning myself

rich adder
#

yeah the curve part is fine

eternal steeple
steep rose
#

i actually didnt even see that other time.deltatime

summer stump
rich adder
pale ocean
#

🤷‍♂️ i downloaded it as part of the tutorial

marble hemlock
pale ocean
#

plus it looks nice

marble hemlock
#

it just says to unlock

#

and then when i go out of it and go back into it, its locked again

rich adder
#

unlock? you mean package manager

marble hemlock
#

ye

rich adder
#

are you doing vscode or VS

marble hemlock
#

visual studio (?)

#

visual studio is... purple?

rich adder
#

yes

marble hemlock
#

then that one

rich adder
#

VS you dont need to unlock/remove anything

steep rose
#

VScode is blue

marble hemlock
#

was i suposed to be using vscode

rich adder
#

huh? you can use either one

marble hemlock
#

oh

rich adder
#

visual studio is a bit easier to setup

steep rose
#

no, they are mainly chose by preference

rich adder
#

you only need the Unity Workload, then select it in external tools unity

sleek kayak
#

I have just learnt abOut SerializeField, does it have any use other than for testing stuff as a dev?

rich adder
#

its a solid way of ensuring your references are set/filled

sleek kayak
#

what does that mean?

rich adder
#

its just for exposing the field that is private so you can Drag n Drop a reference inside
a reference is a specific object/component you're looking for

marble hemlock
#

yeah i dont know what im supposed to do next
i changed the external script editor to VS and then went to package manager, but then it just says unlock

stark rune
stark rune
rich adder
stark rune
wintry quarry
stark rune
wintry quarry
stark rune
#

i tried it backwards but it looks the other way

stark rune
stiff abyss
summer stump
slender nymph
#

where do you put the sheep into gameManager.SelectedItemsList? because if it isn't in that list, it gets destroyed in CleanupInvalidSheep

#

keep in mind that the instantiated object is not equal to the prefab 😉

stiff abyss
slender nymph
#

wdym how? they are completely different objects at that point

#

you and i are both people, that doesn't mean we are the same person

marble hemlock
#

seems i actually dont need most of the ones in there

#

i only need the visual studio one

rich adder
#

I sent you the link on the instructions , follow them

marble hemlock
#

well i was

rich adder
#

each player? wdym by that I'm confused on your setup

marble hemlock
#

but then when i get to the part about installing the unity editor thing, it doesnt really allow me any of those

rich adder
#

where does it say that

marble hemlock
#

i feel like my horrible way of phrasing is a problem let me clarify

rich adder
#

did you check the unity workload ? that was the only important part..

marble hemlock
#

yeah i clicked that one

#

and i think i already start with it?

#

it seems to download the entire engineering thing, which has 7 packages inside, including VS, VScode, and JetBrains Rider

rich adder
#

ohh so if they are already part of the same environment doesnt that hold reference to the player in that environment ?

marble hemlock
#

but I don't seem to be able to individually interact with those packages because it says it was installed as a dependency

rich adder
marble hemlock
#

Game Development with Unity, in Visual Studio

summer stump
marble hemlock
#

I'm starting to think I already have those stuff

rich adder
marble hemlock
#

i did :(

rich adder
#

show that you set Visual Studio in External Tools

marble hemlock
#

the thing was

rich adder
#

is the enemy not in the same enviroment? im not familiar with the ml agents workflow too much . I see #archived-machine-learning was archived

marble hemlock
#

OHHHH

#

IT WORKED

rich adder
#

hard to explain for me seems there is limited knowledge there on how references work ?

#

well prefabs cannot reference scene objects, thats about it in terms of differences

#

so if you spawn it from a scene object, that usually has the reference you need from scene component, you can pass it on spawn

#

can your enemy spawner not reference the Player ?

#

if you have multiple players , a singleton is probably not a good fit

#

wait , does each environment have the player ?

#

you only need 1 environment with everything plugged in, once you duplicate that they all have their own instances

#

iirc yeah if they are training on the same model

#

you probably can do more than 25 depending on how much pc can handle

#

i haven't touched unity ml since 2020 so I may not have the up to date memory on it

summer stump
# umbral rock Yes indeed (: so i was right?

I honestly have no idea what you were saying
That was my issue

It sounded like you were misunderstanding WHICH transform the word transform was referring to. It was referring to the slot.... which is what I said at the very very beginning

desert plinth
#

Quick question: Is there something like a SphereCast but that returns multiple RayCastHit variables or something similar? I forgot which function does that.

#

Preferrably an array of RayCastHits

wintry quarry
#

You can look in the docs to find this stuff

desert plinth
#

Thanks mate

crisp token
#

how can I take a gameobject and instantiate a new gameobject as its child?

wintry quarry
crisp token
#

oh thanks, i wish there was a way to see all the overloads in vs

sudden pilot
#

guys ı cant see anımator wındow

#

there ıs empty anyone know why?

umbral rock
crisp token
#

they want this to be a Transform but the api says any object should work no?

wintry quarry
#

Instantiate would be for a prefab

#

If you're just making a new object get rid of Instantiate

crisp token
#

oh

wintry quarry
#

Also read your error messages

crisp token
#

the error is what I said I think

#

oh wait im stupid; I misinterpreted it

umbral rock
hidden sable
#

does anyone know why I cant import a fbx object with textures to unity (the objects imports completely fine, but leaves the materials/texture behind)

#

cant even change the material

scarlet hawk
uncut shard
#

I've written this code from a tutorial for a basic car control. What should I improve, what better practices should I use?

public class WheelController : MonoBehaviour
{
    [SerializeField] WheelCollider frontRight;
    [SerializeField] WheelCollider frontLeft;
    [SerializeField] WheelCollider rearRight;
    [SerializeField] WheelCollider rearLeft;
    [SerializeField] Transform frontRightTransform;
    [SerializeField] Transform frontLeftTransform;
    [SerializeField] Transform rearRightTransform;
    [SerializeField] Transform rearLeftTransform;

    public float acceleration = 1000f;
    public float brakingForce = 750f;
    public float maxTurnAngle = 15f;

    private float currentAcceleration = 0f;
    private float currentBrakeForce = 0f;
    private float currentTurnAngle = 0f;

    private void FixedUpdate(){
        currentAcceleration = acceleration * Input.GetAxis("Vertical");
        if (Input.GetKey(KeyCode.Space))
            currentBrakeForce = brakingForce;
        else
            currentBrakeForce = 0f;
        frontRight.motorTorque = currentAcceleration;
        frontLeft.motorTorque = currentAcceleration;

        frontRight.brakeTorque = currentBrakeForce;
        frontLeft.brakeTorque = currentBrakeForce;
        rearLeft.brakeTorque = currentBrakeForce;
        rearLeft.brakeTorque = currentBrakeForce;

        currentTurnAngle = maxTurnAngle * Input.GetAxis("Horizontal");
        frontLeft.steerAngle = currentTurnAngle;
        frontRight.steerAngle = currentTurnAngle;

        UpdateWheel(frontRight, frontRightTransform);
        UpdateWheel(frontLeft, frontLeftTransform);
        UpdateWheel(rearRight, rearRightTransform);
        UpdateWheel(rearLeft, rearLeftTransform);
    }

    void UpdateWheel(WheelCollider col, Transform trans) {
        Vector3 position;
        Quaternion rotation;
        col.GetWorldPose(out position, out rotation);

        trans.position = position;
        trans.rotation = rotation;
    }
}```
lone pivot
#

Why when I play my game in the editor my gpu spikes it 80% and even though I have the

    {
        
        QualitySettings.vSyncCount = 0;
        Application.targetFrameRate = 60;

    }```
running
mint remnant
#

Don't think vSync apploes to edit window, why you can only set it on game window in drop down

#

you could toggle the more intense items off from visibility in the heairchy perhaps to reduce GPU load

lone pivot
#

VSync is set to "Don't Sync"

#

My scene is very near empty. It's a new project.

steel stirrup
lone pivot
#

Well ok I just deleted the fishnet network manager and suddenly the GPU usage is fixed. Guess I have to talk with them

mint remnant
uncut shard
#

Guess i gotta go learn c# now..

mint remnant
#

Usually a good thing to learn before Unity heh

steel stirrup
#

C# is the absolute baseline to know before even touching Unity imo

steel stirrup
# uncut shard Damn I didn't understand a thing

Think of it this way, you have four wheels. They’re physically different objects but fundamentally the same type of ‘thing’. Each wheel has a transform, collider and some other fields. These wheels are organized by quadrant (front left, front right etc). Therefore it simply makes sense to describe the concept of a wheel as a class, with each actual wheel being an object of that class. Since we will be accessing the wheels by quadrant, it also makes sense to use a dictionary<direction, wheel> to store them

#

How you define Direction depends on your game. If every car has four wheels, then an enum is fine. If you want something more flexible, I’d personally define a record and place a vector in it describing the position of the wheel on the cars bounds

lone sable
#

I'm trying to get the Normal point of a Navmesh sample position, however, it seems to be always returning "Up" Or in this case, 0.

if (NavMesh.SamplePosition(pointInBox, out hit, 1.0f, NavMesh.AllAreas)) {
                        
                        float slopeAngle = Vector3.Angle(hit.normal, Vector3.up);
                        Debug.Log(slopeAngle);

Anyone happen to know why this might be happening?

steep rose
#

this should work

#

(i think)

lone sable
#

Still 0.

#

For reference, Yellow dot is what is being hit, and, you can see it is on a slope.

steep rose
#

"hit Holds the properties of the resulting location. The value of hit.normal is never computed. It is always (0,0,0)."

lone sable
#

Damn.

#

Guess I'll raycast down then.

vocal urchin
#

Hello all. I'm making a traditional roguelike and I currently have each enemy's Stat (an object with a StatType enum and an int, essentially) in a list of Stat objects. There are some issues with this, as you could have an enemy with two of a single stat type, which I would never want, and could also have enemies missing certain stats, which I would also never want. I would like it if when I drag the enemy component onto something, the component initializes with all the StatTypes in the Stat List that I would need and am unsure how I should approach this. Anyone have any ideas?

lone sable
#

Perfect. Seems to work.

mint remnant
steep rose
marble hemlock
#

So GetKeyDown is for pressing it once and GetKey is for holding?

cosmic dagger
marble hemlock
#

sometimes here just to clarify

steep rose
#

docs clarify

marble hemlock
#

i am not the sharpest tool. i struggled a bit to figure out the difference between button and key

cosmic dagger
#

The docs are absolute (rulers of the Unityverse) . . .

uncut trench
#

Yo I need help

mint remnant
vocal urchin
# mint remnant Sounds a bit confusing, have some code to show or inspector views?

Sure, here are my Stats and Stat classes. Stats is a component that any enemy or player character requires. Stat is a class that contains a StatType and int for the stat's level. The problem is, if I make a new enemy or player character, I have to manually access the statList via the inspector, and add a stat of each type which is prone to mistakes. Perhaps making each enemy initialize from a scriptable object is best for this?

using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class Stat
{
    public enum StatType
    {
        HEALTH, MAXHEALTH, STRENGTH, DEXTERITY, INTELLIGENCE, MELEEATK, RANGEDATK, STAMINA, MAXSTAMINA, STAMINAREGEN, MANA, MAXMANA, MANAREGEN, 
    }
    public int statValue;
    public int effectiveStatLvl;
    public StatType statType;

    public Stat(StatType type)
    {
        statType = type;
        statValue = 1;
        effectiveStatLvl = 1;
    }
    public Stat(StatType type, int lvl)
    {
        statType = type;
        statValue = lvl;
        effectiveStatLvl = lvl;
    }



}```
uncut trench
#

Soo much help required so I was creating a game we'll fps multiplayer game it's all working fine but when I add sliding the code seems fine but when I slide it doesn't work animations is there lol so I leave it there then I tried to do like switching animator which basically like switch from player movement animations with no guns to animations with guns

#

Yea idk what I'm doing

rich adder
uncut trench
rich adder
rich adder
#

and it wont be good because frankly, if you need to ask You're not ready

rich adder
#

its broken, clearly not

summer stump
uncut trench
#

Oh wait dang this a beginner's

cosmic dagger
uncut trench
summer stump
uncut trench
summer stump
#

It is like a stream of thought impossible to follow.
I have no clue what your problem is at this point. Something about... movement and animations?

steep rose
#

punctuation please

#

we cant help you if we dont understand it

uncut trench
#

I'll give an example so like GTA V the player movement walk, run and other but when player holds a gun it like switch animations rifle walk and other stuff.

#

U understand now I didn't use commas or stuff

vocal urchin
steep rose
uncut trench
#

No

#

Not animations

steep rose
#

weapon switching?

#

or if you are holding a weapon, change movespeed to that weaponspeed?

summer stump
steep rose
#

do you want to change playermovement depending on what you are holding?

uncut trench
#

Yes

steep rose
#

ah

#

ok

uncut trench
#

Dang well that took a sec

#

Maybe min

steep rose
#

you can use an if statement with an enum or boolean to and make changes to your movement depending on what you are holding

misty pecan
#

parts.Add(Instantiate(smallCircle, targetPos, Quaternion.identity ));

What is wrong with this? parts is a list<Transform>, i dont get an error in the code, but in the editor, it says "Object reference not set to instance of an object" even though all the fields are filled in??

shell ice
#

How could I make an object still be moveable but after letting go of said object it freezes in place? I'm trying to make a camera that I can place somewhere and it stays there when I can move it somewhere else when need in game.

summer stump
#

@uncut trench This is..... an extremely basic issue then.... i recommend going through the learn course so you can have the foundation needed to actually solve these kind of basic things of your own
!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

uncut trench
#

Our understanding is on another level

summer stump
#

You could consider an FSM though, for different states the player can be in

uncut trench
#

But will do

summer stump
steep rose
#

thats

summer stump
steep rose
#

he didnt even mention playmaker

uncut trench
#

True

steep rose
#

if you are using playmaker i would suggest going to thier discord server

vocal urchin
steep rose
#

and asking this question there

uncut trench
#

I don't use it lol

steep rose
#

then why did you mention it

uncut trench
#

Idk

shell ice
tepid idol
#

Is there a specific support channel or is this it?

summer stump
uncut trench
#

Well it's been pleasure talking even tho understanding is hard

rich adder
steep rose
#

easiest way

summer stump
shell ice
#

I tried making in kinematic but all movement stops

steep rose
#

not always

vocal urchin
tepid idol
# rich adder depends on the problem

My camera controller just isn't working in-game. Works how it's supposed to in scene but once I start up the game, it's stuck. I've been working on the problem for the past few days and can't seem to figure it out.

#

By stuck, I mean it's zoomed in on a tree and won't move.

shell ice
steep rose
rich adder
summer stump
summer stump
#

When picked up, set it to false

rich adder
shell ice
steep rose
#

you can just get the rigidbody component of what you grab

#

easy as that

shell ice
#

How can I do that?

steep rose
#

im guessing you are using a package for vr so you can either make another script that references the grab script and just take what the object grabs and get the component on it.

it most definitely has a either private or public GameObject type in it for whatever object it is currently grabbing so use that when you want to get the rigidbody component from it.

#

if this doesnt help you, i would suggest !learn ing some basics

eternal falconBOT
#

:teacher: Unity Learn ↗

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

summer stump
#

And also see this

steep rose
#

you got these loaded for situations like these 😂

bleak sleet
#

It dont work

#

both layers are given

#

but it just doesnt even come into the loop

mint remnant
#

add in some Debug.DrawRay()'s to verify rays are going where you think they are?

rich adder
#

are the logs even printing?

#

also your ide doesnt look configured

bleak sleet
#

They are cause they play the sound that is given in HitTarget();

bleak sleet
bleak sleet
rich adder
bleak sleet
#

is that important?

rich adder
rich adder
bleak sleet
bleak sleet
rich adder
eternal falconBOT
#
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

bleak sleet
#

thanks

rich adder
bleak sleet
#

I dont get it, its on it

sleek kayak
#

what's the difference between save and save project?

rich adder
bleak sleet
#

Thats crazy

#

It wasnt working just because I was missing a Effect Decal that i deleted

#

how does that make any logic...

#

thanks for everything tho

bleak sleet
#

Why doesnt the Decal apply onto the Mesh where it hits?

rich adder
#

are we supposed to know if pos is even correct 🤷‍♂️

shell ice
#

nvm got it

native hill
#

how do i make it so Vector3.MoveTowards(); doesnt go all the way to whatever the target is and have a distance between each other so they arent pushing each other around

native hill
#

oh, alright thank you

steel stirrup
#

First, Vector3.MoveTowards already doesn't 'snap' to the target, it moves based on the maxDistanceDelta param

#

If it seems to be snapping to a position instantly, what's likely happening is you're applying it in update and not using Time.deltaTime, so the full step is being applied each frame rather than each second

native hill
#

oh okay, yeah i forgot Time.deltaTime

fossil loom
#

Hey could someone help me figure out why my code doesnt work, this is my first time using unity im following a youtube tutorial right now

steel stirrup
#

For the 'pushing' issue, you should offset where you're trying to move to based on the bounds of the objects involved

fossil loom
steel stirrup
# fossil loom

Read the exception and then move your eyes slightly to the right

#

What does it say next to "Lol"?

fossil loom
#

none rigid body 2d

#

do I need to put something there?

steel stirrup
#

And the exception says "UnassignedReferenceException: The variable Lol of blahblahblah" so yes

fossil loom
steel stirrup
# fossil loom

It's on the GameObject, but it's not set as Lol, so Lol is still null

#

you need to drag it into Lol, or grab it via GetComponent in BirdScript

steel stirrup
#

Not a problem, just a heads up to start looking in that direction if this comes up frequently

native hill
#

that sounds like a pain but ill need it in the future anyways, thank u for telling me

fossil loom
#

So I drag "Rigid Body 2D " into None (RigidBody 2D)?

native hill
#

really? thats good to hear

steel stirrup
#

A bit weird to get your head around at first, especially if you're not familiar with graphs

#

but once you have it implemented once it's very, very easy to work with

native hill
#

i suck with graphs 💔 ill try my best though

steel stirrup
#

If you want to get started, I'd say go ahead and take a shot at making a flowfield based pathfinder

#

that's (imo) the most intuitive

native hill
#

whats flowfield?

steel stirrup
#

It's a type of pathfinding that's best suited to reaching fixed points from anywhere. Essentially you create a graph where each node only flows to one other node

#

And you determine that 'flow' based on weights

#

a flowfield of gravity could look like this

native hill
#

ohh that sounds fun, ill try watching a tutorial to understand it

steel stirrup
#

Much simpler than Djikstra or A* to get started imo, and very useful for any game with large numbers of units as the actual 'pathfinding' is O(1) for the agents

fossil loom
native hill
steel stirrup
native hill
#

that looks hard but ill try my best, thank you i appreciate it

spiral yarrow
#

Uhh idk if this belongs here, but I cannot find a way to configure the old input system for Mouse X and Mouse Y. Can anyone tell me what to do?

vocal urchin
#

abstract classes are so nice bros

spiral yarrow
spiral yarrow
#

Ohh

#

Dang

spiral yarrow
steel stirrup
spiral yarrow
#

Yeah I just saw it sorry :/

ionic zephyr
#

If I have a list of possible drops (GameObjects) and I want to check in each of them an specific component variable in order to know which of them should be instantiated them is it too much to do a foreach in which I do GetComponent ?

bleak sleet
#

Anyone know why the forward goes from the Object Transform and not from the Transform attackPos???

steel stirrup
#

Think of your overall structure

#

Rather than worry about what GetComponent costs, I think you should consider why you've wound up in a situation where you want to use it in this way

summer stump
bleak sleet
summer stump
#

Oh weird. It hadn't loaded before

#

Ok, show the attackPos object
Do not crop

ionic zephyr
#

Because I have this "DropComponent" which has Lists of GameObjects(Drops) depending on which tool or weapon was used to get them. These drops have ranks (S,A,B,C) and depending on the weapon rank the drop will be different. That is why I want to distinguish each drop by a OVERWORLD Item script which has the rank information. In order to check the rank should I create a foreach that checks each of the drops in the list if they have an specific rank?

bleak sleet
#

but it still goes forward from the Collider

eternal needle
ionic zephyr
#

public class DropComponent : MonoBehaviour
{
public List<GameObject> FistDrops;
public List<GameObject> AxeDrops;
public List<GameObject> PickAxeDrops;
public List<GameObject> HammerDrops;
public List<GameObject> BladeDrops;
public List<GameObject> ShovelDrops;

summer stump
bleak sleet
steel stirrup
eternal needle
steel stirrup
#

then store Dictionary<weapon, List<drop>>

ionic zephyr
steel stirrup
#

Are there multiple instances of DropComponent?

eternal needle
#

You can instantiate from a reference to a component and itll spawn the whole thing

steel stirrup
#

And they're all different?

ionic zephyr
steel stirrup
#

alrighty, so this might be the one time in history I'm going to say just use a scriptable object

ionic zephyr
eternal needle
ionic zephyr
#

thanks, both of you!

steel stirrup
#

I think there's a better way to organize this, let me just throw something together real quick

#

This way all the actual organization is handled upfront and fetching a drop is nice and quick

#

you'd have a single list in the Dropper editor and just drag and drop over some Drops from your assets, no need to worry about makign sure they wind up in the Axe list or the Sword list or whatever

fossil loom
mint remnant
#

Well this is sure a nasty little thing if (Physics.Raycast(ray, out hit, groundedMask)) it happilly took groundedMask and turned it into maxDistance lol

steel stirrup
summer stump
fossil loom
#

thank you

fossil loom
#

this is my first time making a game

#

he helped me before

#

my bad

ionic zephyr
summer stump
steel stirrup
ionic zephyr
steep rose
#

good job man

summer stump
#

!code

eternal falconBOT
steep rose
#

we can wait dont worry man, take your time

tepid idol
#

_closeButton.onClick.AddListener(CloseShop);
I believe

steep rose
#

i dont see anything about a camera in this script, i think we would need to see the camera script then

#

please answer after your work so we can help you better

slow knot
#

I need help with something, I'm making a 2d top-view car minigame, and I did all the mechanics, like the car moving, drifts and physics. But I don't know how I can make the car not be able to leave the track, right now it can go anywhere without problem, like can get out of the track. But I want to keep it inside the road. Not being able to go out.

steep rose
#

to make sure the car cant go out

slow knot
slow knot
#

Thank you

crisp token
#

Anyone know why Target0 is being assigned for all these slots given the heirarchy?

wintry quarry
#

It searches itself before going up the hierarchy

crisp token
#

oh i just cahnged it to .parent

#

thanks

wintry quarry
#

You can just do .transform.parent

#

Yeah

crisp token
wintry quarry
#

For many things

#

Plus for Transforms those functions aren't that useful since you have.parent etc

crisp token
#

ig, but they should have a separate method then

wintry quarry
#

Probably

lone pivot
#

is the InvokeRepeating method a good way to do tickers?
instead of running stuff every frame

summer stump
gloomy jacinth
#

I have an AI pathfinding monster in my game and i have it able to walk up slopes so it changes the rotation of the monster to match the rotation of the stairs. But it stays rotated forever while walking around so how do i make it not rotate vertically at all?

final trellis
#

btw just wondering bc google is extremely unhelpful, is there a way to mesh.RecalculateNormals(); but without normal smoothing?

tepid idol
valid shuttle
#

I'm new to unity, and I wanted to learn visual scripting. does anyone know of a video tutorial on how to get something started.

gloomy jacinth
#

Can someone look over my text and see if they have a fix to it?

native hill
#

should i learn some more oop before learning algorthims?

#

i havent been very focused with it

summer stump
steel stirrup
native hill
#

okay! i watched a video about flow field and how to make it and i was really confused when i tried understanding what was happening

cosmic dagger
native hill
#

yeah, I’m gonna work on getting better before trying something like that

sick jay
#

Anyone got a quick fix for this?

steel stirrup
#

Don't add force if it would cause it to exceed the max speed, and increase drag rapidly as speed exceeds maxspeed

cedar bone
#

How would I go about procederally making an ammo indicator in unity without having a different prefab for each gun type?

night raptor
steel stirrup
cedar bone
cedar bone
eternal needle
#

did you look at any tutorials on how to do this?

cedar bone
#

i couldnt find any

#

but prov cause im searching the wrong thing

#

idk what its really called

night raptor
cedar bone
#

thats the hard part

#

cause for a a gun with 4 max bullets, i have to make quarters

#

but for a gun with 5 max bulelts id have to make into fifths

#

and make them both occupy the same space

eternal needle
#

you most definitely wouldnt want each tiny bullet UI to be its own game object.
You could just go with an image and use the fill with like radial as the choice. I dont exactly remember what it was called

night raptor
#

That would require masking the gaps out though

eternal needle
#

Whats hard about that? just placing an image on top to act as gaps would be sufficient

cedar bone
#

but then that'll be a ton of gmae objects

#

and id have to make more of them for smthing like a mahcine gun

#

where tehres a ton of bulelts

eternal needle
#

what im suggesting would literally be 2 objects

#

and really, you're gonna need custom stuff per gun no matter what you do. Unless you wanna go the shader route

cedar bone
#

😔

#

ill just do a percentage thing rn, and then once i dwell into shaders ill do that

eternal needle
#

Image with fill options should get you pretty far as well, the only custom part would be the images used above/below the filled image

night raptor
#

I think that unfortunately using shaders would be the only plausable way to do the indicator dynamically change for any gun type without any extra work for each gun. Luckily I don't think it would be that hard of a shader to do though

cedar bone
#

like what setting exactly?

eternal needle
#

unity took a bit of time to open, and honestly i couldnt even find it on the docs

steel stirrup
#

have a base polygon representing the shape of that guns bullets, and just draw it on a texture X times

cedar bone
#

but that'll change the shape

#

i want it to occupy the same shape though

steel stirrup
#

What do you mean it would change the shape?

#

It'll take whatever shape you write it to take, you'd scale the individual bullets based on the number you want to fit, and I assume you'd probably alter the overall layout to match the type of weapon being displayed

cedar bone
#

how would I scale it?

#

cause if i scale it on the y axis, itll be squished

steel stirrup
#

No, not in the inspector, on the texture itself

cedar bone
steel stirrup
#

iirc raw image uses a texture rather than a sprite, hence being raw

cedar bone
#

whats the difference?

#

im a bit dumb

steel stirrup
#

Practically, different parts of unity expect different inputs. Technically, it's that a sprite encapsulates a texture and includes some extra information. It's very easy to generate sprites from textures and access textures from sprites

#

Regarding Raw Image, it has other uses but 99% of the time it's just there for render textures

tepid idol
#

If anyone is up and has any idea why my camera won't move, it'll be helpful. I've set up the inputs in unity, checked everything that my knowledge will let me, and well, no dice. The scene allows me to scroll perfectly fine, it's just once I press "play", it's zoomed into a tree and doesn't let me click, scroll, or do anything that resembles any kind of movement.
https://hastebin.com/share/vozawofaza.java

steel stirrup
tepid idol
steel stirrup
#

What's throwing me is that youre checking if touch supported is false, but then not actually respecting it so far as I can tell

#

Honestly, I'm not sure if this is just a thing with the new input system, but this entire thing seems hideously overcomplicated

#

That could just be me, but without any comments or documentation in there I cannot really follow what you're trying to do

#

Like you're initializing with about a dozen magic numbers, and some of them are readily apparent but others I can't make heads or tails of

drowsy flare
#

Is it possible to hide a Canvas in the editor, but show/enable it when loading the scene?

I have tried "unchecking" it in the editor, and using this code:

        canvas = GameObject.Find("Canvas");
        canvas.GetComponent<Canvas>().enabled = true;

But it doesn't do what I want.

I also tried the following:

        var objectCount = objects.Length;
        Debug.Log("Found objects to activate: " + objectCount);
        foreach (var obj in objects)
        {
            Debug.Log("Found an onbject to activate: " + obj);
            obj.SetActive(true);
        }```
But it didn't find all deactivated objects, I guess they arent loaded to the scene?
steel stirrup
#

gotta read the tooltips

tepid idol
# steel stirrup Like you're initializing with about a dozen magic numbers, and some of them are ...

This is what I followed for camera control. https://youtu.be/kaU11fqe5yE?si=fbMCP5LdaYIPb-pr

Unsure if it helps clarify things. But the camera controller is similar to what you see in isometric games like Clash of Clans.

In this video tutorial series I will make a massively multiplayer online real-time strategy (MMORTS) game like clash of clans. I will be using a TCP networking solution that I have already published and also use MySQL database to store players data.

Discord:
https://discord.gg/FWwDgKjcKQ

GitHub Links:
https://github.com/developers-hub-org/unit...

▶ Play video
drowsy flare
steel stirrup
#

Rider

drowsy flare
#

Thanks, gonna check it out. Tooltips looks awesome 🙂

slender nymph
#

that's not exclusive to rider. a properly configured IDE should show the code's XML comments. i know it works in Visual Studio. vs code may be iffy

steel stirrup
drowsy flare
#

@steel stirrup s method of just hiding the objects in the editor did the job perfect 😉

steel stirrup
#

that was the other guy

steel stirrup
cedar bone
#

how do I check the last value of a variable

#

cause i wanna do smthing the frame that the variable 'state" changes from air to walking

teal viper
short hazel
#

Use another variable!

cedar bone
#

so store it as another variable?

teal viper
#

Yes

cedar bone
#

but thats a waste of a whole variable

steel stirrup
#

There are a bunch of ways to do it, but if you just want to do 'something' on change, then make it a property and throw whatever you want to do in the setter

teal viper
slender nymph
#

alternatively, you could use a property that does whatever it is you want to do when its value is changed

short hazel
#

Waste? That's a first for me
They're literally made to store values

marble hemlock
#

can someone give me an example of a situation where you'd use Awake instead of Start?

steel stirrup
marble hemlock
#

I'm reading the documentation and looking it up, and I'm kind of getting an idea of what its supposed to do, but I can't think of a situation of when I'd use anything except Start

#

As far as I understand, Awake runs at the start regardless if the script is active but I don't really understand why

steel stirrup
#

and here I am wishing we also had a LateStart()

teal viper
steel stirrup
#

Solve that before you try to fix your camera

tepid idol
steel stirrup
#

Yeah, and it's almost certainly unrelated, but exceptions can cause really, really bizarre behavior. Basically you can't trust that anything in your game is actually running correctly if you have exceptions popping up.

marble hemlock
#

okay so

#

if im using something that the other scripts are going to need to use on Start, then i use Awake to do it first?

tepid idol
steel stirrup
#

IDE usually won't help with a null ref unless it's like HashSet whatever = null; whatever.add(x)

queen adder
#

is there an attribute that tells "you can only have one of this type in a scene"?

tepid idol
queen adder
#

like [DisallowMultipleComponent] but for whole scene

steel stirrup
#

I've never used VS, so 🤷🏻‍♀️

teal viper
teal viper
steel stirrup
teal viper
eternal falconBOT
queen adder
#

    #if UNITY_EDITOR
    void Reset()
    {
        var pm = FindObjectsOfType<PanelManager>();
        if(pm.Length > 1)
        {
            DestroyImmediate(this);
        }
    }
    #endif```can have this, but not really fun to write each time
steel stirrup
#

I mean the first question is why, right?

#

Why are you in a situation that this is actually an issue

teal viper
steel stirrup
#

This is putting a bandaid on a wound that shouldn't exist

#

also the least efficient way of doing that possible

#

If you really need to check, then just use a static reference so you aren't searching everywhere

tepid idol
# teal viper Is your !ide configured correctly?

I'll check right now, I just laid back down because I opened the Main UI script and saw the colors for SeralizeField disappeared and decided to lay down in defeat. Everything should be installed correctly but I'll go back and check again to make sure so I can rule that out

queen adder
#

what you talking about, im using editor reset already, why would i need to put extra runtime load Facepalm

steel stirrup
#

same approach works for editor, just have it run in editor and register

teal viper
queen adder
#

pretty sure this did

is there an attribute that tells "you can only have one of this type in a scene"?

steel stirrup
#

Restricting a developer from placing things in a scene is just kind of a strange ask

teal viper
ripe shard
queen adder
#

The real question is the "attribute" part

#

Ive written dozens of singletons in my life

teal viper
sweet sierra
#

I want the quaternion rotation to basically be whatever it is of what I'm instantiating. How do I do that?

#

Like... I don't want to change the default orientation

steel stirrup
ripe shard
sweet sierra
sweet sierra
steel stirrup
#

when you say you want it to be the rotation of 'whatever you're instantiating'

#

do you mean literally the one saved in the prefab?

sweet sierra
#

Yes, exactly

steel stirrup
#

you shouldn't need to do anything

ripe shard
sweet sierra
#

There's no overload that only needs position and parent transform

sweet sierra
#

As in.. assign the position later?

steel stirrup
#

you don't gain anything by using the overloads, it's just convenience

sweet sierra
ripe shard
steel stirrup
ripe shard
sweet sierra
tepid idol
ripe shard
sweet sierra
#

Understandable. I'll keep that in mind 🫡

drowsy flare
#

Is there any editor tool to have an icon on an object shown in editor? The object doesn't have a visual representation in the game, but it would help to see it clearly in the editor

drowsy flare
errant flower
#

a very dumb question but how to stop random animations from just playing on start

#

i tried disabling the animator but i feel there is a better solution

#

nvm did it

teal viper
pale ocean
#

hello all, this is my first time using unity on my own and i'm trying to make a flappy bird clone, anyways im trying to check if there's a pipe under the player. So I'm using this code csharp if(Physics.Raycast(transform.position, Vector3.down, out RaycastHit raycastHit, 2f, PipeLayerMask)) { Debug.Log("pipe?"); } however it's not logging anything, anyone have a clue why? this code is in the player class

rich adder
pale ocean
#

not at all its in the right spot

#

the layer mask is on the parent of the cylinder

languid spire
#

show your declaration and value for PipeLayerMask

tawdry agate
#

any Idea, why I cant assign a gameObject to a Script on a Prefab?

languid spire
tidal kiln
languid spire
tawdry agate
#

ah, ok, then how do I get a reference of my player to a Prefab? It can be disabled at the time it searches for it, so find() doesnt work

tidal kiln
languid spire
pale ocean
pale ocean
#

as for the value its just a layer i made

tawdry agate
#

ok, thx

rich adder
languid spire
pale ocean
pale ocean