#💻┃code-beginner

1 messages · Page 282 of 1

flint heath
#

rb.velocity = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")) * moveSpeed * Time.deltaTime * 60;
So i made this top down movement line of code and noticed that it moves way too fast diagonally, I found on the documentation that to fix this i need to normalize it but when i add .normalized like in the following line it genuinely tweaks tf out idk how to explain. Any way I can normalize the vector without it having an aneurysm?
rb.velocity = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")).normalized * moveSpeed * Time.deltaTime * 60;

static bay
#

rb.velocity handles that for you.

flint heath
#

it still acts weird as though

static bay
#

Same with the 60, idk why you need to multiply it by some random number.

flint heath
#

if i remove both of those and its just ... .normalized * movespeed;

#

it still freaks out

static bay
#

yep

#

the freakout has to be from elsewhere, because that line looks fine

flint heath
static bay
#

well how is it "freaking out"?

flint heath
#

the movement acts really weird when it's normalized, if i tap any movement key and immediately let go, it will keep going for an extra half second

#

and the movement is overall just super jerky and unresponsive

static bay
#

Oh I see.

flint heath
#

but is completely fine when not normalized

static bay
#

Do you know what normalizing does?

flint heath
#

im not exactly sure no

#

its like something to do with the radius of a circle around you or smth

slender nymph
static bay
flint heath
flint heath
static bay
slender nymph
static bay
#

This will prevent the length of the vector from exceeding a value of 1.

#

So you won't speed up on diagonals.

flint heath
#

oh i see

static bay
#

Also, do you know why it's speeding up on the diagonal?

flint heath
#

because moving up 1 and to the side one

#

so 1.41 units

#

ish

static bay
#

Yep, exactly.

flint heath
#

wait how is clampmagnitude different from normalize?

static bay
#

Normalize forces the length to 1, this includes smaller values.

slender nymph
#

because it allows the magnitude to be lower than 1

static bay
#

ClampMagnitude "clamps" it to some specified value. Aka it will not exceed the value, but can be smaller.

flint heath
#

oh that makes sense

static bay
#

So what was happening was Unity trying to smooth out your value, slowly increasing it to 1 (full speed) as you held the button, and slowly decreasing it back to 0 after you let go.

#

Normalize forced all those smaller intermediate values back to 1.

#

And only gave 0 when the input was literally giving 0.

#

Which caused that "unresponsiveness".

flint heath
#

that actually makes a lot of sense

#

aight rate the new smoothing i added

#

not sure what the f means but i saw people typing it after numbers in videos in the past and so it wasnt working at first so i typed an f and it worked 🔥

static bay
slender nymph
flint heath
#

I've tried to search to understand some of the things I have seen in the past like the f that people sometimes type after numbers and what a vector is (point? line?) but honestly the unity documentation isn't very easy to understand

#

so yea some c# courses could be helpful

static bay
#

Do you know what a float is?

flint heath
static bay
#

Ya. It stands for a floating point number.

flint heath
#

from what ive gathered

static bay
#

It represents "real" numbers. Aka everything with decimal places.

flint heath
#

ok sick, why isnt every number always automatically parsed as a float then? why do we have to do it manually?

static bay
#

Vectors are more of a math concept. They're "lines" composed of a magnitude and a direction.

#

You can do an absolute shit ton with them.

eternal needle
static bay
#

How floats do what they do is kinda complicated.

#

Just know that the default is integers, which are whole numbers.

#

You use them for counting things and math.

#

Floats represent all the real numbers. You use them for math and more math.

flint heath
#

🤣

#

good to know

#

is there any c# documentation that contains examples for most things? I've used documentations with examples before and they made it a lot easier to understand how certain scripts can be used and to learn languages as a whole

charred spoke
vale karma
#

how would i go about having a selection of buttons all going to different scenes, kind of like a game selection menu.

charred spoke
#

Do you know how to make a single button do something ?

vale karma
#

i looked at that but didnt know how to use it exactly

#

and yea, but i dont want to code 32 different buttons on one screen

rich adder
#

run a for loop and instantiate the buttons / thumbnail objects in the grid layoutgroup

vale karma
#

okay

rich adder
#

make a prefab for one should look like / button component on it. then from there have a script linked to all the componets to change like icons

vale karma
#

i wanted to use grids for a Supermarket simulator but for a PC repair shop, and ran into issues using grids so i gave up i suck

#

ive realized even though i have the power of god and anime on my side, I cant find it progressive to sit and stare at a big project forever and get discouraged. So i asked chatgpt to come up with a list of 32 games from easy to hard to make for beginners. I plan on putting it all together and refining it into a lil pack 😛

vale karma
jaunty condor
#

