#💻┃code-beginner

1 messages · Page 122 of 1

verbal dome
#

Google blender to unity export/import settings. They use a bit different coordinate space

woven crater
#

do i need multiple text component for each item component like item name and item discription that is display on the same image object parent?

verbal dome
#

When?

knotty gust
# verbal dome When?

like when the script is added to an object i want it to be added to an array on another object instantly in the editor instead of having to add the object in runtime

verbal dome
woven crater
#

thank

unreal phoenix
knotty gust
gaunt ice
#

you can drag the object to the array slot in other object, unless you think making a script to do this is better

knotty gust
#

i wanna try using a script cus theres already alot of objects that need to be added in the scene

#

think it would be better so i dont risk missing any

verbal dome
#

You can try one of the built in methods: Reset, OnEnable, OnValidate

#

Reset probably makes the most sense here

#

Gets called when you add the component

#

(Or manually from the component's context menu)

#

The object with the array must probably be marked dirty after you do that tho, so that it saves the change with the scene

potent echo
#

Figured I could also use direction = (Random.Range(0, 2) == 0) ? -1.0f : 1.0f;. Unity needs an official Random.choice though, I wonder why it doesn't exist.

nimble scaffold
#

What's the problem

wintry quarry
gaunt ice
#

(Random.Range(0,2)<<1)-1;

knotty gust
#

thats useful thanks

knotty gust
verbal dome
#

Im pretty sure thats needed, anyway

verbal dome
knotty gust
#

ohhhhhh

verbal dome
#

Or is the object with the list/array created afterwards?

knotty gust
#

nahhh i see what u meant

#

ight thanks

nimble scaffold
verbal dome
nimble scaffold
#

Well I have given some comments alos

#

Also so can you guys pls check the codes?

#

And what are issues in GitHub?

woven crater
#

i am suppose to use Sprite type to set image in the image component in ui?

elfin eagle
#
{
   var playerStats = collision.GetComponent<PlayerCombat>();

    if (collision.CompareTag("Player"))
    {
        playerStats.takeDamagePlayer(25);
        playerspriteRenderer.material.color = Color.red;
        StartCoroutine(changeColorBack());
    }
}
IEnumerator changeColorBack()
{
    Debug.Log("started");
    yield return new WaitForSeconds(0.5f);
    playerspriteRenderer.material.color = Color.white;
}````

anyone know why ```yield return new WaitForSeconds(0.5f);``` wont trigger? like it starts the  changeColorBack() but it does not excute anything after the debug.log
keen dew
#

I'm guessing the object this script is on gets destroyed

elfin eagle
#

no it gets hidden, maybe thats the problem then

wintry quarry
#

Coroutines will only run on active objects

elfin eagle
#

ahh ok I thought it also worked on deactivated as well

#

thanks

rich adder
#

hey post code properly with link !code

eternal falconBOT
rich adder
#

also is this 3D or 2D game

vestal adder
#

so erm bashically i have the projectile instantiated thing then i destroy it

#

does not work tho

#

its 3D

#

!code

eternal falconBOT
rich adder
#

it has link to site to post code on and sent link here

vestal adder
#

yeah im doing it now lol diddnt realise

rich adder
#

ur supposed to send the link

vestal adder
#

winning

#

thanks for being patient

rich adder
vestal adder
#

nothing shows up in the debug log for collision so i think its that

rich adder
#

well your first mistake is thinking you can have 2 tags on the same object

#

so Tag1 && Tag2 can never be

vestal adder
#

i should get rid of the second tag?

rich adder
#

why does the gun have OnCollisionEnter in the first place

vestal adder
#

thats supposed to be for the bullet colliding rather than the gun

#

the script is on the gun tho

rich adder
vestal adder
#

oops

rich adder
# vestal adder oops

not even sure why gun would have a collider in the first place.
What are you trying to accomplish with that exactly , there. is prob a better way

vestal adder
#

i would like my bullets to disappear after hitting stuff

#

right now they just sit there

rich adder
#

and put OnCollision enter logic there

vestal adder
#

how would i make the script on the bullet not destroy the bullet prefab

finite socket
#

Hey I need some help with animator.SetBool I have the getcomponent but still not working say animator does not contain definition

open kernel
#

Hi! Im currently trying the Alteruna Multiplayer and can`t fix one error. If needed, I can provide my code. The Error: No matter what I try, as soon as I leave the Lobby there are no Cameras rendering onto the display. It could be a conflict between my PlayerController and the camera, because the PlayerController says playerCamera = camera.main. I looked into the scene while the game was running and there were no cameras. At the start (before I join a Lobby), everything works fine. Thank you

rich adder
rich adder
wintry quarry
#

the prefab never goes in the scene

#

the one in the scene that the code actually runs on is a copy

#

the code will never actually run on the prefab itself

rich adder
vestal adder
#

i see

open kernel
rich adder
green briar
#

hi guys just wondering is there a reason why i get an error with this line of code? using Assets.Scripts;

eternal falconBOT
green briar
#

Assets\Scripts\Knife.cs(1,14): error CS0234: The type or namespace name 'Scripts' does not exist in the namespace 'Assets' (are you missing an assembly reference?)
this is the error , i got this code from a github i found about slicing objects, checks the locations of my Scripts folder which is correct.

open kernel
rich adder
green briar
rich adder
#

yea

gaunt ice
#

you are missing the namespace not the folder

rich adder
green briar
#

yupp

rich adder
#

and are they in the same assembly

green briar
#

can i post images here?

rich adder
#

sure

green briar
rich adder
#

namespaces are not folders btw

#

not in unity at least

green briar
#

OH they arent? alright at least i know where to start looking now

#

thanks!

rich adder
gaunt ice
#

namespace is used to group the classes together

rich adder
woven crater
#

why this return null? i set the artifactlist SO in the inspector and the list is not empty

gaunt ice
#

artifact is null not artifactList

vague stag
#

hello

woven crater
#

ah.

green briar
vague stag
# woven crater why this return null? i set the artifactlist SO in the inspector and the list is...

It looks like you're talking about a C# or Unity based piece of code. In the situation you mentioned, when you set a list named "artifactlist" to "SO" (ScriptableObject) via the inspector, there may be several reasons why the list returns empty:

There may be an error that needs to be taken into consideration when adding data to the list. Data addition may not have been done correctly.

The "artifactlist" list may be a part of your code that needs to be populated with the data you expect. It is useful to check this situation.

It may be the case that the "artifactlist" list you may have set up on the Inspector has a reference to a different list in your code. To check this situation, it is useful to review your code and inspector settings.

By gaining control over these cases, you can determine why the list is returning empty and update your code accordingly. If you need detailed help, you can get more specific help by sharing your code snippet or Unity project details.

woven crater
#

tldr
i just forget to create instance of the list

finite socket
rich adder
woven crater
#

omg i thought im the one noticed

#

and i'd rude if pointing out lol

rich adder
#

nah its against server community guidelines(posting AI answers), you would've been fine pointing that out

woven crater
#

there still a tiny chance a person could talk like this. and im too social anxious

finite socket
#

216 and 223

rich adder
#

screenshot it

finite socket
rich adder
finite socket
#

animator

rich adder
#

so is that a yes?

rich adder
finite socket
rich adder
#

Do you, have , another script that is named Animator

#

control click Animator

finite socket
#

yeah

woven crater
finite socket
#

I dint noticed I named it that

rich adder
#

yeah stay away from class names already used by unity

#

otherwise you need namespaces

finite socket
#

Thanks

woven crater
#

how do i set image?

river roost
#

sprite

woven crater
#

nothing?

rich adder
# woven crater

also you should prob have a method on these objects for that

rich adder
#

remove using System.Drawing from top

river roost
gaunt ice
#

you should create a custom class and store the reference instead of relying on getChild(X)...

river roost
#

hey

#

if it works it works

rich adder
woven crater
#

pondering

rich adder
#

you should not aim to write brittle code

woven crater
rich adder
#

what if somehow you only had 2 child. your whole thing breaks

gaunt ice
#

imagine you fix your ui someday and your code no going to work anymore

river roost
cosmic quail
#

also getchild performance is terrible

wintry quarry
#

But really - don't do this

#

it's awful

woven crater
#

okay.

wintry quarry
#

direct references

rich adder
woven crater
#

understandable

spring skiff
#

What can I do, If I have a "void OnCollisionEnter", that doesent react if I move a Collider with Trigger enabled to it?

cosmic quail
#

and its the right one

wintry quarry
rich adder
#

they're using Image from System.Drawing

#

which is a Microsoft class

wintry quarry
#

Did you forget using UnityEngine.UI;?

cosmic quail
spring skiff
wintry quarry
river roost
# woven crater like a class that store EVERY reference?
public class ArtifactUI : MonoBehaviour {
  [SerializeField] TextMeshProUGUI _nameText;
  ...

  public void Set(Artifact artifact) {
    _nameText.text = artifact.itemName;
    ...
  }
}
```you would do something like this, and then call `Set` from your original script
cosmic quail
# rich adder nah says it right here

true i did not see that. i just saw "Image" and "thats not the right class for image" and suddenly i thought i have been using images completely wrong 😅

rich adder
timid hinge
#

hi guys i have a question anyone know how can i put the character on the dungeon?

like spawn on it

rich adder
woven crater
timid hinge
river roost
rich adder
# timid hinge how?

where do you wanna spawn it?
probably easier to make a gameobject and spawn it from there
You can use gameobject brush so you can use the tilemap/grid snap

timid hinge
#

like here

woven crater
#

well not alot my game is not that big

gaunt ice
#

then reference your own script

river roost
gaunt ice
#

(store them into a list, dont use list<gameobject>)

woven crater
rocky canyon
#

you'd want to spawn it first

#

and get a reference to the instance of the spawned component

finite socket
#

OK so I think I need some hep with my code where should I look to add animation to an fps Controller?

toxic pasture
#

I'm having an issue with a very basic thing. Whenever I set an object as a child of the other object, it retains it's world position but doesn't retain it's world rotation. I'm trying to make a script that when a key is pressed, the box will become the "held box" and be snapped to a specific position. This position is set by an empty 3d gameobejct which kinda acts as a socket. The box is supposed to snap to the socket and then follow it as the player moves. When picked up, the box snaps to the socket, but afterward it remains in the spot where it was picked up. It moves to camera rotation but not when the player moves.

rocky canyon
#

it retains it's world position but doesn't retain it's world rotation.

#

? care to fix that or elaborate? lol

river roost
rocky canyon
#

ohh nvm, bit tired

woven crater
rich adder
#

like here

queen adder
summer stump
eternal falconBOT
queen adder
#

Yeah share code pls

rocky canyon
river roost
toxic pasture
#

It's 40 characters over the limit

woven crater
queen adder
#

If im reading this correctly when u set the worldPositionStays parameter of SetParent() to false it doesnt change transform (Position, Rotation, and scale)

river roost
summer stump
rocky canyon
#

does the object have a rigidbody or soemthing on it?

toxic pasture
#

however I disabled it when I pick it up

woven crater
rocky canyon
#

the smartest person in the room is the normally the quietest

toxic pasture
queen adder
#

Yeah i said that backwards sorry

#

You could just manually set the rotation tho

toxic pasture
#

rotation isn't the issue

#

position is

queen adder
#

Oh?

rocky canyon
# toxic pasture yes

i do testing when i get problems like this.. and i try to break it down into bits i can understand..
in this case I would take the object and parent it to the socket.. move it where it needs to be and just test that singular thing..

queen adder
#

Ur setting the position to Vector3.zero?

rocky canyon
#

if it follows the player and acts as it should from the git go.. you can take in that information and move onto the next kink in the chain

toxic pasture
#

picked up and rotated

#

picked up, rotated, and moved

toxic pasture
#

line 35

#

potentialObject.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);

