#πŸ’»β”ƒcode-beginner

1 messages Β· Page 351 of 1

eager spindle
#

Surprisingly none of my assets are above 100mb each

#

Total project size is 26gb kokoswim

grave frost
#

you paid then? You have to just pay for a premium account right?

fluid kiln
#

yep its not abt the dialogue itslf, but the triggers, like speaking to an npc, entering a scene, stepping into a certain area, getting an item... ecc ecc...

(the trickiest part is the one that checks if the player has achieved X things in the story)

eager spindle
#

Even though the repository is 26gb

grave frost
eager spindle
#

Branch protection

#

Yuh

grave frost
#

Yea you can't enable it with a regular repo

rocky canyon
#

more of fluff at that point πŸ˜…

eager spindle
grave frost
eager spindle
#

And also track that the dialogue has already been played before in your save file

eager spindle
#

We don't even bundle our assets

grave frost
eager spindle
#

Hasn't happend yet

grave frost
eager spindle
#

Tbf I've never made a project large enough to justify bundling my assets

rocky canyon
#

whats bundling ur assets mean?

eager spindle
#

Even my genshin ripoff was only 400mb despite having a lengthy campaign

fluid kiln
rocky canyon
eager spindle
# rocky canyon whats bundling ur assets mean?

let's say you're making genshin impact, big open world RPG with lots of assets.
but you can't load 60gb of assets at once

to bundle your assets means to place them in files that get loaded at different times. if you're in one region then the files for that region get loaded and the rest remains unloaded to save ram

#

It's very important for console because consoles have very little ram 😑

rocky canyon
#

NPC: Billy VISIT: #4

rocky canyon
#

AAA kinda stuff

#

Loading Shaders

eager spindle
#

also helpful for sharding downloads for your game

grave frost
eager spindle
#

just a brief summary

rocky canyon
#

/woosh

eager spindle
#

I haven't touched it much because I don't make big game

rocky canyon
#

that 1 thing i haven't even had secondary exposure to

eager spindle
#

Everything I have is low poly

rocky canyon
eager spindle
#

including my skibidi toilet fan game

rocky canyon
#

lowpoly-ftw
not b/c i can't model..
but b/c i can't texture πŸ˜„

grave frost
eager spindle
grave frost
rocky canyon
#

well, i can texture.. but im bad at UV mapping

grave frost
#

womp womp

rocky canyon
#

theres 1 that u can compile urself for free i believe

grave frost
rocky canyon
#

ArmorPaint

eager spindle
#

Tldr I have QuestManager.AddObjective, either takes in Dialogue which plays dialogue, Position which places a marker and asks players to go to a location, Entity which asks player to kill enemy(ies) and Puzzle

#

This Quest manager is independent of CampaignManager

rocky canyon
eager spindle
#

I enjoy low poly games a lot

rocky canyon
#

ya, im growing tired of flat shaded models tho..

eager spindle
#

as a Roblox child

rocky canyon
#

i'd like to adda bit of texture here and ther..

eager spindle
#

can't you texture in unity?

rocky canyon
#

ya, but only when the UV's are decent

#

thats my issue..

eager spindle
#

if you're daring enough you can make submeshes and do the base map in unity

rocky canyon
#

not the texturing.. but the UV mapping

#

just havent learned enough yet to be good at it

eager spindle
#

you can start small ig make submesh for the walls of the barn and put some stock texture

#

I don't really 3d model I just paste cubes in the scene and call it a day

rocky canyon
#

all of these come with great UV's

eager spindle
#

Ooh

#

Right now I'm using Womp3D for my more complicated models

#

Very fast to get into

rocky canyon
#

thats what i use to practice my texturing for now... and once i feel comfortable doing that.. i'll have more context to use myself.. when trying to layout good UVs

#

b/c its not that i can't UV its more like I don't know what good UV's should look like..

#

i'll just Smart UV unwrap everything! 🀣

eager spindle
rocky canyon
#

but anywho, i believe we've went offtopic a bit 🀏

#

🀫 i'll be quiet.. just waiting for some code related questions lol

eager spindle
#

right now I'm thinking of server side implementation to store user data, I'm making a small project right now and am lazy to set up firebase

how secure is making an in-memory database in python flask? user passwords will be hashed with bcrypt

rocky canyon
#

i'll probably just try to contend with this error for a while

rocky canyon
#

does it have an API that unity can use?

eager spindle
#

you can send POST/GET/FETCH requests with unity networking

#

which flask does

rocky canyon
#

i do know 1 thing.. server-side is hella lot better than client side

#

soo u got that going for ya

rocky canyon
eager spindle
#

Yep

rocky canyon
#

i haven't much experience with those outside of setting up a Mirror lobby

#

i should experiment myself

eager spindle
#

the database
Dictionary<int, string> passwords; // user passwords hashed with bcrypt

Dictionary<int, Inventory>; // user's inventory
struct Inventory {
int coins;
List<item>
}

#

in theory this is secure

#

but people absolutely despise me for this implementation

rocky canyon
#

why is that?

eager spindle
#

no one uses flask to make an actual backend they keep saying it's for learning purposes

#

and to go use a proper backend

spiral narwhal
#
        private static IEnumerator LoadGame(GameStateModel modelToLoad)
        {
            var operation = SceneManager.LoadSceneAsync(modelToLoad.CurrentSceneName);

            while (!operation.isDone)
            {
                yield return null;
            }
            
            GameSaveService.LoadGameState(modelToLoad.FileNameWithoutExtension);
        }
#

Is there a way to do this statically

#

Because StartCoroutine does not exist in a static context

eager spindle
slender nymph
#

you can start the coroutine from a non-static method on a MonoBehaviour, such as in response to pressing a Play button

eager spindle
#

Put it in donotdestroy

spiral narwhal
#

I do want it from a static context

eager spindle
#

❌

spiral narwhal
#

But StartCoroutine does not exist

eager spindle
#

you can make a public static instance though

slender nymph
spiral narwhal
#

Easy service integration

#

If there's no way to make it static that's ok

#

Just making sure

slender nymph
#

then either make a persistent gameobject that you can start the coroutine from or don't use a coroutine

spiral narwhal
#

Do I HAVE to use a coroutine for just "waiting" while loading?

eager spindle
#
public class GameLoader:MonoBehaviour {
  public static GameLoader instance
  Start() {
    DoNotDestroy
  }
  public IEnumerator LoadGame() {
  }
}
#

smth like this

spiral narwhal
#

I know what a singleton is haha

slender nymph
eager spindle
#

then just Start routineGameLoader.Instancr.LoadGame())

spiral narwhal
#

22 LTS

slender nymph
#

then the only built in option for waiting for that load to complete is a coroutine