HI. I can't do a certain thing in my game. when I hit an object, it deactivates and reactivates another cube. These cubes have a specific tag. How do I tell to activate cube for example 1, after hitting cube 0, and then for example when I hit cube 1, it deactivates and activates cube 2. I tried searching on google, but I can't find anything :(

eternal needle
jaunty condor
jaunty condor
vale karma
#

oooo i did ittt i feel smart 😮

eternal needle
eternal needle
jaunty condor
#

okk, i try, thx

vale karma
#

How would i be able to make the grid usable after instantiating prefabs? I cant exactly use the scripts on the buttons and match them with scenes i think

#

i dont have any access to it until runtime

vale karma
#

I got the grid layout working, it instantiates the button w/ image on the correct spot. But how would I get it to do anything at runtime if i cant reference it before runtime?

eternal needle
vale karma
#

whos listenin?

static bay
#

Buttons have an OnClick unity event.

#

You can add a callback through code.

vale karma
#

how would i reference the script to it tho

static bay
#

Reference what script?

hoary ice
#
while (true)
            {
                // Go to the throne location with offset
                agent.SetDestination(throne.transform.position);

                // Wait for 3 seconds at the throne location
                yield return new WaitForSeconds(3f);

                // Go back to the work location with offset
                agent.SetDestination(workLocation);

                // Wait for 3 seconds at the work location
                yield return new WaitForSeconds(3f);
            }

this loops for like only 3 times then they will get somewhat stucked in the position

vale karma
#

im realizing i can just put the script on the object. im dumb

hoary ice
#

they do like this

slender nymph
#

you're probably starting a whole bunch of those coroutines

static bay
hoary ice
static bay
#

You could also just directly add a listener to the buttons "OnClick" unity event, and just specify what scene to transition to. Something something anonymous methods.

slender nymph
hoary ice
slender nymph
#

!code

eternal falconBOT
hoary ice
#

its long it became like that

slender nymph
#

if only there were specific instructions for posting large code blocks. since you don't know how to read, i guess we'll never know if that is the case

slender nymph
hoary ice
#

it automatically creates a text file

slender nymph
silver girder
#

hello

#

i am a beginner

#

i am looking forward to introduce myself and meet all the fellow members and experience how the creation team works !

vale karma
static bay
#

that's fine

vale karma
#

like now i have a method to loadbysceneindex... but how do I give a number to the scenes at runtime, or do they need to be given at runtime?

languid spire
vale karma
#

how would i reference the number? would i drag it on a reference i make myelf? or is it a method built in to unity already?

#

unless i need to make a dictionary or soemting

vale karma
#

thankyou, trying chatgpt seems to do more harm than good

languid spire
#

no surprise there

vale karma
#

haha i think the only good thing it did was build a controller that used character controller and 3d pov

#

i think 5 minutes faster debuging it than making it myself

#

is it better to loadscenemode.single or additive most the time?

languid spire
barren vapor
vale karma
#

yea it basically makes stuff up. Right now im finding a problem with referencing the scenebuild number. I made a build and have the button code written and ready to go, but like... how XD i think im just blind

#
    public void LoadBySceneIndex(int index)
    {
        SceneManager.LoadScene();
    }

im stuck at what to code to for the value index

vale karma
#

ookay okay were getin somewhere

languid spire
#

man, your first action should be to RTFM

vale karma
#

lol yea i start there, but get confused fast. Theres alot more there than i need but i dont know exactly what im lookin for. So it takes a while

honest haven
#
        money.text = GetComponent<CoinUI>().amount.text;``` is one faster then the other? trying to work out the difference
iron hull
languid spire
iron hull
#

adding onto the above statement its efficient because you dont want to be going GetComponent<>() calls every update if you can avoid it ok

honest haven
#

The reason i ask is becuase its a DDOL and when i load the scene the field says missing, yet the clone Coin UI is there. Could it be a who loaded first issue?

#

are DDOL loaded before normal gameobjects?

iron hull
#

you can try using SceneManager.sceneLoaded to test? hmjj

languid spire
#

tbh the code makes no sense as the component seems to be in the same gameobject so why would it need a singleton instance reference in the first place?

honest haven
#

im calling it on my battle manager its its own UI, and CoinUI is its own UI

#

need to get a ref to the amount

languid spire
#

then your GetComponent call is nonsense

honest haven
#

yh im using sington, is that also wrong?

iron hull
#

they're saying the second line is redundant if you use the first line

languid spire
#

if CoinUI is DDOL and a singleton, no

honest haven
#

yh, but the singleton amount is missing

languid spire
#

impossible

#

ah, is the TMP also DDOL?

iron hull
honest haven
#

yh its part of ddol

#

it sits in the ui

languid spire
#

should not lose the reference then

honest haven
#

battle manager is not a ddol

#

but coin ui is

languid spire
#

what is battle manager? where this code is being executed?

honest haven
#

yes, want me to make a quick video?

languid spire
#

no

#

if Money is correct when you ddol CoinUI and the TMP referenced is also DDOl then there should be no problems

iron hull
#

also to clarify , your UI itself is ddol ?

#

or just the singleton

honest haven
iron hull
#

In battlemanager on its start/awake are you referencing money = CoinUI.instance.money?

#

or smth like that

honest haven
#

yh

#

money.text = CoinUI.instance.amount.text;

#

hang on i am setting the .text should i be setting the gameobject?

iron hull
#

I mean either work but you only want text in this case so text is fine i'd assume

honest haven
#

yh so im thinking maybe its a load issue? maybe battlemanager is being loaded before the DDOL?

#

but would that not throw a null ref error or somthing

silver girder
#

is it possible to convert 1st person camera to 3rd person camera?

iron hull
silver girder
#

and btw to add sfx do i need to create a file named ''sfx'' and add audio source?

#

because i am a beginner im trying to learn and help

iron hull
silver girder
#

i am currently trying to make a soccer / football game but i am lost

iron hull
#

so sfx is good start NODDERS

silver girder
#

thx i am literally looking up for tutorials but cant seem to find any soccer game tutorials 😦

iron hull
#

you can look up tutorials for things you need rather than a game specifically and stitch it all together happ

honest haven
#

ok i fixed it

#
    {
        //Singleton method
        if (instance == null) {
            //First run, set the instance
            instance = this;
            DontDestroyOnLoad(gameObject);
 
        } else if (instance != this) {
            //Instance is not the same as the one we have, destroy old one, and reset to newest one
            Destroy(instance.gameObject);
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
    }``` i added this
#
    {
        if (instance == null)
        {
            instance = this;
            
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            if (instance != this)
            {
                Destroy(gameObject);
            }
        }
    }
``` instead of this
#

but i dont no why that would work

languid spire
#

the comment even tells you this
//Instance is not the same as the one we have, destroy old one, and reset to newest one

honest haven
#

but why would the instance not be the same

#

is what i mean

languid spire
#

because it is coming from the newly loaded scene

honest haven
#

ok so even tho its a ddol on a new scene it creates a clone, would that then mean its a new instance?

languid spire
#

yes, of course

honest haven
#

ok i understand now thanks steve

languid spire
#

question is why do you have the same object on multiple scenes if you are going to ddol it?

honest haven
#

Well i wanted to carry the amount over to a new scene

#

i.e the coin u

languid spire
#

that makes no sense

#

the ddol object will exist for ALL scenes, so no need to duplicate it per scene

ebon robin
#

So I reworked the FSM code, states no longer reference StateMachine. The StateMachine now checks transition by using a Func<bool>, but uhh it's got lot more spaghetti than I thought. Could someone check for me if this feels right?
https://gdl.space/ecurofotiw.cs

honest haven
languid spire
# honest haven Can you explain a bit more, where you think my mistake is so i can understand. I...

this

 private void Awake()
    {
        if (instance == null)
        {
            instance = this;
            
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            if (instance != this)
            {
                Destroy(gameObject);
            }
        }
    }

is what you need in one scene, nothing more
I am assuming this is on your CoinUI class
because instance is static it can be referenced from anywhere without an additional reference
CoinUI.instance gives you all you need
the only thing you need is to make sure that the only things that the instance references are also DDOL

silver girder
#

guys please can you tell me how to make a soccer game cuz i am new 😦

rare basin
#

Did you try to Google it lol

#

There is plenty of possible ways to make a soccer game

#

And define soccer game

languid spire
ebon robin
#

why do my setting up transitions takes like 40 lines

#

does anyone have a better way of setting up transitions for statemachine

languid spire
silver girder
rare basin
#

Any server won't tell you how to make a soccer game

silver girder
rare basin
#

Then Google it

#

Learn yourself

#

Step by step lol

eternal falconBOT
#

:teacher: Unity Learn ↗

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

silver girder
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

iron hull
silver girder
iron hull
#

try starting out by adding force to a rigidbody happ

near wadi
#

all the concepts are covered on the learning site i linked. best to spend some time there

silver girder
#

and i am

#

i just have problem with cloth too

charred heart
#

What happened when two scripts attached to a game object implement OncollisionEnter? UnityChanHuh

iron hull
#

whatever you tell them to do

#

when two colliders hit each other, any objects with a script containing oncollisionenter will be triggered

#

bearing in mind that there also is OnCollisionEnter2D as well Prayge

silver girder
#

is there a collaboration system in unity where you create games with another one?

wintry quarry
silver girder
round tulip
silver girder
#

i have a problem with cloth i dont understand its given properties

round tulip
round tulip
silver girder
#

i think handball would be way easier

rare basin
#

Just start learning finally instead of spamming the channel with such generic questions

sullen canyon
#

Hi everyone, is this the correct way to use lock statement in C#? My game has multiple threads accessing the Inventory simultaneously. Thanks

wintry quarry
#

because you're just locking around accessing the list reference. But once the caller has a reference to the list you have no control over when or where they access it or modify it

#

My game has multiple threads accessing the Inventory simultaneously
I question the motivation of this

tall delta
# sullen canyon Hi everyone, is this the correct way to use lock statement in C#? My game has mu...

"multiple threads accessing the Inventory simultaneously" I have no idea why on earth you'd want to do this. but I'd recommend using the built-in concurrent collections.
https://learn.microsoft.com/en-us/dotnet/standard/collections/thread-safe/

sullen canyon
#

I want everyone in a guild to be able to access the guild's inventory at the same time, I want to learn how to synchronize atwhatcost

#

I still don't know if what I'm doing is really right

tall delta
shell matrix
#

I have a question. Can I see the base layer as an Eulerian graph?

rare basin
#

Did you try to Google it first? lol

shell matrix
#

I can't find anything on google about it

#

that's why I asked here -_-

rare basin
#

Anyway this is a code related channel

ornate lynx
#

hi, is there a built-in function that detects the number of keys being pressed at once?

wintry quarry
ornate lynx
#

no like....at least two keys?

keen dew
#

That seems like a strange requirement. What are you planning to use it for?

ornate lynx
#

unity struggles to run an animation when the player is walking diagonally so i thought instead of detecting every two keys which would result in 4 if statements, i would detect if two keys are being pressed, if one of them is the up arrow key, i'd run the animation of going up, if it's the down arrow key, i'd run the animation of going down

keen dew
#

You can do that in 2 if statements

ornate lynx
#

well

#

that is if i detect if 2 keys are pressed

keen dew
#

I also don't get why you need to check if other keys are pressed, just check if up key is pressed -> always play the up animation, if down key is pressed -> always play the down animation

ornate lynx
#

yeah but i have other if statements for when only the right or left key is pressed

keen dew
#

Why is that a problem?

ornate lynx
#

because now unity tries to play both animations

#

going vetically and horizontally

keen dew
#

Only because you tell it to do that

rich bluff
ornate lynx
#

yeah

ornate lynx
rich bluff
#

you tried using blend trees? i dont know how well they work with 2d but in 3d all you need is to provide the direction vector in the form of 2 float params to a blend tree

ornate lynx
#

well no, idk how to use them

keen dew
ornate lynx
#

but hold on i think i might have a fix

rich bluff
#

just right click in AnimatorController and create a blend tree and check it out

ornate lynx
#

sounds fun

ornate lynx
vast vessel
#

why is Destroy(); not running?

#

as you see in the second image, i am invoking the action, which is Destroy();

rich bluff
#

any errors?

vast vessel
#

nope

honest haven
#
         Transform position2Transform2 = GetEnemyAtOriginalPos2();

         if (position2Transform2 != null)
         {
             Debug.DrawLine(playerTransform2.position, position2Transform2.position, Color.red);
             
             Debug.DrawRay(playerTransform2.position, playerTransform2.forward * 5, Color.blue);
         }
         foreach (var battlers in activeBattlers)
         {
             Transform enemyTransform = battlers.transform;
             
             Vector3 directionToPosition2 =  activeBattlers[0].transform.position - enemyTransform.position;
             directionToPosition2.y = 0;
             
             Quaternion lookRotation = Quaternion.LookRotation(directionToPosition2);
             
             enemyTransform.rotation = Quaternion.Slerp(enemyTransform.rotation, lookRotation, Time.deltaTime * 5f);
         }
         
         if (activeBattlers.Count > 0 && activeBattlers[0].isPlayer)
         {
             Transform playerTransform = activeBattlers[0].transform;
             
             Transform position2Transform = GetEnemyAtOriginalPos2();
             
             if (position2Transform != null)
             {
                 Vector3 directionToPosition2 = position2Transform.position - playerTransform.position;
                 directionToPosition2.y = 0;
                 
                 Quaternion lookRotation = Quaternion.LookRotation(directionToPosition2);
                 
                 playerTransform.rotation = Quaternion.Slerp(playerTransform.rotation, lookRotation, Time.deltaTime * 5f);
             }
         }``` im trying to make my player face the npc at pos2 but it seems to be off by nearly 50deg
rich bluff
#

you ran the debugger and the line is hit?

vast vessel
tawny hedge
#

hope this is okay to post/ask: is there a way to change the font/material face color slowly and fade between each colour or just cycle through the rainbow, similar to the video?

vast vessel
rich bluff
#

and when you step into what happens?

vast vessel
#

wdym "step into"?

rich bluff
#

debugger step into button/hotkey

#

F11 i think by default

vast vessel
#

when i press the button, the yellow marker moves to the next line

rich bluff
#

look into destroy object, maybe something like invocation target is null or something else

#

this can be some closure/uobject related fuckery, i dont know

vast vessel
#

the flechette value, is not null

cosmic dagger
rich bluff
#

your delegate type is Action<T> but you pass Action<void>

vast vessel
#

well what do i do?

#

never used actions before

rich bluff
#

i just dont know how it even compiles, but in case when you need to match signatures you can wrap it into a lambda

#

DirectHit(..., x => { Destroy(); }, ..)

vast vessel
rich bluff
#

nono thats just your DirectHit

#

you pass it, as a lambda that already matches the signature of Action<T>

#

x is the argument

#

you just dont use it inside the lambda, since Destroy() has no params

vast vessel
#

dude i dont get itnotlikethis

rich bluff
#

what exactly?

#

i also dont get how it allows you to pass in an Action, when the signature has Action<T>

vast vessel
rich bluff
#

just try the x => { Destroy(); } instead of Destroy

#

if it works ill explain what you dont understand

vast vessel
#

like this? config.DirectHit(this,rb, x => { Destroy(); }, collision);

rich bluff
#

yes

vast vessel
#

it works!

rich bluff
#

ok, can you change destroy to Destroy(Hunter_Fletchette x) ?

vast vessel
#

why not

rich bluff
#

in terms of your architecture

#

because you may want unified Destroy() across all your classes

#

otherwise each will require random bits of params

vast vessel
#

this is just for object pooling, and its only used in this class

rich bluff
#

now you can just pass it without the lambda

#

as it was before

vast vessel
#

right, so before it didnt take any perams, but now it takes x of type Hunter_Fletchette, which the action passes that x onto the method. correct?

rich bluff
#

someone more up to date may explain why compiler allowed you to pass in a delegate with signature mismatch

rich bluff
#

actually not .net just old c# version

#

i cant find anything on the topic, cant come up with good search terms, but my guess is, if it is a feature in new c# and not a bug, it may try to generate a delegate that matches the sig under the hood, and because unity doesnt fully support all new c# features it may fail at that

queen adder
#

when I jump beneath the coin, my player touches it and falls down, I want my player to jump equally at all times. 2D game

tawny hedge
#

it is a textmeshpro

#

but im trying to change the face - color of the font material if possible, the material font is only attached to one text object

scarlet skiff
#

any tips?

silver girder
thorn holly
#

Can you also send a screen recording of what’s happening?

thorn holly
#

Yes

silver girder
#

okay

thorn holly
#

Why are you calling me? Send a screen recording in here of what’s happening.

#

@silver girder

silver girder
#

i cant send screen recording

#

i can screenshare tho

thorn holly
#

…why can’t you send a screen recording

silver girder
#

i dont have a recording app

thorn holly
#

And nothing personal, but I’d rather not hop on a call with someone I don’t know

thorn holly
silver girder
#

okay i will download it and send

thorn holly
#

And post your code correctly

barren loom
silver girder
#

idk

thorn holly
#

People on mobile can’t see txt files in discord

silver girder
#

YE YE

#

it works

thorn holly
#

Cool

barren loom
thorn holly
#

Fr

#

Might as well come pre installed at this point

silver girder
#

the file is too large

swift crag
#

!code

eternal falconBOT
swift crag
#

follow the instructions.

grizzled zealot
#

Is there a standard pattern for automatically unsubscribing from all Actions in OnDestroy() ?

silver girder
#

i will upload the vid

swift crag
#

for input system callbacks, I'll make a Dictionary<InputAction, System.Action<InputAction.CallbackContext>> so that I can iterate over it to subscribe and unsubscribe, at least

queen adder
#
Instantiate(bullet, SpawnLocation, Quaternion.identity);
``` When I do this it starts infintely spawning bullets, I want it to spawn only once. 2d game
grizzled zealot
swift crag
#

is it maximally efficient? no, but i'll survive

#

I do want to figure out a way to detect when I forget to unsubscribe from events

thorn holly
swift crag
#

other than just changing scenes and destroying objects and seeing if an error falls out

sonic dome
#

how do i use vector3.rotate towards for lets say i press A and i want it to rotate left?

silver girder
#

and go to 1:44

wintry quarry
#

And over what time period?

sonic dome
wintry quarry
#

That's pretty vague

sonic dome
thorn holly
wintry quarry
sonic dome
wintry quarry
#

No idk what a "game rotation" is

sonic dome
sonic dome
#

lets say 90

wintry quarry
#

Transform.Rotate lets you specify how many degrees to rotate

silver girder
wintry quarry
#

RotateTowards rotates towards a certain rotation. Not necessarily a certain amount

sullen epoch
#

Hello There. I have an enemy prefab that requires the player & cameras transform transform. however every time I move it into my scene I have to reassign the players transform to the script, what's the best way to automate this?

my thoughts on this is to create an empty game object and create a script containing public variables for all my references so instead of assigning the variable directly to my enemy controller script I could replace it with something like "Refernces.playerTransform"

silver girder
sonic dome
wintry quarry
hazy crypt
wintry quarry
#

Words? A video?

#

An explanation?

sonic dome
#

let me try with transform.rotate(0,0,20f)

#

then ill try

thorn holly
#

Not like that. Delete that and use one of these !code

eternal falconBOT
hazy crypt
#

YO WTF LMAO

silver girder
sonic dome
hazy crypt
#

heres what ive used before

hazy crypt
#

You can also make the players transform a public static set of vales and then reference them from another script

thorn holly
# silver girder like the large code blocks?

Yes, that is definitely a large code block. Let’s start from the beginning. Delete that giant block of code you posted. Put your question, the recording, and both scripts in one message.

thorn holly
#

What don’t you understand?

silver girder
thorn holly
#

First step, delete this.

silver girder
#

okay

#

deleted

#

2nd step?

thorn holly
#

It’s still here.

#

Delete the message in which you sent the scripts

silver girder
#

i deleted it from unity studio

wintry quarry
thorn holly
sonic dome
wintry quarry
#
Vector3 rotationPerSecond = new Vector3(0, 50, 0); // 50 degrees per second
transform.Rotate(rotationPerSecond * Time.deltaTime);```
@sonic dome
silver girder
thorn holly
#

Alright, put the scripts back into unity studio. Use this message to copy and paste into a new script file as needed.

silver girder
#

all scripts except Target script are there

#

@thorn holly

thorn holly
silver girder
thorn holly
#

Can you recover it?

silver girder
thorn holly
#

Okay, so everything is how it was originally?

silver girder
thorn holly
#

Next step: delete this message.

silver girder
#

deleted it

thorn holly
#

Next step: make a message that looks like this.

(Question here)
(YouTube video link)
(Script one name): (script one link)
(Script two name): (script two link)

#

Use one of these links to post your code !code

eternal falconBOT
silver girder
#

Why does the ball get anchored when i add scripts to their places while the ball has physics ?
Youtube Link: https://www.youtube.com/watch?v=2zy8WWU48Xs
Target Script : https://hastebin.com/share/osoqebokor.csharp
Equipt Script : https://hastebin.com/share/igobekeqos.csharp

#

@thorn holly

thorn holly
thorn holly
#

Good job. I know that was tedious, but it’s important to format your question correctly. Now we can figure out what’s going on

silver girder
thorn holly
silver girder
#

no i dont

thorn holly
#

Basically, that makes it not use physics. Something that is kinematic can only be moved explicitly through script, not with the physics engine

#

Is this code from a tutorial or chat gpt or something or did you make it yourself?

silver girder
thorn holly
#

No

silver girder
thorn holly
#

Do you know basic c#?

silver girder
thorn holly
#

You should definitely learn the basics of c# before using unity

thorn holly
#

Well, I mean, you have to be able to make your own code if you want to develop.

#

I reccomend using codecademy to learn c#, but there are many online tutorials you can use

#

After you learn c#, learn the basics of unity here : !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

thorn holly
#

Then you’re ready to start developing

thorn holly
#

So to be able to make your own code, you have to learn c#

silver girder
thorn holly
#

? Do you mean how long does it take?

silver girder
thorn holly
#

You can’t really quantify that, it varies a lot between what tutorial you’re using and from person to person. Codecademy estimated their tutorial takes about 20 hours.

silver girder
#

20 HOURS JUST TO LEARN??????!!!!!!

frosty hound
#

Don't be so dramatic

#

It takes longer "just to learn". Have you never spent time learning a new skill before?

sullen epoch
frosty hound
#

Then you should be smart enough to know it takes time to get anywhere.

thorn holly
thorn holly
thorn holly
silver girder
#

oh yea figured it out

thorn holly
frigid sequoia
#

I literally just did a couple of simple tasks in Java and CSS on a course and then jumped to Unity Learn and finished the Code part in like 2 weeks?
Now I don't know many, many things, but I feel kinda confortable coding

thorn holly
#

Cool

frigid sequoia
#

So it is not really hard, just takes some getting use to it, like everything

silver girder
#

wetnoodle11 and all members who helped god bless you guys

thorn holly
#

Of course! We’re here to help.

silver girder
#

yooo

#

created something in c#

#

just by learning WOOO

sullen epoch
#

anyone able to provide feedback on this?

if I cache the results like so

    void Awake()
    {
        rb = GetComponent<Rigidbody>();
        healthBar = GetComponentInChildren<HealthBar>();
        player = GameObject.FindGameObjectWithTag("Player");
        playerTransform = player.transform;
    }

will it negate the performance cost of using FindGameObjectWithTag? I intend to have a large amount of enemies.

very much appreciated as always.

#

i'll happily provide additional context if need be

wintry quarry
hazy crypt
sullen epoch
#

Brilliant, Thank you both

silver girder
#

waa the codeacademy is paid

#

i will take a break

sleek orchid
#

Hello! My Intelisense seems not to be working anymore, any hints?

I've tried to Regenerate Project Files

#

Okay... it is working now?

frail star
#

Does anyone know how to fix an android app icon?

#

Can't seem to get it to fill the icon space , google keeps adding the white boarder

#

I have resized the image to be 512x512 and I Have shrunk the icon to fit the subject matter in a 344x344 interior dimensions with a boarder fill

queen adder
#
Instantiate(bullet, SpawnLocation, Quaternion.identity);
``` When I do this it starts infintely spawning bullets, I want it to spawn only once. 2d game
timber tide
#

perhaps show more than a single line of code

queen adder
#

theres nothing else

#

except spawnlocation vector2 and public gameobject bullet

#

I dont have a problem in code I just do not know how to do it

swift crag
#

you can't just slap one line of code into a script file and have it work

#

share the entire script.

queen adder
#
public class bulletSpawn : MonoBehaviour
{
    public GameObject bullet;
    public Vector2 SpawnLocation;
    

    void Update()
    {
        spawnbullet();
    }



    void spawnbullet()
    {
        if (Input.GetKey(KeyCode.Space) == true)
        {
            Instantiate(bullet, SpawnLocation, Quaternion.identity);
        }
    }
}
queen adder
#

i KNOW the difference

swift crag
#

Then you know how to solve the problem.

charred heart
#

I have a class with two modes, and this class will switch between them. What is an effective way to implement "mode"?

For example, if I use the flags Mode1 and Mode2, I'll check to see if Mode1 or Mode2 return true before proceeding with any logic.
Another example is use polymorphism. But it's only have 2 modes. Is it worth it?

crimson sinew
charred heart
# crimson sinew What exactly changes between modes?

My NPC system have 2 type of behavior. 1 behavior is following preprepared data (i named it PathAction), 1 behavior is following state machine. 
They first running around the scene using PathAction. If player or the environment impact them, they may switch to the statemachine.

crimson sinew
silver girder
#

how do you make a shooting ball cuz i have no idea 😦

silver girder
#

not that

#

its okay if you didnt understand

#

what i want is like handball shooting

summer stump
scarlet skiff
#

any tips?

silver girder
#

basicaly throwing

cosmic quail
silver girder
#

no

#

pc

cosmic quail
#

then its the same isnt it

sonic dome
#
        if(Input.GetMouseButtonDown(0))  <--- this is in update
        {
            if(!attack1)
            {
                anim.SetTrigger("attack1");
                attack1 = true;
                StartCoroutine(combo());
            }
            if(attack1)
            {
                anim.SetTrigger("attack2");
            }
        }
    }

    IEnumerator combo()
    {
        yield return new WaitForSeconds(10f);
        attack1=false;
    }

why is it that both the attack animations r being triggerd one the 1st press?

silver girder
#

idk

summer stump
silver girder
silver girder
cosmic quail
# silver girder idk

just shoot it with less force i guess, then it goes from being like a bullet to being like a thrown ball right?

summer stump
languid spire
cosmic quail
# silver girder can you send me a tutorial of handball shooting i am really lost

but if u google ball throwing tutorial then you will find that too https://www.youtube.com/watch?v=ZonVUxvZiwE

This video will show you how to make a Ball Throwing Game with Unity. Throwing objects or hitting cans. Games like that can be done with this script.
Explanation Video: https://youtu.be/fljP8zJ75Lk
Ball Thrower: https://pastebin.com/ScXTY011
Ball Script: https://pastebin.com/2JPEYMiw
Learn Python: https://www.udemy.com/course/python-for-complete...

▶ Play video
silver girder
#

with character tho

sonic dome
silver girder
#

capsule that throws ball

#

like handball passing

summer stump
summer stump
#

Combine those

#

Bam

cosmic quail
# silver girder like i cant find them

Build your own Unity games HERE: https://academy.zenva.com/product/unity-game-development-mini-degree/?utm_campaign=youtube_description&utm_medium=youtube&utm_content=youtube_2017_unitybasketball4

Interested in learning Unity game development? This course will teach you how to create a simple basketball shooting game. The main goal of this trai...

▶ Play video
silver girder
round tulip
#

I have this problem where if I move my player it jitters. I am using a cinemachine/pixel perfect camera. The sprite is (supposed to be) 32 units with point filter and no compression. I think the problem is because of the camera movement, but I dont know. Can someone help me with this?

vapid mesa
#

hi, i try to make animation systeme but it did'nt work, the parameter don't change i think is the link between the 2 scripts

lost anvil
vapid mesa
swift crag
# vapid mesa

You have not serialized FpsController, so you can't assign it in the inspector, and nothing in your code assigns anything to FpsController

vapid mesa
#

fps controller is from this script

#

and before my animation script was in my FPScontroller script

swift crag
# vapid mesa

yes, and you need to tell Animation how to find the FPSController

#

adding [SerializeField] to the field will make it appear in the inspector

#

then you can drag a reference in

vapid mesa
#

okay i see

#

thks

#

it work

languid spire
lost anvil
#

what do you want

languid spire
#

what do you think?
A screen shot of the error
A screenshot of the object involved
The normal stuff

lost anvil
#

i think this, theres no object

summer stump
#

And he wants a screenshot of the object involved too

languid spire
#

He always does this, drip feeds information

frigid sequoia
#

Guys my light ran out while compiling yesterday, now I get all these errors and I have no idea what any of them mean

languid spire
queen adder
#

I made rigidbody2d and wrote script for bullet to move, in editor I attached the script to my player, and in the rigidbody2d field I dragged my bullet gameobject. And the bullet wont move, however if I make new script and attach it to the bullet gameobject in editor it works. Does that mean it is not possible to move any other gameobject than the one script is attached to?

lost anvil
summer stump
lost anvil
languid spire
lost anvil
#

i dont know what else you would want

#

no

summer stump
lost anvil
#

lol what do you want selected

#

what the 2 scripts are attached to?

languid spire
#

Stamina Controller is in a different namespace

silver girder
#

how to fix the "Can't add script component 'BasicEnemyDone' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match."?

lost anvil
#

okay so how do i put it into the same one? via namespace blahblah at the top of stamina script?

silver girder
lost anvil
#

ive got one mate im fixing it

silver girder
#

ah

#

alr

#

how to fix the "Can't add script component 'BasicEnemyDone' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match."?

lost anvil
languid spire
#

no

lost anvil
#

how would i go about doing that

summer stump
silver girder
#

yes

summer stump
languid spire
silver girder
#

the class name match the file etc

summer stump
#

What is the issue?

silver girder
#

the rename thingy

summer stump
silver girder
#

i did

silver girder
#

but still doesnt work

languid spire
# lost anvil this?

ok it doesnt, so you can just put your Stamina Controller into the same namespace as the char controller

silver girder
#

is there a solution??

summer stump
summer stump
#

Pictures would be much better

queen adder
#

My 2d character shoots shurikens, is it possible to make them roll (rotate ) forward through script or would it be better to make animation?

silver girder
queen adder
eternal falconBOT
#

:teacher: Unity Learn ↗

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

silver girder
summer stump
#

Show the class, the file, and the console

silver girder
#

ah alr

#

by class wdym

#

in the script?

summer stump
summer stump
summer stump
silver girder
#

console:

languid spire
#

So you have compile errors. Did you not read the error message?

summer stump
silver girder
summer stump
#

BasicEnemyDone is not BasicEnemy

#

You said you renamed it

silver girder
#

yea

#

i did

summer stump
#

Show the file I guess. Is it called BasicEnemyDone?

silver girder
#

yea

#

it is called basicenemydone

summer stump
silver girder
#

2nd option

languid spire
#

And what does this say?

summer stump
#

So then the issue is that you are referring to BasicEnemy in other scripts

silver girder
#

ahhhhhhh

silver girder
summer stump
vapid mesa
#

hi, I have a script for animator but the parameter don't work with the spacebar

#

when i jump the parameter don't change

summer stump
#

You have one parameter for everything and just set an int value?

#

Very interesting, never seen that

languid spire
# vapid mesa

It wont you set the int to 30 and then immediately back to 0

queen adder
vapid mesa
silver girder
vapid mesa
#

it work for all other animation

#

but not the jump

silver girder
frigid sequoia
summer stump
frigid sequoia
#

Sure this doesn't break anything?

summer stump
#

So it sets it to 0

#

And this happens too fast for you to see

languid spire
summer stump
vapid mesa
#

ye but the fall animation is on exit

queen adder
# silver girder i just find difficulty understanding a bit so i come here 😄

Yeah that's fair enough, like I don't want to sound like I'm discouraging you from doing your own thing and seeking help on here, that's what this community appears to be for.
I'm just talking from first hand experience as I'm currently going through the Pathways, having finished the Unity Essentials last week and moving onto Junior Programmer. Anyway good luck on your tutorials.

silver girder
summer pulsar
#

hello, is there a way i could the script run only if the requirements are met ? instead of throwing an error it stops the script ?
for example if i try to reference a box collider in a sphere instead of throwing an error the script wont work, is that possible ?

silver girder
silver girder
#

but still i wanna find a way to get useful for this community

crimson sinew
languid spire
silver girder
shell zephyr
#

Hello! I want my game to finish once the rigidBody2D speed is = 0. how can i do it?

#
private void FixelUpdate()
    {
        rb2d.velocity = new Vector2(4f, rb2d.velocity.y * dashingPower);
        speed = rb2d.velocity.magnitude;

        if (speed == 0)
        {
            Debug.Log("El juego termino");
        }
    }`
summer pulsar
crimson sinew
#

that would just be null I believe

crimson sinew
#

if (boxcol == null) <disable script here>

summer pulsar
cosmic dagger
shell zephyr
cosmic dagger
#

also, you should check if it's 0 or less, or use Mathf.Approximately . . .

shell zephyr
cosmic dagger
#

place a log inside of the method that runs the code you use to check the speed (to make sure it's running) . . .

shell zephyr
cosmic dagger
#

do you know what a method is?

shell zephyr
#

void

cosmic dagger
#

void is a return type . . .

summer stump
shell zephyr
#

👺

cosmic dagger
#

you've been coding so far, where do you place your code within the c# script?

shell zephyr
#

is that what you asked?

#

sorry, i'm just so bad with coding xd

cosmic dagger
#

it's hard to suggest fixes or solutions if you don't know how to use them . . .

shell zephyr
#

😔

cosmic dagger
#

watch a quick tutorial on the basics, or at least methods in c# . . .. . .

shell zephyr
cosmic dagger
#

you need to place a debug log in the same method where you check the speed to ensure that the method is running . . .

cosmic dagger
queen adder
shell zephyr
summer stump
cosmic dagger
shell zephyr
queen adder
#

You could have also have stuck a debug.log(speed) right before your if statement to see if it was picking up that variable, which I think is what RandomUnityInvader(); was suggesting. The result would have been that that too would not have been printing to the console and given you a better idea to troubleshooting.

Good luck for your game jam.

snow socket
#

Hello, I'm trying to apply the player settings to change the resolution of my build, but it's not changing the resolution. Does anyone know the fix?

timber tide
#

Ususally I force the resolution in my scripts

frigid sequoia
#

Maybe I am freaking dumb, but why is this reference not destroying the stuff?

#

Like the last one does work

frigid sequoia
queen adder
frigid sequoia
queen adder
#

yes but then I slide off when i climb on it

summer stump
queen adder
#

what code exactly?

#

it happens if I jump and hold right arrow

#

I want it to just slide along the wall

summer stump
cosmic dagger
# queen adder what code exactly?

we need to see your movement code. hard to suggest how to move/slide along a wall if we don't know how you move the character . . .

queen adder
#

ok I thougt u need the collider code too...

#
public bool isGrounded()
{
    if (Physics2D.BoxCast(transform.position, boxSize, 0, -transform.up, castDistance, GroundLayer))
    {
       
        return true;
        
    }
    else
    {
        return false;
    }
        
}

public void kretnja()
{
    if (Input.GetKey(KeyCode.RightArrow) == true)
    {
        igrac.velocity = new Vector2(speed * 1, igrac.velocity.y);
        
    }

    
    


    if (Input.GetKey(KeyCode.LeftArrow) == true)
    {
        igrac.velocity = new Vector2(-speed *  1, igrac.velocity.y);

    }
    


    if (Input.GetKeyDown(KeyCode.UpArrow) == true && isGrounded())
    {
        igrac.velocity = new Vector2(0, JumpStrength);
        

    }
eternal falconBOT
summer stump
#

And you have collider code?

queen adder
#

yep

summer stump
#

That would certainly be relevant

#

We don't know what you have of course

queen adder
#

ofcourse I have collider code for that

#

it wouldnt stick to wall if I didnt

#
private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.tag == "Enemy")
        Destroy(gameObject);
}
#

the code for collider

summer stump
#

Like, obviously if something that has to do with sticking to the wall it is relevant to your issue of sticking to the wall

queen adder
#

ok I will send all my scripts cuz idk what exactly you need

silver girder
queen adder
#

wdym

#

im working on 2d game

silver girder
#

ah so i cant help you in 2d i can help in 3d movement system

#

is it a top down camera

queen adder
#

no

#

bro what are u saying

#

I done that

#

just let this guy help me

crimson ibex
#

A very newbie doubt. if i have a 3d game, and I want to show a "cell" where 3d spheres can be placed on a plane. Will this "cell" be 3d or 2d gameobject

silver girder
#

well say that

queen adder
#

well read my script

#

and you will know what I need

silver girder
#

okay

#

ur character is named igrac?

queen adder
#

yes

silver girder
#

okay

#

idk im not an expert in 2d i know a bit of 3d

#

but i can make sfx

crimson ibex
summer stump
digital vessel
#

Hey guys. Which language code is the best for unity?

crimson ibex
#

c#

summer stump
digital vessel
silver girder
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

silver girder
eternal falconBOT
#

:teacher: Unity Learn ↗

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

vapid mesa
#

hi i have a little problem, i have a script for some animation and i have a conflict between jump and fall animation

#

when i jump the parameter direct switch on fall animation so the jump animation don't work

#

the jump animation don't have the time to be execute

summer stump
vapid mesa
#

okay

silver girder
#

hey i have a problem in unity bolt visual scripting

silver girder
#

i wanna know if the cloth can be put only by itself or does it need a shape to form

long jacinth
#

how do i do this

silver girder
#

i wanna know if the cloth can be put only by itself or does it need a shape to form

zealous oxide
#

hey friends. i've input a system.action into one of my scripts for the first time today. its being invoked when an enemy takes damage. then another script is "listening" to this, in this script https://hastebin.com/share/hewezaguwi.csharp the thing is, when i dont have the justHit bool anywhere in the script, it seems like "enemyHealth.damageTaken += DamageTaken;" gets called about 250/300 times in the space of a second or a frame? i get a huge lag spike. I was under the impression it would have only been called once? [i've added the justHit bool into the script to prevent this from happening but i'm assuming i'm doing something wrong here if the invoke is being called in the other script so much].