toxic pasture
queen adder
#

Aight just so i understand correctly

#

The box doesnt follow the player when the player moves
But when the camera rotates it does move

#

Could u possibly share a video of the problem?
With the game view and scene view running at the same time in it

#

also on line 67 i believe you only need to set the parent of the _currentObject once instead of doing it in Update

rocky canyon
#

any sort of mis-scaled object will have adverse reactions to the chain of children below

#

maybe something there? not sure tbh.. keep trying/ asking if it doesn't surely someone will come along and know

summer stump
#

I agree with Vee
Line 67 is an issue. Try commenting it out
You already set parent in PickupItem

hazy crypt
#

I imported 2 pngs im going to put inside my canvas as UI, but it imported as textures, and cant be dragged into unity. How do I turn it back to normal?

mystic oxide
#

can't figure out to fix the blurry text, even though i used Text TMP

queen adder
#

Click on the .pngs and then go into the inspector set the type to Sprite 2D

#

Ur on the right thing spaced out just change the first option to 2D

#

Zwush Is that in the Scene view or while the Game is actually running

queen adder
#

Ofc good luck with development!

jovial peak
#

heyo all -- im using gl draw to draw some lines but its rendering to multiple cameras (a render texture), how do i prevent this?

timber tide
#

i'd check the docs as it mentions the camera

toxic pasture
#

now I have a new issue

#

the dropitem functionality isn't working

rich adder
#

also not code question

mystic oxide
#

my bad

waxen oracle
#

I have a rly weird problem with my room. I have a platform at X 67.78 and to the right of it is an empty object which says its at 17.74. This should be impossible and every platform matches up correctly, i have no idea wth is going on

wintry quarry
#

aka position relative to the parent

#

they are not world space positions

waxen oracle
#

Ooohhh

#

thank you that makes sense

#

Is there a way to see the global position

rare basin
#

with custom inspector - yes

#

with default inspector - no

#

only via code

#

Debug.Log(transform.position);
Debug.Log(transform.localPosition);

waxen oracle
#

Oh using the log

#

yeah alr ill try that

hazy crypt
#

any reason for that?

#

it doesnt seem to have any affects on the gameplay

#

but it only happened with the new font

frosty hound
#

Looks like an editor bug, so can just ignore it if its not affecting you

vast tangle
#

Im not sure what happened but I can no longer activate my start button, it refuses to execute my StartGame Method

NEVERMIND fixed it, i was missing the Graphics Raycaster... must've deleted it by accident

meager steeple
#

i made a new tile palette but when i place then they appear really small im not sure what i need to do to make it so they fill up the size of the grid

summer stump
#

Which will correspond to the size of the image

#

If, for example, it is 8x8, the ppu is 8

Oh, also not a code question

rocky canyon
#

lol wait i see a bug i think.. oof, i know the position part of it works / edit: but yea, i thinky theres some scaling stuff that isn't quite worked out..

meager steeple
summer stump
rocky canyon
#

just click the icon in ur stuff

amber spruce
#

can someone help me with making my character move properly im trying to adjust my current movement to use the new input system i have the input sysetm working just need to get the correct movement equation and stuff

meager steeple
#

it doesnt seem to change anything

rocky canyon
#

click apply

amber spruce
rocky canyon
#

also not coding question, more of a rendering question

meager steeple
#

is there a channel for that?

serene barn
#

so i ran into an issue with this guide and I don't see any issue were I went wrong but I can't figure it out. When I'm spawning pipes I kept x the same y gets change to any postion that it can new Vector3(transform.position.x, Random.Range(lowestPoint, highestPoint) and z stays the same and when i run it nothing happens and so im lost

rocky canyon
#

yea, im sure not sure which one tho, art-asset flow, or 2d-tools mab

#

for general stuff u can use unity-talk, and stuff like window, and the layout panels

summer stump
#

I feel like Art Asset Flow is for third party tools. But could fit. I dunno haha

I don't go in those very often