eager spindle
spiral narwhal
#

Ah I see

#

Yeah no it's just simple 2D no need really

#

But thanks

eager spindle
#

stuff might explode though last time I tried it the engine didn't like me

#

I'm ngl a lot of loading screens are fake

#

If you're not loading 8gb of assets or waiting for other players to join you can fake a loading screen

slender nymph
#

just write a static class that will spawn a gameobject with a component that just starts the coroutine on it and marks itself as DDOL. then the static class just keeps the reference to that spawned object for the duration of the session and you can change scenes using that

#

or you could use a singleton, but that would require putting it in a scene manually or lazy loading it which is basically the same thing i just described anyway

#

i personally prefer the static class option because then the monobehaviour can be private so nothing can access it directly without some wacky shit like Find

eager spindle
#

imagine using Find in production

mystic dawn
#

can anyone help me figure out why my enemy movement script is not working?

my enemy keeps just moving up and down and does not follow the player at all :((( i've set up the entire enemy script and everything works correctly apart from moving the enemy

https://gdl.space/lolaqufidu.cs

slender nymph
#

what is the target field assigned to

wintry quarry
#

yeah that code doesn't make sense

#

seems like it shouldn't even compile

eager spindle
wintry quarry
#
Vector2 direction = (target - (Vector2)transform.position).normalized;```
#

but yeah it's unclear which script this is

#

or what object it's attached to

#

or what the variables are assigned to

#

etc

mystic dawn
#

i think i found it as i sent the message it's so dumb im ashamed of saying what it was

eager spindle
mystic dawn
#

i checked the freeze x on rb

#

by accident and forgot it

rocky canyon
# eager spindle I'm ngl a lot of loading screens are fake

whats wrong with that?

    IEnumerator BootEnvironments()
    {
        FindLightController();
        yield return GetRandomWaitTime();
        environmentProgress = 100f;
        IncrementSector();
    }

    IEnumerator BootSystems()
    {
        FindGamePlayObjects();
        SetupSettings();
        yield return GetRandomWaitTime();
        systemsProgress = 100f;
        IncrementSector();
    }

    IEnumerator BootGameSetup()
    {
        SetupPlayer();
        yield return GetRandomWaitTime();
        gameSetupProgress = 100f;
        IncrementSector();
    }``` πŸ˜„
#

eventually i wont need to fake it 🀣

eager spindle
#

🎊

#

Ooh

#

LMAO

rocky canyon
#

but u can tell from the video its soo fast.. b/c i reduced the GetRandomWaitTime() to zero

strong wren
#

how can i check if a value is going down in an if statement?

#

cause if(value--) doesnt work

wintry quarry
strong wren
wintry quarry
#

and if that "other value" is the previous value of the variable

#

then we know it's "going down"

#

you asked quite a vague question btw, so I'm answering to the best of my ability with the given context, which was basically 0

strong wren
#

ok leme explain more

eager spindle
#

int coins;
int coinsLastFrame;

Update() {
if(coins < coinsLastFrame) {
}
// other logic
coinsLastFrame= coins // make sure this is last
}

#

depends on what you're doing

wintry quarry
#

Yes^ in other words if (value < previousValue)

#

but if this really doesn't answer the question, more context would be nice.

radiant frigate
#

im having an error that says that addforce doesnt take 4 arguments, what sintaxis error am i having? i searched in the docs and couldnt find it or dont understand it

wintry quarry
#

this is a Rigidbody2D

eager spindle
#

do check the examples

faint sluice
wintry quarry
spiral narwhal
#
        private IEnumerator LoadGame(GameStateModel modelToLoad)
        {
            Debug.Log("loading");

            var operation = SceneManager.LoadSceneAsync(modelToLoad.CurrentSceneName);
            operation.allowSceneActivation = true;

            while (!operation.isDone) yield return null;

            Debug.Log("finished");

            GameSaveService.LoadGameState(modelToLoad.FileNameWithoutExtension);
        }

"loading" is printed and the scene changes correctly, however, "finished" is never printed, nor is the method unterneath it called. Why?

wintry quarry
eager spindle
radiant frigate
#

thanks everyone ill check!

eager spindle
#

you can load it additively

wintry quarry
eager spindle
#

then unload after finish is printed

spiral narwhal
#

Ah so I can simply transfer it to a DDOL object?

wintry quarry
#

You need to either load additively or this object needs to be DDOL

strong wren
#

oh nvm the hting i needed fixed itself out

eager spindle
#

suspicious

strong wren
#

no i confused myself

#

when i was asking for help

wintry quarry
#

i mean if(value--) was certainly pretty confusing

strong wren
#

im adding sprinting and i wanted to make it so when a person is running or jumping to set the regentimer to 5

#

and idk why i came to check if the stamina value is going down

wintry quarry
#

yeah that seems roundabout

#

classic XY problem

strong wren
#

like chromosomes? or Cords?

wintry quarry
#

basically you actually wanted to know if you were sprinting, you thought you could do this by checking if stamina was going down, but really you should just be checking your isSprinting variable or whatever

strong wren
#

oh

#

yeo

#

yep

#

idk i confuse myself when i am reworking on my own code, so sometimes if i just reread the code then i can easily do it

bronze mortar
#

Hey guys, I just wrote a script to spawn a prefab within this range, but it's not spawning anything. Does anyone know why? Yep, the object has a collider and is prefabbed

wintry quarry
bronze mortar
#

True :p

short hazel
#

Unless that function is hooked up to an event (like a button click), the "0 references" on top of that in the code should be pretty self-explanatory :)

radiant frigate
wintry quarry
#

The spaceman?

radiant frigate
#

yes

wintry quarry
#

You just need to make sure its colliders are properly arranged

#

looks like the sprite and collider are not aligned properly

radiant frigate
#

if i allign it it shouldnt phase through the wall?

eager spindle
#

for the spaceman could you show the collider

wintry quarry
eager spindle
#

like the circle collider attached to it

radiant frigate
bronze mortar
radiant frigate
eager spindle
#

show the component

#

make sure Is Trigger is off

radiant frigate
#

well i will just test lmao

#

yeah trigger is off

wintry quarry
radiant frigate
#

the wall is a tilemap

#

and has a tilemap collider

wintry quarry
short hazel
radiant frigate
#

i think the collider is directly related to the grid so i shouldnt or maybe even cant change that

#

but i might be wrong

wintry quarry
#

it's from the tiles

#

and the colliders for the tile sprites can be configured in the sprite editor

#

make sure the collision shape is correct for the tiles

wintry quarry
#

and again, do you have an event system in the scene

hollow dawn
radiant frigate
#

but even if it were wrong wouldnt it just stop at the collider point

#

something like this

#

where even if the sprites where overlaping

#

the colliders arent

wintry quarry
bronze mortar
wintry quarry
#

but it's more likely an issue of how you set things up in the inspector

wintry quarry
#

and also the physics raycaster2d on the camera

bronze mortar
#

How do I add an even system? I'm a little unfamiliar with that

hollow dawn
wintry quarry
#

you probably didn't put the script on the right object or your objects are not arranged properly in the hierarchy etc.

short hazel
wintry quarry
#

the sprite editor for the individual sprite is where you'd set the physics shape

eager spindle
#

show us your spaceman

#

the list of every component your spaceman has

radiant frigate
eager spindle
#

and your wall too

radiant frigate
#

my wall is a grid map with a rule tile

#

i dont know how to exactly show that

bronze mortar
short hazel
#

Yeah when you right-click in the Hierarchy

radiant frigate
#

maybe that?

wintry quarry
#

so you'd have to show that prefab

#

as that will be a separate GameObject and won't be related to the Tilemap collider really

bronze mortar
radiant frigate
#

ohhhhhhhhh

#

the prefab doesnt have a collider

#

maybe thats the problem?

wintry quarry
#

maybe, but

#

Why are you doing it this way

radiant frigate
#

ill just try

eager spindle
#

I mean the tile map collider should cover that but

short hazel
wintry quarry
#

instead of using a normal tile

radiant frigate
#

this was what made the most sense to me

#

since it wouldnt let me just choose the square sprite as default i created a gameobject that was just the sprite

wintry quarry
# radiant frigate because im a begginer and dont know any other way

I recommend investing in this short tutorial to learn how to use tilemaps https://learn.unity.com/tutorial/introduction-to-tilemaps

Unity Learn

Unity’s Tilemap system makes it easy to create and iterate level design cycles within Unity. It allows artists and designers to rapidly prototype when building 2D game worlds. In this tutorial, you'll create a Tilemap and explore the Tilemap system including Tilemap settings, and you'll use the Tile Palette to edit your Tilemap.

radiant frigate
#

i watched it but ill watch it again

#

maybe i missed out something

wintry quarry
#

Yes the meat of it it seems

#

create a tile palette

#

and drawing with your tiles

short hazel
# bronze mortar

UI > Event System
Seems like they pulled all the options up to the root menu itself

#

And grouped them up better

bronze mortar
eager spindle
#

I mean just have it in

short hazel
#

Yes, that is what detects objects and dispatches events to scripts

eager spindle
#

It's not that expensive

wintry quarry
#

That's part of the event system

bronze mortar
#

aa oki

short hazel
#

You'll need a Physics Raycaster on the camera too

wintry quarry
#

2d*

bronze mortar
#

yippie

#

it worksss

#

for whatever reason

eager spindle
#

🎊

rocky canyon
radiant frigate
#

lmao

#

mood

radiant frigate
#

and it has collision thanks to the tilemap collider

#

but i still phase through it

wintry quarry
#

You already had the sprite I thought. This was more a question of using a Tile vs a GameObject

#

So you owuld have added the tile to a tile palette

radiant frigate
#

yes i added the tile to a tile palette

#

should i have just placed a bunch of gameobjects as walls?

wintry quarry
#

no

#

tilemap is better

radiant frigate
#

srry im not understanding what the problem is now

wintry quarry
#

look at the colliders

radiant frigate
#

its in chunk mode

#

and its well represented i think

#

the yellow part is the collider

#

or should be

wintry quarry
#

the green outlines are the collider

#

it's common to combine that with a Composite Collider2D btw

#

regardless, this should be alright so - back to the player

#

Also make sure your camera is head-on. Are you in 2D mode?

radiant frigate
wintry quarry
radiant frigate
#

sure

#

what part of the code

#

the one that adds the force?

wintry quarry
#

ideally the whole script for player movement

#

!code

eternal falconBOT
radiant frigate
wintry quarry
#

this code isn't really adding forces it's just setting velocity, btw

radiant frigate
#

yes the movement isnt

#

but the collision should

rocky canyon
#

if ur setting the velocity every frame (b/c of movement) adding forces isn't going to do anything

#

you'll just reset them the next frame

wintry quarry
rocky canyon
#

πŸ˜„

radiant frigate
#

so i should addforce instead of .velocity?

wintry quarry
#

Not necessarily

#

i mean basically it has nothing to do with the problem you're talking about

radiant frigate
#

okay i will give some context of why i did things so maybe that helps you help me

#

at first whenever i collide with the ball it would slow down, so what i made was that whenever i collide with it, it just sends me back

#

and the way i thought of doing this was with .velocity

#

but it didnt work, so i tried with addforce and it kinda works, the problem is that i now phase through the walls

silk fossil
wintry quarry
radiant frigate
#

should i try to change to addForce instead of velocity

wintry quarry
#

it won't make a difference

radiant frigate
#

because since it resets each time for it to impact it has to be very high in the only frame it acts, so maybe by changing it to addforce i can lower it and make it so it doesnt have the speed to phase?

wintry quarry
#

it has to be an issue with your colliders

rocky canyon
#

one workaround is to pause ur player's movement code for the knockback to take affect..

#

then after a short delay.. reenable it

radiant frigate
#

a couroutine?

rocky canyon
#
    private IEnumerator ResumeMovementAfterKnockback()
    {
        yield return new WaitForSeconds(0.2f); // Adjust as needed
        allowMovement = true;
    }
``` yes a coroutine could probably achieve that
radiant frigate
#

but that would be the same as making my character work with addforce right?

#

well not completely

#

but in that aspect

rocky canyon
#
Knockback(){
allowMovement = false;
rb.AddForce(knockbackforce);
StartCoroutine(ResumeMovementAfterKnockback());}```
rocky canyon
wintry quarry
#

Again ultimately adding forces and setting velocity will move the object via velocity

#

so it doesn't matter which one you use

rocky canyon
#

u can't continually addforce or ur player would keep speeding up

wintry quarry
#

it won't change this problem of overlapping

radiant frigate
#

but iΒ΄ve checked the colliders and they seem to be working

wintry quarry
#

you should pause the game when it's happening and closely inspect the obejcts and their colliders

rocky canyon
#

try this ^

#

step thru it frame by frame..

wintry quarry
radiant frigate
#

maybe its collision detection mode?

wintry quarry
#

and turn on interpolation (set to interpolate) to make the movement smoother

radiant frigate
#

what does interpolate do?

wintry quarry
#

makes the motion look smoother

#

it will be naturally stuttery because physics runs at a fixed framerate

radiant frigate
#

ohhh

#

so i should alwas have it at interpolate ?

wintry quarry
#

Pretty much for any moving Rigidbody

radiant frigate
#

or is there a situation where its detrimental ?

wintry quarry
#

it has a small performance cost but for a single object and especially the player object it's worth it.

cunning narwhal
#

Is there a go-to guide for when I should be using a scriptable object? Technically everything in the entire game can be one right?

rocky canyon
#

Another workaround is if ur knockback affects 1 axis.. that ur movement doesn't for example its common in here to see:

  • players being moved with velocity
  • jump being added with AddForce

in that circumstance there a work around where u feed the Y velocity into ur movement function.. so the movement function is not affecting the axis that u apply the forces to.. playerRB.velocity = new Vector3(0f, rb.velocity.y, 0f);

just another tidbit of information that might be beneficial to know..

wintry quarry
#

You will need a presentation layer of some kind

#

Either GameObjects or Entities

radiant frigate
cunning narwhal
#

Ah gotcha, I'm confused on when to make one and for what purpose really

rocky canyon
#

they're good at holding data

#

for example

wintry quarry
rocky canyon
#

all this data is read-only data.. my player controller just uses it to set up the controller

hollow dawn
#

Everything is ruined and now I have to make a new project 😦

rocky canyon
#

!vc

eternal falconBOT
#
Using version control in Unity

Unity Version Control

git Git

Get the latest .gitignore file from here. It should be placed at the root of your Unity project directory.

cunning narwhal
#

Thanks to you both again, I'm a bit new to SO's and DOTS concepts. So if I understand it right, while I could use a class with my variables to initialize and set values, the SO comes in as a way to save it to a file for later reads?

#

So I would have a scriptable object that holds player data, map data, items, etc

rocky canyon
#

yea, but u wouldn't necessarily use them to save data to a file that gets read later..

#

thats more of a job for a JSON type text system

#

If you need to save ScriptableObject data to a file for later use, you would typically serialize the data to a file using Unity's serialization system (e.g., using BinaryFormatter, JSONUtility, PlayerPrefs, etc.) and then deserialize it when needed..

#

they're not typically used for persistent data

rich adder
#

if you must use BinaryWriter

rocky canyon
#

noted.

#

i use JSON myself.. just trying to think of all avenues

cunning narwhal
#

Oooh I think I get it now, basically it moves it outside of memory so that other things like prefabs that are instantiated a hundred times can access the values stored in there vs making new memory spots per instance

rotund quest
#

hi
is there a way to spawn an object randomly within a certain range?

for example: i want to spawn object X between these 2 lines, and that no matter what the size of object X is, it will always be between these 2 lines (no clipping)

rocky canyon
#

absolutely.. use min and max values..

#

and generate a random number between them 2

rich adder
#

yup. use something like Random.Range

rocky canyon
#

u can take the size of the object into account

#

and just subtract half of it from the min

#

and half of it from the max

rotund quest
#

wow thanks

rocky canyon
#

well i mean Add half of it to the min and Subtract half of it from the max, but u got the idea

rotund quest
#

yeah

rocky canyon
#

so stats for a gun in a shooter game for example

willow scroll
rocky canyon
#

u should make it an extension to the Random.Range class πŸ˜‰

#

Random.Range(min,max,sizeOfObject);

#

lol

willow scroll
#

Haven't used it in a while, found in the old code

rocky canyon
#

i been working my way up to extension methods

#

starting with my own static classes.. and then once i feel comfortable i'll start using predefined classes to add to

willow scroll
#

Why don't you implement the Up?

rocky canyon
#

lol, havent needed it yet πŸ˜‰

#

but i will

#

im just goofing atm

willow scroll
#

Also you know that ternary operators are cool?

rocky canyon
willow scroll
#
using Input = UnityEngine.Input;

return held ? Input.GetMouseButton(0) : Input.GetMouseButtonDown(0);
rocky canyon
#

imma change it right now πŸ˜„

willow scroll
#

Shouldn't you have changed it to the lambda switch?

rocky canyon
#

lol.. when i showed my previous switch statement and said it was ugly?

rocky canyon
#

ohh yea.. lambda switch

#

nah, i hadnt tried that yet

#

ofc, imma tie the two together sometime.. right now its just a public enum called Direction..

willow scroll
rocky canyon
#

but i'd like it to return the direction.. but to do that imma need to pass in the gameobject first

#

so i can get the correct local transforms

#

lmao.. eyes still bleeding i guess

willow scroll
#

Now the right one

rocky canyon
#

haha.. i apologize

willow scroll
#

That's alright, I've almost recovered

rocky canyon
#

u found that code too quickly..

#

i gotta obsfucate my messages a bit better πŸ˜„

willow scroll
#

I just searched for my messages containing "left eye"

#

There weren't a lot

rocky canyon
#

lmao ahh, good memory then πŸ‘

willow scroll
#

It's not, you usually don't forget something that makes your eye bleed fast

rocky canyon
#

c'mon! (β•―Β°β–‘Β°)β•―οΈ΅ ┻━┻

#

when I'm refactoring I always like to get ChatGPT to make me chuckle first

#

never fails

willow scroll
#

ChatGPT is definitely going to throw a few errors and skip a few parts of the code when refactoring

rocky canyon
#

oh yea, im very aware.. its like coaching a toddler

willow scroll
queen adder
#

Why can't I put any game objects inside of this prefab?

willow scroll
queen adder
#

Oh

queen adder
willow scroll
willow scroll
# queen adder

I mean, you don't expect Start to run on the prefab, do you?

willow scroll
# queen adder Wdym

If you want the Start method to run, you'll have to make sure the object is in the scene. The Unity methods don't run on the prefabs.

queen adder
#

Maybe that helps clarify some things because I'm a little confused ngl

wintry quarry
#

so it can know where to spawn its babies

queen adder
willow scroll
#

As PraetorBlue mentioned, simply pass the objects needed for the card when instantiating it

queen adder
willow scroll
wintry quarry
rocky canyon
#

instantiatedPrefab = Instantiate(prefab)
instantiatedPrefab.someVariable = 10

wintry quarry
#

More generally it would probably be good if there was a "CardPlatform" script or something

#

that you generically pass to every card you spawn

#

and contains all that information

rocky canyon
#

yup, i concur

queen adder
#

Cards? I'm a lil confused, I feel like we're not exactly on the same page 😭

wintry quarry
#

unit

#

tamagotchi

willow scroll
#

And you would usually make a struct for the variables required

wintry quarry
#

whatever you want to call it

queen adder
#

chicken? xd

rocky canyon
#

chicken.. same thing

#

the thing u spawn

wintry quarry
#

when you spawn it, you should pass it a reference to the platform it will live on

rocky canyon
#

how about that.. big blanket term

queen adder
#

aaa

#

lemme try

rocky canyon
#

noo memes k thx bye

queen adder
rocky canyon
#
public class Chicken : MonoBehaviour
{
    public void Initialize(GameObject ground)
    {
        Debug.Log($"Chicken spawned on: {ground.name}");
    }
}

public class ChickenSpawner : MonoBehaviour
{
    public Chicken chickenPrefab;
    public GameObject ground;

    public void SpawnChicken()
    {
        Chicken newChicken = Instantiate(chickenPrefab, transform.position, Quaternion.identity);
        newChicken.Initialize(ground);
    }
}```
queen adder
#

sooo i shouldnt use the "top left bottom right" thingy at all?

rocky canyon
#

are you using UI components for all this?

#

if ur gonna set the position of the chicken/egg/ or whatever.. u can probably just leave it anchored to the center

#

dont quote me on that tho...

#

i tend to use 2D Sprite objects.. instead of UI components

#

which dont have an anchor

wintry quarry
queen adder
# rocky canyon what u mean by that?

That's the issue I'm trying to solve. I have two game objects: one at the top left and one at the bottom right.

I also have an egg prefab, but I can't assign these two objects to it to determine the spawn area because prefabs can't take game objects

wintry quarry
#

ALmost every programming problem can be solved by adding layers of abstraction or indirection

wintry quarry
rocky canyon
#

well that problem has already been solved for u..
regardless of ur setup its the same problem.. u cant put scene references in a prefab

rocky canyon
#

u have to do that after the prefab is instantiated

#

thats true for every prefab.. not just Ui objects

#

u can use regular values for the bounds..

#

just find out what the X coord is for the left one.. and the right one

#

and what Y coord is for the top one and bottom one

queen adder
#

True I guess, you could also do it that way

#

i guess its the easier way

#

bump

#

months and months of dealing with this issue

slender nymph
#

this is a code channel

outer quail
#

Why does this hide cursor script not work if I add it as a the player component?

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

public class HideCursor : MonoBehaviour
{
void Start()
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}

grave frost
#

did you click into the game view / is the game view focused??

frail laurel
#

Hello, could anyone help me im trying to figure how to make when Playerisdead the player couldn't move ?

eternal needle
frail laurel
#

!code

eternal falconBOT
eternal needle
frail laurel
#

i don't want him to move

#

at all

#

when dead

main anchor
rocky canyon
#

your controller probably is flagged as isGrounded when that starts to happen

#

its probably how u implement ur gravity

eternal needle
# frail laurel i don't want him to move

Yes I understand the issue, and my answer above is to guide you how you can return early from the functions that do move the player. Also you could just set the rb to kinematic, but then it will also not even fall on the ground

rocky canyon
frail laurel
#

thank u πŸ™‚

#

if(!ican'tmove?

#

or if(!canMove)

rocky canyon
#

! means not

frail laurel
#

thanks

eternal needle
rocky canyon
#

!canMove or cantMove would be the same thing

#

but thats just my example.. u can use a false flag or a positive flag

#

and name it anything u want

frail laurel
#

so if i am dead but my player can still move

if(!canMove)
{
return;
}

}

}

main anchor
frail laurel
#

so i put walk and thoose things in return?

rocky canyon
#

that way, if !dead.. the return wont run.. and the code below it executes.. (the movement code)

frail laurel
#

mhm

rocky canyon
grim tulip
#

What are the most common questions being asked in beginners code?

rocky canyon
#

the code thats working against u when isGrounded.. isn't going to slow it down as much

rocky canyon
languid spire
#

how fix

grim tulip
rocky canyon
#

its differnt day to day..

frail laurel
#

we learning

#

every day

rocky canyon
#

a lot of How i reference this

#

how i make this code do this to this other object..

#

or why i can't make my prefab do a thing (when they're trying to access the actual prefab and not the instance)

languid spire
#

what does this mean

rocky canyon
#

orrr.. how can i set this thing from this other scene before i even access the other scene

grim tulip
#

Ohhh

#

Okay

rocky canyon
slender nymph
#

I want that <incredibly googleable thing> to happen. Does anyone have a script I can use

rocky canyon
#

oh oh, heres the best one: chatGPT told me to do this, and it was working at first, but i changed something and now it doesn't

frail laurel
#

!code

eternal falconBOT
languid spire
#

how about 'I changed nothing and now it doesnt work'

frail laurel
rocky canyon
rocky canyon
#

meaning.. if ur bool isDead is true.. theres no possible way for the code thats highlighted to set it back to true

frail laurel
#

how do i fix that?

rocky canyon
#

ohh wait.. that doesn't matter.. because its already true if thats the case

#

whast wrong with it?

frail laurel
#

i want the player to stop mowing

rocky canyon
#

well when its dead it will..

frail laurel
#

okey

#

thanks

#

1/2 script solved

#

!code

eternal falconBOT
rocky canyon
#

when green is true the return makes it skip the rest

#

if its false.. it skips the return and does the rest of the code

frail laurel
#

this script doesn't stop playing the audiosource

#

when the player isdead

wintry quarry
#
    public void SetWalking(bool _state)
    {
        if (isDead) // Check if the player is dead before playing the sound
        {
            return;
        }```
#

look at what your code does

frail laurel
#

dam

wintry quarry
#

it's not going to reach the part where it stops the audio source

frail laurel
#

it checks

wintry quarry
#

you probably only want to not start the sounds when dead

#

but still stop it

frail laurel
#

i want like when the player is dead the sound would stop working because now when the player is mowing the realistic sound of walking starts playing

wintry quarry
#

Something like

public void SetWalking(bool _state)
{

    if (_state && !audioSource.isPlaying && !isDead)
    {
        // Play the walk sound
        audioSource.PlayOneShot(walkSound, soundVolume);
    }
    else if (!_state)
    {
        // Stop the walk sound
        audioSource.Stop();
    }
}```
frail laurel
#

now it shows this menu but when i press w i still hear the sound of walkingπŸ€”

wintry quarry
#

Or perhaps just

public void SetWalking(bool _state)
{
    if (_state && !audioSource.isPlaying && !isDead)
    {
        // Play the walk sound
        audioSource.PlayOneShot(walkSound, soundVolume);
    }
    else
    {
        // Stop the walk sound
        audioSource.Stop();
    }
}```
#

but idk if this code is even running at all on the menu something is off

#

you should probably not even have the movement script enabled anymore when the player dies

devout oak
#

Hi, it's my first time making a post in this server so sorry if something is posted incorrectly. I am making an FPS game as a project but have ran into an issue that I am having trouble fixing. I am making a hover system where upon hovering, the GameObject is outlined (using an Outline script that I got from the Asset Store called QuickOutline) and when F is pressed, the GameObject is also destroyed. I'm trying to hover over a stationary gun GameObject with a raycast and it doesn't detect it.

Couple of things I have already tried:

  • assigning a Box Collider to both the GameObject and the model within it,
  • assigning the Weapon script to the GameObject,
  • tried using ChatGPT to add debugging logs and it said that the raycast detection was working perfectly but it wasn't detecting anything: No Weapon component found on hit object or its parent UnityEngine.Debug:Log (object) InteractionManager:Update () (at Assets/LowPolyFPSLite/Scripts/InteractionManager.cs:72)

https://hastebin.com/share/eyuqagizic.csharp <- InteractionManager
https://hastebin.com/share/kicozatemo.csharp <- Weapon
https://hastebin.com/share/nonusezoti.csharp <- WeaponManager

Apologies if this post is not formatted the best, thank you!

wintry quarry
#

I see you said you used CGPT to do it but...

#

You need to print which objecty your raycast his hitting

#

make sure you're hitting the expected object

#

note that it will be the actual collider object, so if that's a child of the gun, it's not going to have the other stuff directly for example

#

Debug.Log and print what you're hitting

devout oak
swift crag
#

well, it's time to get some experience (:

wintry quarry
#

Debugging is such an underlooked skill

devout oak
wintry quarry
devout oak
#

Yeah I don't really know how lmao

wintry quarry
#

Just print the name or something

#

for example

#
Debug.Log($"The name of the object we hit was {objectHitByRaycast.name}");```
#

but really... you are being pretty careless with some of this

#

There's a difference between hit.transform and hit.gameObject and hit.collider

#

those can be different objects

#

so.. start printing out what everything is

devout oak
# wintry quarry There's a difference between `hit.transform` and `hit.gameObject` and `hit.colli...

I was following a tutorial on YouTube for this because I'm not too experienced with Unity overall. I ran into this issue and just haven't really found any help with it online.

I debugged it the way you're detailing: https://hastebin.com/share/nenirohoqe.csharp

And it says that "Raycast hit: Box_01 (4)
UnityEngine.Debug:Log (object)
InteractionManager:Update () (at Assets/LowPolyFPSLite/Scripts/InteractionManager.cs:33)"

Box_01 is a box asset which the GameObject (the gun) is placed on so it seems like it's ignoring the GameObject completely.

wintry quarry
#

Your raycast is hitting the gun itself

icy sluice
#

hello, why AI refuses to pathfind when i build my project, but it does well in editor

wintry quarry
#

that's huge

#

And easily fixable

devout oak
#

Can you teach me how like I'm five years old lmao, I'm new to Unity sorry

wintry quarry
#

you can just use a layermask on the raycast.
Or perhaps rethink why your gun even has an active collider at this point in time in the first place

devout oak
#

I tried a layermask earlier because that's something that ChatGPT recommended me actually but it's already set to the default layer

wintry quarry
#

Yeah why

#

You need to use a mask that includes the interactable things but doesn't include other stuff like your gun

#

For this raycast we only want interactable stuff right?

devout oak
#

Yeah so I want the guns to be detected by the raycast to be hovered so the outline script works when hovered or to be picked up with a certain key

#

but not other stuff like the boxes

wintry quarry
#

the gun you're holding is certainly not something we want our raycast hitting

#

so either exclude it via a layermask, or turn its collider off entirely

devout oak
#

It's not being held. It's placed down stationary

wintry quarry
#

because again, why does the gun you're holding need a collider

#

oh it's not the one you're holding

devout oak
#

The gun isn't being held by the player

wintry quarry
#

ok but like

devout oak
#

It's placed down on a box

#

that's why the box is detected

wintry quarry
#

Oh it's a totally separate object

devout oak
#

yeah

wintry quarry
#

ok then yeah your gun either doesn't have a collider

#

or its collider is on a layer that's being ignored by your raycast

#

or your raycast isn't passing through it

devout oak
#

It definitely does have a collider

wintry quarry
#

show the full inspector

devout oak
#

I think it might be the raycast not passing through it. It detects the box but not the GameObject itself so I'm 100% certain that the raycast is working but the gun just isn't being detected for some reason

wintry quarry
#

ok and the inspector for the box?

devout oak
#

Wait I just noticed something, it said it hit Box_01 (4) but Box_01 (4) is over here.. the box under the gun is called Box_01 (8)

wintry quarry
devout oak
#

Yeah most likely

wintry quarry
#

Looks like you're using Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));

Where's your main camera located?

devout oak
#

MainCamera's located on the player body

#

Won't post the image for some reason

#

One second

wintry quarry
#

You sure that's the main camera?

devout oak
wintry quarry
#

nope it's not the main camera

devout oak
#

?_? How is it not

wintry quarry
#

the main camera will have the MainCamera tag

devout oak
#

Oh

wintry quarry
#

so you are firing your raycast from some completely different place

devout oak
#

I gave it the tag now

wintry quarry
#

well...

devout oak
#

Let me try again

wintry quarry
#

now you have two

devout oak
#

Oh

#

Hold on

wintry quarry
#

you should find the other camera that had the tag

devout oak
#

wtf

wintry quarry
#

(there could be more than one)

devout oak
#

all the cameras that came with the asset I installed had the maincamera tag on all the cameras and there were like 5

#

lmfao that is not something I bothered to check

wintry quarry
#

yep there's your problem

devout oak
#

Let me test it out now

wintry quarry
#

in the future a Debug.DrawRay with your raycast will also have revealed the issue

#

It would show that the ray is going in the completely wrong place

devout oak
#

Oh my god it works

#

Amazing

#

Yeah thank you, I never thought about that

#

As I said I'm new to Unity, I spent over like two hours stressing about this and couldn't fix it haha

#

Thank you

devout oak
#

I'd like to try it out before I get off

wintry quarry
#

the spot where you do the raycast of course

devout oak
#

"Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));"

#

Here then right

icy sluice
#

hello, why AI refuses to pathfind when i build my project, but it does well in editor

swift crag
#

A console will appear in the game to display them.

devout oak
icy sluice
# swift crag You should make a development build and see if you're getting errors

RuntimeNavMeshBuilder: Source mesh Plane.011 does not allow read access. This will work in playmode in the editor but not in player
UnityEngine.AI.NavMeshBuilder:BuildNavMeshData
couple of bilion theese

"GetRemainingDistance" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
and coupple of bilion theese

swift crag
icy sluice
#

yes

swift crag
#

if you're using the "Render Meshes" mode for NavMeshSurface, you'll need to enable Read/Write on the relevant mesh assets

icy sluice
#

thank you

final glade
#

Hello I have a question,
I have 3 scenes in my game, when I load a scene after the one prior is complete it just shows it without actually running the game or initiatializing anything, any recommendations?

#

I used SceneManagement.LoadScene

deft grail
final glade
#

It just shows it on game mode without running

#

Like I can’t even play

final glade
swift crag
#

show your code

final glade
#

!code

eternal falconBOT
final glade
#

It actually loads it but just shows it on game view without anything running

#

For more details these scenes are a copy I created (ctrl+d) with some changed varriables

swift crag
#

how do you know that nothing is running? do you have components with Awake/Start methods that aren't running?

#

(you'd add a log message to check this)

final glade
#

Never mind I fixed it

#

I am too dumb forgot to reset Time.timeScale back to 1

swift crag
#

ah, that'll do it

#

common problem!

sly peak
#

Hello, i am having an error from assets ive imported.
I was wondering if someone would be able to assist me in finding out whats causing it and how to fix it?

slender bridge
near wadi
frosty hound
#

Specifically, you have two namespaces that use MinAttribute and you need to specify which one you're using.

#

You can first see if you're even using both the ones specified by checking at the top of your script in the using. If it's greyed out, you can just delete it.

dull saffron
#

hi im fairly new to unity and im recreating watermelon game, does anyone know how to make it so the cloned fruits are deleted when the game over screen pops up?

timber tide
#

Destroy method

#

or just restart the scene

dull saffron
#

how do i do

#

destroy(gameObject) for all of them

wintry quarry
#

Put them in a list as you spawn them

#

Then iterate over the list to destroy them

dull saffron
#

array?

#

sorry i only use jsabs

#

java

wintry quarry
#

No a List

#

Java has lists too BTW

#

Unless you're talking about ArrayList

#

C#'s List is the same as Java's ArrayList basically

dull saffron
#

oh ok ill check that out tyy

final glade
#

Guys another quick question sorry, I have different levels (scenes) in my game. I want to set a var differently for each level through serialized field. The problem is it sets it the same for all levels I can’t have different values for it

wintry quarry
#

On a script? Which script?

final glade
#

It is attached to a prefab

wintry quarry
final glade
wintry quarry
#

Then you need to either put the prefab directly in the scene at edit time instead and edit the value there, or use another script which you put in the scene and set the field there, and have it communicate with the germ one

wintry quarry
#

On the actual instance in the scene

final glade
#

Like if I set it one it is the same for all the others

wintry quarry
#

Only if you are changing the actual prefab

#

But the one in the scene can have an override

rustic dagger
#

I need help someone please. I don't know why i'm getting errors for this, but I may just be stupid

wintry quarry
#

When it's configured you will see your errors underlined in red in the code editor itself

#

!ide

eternal falconBOT
rustic dagger
#

thanks!

wintry quarry
#

you will also get autocomplete etc

crude rampart
#

Good evening everyone

I am currently having an issue where I'm trying to split the player and launch it towards the mouse cursor
However the issue is that it doesn't seem to want to go towards the mouse and I can't seem to quite understand
Can anyione tell me if there are any issues with my code?

 void Split()
 {

     if (transform.localScale.x <= originalSize * splitFraction)
     {
         Debug.Log("Player too small to split");
         return;
     }

     // Reduce player's size by a tenth before splitting
     float newSize = transform.localScale.x * (1 - splitFraction);
     transform.localScale = new Vector3(newSize, newSize, 1f);

     // Create the detached part
     GameObject detachedPart = Instantiate(playerPartPrefab, transform.position, transform.rotation);
     float detachedPartSize = newSize * splitFraction;
     detachedPart.transform.localScale = new Vector3(detachedPartSize, detachedPartSize, 1f);

     // Launch the detached part towards the mouse cursor
     Rigidbody2D rb = detachedPart.GetComponent<Rigidbody2D>();
     if (rb != null)
     {
         //find mouse position
         Vector3 mousePos = Input.mousePosition;
         mousePos.z = Camera.main.nearClipPlane;
         Vector3 mousePosition = Camera.main.ScreenToWorldPoint(mousePos);
         //Sending it towards the mouse
         Vector2 launchDirection = (mousePosition - transform.position).normalized;
         rb.velocity = launchDirection * launchDistanceMultiplier * detachedPartSize * launchVelocity;
     }

     // Set the cooldown timer
     cooldownTimer = cooldownDuration;
 }```
crude rampart
#

I think its shooting opposite of the mouse actually when I take a closer look

wintry quarry
#

specifically all the stuff here:
rb.velocity = launchDirection * launchDistanceMultiplier * detachedPartSize * launchVelocity;

#

This seems maybe a little sketchy too: mousePos.z = Camera.main.nearClipPlane; You sure that's right? And is this an orthographic camera, or a perspective camera?

crude rampart
#

Perspective camera I'm pretty sure

#

yeah its perp

wintry quarry
#

Camera.main.nearClipPlane is almost definitely really small

#

With a perspective camera it's usually better to use Plane.Raycast instead

crude rampart
#

is there any particular reason?

wintry quarry
#

Yes because it lets you actually get the world position on the desired plane in the world you want

#

instead of hoping and praying like you do with ScreenToWorldPoint

#

with ScreenToWorldPoint you need to make sure the z distance is correct, and correlates to the plane in the world you're interested in

#

And see the bottom section about using Plane.Raycast instead which is better IMO

#

Almost always in these circumstances it makes more sense to specify a plane on which you want to project the mouse, rather than a distance

zenith python
#

How did you make your object face the mouse? I have been trying to do that for a while

zenith python
#

3d

wintry quarry
#

You do what we're discussing here to get a world space position

#

then you do myObject.transform.LookAt(mousePosition);

#

or you do transform.forward = directionTowardsTheMouse; which you'd calculate based on the mouse world space position

#

or transform.rotation = Quaternion.LookRotation(direction, desiredUp;

#

lots of options

radiant frigate
#

im searching how to measure the distance between 2 points, found vector2.distance but i cant manage to make it work, i need to know the distance in a line from point a to b in meters in both x and y dimensions, but every video that i find displays it only in the x dimension

zenith python
#

I just tried that and its rotating in multiple directions as well as not rotating a full 360

wintry quarry
#

it's literally the pythagorean theorem btw

radiant frigate
#

yes i know

polar acorn
wintry quarry
#

So what's the issue with it?

radiant frigate
#

and that straight line should be 1 single number that would be a float right?

wintry quarry
#

yes

#

That's what Distance returns

radiant frigate
#

i try to make a comparison with an if and it tells me that i cant do that

wintry quarry
#

show exactly the code you wrote

radiant frigate
#

omw

wintry quarry
#

and the error you got

#

sounds like you tried to compare a Vector2 with a float or something

radiant frigate
polar acorn
wintry quarry
#

What is that

#

distance = Vector2.Distance(a, b);

radiant frigate
#

I WROTE 2D πŸ’€

#

damn

wintry quarry
#

well you wrotre a lot more than that

#

you wrote new Vector2Distance

radiant frigate
#

yes

wintry quarry
#

which is just.... nonsense to be frank

polar acorn
#

Which would be a class named Vector2Distance, which you would have had to create

radiant frigate
#

whenever i create a var that is a vector i usually need to create a new vector to which i can later on make the var that i created compare or make equal to

wintry quarry
#

remember, first of all, that you're not creating a Vector2 here

#

you already have two vectors

#

and you're trying to create a float that is the distance between them

#

and we have a function that does that

#

so no need to construct anything with new

radiant frigate
#

im an ape bruh

#

i even looked at the docs and found nothing but 1 line and got scared

#

lmao

#

but it was a whole diff thing

#

ty guys!

zenith python
#

The mouse's x and y?

wintry quarry
misty coral
#

does OnCollisionEnter not get triggered if the rigidbody it is colliding with is kinematic?

#

I have a wall

wintry quarry
misty coral
#

huh

#

so they cant be kinematic?

wintry quarry
#

one can be

#

but you need one dynamic at least

#

otherwise there is no collision

zenith python
wintry quarry
zenith python
#

Yeah ive read that like twice now

wintry quarry
#

well I'm not sure how to help much further than that

zenith python
#

What is Plane.Raycast

#

If i try to put it anywhere it doesnt work

wintry quarry
misty coral
wintry quarry
#

direct physics queries

#

or write your own math

misty coral
#

😩

wintry quarry
#

is there a reason you need to not use Rigidbodies:?

#

maybe explain what your goal is

misty coral
#

ok so

#

I made a monster neck by making a bunch of spheres follow eachother

#

and the problem is

#

the neck goes through walls

#

so I want to use collision detection to make it not go through walls

#

but adding a rigidbody breaks the way the neck works

wintry quarry
#

well you either need to re-make it with dynamic Rigidbodies or you need to do your own Sphere/Circlecasting as you move the pieces of the neck to make sure they won't go inside stuff

#

Hence what I said about "direct physics queries"

misty coral
wintry quarry
#

Seems pretty obvious

misty coral
#

Huh?

wintry quarry
#

adding a realistic physics simulation fights with whatever your existing movement logic is

misty coral
#

Ok but I can just choose to disable gravity

#

even doing so it still has issues

#

My code is literally just a bunch of distance checks

#

so if sphere1 is too far from sphere2 it moves back

wintry quarry
#

simply disabling gravity doesn't take away from the fact that the physics simulation is fighting your code

#

your code is attempting to directly control the spheres.
The physics engine does the same thing.

Chaos ensues

#

you either need to work with it or bypass it.

flint python
#

Hello, in my code, I have .SetActive(false) for the child game object, is there a way to activate back the child object by activating its parent object?

wintry quarry
flint python
#

ok thanks

eager spindle
#

if this is a problem you're encountering, do you happen to use transform.GetChild?

#

or anything relating to getting/finding gameobjects

zenith python
eager spindle
zenith python
#

I cant seem to figure out a solution

wintry quarry
#

if you use a plane that is at the height with your object on the y axis, it will only rotate on the y axis

#

very simple to do that if you just use your object's position to build the plane

zenith python
#

I tried using my objects position but it doesnt work

wintry quarry
#

it works

#

maybe show your code

#

and your scene setup

#

and what you're trying to do

queen adder
#

guys i have spaghetti code 😩

misty coral
#

How does movePosition differe from MoveTowards

wintry quarry
#

MoveTowards is just a math function, it just calculates a position.

#

Rigidbody.MovePosition is teleportation with RIgidbodies that respects the interpolation settings

misty coral
#

so then the commented out line and the three lines below it are functionally the same right?

#

(because they are absolutely not working the same in engine)

wintry quarry
#

except for the * 1.15 bit

#

but also

#

it depends where this is running

#

if it's in FixedUpdate yes

#

if it's in Update then you're doing it wrong

#

because Rigidbody.MovePosition only can live in FixedUpdate

wintry quarry
#

And a third point - MovePosition doesn't really help you here

#

it doesn't respect collisions

misty coral
#

Well you said I need to change the way to neck works to use dynamic Rigidbodies

#

and after that I can worry about collision

wintry quarry
#

I said that was one option

#

and if you're doing that you'd have to deal with velocities or forces

radiant frigate
#

i remember doing this in my last project but i cant find anything that i manage to understand, how was it that i rotated something in the z axis at the moment of instantiating it ?

acoustic arch
#

can i check if a list contains a specific field on an element?

wintry quarry
#

You mean if any element of the list has a specific value for one of its fields?

acoustic arch
#

so my list contains items that are scriptable objects and it's checking if it contains a specific item/s within it

wintry quarry
#

bool containsItem = myList.Contains(someItem)

wintry quarry
zenith python
wintry quarry
eternal falconBOT
zenith python
#

Yes i would do that but the internet on my pc is broken

dull saffron
#

ive got a countdown script, but it starts when the game starts. is there a way to hide it and then have it appear and start at a certain point in the game?

wintry quarry
#

disable it

dull saffron
#

like the hide icon?

#

the chekc box

wintry quarry
#

no like the enabled checkbox

dull saffron
#

this one?

wintry quarry
#

that's to deactivate the GameObject

#

you could do that

dull saffron
#

that works yes

wintry quarry
#

or just disable the script itself

dull saffron
#

bbut how do i get it to be called at a certain point

#

and reaappear

wintry quarry
#

activate it

dull saffron
#

how do you activate it in code

dull saffron
#

oooo ill take a look

#

thanks

#

what does this mean?

wintry quarry
dull saffron
#

ohhh rn im calling it on the script

wintry quarry
#

well that doesn't make any sense

#

SetActive is a thing on GameObject

dull saffron
#

does it work on a textmp?

wintry quarry
#

GameObject

#

Only GameObject

dull saffron
#

ohh ok got it

wintry quarry
dull saffron
#

so if i simply put a tmp on a gameobject

#

i can use set active?

wintry quarry
#

THere's no way to have a TMP that is not attached to a GameObject

#

so I don't really understand the question

dull saffron
#

i want to make the countdowntext appear

wintry quarry
#

those are GameObjects

dull saffron
#

at a certain point

wintry quarry
#

Everything you see in the Hierarchy is a GameObject

dull saffron
#

but its a text

#

the countDownText is like a tmp

#

text

wintry quarry
#

TMP_Text is a COMPONENT

#

do you understand the difference between Components and GameObjects?

wintry quarry
#

GameObjects have components attached to them

#

When you select a GameObjectyou can see all its Components in the inspector.

#

these are components^