queen adder
silver girder
summer stump
#

Are you using bolt for the cloth?

silver girder
#

i aint using bolt for cloth

#

i am making it normally

summer stump
silver girder
summer stump
silver girder
silver girder
queen adder
long jacinth
#

TakeDamages(Amount) is the function i want to call

queen adder
#

So at the bottom of that link, it says "If you need to pass parameters to your method, consider using Coroutine instead."

long jacinth
#

k thank you

#

The body of 'Health.OnTriggerStay2D(Collider2D)' cannot be an iterator block because 'void' is not an iterator interface type

#

i really dont get the problem here

#

oh i guess i need an ienumerator :(((

cosmic dagger
eternal falconBOT
long jacinth
#

private void OnTriggerStay2D(Collider2D other)
{
if(other.tag == "Enemy")
{
TakeDamages(25);
}
}

#

this is what it normaly does

#

it instantly kills my player

#

i dont want to make it on enter

#

i want it so every 2 seconds it takes damage

summer stump
#

yield return new WaitForSeconds(2.0)

#

Coroutine routine = StartCoroutine(TakeDamage(25))

StopCoroutine(routine)

#

Also cache it so you can do that 👆

wintry quarry
long jacinth
#

ya its still giving me them red lines

summer stump
#

What red lines

#

What do the errors say?

#

What did you write?

long jacinth
summer stump
#

That is not right at all

long jacinth
#

i need an ienmuerator right

summer stump
#

An equals sign is required there, and both lines would need semicolons
These errors are just basic syntax errors

#

And you probably don't want to IMMEDIATELY stop the coroutine

#

And you are calling TakeDamage and then starting a coroutine called TakeDamage

#

And I hope you aren't still doing it in OnTriggerStay...

summer stump
long jacinth
#

i think i got it

#

still kills me instantly

summer stump
#

You didn't address the issues I said

long jacinth
#

wait should takedamage(25) be before or after the yield

summer stump
#

It is in OnTriggerStay, that is wrong

#

You are calling TakeDamage directly, that is wrong

summer stump
#

You are calling StopCoroutine on the line after, that is wrong

#

Your wait does nothing because TakeDamage isn't a loop, that is wrong

long jacinth
#

what should i replace ontriggerstay2d with

summer stump
#

OnTriggerEnter

long jacinth
#

i still want it to detect triggers

summer stump
#

And StopCoroutine goes in OnTriggerExit

wintry quarry
#

OnTriggerEnter2D <

summer stump
#

Yes, sorry

queen adder
#

Hey, so I'm trying to make a script between the player and a mob that has a 50/50 chance of destroying either of them, but for some reason it's been doing nothing but destroying mobs; am I missing something in my logic here?

long jacinth
#

wait why

summer stump
#

Is that not what you want?

long jacinth
#

yea

wintry quarry
summer stump
#

Extremely unlikely to be exactly 0 ever

glass light
queen adder
#

so all I'd need is this, correct?

#

I am never using gpt for this kinda stuff again lol

queen adder
#

hell yeah appreciate it, no idea why I didn't realize it was saving their exact values being floating-point numbers lol

glass light
#

chat gpt is a useful tool to give you like an idea for coding, but you shouldnt use it to code. it makes sloppy art, and it also makes sloppy code

queen adder
glass light
#

^, generally debug.log is good for debugging

long jacinth
#

i have never worked with coroutines

queen adder
#

25 damage
wait 2 seconds
...

#

basically

long jacinth
#

ya thats what i want

summer stump
# long jacinth ya thats what i want

Inside the coroutine, you make a while loop. Inside the loop you do whatever TakeDamage did, and then yield return

In OnTriggerEnter2D you do StartCoroutine

In OnTriggerExit2D you stop it

#

That is it

long jacinth
#

i cant use on triggerstay

summer stump
#

Really no point in using stay

long jacinth
#

so this is how it should look right

summer stump
#

And you should validate that it is enemy you are leaving the coroutine of

wintry quarry
#

OnTriggerStay actually could make this pretty simple:

float timer = 0;
float damageInterval = 2;
void OnTriggerEnter2D(Collider2D other) {
  timer = 0;
  DamageThePlayer(); // if you want instant damage
}

void OnTriggerStay2D(Collider2D other) {
  timer += Time.fixedDeltaTime;
  if (timer >= damageInterval) {
    timer -= damageInterval;
    DamageThePlayer();
  }
}```
mental flower
#

So.. to sum it up, my boyfriend is working on creating a 3D racing game in Unity and its going good so far but... we've run into a problem... we can't find the right script for adding a nitrous boost to the car itself (example Need for Speed Heat)... i was hoping someone here could help?

The car does move, and we'd need the script written in C#, with a separate script for the sound and key binding for the booster. (Left shift if anything) Is this the right place to come to?

Someone previously provided a 2D script but we need a 3D script

summer stump
mental flower
#

maybe getting it transcribed or transferred to be correct..?

summer stump
long jacinth
#

ya im figuring it out

#

WOAH IT WORKS

#

thanks guys not all heros wear capes fr

brazen wigeon
#

Who knows how to get players to shoot straight. In the 2D version of Android using buttons?

#

I'm having trouble here, even searching using YT, I can't find only tutorials for PC, not Android mobile

vapid mesa
#

hi, i have make animation and now when i jump we see the knee of my character, can i do something to make my camera follow like the head of my character ??

brazen wigeon
mental flower
#

Complete newbie here.. me and @tired pilot dont know how to write scripts.. much less adding a C# nitrous script. we dont have one started.

slender nymph
#

there are beginner c# courses pinned in this channel. after learning the basics of c# i recommend going through the pathways on the unity !learn site to learn how to use the engine

eternal falconBOT
#

:teacher: Unity Learn ↗

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

slender nymph
#

!collab 👇

eternal falconBOT
crimson ibex
#

I have tried multiple times, installing everything, cleaning up everything, including java, android n unity . but I am not able to build a plain simple mobile 2d and mobile 3d templates. If i build other regualr ones, they work. Error is

Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.22f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only

I googled, no answer seem to fit why a simple blank template woul dnot builf

tired pilot
#

wow thanks for the help...I'm leaving...

summer stump
lusty sage
#

dont know if this is the right thread but im trying to figure out how to disable my scoring system after my player has died, any help is appreciated!

#

how do i post my code here? just copy and paste?

queen adder
#

!code

eternal falconBOT
lusty sage
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class scorescript : MonoBehaviour
{

    public int playerScore;
    public Text scoreText;
    public GameObject gameOverScreen;
   

    [ContextMenu("Increase Score")]
    public void addScore(int ScoreToAdd)
    {
        playerScore = playerScore + ScoreToAdd;
        scoreText.text = playerScore.ToString();
    }

    public void restartGame()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }

    public void gameOver()
    {
        gameOverScreen.SetActive(true);
    }
}

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

public class pipetrigger : MonoBehaviour
{
    public scorescript logic;
    public logoscript countercomms;

    // Start is called before the first frame update
    void Start()
    {
        logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<scorescript>();  
    }

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

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (countercomms.birdisAlive is false)
        {
            logic.addScore(0);
        }

        else if (collision.gameObject.layer == 3)
        {
            logic.addScore(1);
        }

    } 

    
       

   

}

#

the first prompt in ontriggerenter2d seems to work to stop the scoring but then it just doesnt score at all

#

please let me know if you need anymore info and ill try my best to supply it

wintry quarry
#

any number plus 0 is the same number you started with

river pecan
#

How could I multiply a float every frame and have it framerate independent, I assumed float *= 36 * Time.deltaTime would work but it doesn't

wintry quarry
#

but like

#

why multiply every frame?

#

That's crazy

#

don't you want to add?

#

What ar eyou trying to accomplish

river pecan
wintry quarry
river pecan
#

(3 * 0.6) * 0.6

#

Like get the value to lower each frame percentage wise

wintry quarry
#

Can you explain what you are trying to accomplish in gameplay terms?

#

doing a percentage per frame isn't really sensical

dreamy urchin
#

how can I check in 2D if an object is near an other object, so not if it collides but it has basically an offset to the collider

river pecan
wintry quarry
river pecan
dreamy urchin
wintry quarry
#

then you just set targetVelocity elsewhere

lusty sage
wintry quarry
#

it means "add 0"

wintry quarry
modest dust
#

Or just disable the trigger collider

wintry quarry
#

or you could add bird being alive as a condition to the other one:

if (collision.gameObject.layer == 3 && countercomms.birdisAlive ) {
  logic.addScore(1);
}```
river pecan
wintry quarry
#

this is modifying the velocity over time according to your desired velocity

river pecan
#

I'm using a character controller to move

wintry quarry
#

not relevant

river pecan
#

Would they conflict?

wintry quarry
#

would what conflict?

#

MoveTowards doesn't move anything. It's just math.

river pecan
#

Oh