serene barn
#

I'm generally stuck on one part of a flappy bird code and I had to restart to figure what I did wrong but I did nothing wrong and I'm just wondering if it's the code

rocky canyon
rocky canyon
#

did you follow the tutorial and take it step by step?

serene barn
#

I made unity crash because I change one thing

rocky canyon
#

im inclined to think if you did it would have been working up until the part / error in the code you say it might be

#

oh, well easy, change that thing back.. lol

#

and its probably b/c of that bit, might share the code

summer stump
sullen iron
#

can someone tell me why this looks pink

#

on the tutorial it doesnt look pink

#

😭

rocky canyon
summer stump
serene barn
#

Like visual studio has never gave me the error lines at all and I've tried to figure it out but also visual studio didn't gave me a unity code prompt

wintry quarry
#

Wrong channel

serene barn
rocky canyon
#

yea, thats a bad crash

amber spruce
rocky canyon
#

like code stuck

serene barn
#

I can't figure out what is wrong

summer stump
rocky canyon
#

the loop where ur pipes run is probably never ending

#

somehow

serene barn
#

Can't get the pipes to randomly spawn on the y

rocky canyon
#

just create a value, with a random.range value or something

#

and then plug that value into ur spawn position

summer stump
eternal falconBOT
rocky canyon
#

on the y access

#

and if the tutorial is old and has remained up the code is probably fine in that tutorial

serene barn
#

Vector3(transform.position.x, Random.Range(lowestPoint, highestPoint) this is the line of the code that should of made it random, the 2 variables are lowest point and highest point

summer stump
serene barn
#

Dec 2 of this year

rocky canyon
#
context matters
serene barn
#

Give me a second

amber spruce
# amber spruce i may have gotten it let me check i found a good tutorial

nope i didnt for some reason now it doesnt even get recognized lol im using a Player input and the behavior is invoke unity events and it doesnt show it

public void OnMove(InputAction.CallbackContext ctx, InputValue inputValue)
{
    m_Rigidbody2D.velocity = Vector2.SmoothDamp(m_Rigidbody2D.velocity, inputValue.Get<Vector2>() * m_Speed, ref m_Velocity, m_MovementSmoothing);
}
serene barn
slender nymph
eternal falconBOT
serene barn
#

Is that a add on?

slender nymph
summer stump
slender nymph
# serene barn Is that a add on?

it needs to be configured for use with unity so you get proper syntax highlighting, autocomplete, and error underlining.
having a configured IDE is also a requirement to get help here

summer stump
# serene barn

Also, this is not how the bot said to share code
Although, I'll say it worked out this time so we could see it is not configured

serene barn
#

my head hurts give me one second

#

I GOT A ERROR

#

YAAA

sullen iron
#
Library\PackageCache\com.unity.jobs@0.2.10-preview.13\Unity.Jobs\IJobParallelForDefer.cs(73,85): error CS8377: The type 'U' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'``` how do I access this class even
amber spruce
slender nymph
slender nymph
summer stump
#

For holding, check the context state. Start the movement on ctx.started and end on ctx.canceled

serene barn
#

okay it works but no errors for the code so i still have no idea what i did wrong

summer stump
serene barn
summer stump
slender nymph
summer stump
# serene barn 36

That does not change those values. It creates new ones based on it
They are still 0.
So your two values are just a range from transform.position.y to transform.position.y

serene barn
summer stump
slender nymph
#

so every single time you spawn a pipe it spawns at the same exact position as the object spawning them

serene barn
#

changed two variable hope it doesnt freeze

#

oh god

#

i might have figure it out but i got to try

#

yea nope im still lost

slender nymph
#

how about actually describing what your current issue is

summer stump
#

Set HeightTop and HeightBottom to something other than 0. Like 10

Did you try that?

serene barn
slender nymph
#

surely you read what i told you about why it isn't being random

polar acorn
serene barn
#

!code

eternal falconBOT
serene barn
#
public class PipeSpawning : MonoBehaviour
{
    public GameObject pipe;
    public float spawnRate = 2;
    private float timer = 0;
    public float heightTop = 0;
    public float heightBottom = 0;
    // Start is called before the first frame update
    void Start()
    {
        spawnPipe();
    }

    // Update is called once per frame
    void Update()
    {
        if (timer < spawnRate) 
        {
            timer = timer + Time.deltaTime;
        }
        else 
        {
            spawnPipe();
            timer = 0;
        }
        
    }
    void spawnPipe() 
    {
        float lowestPoint = transform.position.y - heightTop;
        float highestPoint = transform.position.y + heightBottom;
        Instantiate(pipe, new Vector3(transform.position.x, Random.Range(highestPoint, lowestPoint), 0), transform.rotation);
    }
}
serene barn
#

yea I've looked over this so many times and just can seem to figure out what's wrong. I've changed values, ive change variable locations and not to sure what is the issue and dont say remove this or it can end up spawning way to many pipes and freezing unity

slender nymph
#

did you change the value of heightTop and heightBottom in the inspector

polar acorn
serene barn
thorn holly
#

Yes

polar acorn
serene barn
slender nymph
#

wrong object

polar acorn
serene barn
#

why the heck

#

oh god i nearly made unity crash

#

now the question is WHAT IS MAKING IT SPAWN SO MUCH!

polar acorn
#

Still waiting on that inspector

slender nymph
#

at this point i believe their strategy has turned into "ignore the helpers and change random shit"

serene barn
#

i "fixed" the issue i had 2 game objects

serene barn
#

so deleted the 2 and added the one that was intened to be there

#

cant start it or things be getting crazy

polar acorn
celest holly
#

surely you should be putting the pipe spawning script within an empty game object?

polar acorn
verbal dome
#

This is like the 7th self-spawning pipe I have seen here

serene barn
#

yea i did that is why i said i "fixed" the issue

serene barn
polar acorn
serene barn
#

i've been trying since 4am

polar acorn
celest holly
#

make sure the open the prefab and remove the script component

#

instead of just removing it on the current pipe

serene barn
#

heh?

polar acorn
celest holly
#

each pipe that spawns will spawn another pipe basically lol

polar acorn
#

Whenever you spawn a pipe that pipe spawns a pipe and then that pipe spawns a pipe and then that pipe spawns a pipe and then -

charred spoke
#

Dear god pooh your eating recursion.

serene barn
#

oh, that makes more sense and now the are spawning behind me

#

now i have it on a separate game object and now i need to figure out what is happening

#

who has a FUCKEN GUN

#

becuase it just clicked

#

IT WORKED

#

HAHA

spring skiff
#

If I want to check, if a Collider with Trigger enabled enter another object with only a Collider, DO I really need a rigidbody in both of those object?

serene barn
spring skiff
#

3d

thorn holly
#

I don’t really see why 2D or 3d would make a difference

serene barn
#

i was gonna say if its a 3D box colider or a 3D circle colider

thorn holly
#

I still don’t think that makes a difference

thorn holly
spring skiff
#

but does the Collider or the trigger need them?

polar acorn
thorn holly
#

So I have a mesh, is there a way to add lines or something on the connections between vertices?

#

I kinda want to highlight the connections between the vertices to show the different triangles

vast vessel
thorn holly
#

Got it, thx

amber spruce
#

because im looking at the docs and it seems to say to do what im doing rn

#

i think i got it i was over complicating it i think

#

only problem is i need to have it only move it on the x because moving it on the y messes with the gravity

uncut hornet
#

how can i add a simple cooldown to this dash like ability i have. all the dash does is move the player forward a certain amount

amber spruce
#
m_Rigidbody2D.velocityX = moveAmount.x;

this should only affect the x right

vast vessel
distant prairie
#

hey guys did someone have the same problems recently? i cant find anything on google about it (Unloading broken assembly Library/ScriptAssemblies/Unity.Rider.Editor.dll, this assembly can cause crashes in the runtime)

vast vessel
fierce shuttle
# uncut hornet how can i add a simple cooldown to this dash like ability i have. all the dash d...

An alternative approach to a timer could be either a corouttine, or what I do often is use Time.time to store a kind of "timestamp" and subtract the difference, for example:

public float delayBetweenInput = 5f;
float timePassed;

void SomeFunc()
{
if(Time.time < timePassed) {return;}

//do logic...
timePassed = Time.time + delayBetweenInput;
}

So in that example, spamming SomeFunc will only fire the logic every 5 seconds, this way you dont need to constantly iterate a value over frames (deltaTime), though both approaches are viable, just an alternative

uncut hornet
#

alright cool, ill try both. thanks you all

#

ok so i might be dumb but when using the first example, im encountering this bug where spamming the E button would set the timer back each time, which is how its written out. im just not sure how i can check if the dash happened

#

im pretty new to programming

round scaffold
#

Put a debug log on the dash function to check

fierce shuttle
# distant prairie hey guys did someone have the same problems recently? i cant find anything on go...

Ive never gotten that specific error before but I have gotten library package errors before, some things you can try:

  • right-clicking the package from your project browser and "Reimport"
  • make sure you have the latest version of the package in Package Manager (in your case, Rider Editor"
  • if all else fails, you can also try closing Unity and delete your Library folder (it will be regenerated when you open your project again)

This last option will increase the time it takes for your project to reopen though as that folder tends to be >50% of a projects total size most of the time, but then re-opening your project every other time after should be faster once its generated

uncut hornet
#

sorry if my wording is off

#

my first thought goes to a bool but like i literally dont even know where to begin with that honestly, and i feel like theres a better answer

fierce shuttle
uncut hornet
#

its pretty not good lol

#

im like brand new to c# and coding in general honestly so yeah

#

so i should make a function for the dash?

#

OH YEAH the *50 is like way over so that i can actually see if it works haha

fierce shuttle
# uncut hornet so i should make a function for the dash?

You dont have to, its just often more "clean" to do so - as Kiatu suggested, after you set your dashTimer to 3, you can add a Debug.Log and put anything you want in it, such as Debug.Log("dashed"); - if that gets logged to the console every 3 ish seconds, you know your logic works, if not, then its possible your timer is not being decreased or there could be another problem

uncut hornet
#

also, this is definetly not right. feel free to laugh ha

#

and when i tested it it worked because i couldnt dash until after a few seconds after i started the game

distant prairie
#

thats the only error i get now

fierce shuttle
round scaffold
uncut hornet
#

ok ty

distant prairie
#

i've only found people deleting and not so clear messages on random forums

uncut hornet
#

ok its working now, thanks guys!

distant prairie
#

not really an clear answer

#

can i maybe message you in private if you have time?

fierce shuttle
# uncut hornet im like brand new to c# and coding in general honestly so yeah

Glad you got it working - also if youd want to get some more practice with C# in general, id suggest the w3schools course, its completely free and has interactive lessons on the site - once your familiar with that, you can also try Unity Learn for Unity specific beginner tutorials, though if you feel youd like more info on C#, theres always MSDN and C# playlists on YouTube that cover more advanced topics, just some suggestions if your inclined, GL!

fierce shuttle
distant prairie
#

so it started when i deleted a script

#

and somehow i got the error i told about earlier

#

so i deleted the folder library

#

and now i get that 1 error which doesnt say what the problem is

#

Internal build system error. read the full binlog without getting a BuildFinishedMessage, while the backend process is still running
thats the only error i get now

#

atleast i think it is because of deleting a script

uncut dune
#

I have a custom list and a single variable to add values to the custom list
everytime I change the variable all the elements added through it get changed and are equal how can I add and make it keep the initial value

fierce shuttle
distant prairie
#

yeah i restarted unity after deleting the folder

#

and now i only get this error : Internal build system error. read the full binlog without getting a BuildFinishedMessage, while the backend process is still running

fierce shuttle
rare basin
#

Class?

#

Class is a reference type, you should make it a struct which is value type

distant prairie
uncut dune
#

Its the same as informação but not a list

rare basin
#

Typical begginer mistake

rare basin
#

Google it

inland cobalt
#

Hey all, I'm trying to make a simplistic chess game as my first unity project and currently im setting the foundations for how the Pieces and the Board will be defined, so far i have a namespace called Pieces than i plan to fill with a class for each piece in the game, an example shown by the class Pawn.

namespace Pieces
{

    interface IPiece
    {
        public Vector2Int[] GetValidSquares();

    }


    public class Pawn : IPiece
    {
        public Vector2Int[] GetValidSquares()
        {


            return null;
        }

    }



}

I want to be able to reference a piece such as Pawn in the Square class, however as they may be different types, I cant define it the usual way, would i need to use generics for this, or is there a better approach? Hope that makes sense

using UnityEngine;
using Pieces;

public class Board : MonoBehaviour
{
    public static Square[,] boardSquares = new Square[8,8];

    public class Square
    {
        

    }
}```
uncut dune
rare basin
#

Basically when you have
CurrentInfo a;
CurrentInfo b;

Then after doing
a = b

And when you modify a it also modifies b

#

Because it is a reference type

distant prairie
#

im gona try to open a new project and see if it has the same problem

fierce shuttle
fierce shuttle
distant prairie
#

An error occurred while resolving packages: One or more packages could not be added to the local file system: com.unity.ads: Converting circular structure to JSON --> starting at object with constructor 'Error' --- property 'error' closes the circle com.unity.ai.navigation: Converting circular structure to JSON --> starting at object with constructor 'Error' --- property 'error' closes the circle com.unity.analytics: Converting circular structure to JSON --> starting at object with constructor 'Error' --- property 'error' closes the circle com.unity.nuget.newtonsoft-json: Converting circular structure to JSON --> starting at object with constructor 'Error' --- property 'error' closes the circle com.unity.purchasing: Converting circular structure to JSON --> starting at object with constructor 'Error' --- property 'error' closes the circle com.unity.services.analytics: Converting circular structure to JSON --> starting at object with constructor 'Error' --- property 'error' closes the circle com.unity.services.core: Converting circular structure to JSON --> starting at object with constructor 'Error' --- property 'error' closes the circle com.unity.xr.legacyinputhelpers: Converting circular structure to JSON --> starting at object with constructor 'Error' --- property 'error' closes the circle

#

now my new project gets this error too

#

but my old project only has the old error

inland cobalt
# fierce shuttle What info about a specific piece, outside of your interface, might you need to a...

well my plan was to have a 2D array of squares as shown in the second snippet, then each square contains properties describing whether or not the square is occupied, the piece on the square, etc. I want to reference the piece on the square in the event that it is occupied. However, the current way im doing it, each Piece is a separate class, so if i want to reference a piece within Square, there is no singular type i can use. Which is why i was asking whether or not there was a better way than using separate classes for each piece type

serene barn
#

so every time i close unity it resets it external tools is there a way i can stop that?

fierce shuttle
fierce shuttle
inland cobalt
distant prairie
fierce shuttle
# inland cobalt Well each piece won't be the same code as they all have different logic to valid...

Ah, then in that case I think the multiple classes makes sense, your Square can just hold that IPiece or a list of them if you prefer, you should still be able to do .GetType and check if its a specific piece if you need that info, or have it a part of your interface - if some pieces need to do different things than whatever logic each piece has for their version of GetValidSquares, youll then need to be able to cast to that type, otherwise the class "Knight", "King", "Pawn" etc shouldnt need to be known for their independent logic, though I could be wrong

fierce shuttle
inland cobalt
fierce shuttle
# inland cobalt Gotcha thanks, I think i'll need to read up a bit more about interfaces

Personally I dont use them too much outside of cases like dealing damage to different things, I could put a IDamagable on a breakable crate, glass window, vending machine, enemy, car and even the player for example, all very different things with very different functions, but they all have "health" and therefore all take "damage" so whatever bullet or blunt object hits them, I dont care what was hit, just something that CAN take damage (IDamagable) was hit, then the object/class decides what to do after (glass might shatter at 0, a enemy might ragdoll, etc) - in your case, that kind of logic may or may not be useful to you but they are certainly worth looking more into, I believe the "abstraction pattern" uses them often

empty yoke
#

would it be fine to just throw a component script with "dontDestroyOnLoad" and nothing else on the ----gameManagers---- gameobject here for that to cascade down to all the managers I want to maintain through scenes? I want to make sure I understood the documentation
https://i.imgur.com/bpKPP6N.png

inland cobalt
# fierce shuttle Personally I dont use them too much outside of cases like dealing damage to diff...

Okay so i've just scrapped the interface as like you said it probably wasn't necessary. So I now have something like this for pieces:

namespace Pieces
{

    public enum Colour
    {
        White,
        Black
    }

    public class Piece
    {
        public Colour colour;

    }

    public class Pawn : Piece
    {
        public Vector2Int[] GetValidSquares(Board.Square[,] boardState)
        {
            return null;
        }

    }
}```

Looking in board now,

```cs
public static class Board
{
    public static Square[,] boardSquares = new Square[8, 8];

    public class Square
    {
        public object occupyingPiece;
        public bool isOccupied;


        public void AddPieceToSquare(/*Some piece object here*/)
        {
            if(isOccupied)
            {   // If already occupied, ensure colours don't match

                


            }


        }


    }
}```

I'm trying to define a method to as it sounds, add a piece to a square. And just to make sure, i want to add some logic inside of this function before proceeding with actually adding it to the square to ensure that im not trying to move to a space that is occupied by my own colour of piece, and if it is i want to throw an error as that should already have been handled. However this is where i was concerned about how to implement it before; I cant just simply check the object that is passed as a paramater for it's colour, as i cant define a singular type when there are multiple, so it could be any object which may not inherit from Piece. Basically what I'm asking is how can i make it so that this function takes in an instance of any one of the piece classes such as `Pawn`, without allowing any object. That way i know for certain that they will inherit from Piece, and they will contain a colour property. Hope that makes sense
true pasture
#

whats a good way to stop a player from doing inputs in a text field for a little while after submitting it. I have a coroutine and im not sure how to disable the input field.

kind cove
#

Making a platform held by chains. The chains are using HingeJoint2D's and it seems like the anchor points stretch causing a bounciness I don't want. Any Ideas?

serene barn
#

I FINALLY FINISHED MY FIRST RIP OFF GAME WOOO

#

only took 12 hours

inland cobalt
# inland cobalt Okay so i've just scrapped the interface as like you said it probably wasn't nec...

Following on from this attempting to solve it with generics, i've come up with something like this

using UnityEngine;
using Pieces;

public static class Board
{
    public static Square[,] boardSquares = new Square[8, 8];

    public class Square<T> where T : Piece
    {
        public T occupyingPiece;
        public bool isOccupied;


        public void AddPieceToSquare(T pieceToAdd)
        {
            if(isOccupied)
            {   // If already occupied, ensure colours don't match
                if(pieceToAdd.colour == occupyingPiece.colour) 
                throw new System.Exception("Error adding piece to square, a piece is trying to be placed over another of equal colour");
            }


        }


    }
}```

But im getting the error with the boardSquares 2D array static that the generic requires 1 type arguments, but i thought that was the point of where T : Piece? I'm still trying to wrap my head around this so if anyone could explain where i have gone wrong here that would be appreciated
tacit estuary
inland cobalt
#

works now

open vine
#

Hey so I have rigidbody movement and it works but its jittering when I move both the player and camera at the same time. By itself the movement isnt jittery and the camera look isnt either, anybody know what might be the problem? I'm not sure if this helps but the player movement is in FixedUpdate() and the camera turning the player and looking around is in LateUpdate()

inland cobalt
# tacit estuary Don’t use `object`, you can just use `Piece`

Nevermind, I just realised this won't work actually. The occupyingPiece variable needs to be a class like Pawn as an example, or others such as Rook that will be written up when necessary. They all inherit from piece, hence my original idea. occupying piece cannot just be Piece if that makes sense

open vine
thorn holly
open vine
#

!code

eternal falconBOT
open vine
thorn holly
teal viper
open vine
teal viper
#

Share the code where rotation happens

#

velocity is totally fine as you have it now

thorn holly
#

Oh I didn’t notice it was moving fine when not rotating

teal viper
open vine
#

ah yeah it only starts jittering when both are happenign

teal viper
#

What is the structure in your hierarchy and where is the RotateCamera method implemented?

open vine
teal viper
#

Donno where you heard it, but it's totally unrelated.

#

Where is the rb?

open vine
#

rb is on the player empty

teal viper
#

And the camera controller is on the same object?

open vine
#

i think ur right about the breaking on rotating the player. up and down camera movement has no jittering only side movement

#

no camera controller is on the camera child

teal viper
#

Do you have interpolation enabled on the rb?

open vine
#

yeah I have the Interpolate option in the Interpolate field

teal viper
#

Hmm... That's weird. If the camera controller is a child, it shouldn't affect the rb.

#

Aaa

open vine
#

the line that seems to be affecting it is transform.parent.Rotate(Vector3.up * mouseX);

teal viper
#

Yeah, I didn't notice that you're rotating the parent.

#

Why not just rotate the child itself?

#

At this point it's not really rotating the camera, but the character itself.

open vine
#

yeah i have it this way so that the player moves in the direction of the camera, is this a bad way of doing it?

teal viper
#

It is from many perspectives, but mainly because it breaks the interpolation.

#

Ideally, you want to rotate the character in it's own script using physics.

#

The vertical camera rotation can stay in the camera controller.

open vine
#

would making the camera do the rotation and in the player movement script setting the horizontal rotation equal to the child object work?

shrewd swift
#

hello
so i have a NullReferenceException, but after mutliple check i cannot see why
all 3 Cameras are enabled

queen adder
#

is there a place to go for help? I downloaded this asset, imported it and tested it, but how do I edit it? I don't see any code or anything on the top left of unity. I have previous coding experience in other languages, and learn quickly, but just wanted to get into editing something right away. I can't see anything on the Scene, or Game tabs, but if I build it, you can play it.

teal viper
open vine
teal viper
shrewd swift
#

wait, i need to init it right ? when declaring

#

im not used to c# dicts

teal viper
teal viper
shrewd swift
#

okay im dumb adding = new Dictionary<CameraSwitcherCameras, Camera>() was the solution
i though this was only to init the dict with some pre values

#

ty

teal viper
eternal falconBOT
#

:teacher: Unity Learn ↗

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

teal viper
queen adder
#

Im not sure why this error is happening? It says "NullReferenceException: Object reference not set to an instance of an object trampleDetect.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Scripts/trampleDetect.cs:18)

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

public class trampleDetect : MonoBehaviour
{
    public ScoreScript score;
    public growScrip grown;

    

    void Start() {
        score = GameObject.FindGameObjectWithTag("Logic").GetComponent<ScoreScript>();
    }


    private void OnTriggerEnter2D(Collider2D other) {
        Destroy(gameObject);
        if(grown.isGrown) {
            score.addScore();
        }
        else {
            score.removeScore();
        }
    }
}
north kiln
#

and what is line 18

queen adder
#

line 18 is the defining of the score variable

teal viper
#

This??
public ScoreScript score;

queen adder
#

no wait

#

its actually the if(grown.isGrown) {

north kiln
#

Then grown is null

queen adder
#

but i thought i defined it to be the growScript at the start?

north kiln
#

No, you declared a reference to an instance at the start

#

you have to assign the instance

serene barn
#

I have no idea what to do

teal viper
queen adder
#

but when i try to assign it in the inspector it doesnt show it as an option

teal viper
#

Declaration just says "something of this type might exist at some point"

north kiln
#

have you added that script to an object?

queen adder
#

i see

#

That script and the grow script are on the same prefab

serene barn
#

anyone go ideas how i can learn coding ive completed a tutorial but still have no idea what i'm doing

queen adder
teal viper
serene barn
serene barn
queen adder
#

Are you following the tutorial line for line writing the exact same thing they are?

teal viper
serene barn
teal viper
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

queen adder
#

and i never recommend doing something exactly the same line by line

#

Thats just replicating not actually learning

serene barn
#

i dont like unity learn

queen adder
#

is it the tutorial by GMTK?

teal viper
#

But that wouldn't really teach to work with unity. Just coding in C#.

slender nymph
#

are you perhaps trying to drag a scene object into a prefab?

queen adder
#

yes

queen adder
#

yeah i forgot i cant do that

#

but then i dont know what to put in those options because teh Grown script is inside the same prefab

serene barn
#

well im gonna take a small break as my head feels like it's gonna explode

north kiln
queen adder
#

All im trying to do is read true or false value from a boolean of another script, so how do i create an initialization instead of an declaration to it

vestal gazelle
# serene barn i dont like unity learn

If you want to learn, the way im doing it is,
I copied almost line for line this guys 3d controller. I then looked at what i typed and tryed to understand what each part does. Not just each line but each word in each line. If i couldnt figure out what something did i just looked up "unity localEulerAngle.y" and that took me to a manual that explained the little thing i didnt understand.

Also first time i tried learning unity i got overwhelmed, and didn't touch it for a year. When i came back i felt more comfortable so i do recommend maybe taking a small break (not recommending a year but still)

teal viper
vestal gazelle
#

Most of the real learning happened when i started when i started trying to apply what i figured out to my own project

vestal gazelle
serene barn
vestal gazelle
#

The other 10% is still needed but

#

What did you write a script for?

serene barn
vestal gazelle
#

What do you want to code?

serene barn
#

2d game

vestal gazelle
#

Can i have something specific

#

This is gonna have a player right?

serene barn
#

ye its like a dungeon loot and shooter

vestal gazelle
#

So top down?

serene barn
#

ye

queen adder
#

it worked, thank you dlitch and vertex

#

then start small Mix

serene barn
#

my brain restorted to short words right now

queen adder
#

Create a script on moving a character using input

vestal gazelle
#

Fluid movement or attached to a grid?

queen adder
#

Is it even a tilemap based game?

serene barn
#

ye that is what im trying to do but even the movement is confusing, its either i do input.axisraw or inputaxis, or input key

serene barn
queen adder
#

do you want to addvelocity to an object or transform it?

#

assuming its not tilemap?

serene barn
teal viper
serene barn
#

how do u transform velocity?

#

i get add velocity but transforming it

queen adder
#

no

#

Transforming a rigidbody's X and Y coords

#

transform as in move along x and y axis

teal viper
#

You mean "translate"?

queen adder
#

ah yea sorry

#

regardless

#

taking input from a player is something youll have to decide

serene barn
#

ye im still lostnotlikethis

queen adder
#

and there are tutorials for everything out there, you just need to be able to translate something they're doing for their project into your own

teal viper
queen adder
#

Lets take this tutorial for example https://youtu.be/XtQMytORBmM?si=Tk-vyjN2l9hplspC

GMTK is powered by Patreon - https://www.patreon.com/GameMakersToolkit

Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then give you some goals to learn ...

▶ Play video
#

In my own game

#

I have a UI in which i need to add score based on collecting something right?

#

However he's giving a tutorial on how to add score based on going through pipes

#

However how you do it is whats important not what youre doing it for

amber spruce
#

hey so im using the new input system and i have a slight problem when i start to sprint it doesnt change my speed properly because it doesnt redo move1 it only sets the speed correct when you press a or d again ```csharp
private void FixedUpdate()
{
m_Rigidbody2D.velocityX = moveAmount.x;
}
public void Move1(InputAction.CallbackContext ctx)
{
Vector2 inputVector = ctx.ReadValue<Vector2>();
moveAmount = ctx.ReadValue<Vector2>() * m_Speed;
Vector2 currentSpeed = ctx.ReadValue<Vector2>() * m_Speed;
float currentspeed1 = currentSpeed.x;
animator.SetFloat("Speed", Mathf.Abs(currentspeed1));
if (currentspeed1 > 0 && !m_FacingRight)
{
Flip();
}
else if (currentspeed1 < 0 && m_FacingRight)
{
Flip();
}
}

public void Sprint(InputAction.CallbackContext ctx)
{
if (ctx.started)
{
m_Speed = m_SprintSpeed;
}
else if (ctx.canceled)
{
m_Speed = m_OriginalSpeed;
}
}

slender nymph
#

instead of multiplying by m_Speed inside of Move1, do it in FixedUpdate

amber spruce
#

ah ok that makes sense thanks

vestal adder
#

thanks 😎

#

do you also perhaps know why it isnt shooting in a straight line

#

right now it shoots in a curve

rich adder
vestal adder
#

wait nevermind dawg it was easy

#

i just had gravity on the rigibody

final trellis
#

If i had a string such as 1d20 + 4, how would i seperate it into the appropriate variables of rollMin, rollMax and rollMod, and have it be compatible with potential input variations such as 1d20+4, 1 d 20 + 4 and 1d20 - 4

#

I know i can use the String.Split() method but im not sure about the modifier part

timber tide
#

why strings tho

final trellis
#

because its a user input thing

#

sure i could have seperate text boxes for each

#

but its a lot faster for a user to type in 1d20 + 4 than typing 1, 20 and +4 all in seperate text boxes

timber tide
#

well, two ways I'd parse it. The smart way would be regex, otherwise split search parsing by numerical, alpha, ect

final trellis
#

the hell is a regex

#

that sounds important

timber tide
#

regular expressions, usually useful for longer strings

final trellis
timber tide
#

pattern matching stuff, otherwise manual splitting like above

final trellis
#

because my problem with just using normal split is if the user formats it like 1d20+4, then i cant seperate the max from the modifier while preserving the sign of the modifier

#

i could still do that, and then preserve the original string so I can then search for a + or - in it anywhere

#

but it sounds like a really clunky way to do it

timber tide
#

well, there's obvious matching here so splitting it up into 3 different variables is just a matter of linear appending values until you hit values not numerical

final trellis
#

or i could use regex split bc actually, looking into it

#

I can split on plus and minus signs but preserve them in the output string

timber tide
#

right, usually the best idea especially if you're adding more complex string elements

final trellis
#

the real trouble i think is gonna be my worst enemy

#

input validation

timber tide
#

but if your requirements are small enough I usually just lazy it up and do linear string appending ;)

final trellis
#

true but the more i read on regex the more i feel like its a valuable thing to learn how to use

#

im surprised i havent heard of regex before so thanks for introducing me to it now rather than later lol

timber tide
#

ye, usually used in games to filter out the* 9 hundred variations of a single curse word

swift crag
#

This should be pretty straightforward with a regex

#

(\d+)d(\d+)\s*[+-]\s*(\d+) matches anything like XdY + Z or XdY - Z, and (\d+)d(\d+) matches anything of the form XdY

#

they would grab X/Y/Z into capture groups 1, 2, and 3

#

If I wanted to do anything more complex I might just write a parser

#

oops, i pasted garbage into the Text field

final trellis
swift crag
#

for that I'd need more whitespace symbols!

#

I updated the link

#

As long as it's just one die plus a constant, you could get rid of the whitespace

#

but if you want to parse, say

#

1d6 + 2d5 + 2d4 + 5

#

actually, that'd still be fine. there are symbols in between each thing!

#

1d6+2d5+2d4+5

#

in that case, I would first chunk it up with a regex

#

then parse each entry

#

in that case, I would use ([^+-]+) to match a chunk of text that contains no + or - symbols. That would chunk out 1d6, 2d5, 2d4, and 5 (with extra whitespace). Trim the whitespace and then handle each one individually

final trellis
#

hmmm, if im giving the option to have more than 1 sided "dice" be rolled, I should probably modify the expression to preserve the d so the thing that eats the string knows what is another dice and what is just a modifier, also i should preserve the + and -

swift crag
#

[^+-]: any character that isn't + or -

swift crag
#

[^+-]+: at least one character that isn't + or - in a row

#

you can drop the parentheses; you'd just ask to find every matching substring

swift crag
#

getting smaller pieces out of a single match

#

another valid option would be to just go one character at a time

final trellis
#

my brain is being fried with these wacky words

swift crag
#

regexes are a lot :p

swift crag
#

still non-trivial if you've never written anything like that before, though

final trellis
#

pain

swift crag
#

i'd start by just handling XdY + Z

#

delete all whitespace to crunch it down to XdY+Z, so that spaces don't matter

#

you can use myString.Replace(" ", "") to get a new string with no whitespace

#

split it with "+-d". if you get 2 results, it's XdY. if you get 3 results, it's XdY+Z or XdY-Z

#

if you got 3 results, check if the string contains +

#

if it doesn't, try -

#

if you got anything else, or it doesn't contain + or - despite splitting into 3 strings, or any of the split strings don't parse into ints, then display an error

final trellis
swift crag
#

Regular string split

#

no regex here

#

You can pass a string with several characters in it to split with any of them

#

oh wait, I am wrong! you actually pass an array of strings. my bad

#
var results = "2d6+1".Split(new char[] { 'd', '+', '-' });
#

or an array of single characters

#

might as well do that

#
var results = "2d6+1".Split('d', '+', '-');
#

you may also just write it like this.

#

that's easier to read

#

god the String.Split doc page is so long

queen adder
#

    IEnumerable loghotdogs() 
    {
        Debug.LogError("it1log");
        yield return new WaitForSeconds(2);
        Debug.LogError("itlog");
    }```my worst coroutine so far, was wondering why it's not working
swift crag
north kiln
queen adder
swift crag
#

you need to tell us what's actually happening

#

are both LogError methods running simultaneously?

queen adder
#

it's using IEnumerable instead of -rator

#

and no error, but it doesnt do what it's intended

swift crag
#

IEnumerable is something that can give you an enumerator

queen adder
#

took me like days til i realized the messed up

north kiln
#

Do you start coroutines via string notlikethis

swift crag
#

yes, that's a compile error if you actually pass loghotdogs() to StartCoroutine

queen adder
swift crag
#

ah

#

IEnumerator can yield literally anything

queen adder
#

no error

swift crag
#

hence why you didn't get a compile error

north kiln
#

I'm surprised it even runs at all

swift crag
#

and I imagine Unity just looked at that IEnumerable and thought "idk, whatever"

#

you can yield anything you want

queen adder
swift crag
#

most things do nothing

#

like yield return 1000

queen adder
#

it was supposed to stop/slow things

swift crag
#

or yield return "potato";

north kiln
#

oh you're yielding it directly

#

that wouldn't even work fully if it was a coroutine with multiple yields

swift crag
#

non-generic collections my unbeloved

swift crag
#

oops, wrong reply

north kiln
#

you should yield StartCoroutine(...)

#

So if the coroutine actually had multiple yields then it would actually correctly wait for them

ruby ember
#

so im making a new scene of the project im making i want to add a system to like you press the arrow it rotates left and right but i want it when i hold it it rotates but i don't know if is possible in unity

final trellis
queen adder
final trellis
#

also just to be sure, I can do a foreach loop for chars in a string right?

#

also lord java and C# being so similar makes their differences so jarring

queen adder
#

yea that works

#

get enumerator on an ienumerable member

final trellis
#

Im in a college course that involves java, so im used to typing String instead of string now 😭

swift crag
north kiln
#

is it silly 🤔

swift crag
north kiln
#

it yields the IEnumerable

#

which gets passed to Unity, and Unity does shit all with it

swift crag
#

right, I mean an IEnumerator, not the incorrect IEnumerable

#

yield return StartCoroutine(BogusMethod()) would be a compile error

#

which would be nice for catching that

gilded pumice
#

Is it bad that I referred to my pregnant wife as a parent object and my unborn child as a child object?

north kiln
queen adder
#

is it legal and/or possible to decompile unity api, I wanna know how they implemented Mathf.Pow

north kiln
#
public static float Pow(float f, float p) { return (float)Math.Pow(f, p); }
queen adder
#

where from? 🥹

north kiln
#

You know that the Unity CS Reference exists

queen adder
#

does that have all?

north kiln
#

I am fairly sure this has been mentioned around you multiple times lol

#

It has whatever is declared in C#

#

because it is the C# reference (CSReference)

queen adder
#

oh, i thought it's just the source that has already been translated

north kiln
#

translated?

queen adder
#

fwom c++ to c# :3

north kiln
#

It is the source code of the C# portion of the engine

#

the C++ portion is closed source

teal viper
#

unless you pay some mony

queen adder
#

hmm, is getcomponent implemented in c++? I cant find anything related to it in c# ref

north kiln
#

If you see extern that is a call to C++

queen adder
north kiln
#

The github search isn't that good, it's best to download it and use your IDE

queen adder
#

think I found it, yea it's c++ 🥹

round scaffold
violet lagoon
#
    private string mSaveDataPath = "saveData.json";
    string fullPath;

    private void Awake()
    {

        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        mPersistentDataPath = Application.persistentDataPath;

        fullPath = Path.Combine(mPersistentDataPath, mSaveDataPath);


        if (File.Exists(fullPath))
        {
            LoadGame();
        }
        else
        {
            Debug.Log("No save data found in " + fullPath);
        }
    }

    public void SaveGame()
    {
        Debug.Log("We are saving the game in path " + fullPath);
        // we write the file will not include in discord
        string json = JsonUtility.ToJson(saveData);
        //File.WriteAllText(fullPath, json);
        StartCoroutine(SaveGameUsingWWW(json));
    }

    private IEnumerator SaveGameUsingWWW(string json)
    {

        // Use UnityWebRequest to save the data
        using (UnityWebRequest www = UnityWebRequest.Put(fullPath, json))
        {
            yield return www.SendWebRequest();

            if (www.result != UnityWebRequest.Result.Success)
            {
                Debug.LogError("Failed to save game data: " + www.error);
            }
            else
            {
                Debug.Log("Game saved successfully.");
            }
        }
    }```

I dont understand why my path is not found and returning Failed to save game data: HTTP/1.1 404 Not Found when the idbfs/Game is in my storage in F12 in firefox
Can someone help please?
steep shoal
#

https://gdl.space/iqagavilar.cs

Is there way to load my scenes using the same end level script for each level without copy pasting and putting in the new scene name each time? I just need a name of a function/functionality if there is. I can figure out how to use.

cosmic dagger
steep shoal
#

Got it thanks

shrewd hare
#
// the mesh is a grid
// size is the size of that grid
Texture2D texture = new Texture2D(size, size);
Color[] colorMap = new Color[size * size];
...
texture.filterMode = FilterMode.Point;
texture.SetPixels(colorMap);
texture.Apply();

MeshRenderer meshRenderer = gameObject.GetComponent<MeshRenderer>();
meshRenderer.material = terrainMaterial;
meshRenderer.material.mainTexture = texture;

what's wrong with my code? the material is not being applied to the mesh correctly

#

got it. i didn't put the UVs in the mesh

uncut hornet
#

I dont understand this error with this code because im using things i see on the official documentation

gaunt ice
#

why you name the variable as the name of built in class

uncut hornet
#

oh i diddnt know

#

literally day 2 man

#

im so stupid i just looked at it again

gaunt ice
#

avoid using the name of built in classes as your class name/variable name

uncut hornet
#

and yeah i have another error i was about to address

gaunt ice
#

if(A=B){
}

#

also please dont use == operator for checking float, instead use Mathf.approximately
and you probably looking for getaxis raw (in this case using == is safe)

uncut hornet
#

i feel like the input manager should be easier to understand than this so what do you mean by that

#

negative button is A
Positive button is D

#

simple enough??

gaunt ice
#

getting input has nothing to do on how you compare two floats
btw did you notice that you type = (assignment) instead of == (logical and) in the two if statements?

uncut hornet
#

ok the == fixed it i looked over that. thank you

gaunt ice
#

getaxis returns float in range from -1 to 1, so you probably want to check if the returned value < 0

uncut hornet
#

yeah i did that

north kiln
# uncut hornet

If your IDE is not underlining errors in red you need to configure it !ide

eternal falconBOT
queen adder
ivory bobcat
deft salmon
#

hello everyone. i need help to fix a playermovement skript. dm me please . thanks

queen adder
ivory bobcat
eternal falconBOT
deft salmon
#

hello everyone. i need help to fix a playermovement skript. it all works ,its just that when i look down 1. i dont move and 2. i cant jump. i have tried putting my camera movement to my main camera, but when i move i only move in a locked path.(the degault path of unity forward back side to side. i want my movement to follow my main camera.

eternal falconBOT
wild cargo
#

Wrap your code in backquotes `` or like in this case, paste it in a !code website because it is quite long

eternal falconBOT
wild cargo
#

This will help us help you

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

public class PlayerMovement : MonoBehaviour
{

   public CharacterController controller;
 
    public float speed = 12f;
    public float gravity = -9.81f * 2;
    public float jumpHeight = 3f;
 
    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;
 
    Vector3 velocity;
 
    bool isGrounded;
 
    // Update is called once per frame
    void Update()
    {
        //checking if we hit the ground to reset our falling velocity, otherwise we will fall faster the next time
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
 
        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }
 
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");
 
        //right is the red Axis, foward is the blue axis
        Vector3 move = transform.right * x + transform.forward * z;
 
        controller.Move(move * speed * Time.deltaTime);
 
        //check if the player is on the ground so he can jump
        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            //the equation for jumping
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }
 
        velocity.y += gravity * Time.deltaTime;
 
        controller.Move(velocity * Time.deltaTime);
    }

}
#

like that

wild cargo
#

Well, I said put it in a website but whatever

#

Also delete that previous code message for less clutter

woven crater
#

i have two ui in a canvas that i can only set the "order in layer" on the canvas gameobject but i want a gameobject sprite to render between the two ui in the canvas

#

do i need another canvas or something?

wild cargo
deft salmon
#

how would i add it in the code

wild cargo
#

Actually, does your rotation script rotate the player transform automatically? I suppose it does so then that "fix" I proposed would just create more bugs

woven crater
#

do i need all ui to be on screenspace camera to do stuff like screen transition effect?

buoyant prawn
#

still very new to coding, I have a text mesh that I want to change if a specific public variable changes, how do I script that? (or if someone could point me to a page that explains the concepts)

gaunt ice
#

create a property (getter setter) that changes the textmeshpro at once when you change the variable

private int a;
public int A{
  set{
    a=value;
    theText.text=a.ToString();
  }
}
buoyant prawn
#

basically its an HP bar and Its normally set to 5 and i want the text on my UI to change if that variable that is 5 to change

eternal needle
buoyant prawn
#

i think I understand until the

#
theText.text=a.ToString();
violet falcon
#

Hello i installed a package on my unity project and it update somne packages and it broke some of my codes what i should do

languid spire
north kiln
#

and that is the reason nothing works

violet falcon
north kiln
#

Search for it; I have no idea, it's your project

#

My guess would be you made the class

ionic galleon
#

hello everyone

#

How can i debug object names in triggers particle system unity

buoyant prawn
ionic galleon
#

I have code like this but I can't get the object name. If I use collision, the particle will have an error. It will be thrown away a lot. I don't want that to happen.

north kiln
#

What do you expect to see? Particles don't have names, the only thing that has a name in this scenario is the object that emits them

static cedar
#

Oh, never knew that's a thing.

deft salmon
#

anyone know the color theme that most YTbers use

#

for visual code studios

north kiln
#

no

ionic galleon
static cedar
#

I'm pretty sure most people use Visual Studio or Rider when programming in unity.

north kiln
static cedar
#

I heard there's one guy here in notepad. And a handful only on VSC.

ionic galleon
#

that right ?

north kiln
#

A box, spheres, whatever. Yes, that's the most common way to do it

languid spire
#

because you do not start Coroutines like that

silent idol
#

WAIT

ionic galleon
#

If you do it like that, it's okay, but it takes a bit of time to set up and another thing is that if you change the scale particle, you also have to change its size box.

silent idol
#

I FORGOT TO START MY COROUTINE

#

FUCK

#

ugh looking at it in fanci colors

#

and i realize i forgot to start it

#

rip

queen adder
buoyant prawn
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Health : MonoBehaviour
public TextMeshProUGUI playerHealth;
{
   public string playerHealth = "5";
   private int a;
   public int A{
       set{
           a=value;
           playerHealth.text=a.ToString();
           
       }
   }
    
    
}
#

so I dont think im referancing my textmesh properly, Does anyone know how to

languid spire
#

missing a using for TMPro;

short hazel
#

And it's outside the class

buoyant prawn
short hazel
#

Stuff must be in the {}

languid spire
#

look at you code, you already have using statements

eternal needle
#

this would surely give you errors, you should configure your !ide

eternal falconBOT
buoyant prawn
gaunt ice
#

pick an ide you like and switch to it now

static cedar
#

To think there is one rn. notlikethis

eternal needle
static cedar
#

He got quite far surprisingly to be using TMP.

#

🍵

buoyant prawn
eternal needle
#

there are even written lessons online

static cedar
#

Actual basic C# tutorials should let you give space for it.

buoyant prawn
#

also I jsut use np+ cuz i used to use it to edit stuff for minecraft mods and its just the default on my pc

twilit pilot
buoyant prawn
twilit pilot
static cedar
#

I'm hoping you at least make rock paper scissors, or a number guesser, just something simple that most tutorials would ask you to do.

#

Not in unity.

buoyant prawn
#

im sorry, i have been trying to do learn as effectively as I can, I came here bc its way easier to be able to ask people questions when I cant find a specific tutorial for something

#

sorry to bother you all

twilit pilot
#

It's not about bothering anyone, it's about what is best for your own education. When you are a complete beginner it's probably better to follow a complete introduction that will establish the ground rules and give you a proper foundation to build from

buoyant prawn
#

I have followed several, I genuinely cant learn something unless I can ask questions and i cannot ask a youtube video questions

#

I tried it that way now im trying here

eternal needle
buoyant prawn
deft salmon
#

anyone got a simple playermovement and camera movement skript for a basic start for a character

languid spire
deft salmon
#

oh ok

#

ty

deft salmon
languid spire
woven crater
#

can i use a collider (not trigger) to detect a gameobject with trigger collider?

woven crater
#

yeah i have this on a game object with a collider. but its seem to use the trigger collider from it child game object instead

rare basin
#

OnTriggreEnter wont be called

#

if your collider is not isTrigger

#

also !code

eternal falconBOT
rare basin
#

i've told you how to share code like 10 times

#

this month

#

cmon man

woven crater
#

sorry. i thought its just that

#

nah im pretty sure its just that.

#

so i cant use OntriggerEnter2D on a non trigger collider

but OnColliderEnter2D seem like it not detect gameobject with istrigger collider

#

i guess imma make another game object with trigger collider and make its the child then

rare basin
#

there is no such callback

#

as OnColliderEnter2D

woven crater
#

"OnCollisionEnter2D" my bad

rare basin
#

OnColliderEnter2D seem like it not detect gameobject with istrigger collider

#

did you read the docs about OnCollisionEnter2D?