#💻┃code-beginner

1 messages · Page 704 of 1

native seal
#

and the object can always access it aswell

cosmic dagger
#

Curious, why are you creating an instance of an SO (with ``Singleton.Create`)? You may as well use a C# object . . .

native seal
willow iron
#

can raycasts detect an item if the origin is inside that very item? for example, i place a empty transform inside a cube with a cube collider, and then point the raycast outside of the cube starting from the empty transform, would it detect the cube?

shell sorrel
#

so if it originated inside a collider and cast out, i do not think that is a hit.

#

but to be sure i would just make a test case, would not take more then 5 mins to setup and test

wintry quarry
dull grail
#

Is it possible to get data of an object dragged by player? I want to see if item which was dropped to inventory slot is the same as the item already placed in there. I use drag handling interfaces to drag it

native seal
#

you can use eventData.pointerDrag.GetComponent

dull grail
#

Thank you

odd holly
#

How do I do that in code…?

#

Like I think I understand

#

But I also just don’t

chilly vigil
#

using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;

public class GameMaster : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{

}

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

public void StartGame()
{
    SceneManager.LoadScene("HammerStaff");
}

}
i am following rpg book for unity 5

eternal falconBOT
chilly vigil
#

and when i assign the Onclick() methord the load scene don't pop up

odd holly
#

ngl I have literally no idea what this means

chilly vigil
odd holly
chilly vigil
odd holly
#

oh then Im not sure

teal viper
chilly vigil
#

nothing is appearing in the console

teal viper
chilly vigil
#

what did i forget to call in my code, becuase i have it as " SceneManager.LoadScene("Hammerstaff");"

teal viper
odd holly
#

Is it possible to make an enemy that literally have like barely any at and just runs straight at you?

odd holly
#

Because every single tutorial I’ve found has had ‘Patrolling, Attacking, Wandering, fighting’ but I literally just want it to run at me and do contact damage

teal viper
willow iron
#
            ItemNumber itemNumber = item.GetComponent<ItemNumber>();
            Debug.Log(itemNumber);
            itemNumber.SetDestination(speed, nextBelt.targetlocation, this);```

so I have the above lines of code. Inside itemNumber i have the method SetDestination

``` public void SetDestination(float newspeed, Transform newtarget, Belt newcurrentBelt)
    {
        Debug.Log(newspeed+ " " + newtarget +" "+newcurrentBelt);
        currentBelt = newcurrentBelt;
        speed = newspeed;
        target = newtarget;
    }```

upon running the code this is what the console looks like (attached picture)

i just dont understand why everything seems to be working correctly except for the ItemNumber script
#

the errors claim that there is a "Object reference not set to an instance of an object" error when i call SetDestination, but it identifies itemNumber when i use debug.log

rough granite
#

where it should log the name of the object which im also 90% sure you didn't name object

#

oh wait nvm, i cant read 😭

#

can you provide more code?

odd holly
thick saddle
#

hey I have a script that requires me to assign a tilemap in the inspector but for some reason it's not accepting the tilemap that I have

#

I even tried making a new tilemap and it wouldn't assign

ivory bobcat
#

Assuming the error is on that line - error wasn't presented yet.

ivory bobcat
thick saddle
#
using UnityEngine.Tilemaps;

public class RoomLock : MonoBehaviour
{
    public Tilemap wallTilemap;
    public Tile lockTile;
    public Vector3Int[] exitPositions;

    private bool isLocked = false;

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player") && !isLocked)
        {
            LockRoom();
        }
    }

    void LockRoom()
    {
        foreach (var pos in exitPositions)
        {
            wallTilemap.SetTile(pos, lockTile);
        }
        isLocked = true;
    }

    
    public void UnlockRoom()
    {
        foreach (var pos in exitPositions)
        {
            wallTilemap.SetTile(pos, null);
        }
    }
}
thick saddle
#

and I'm trying to connect this puppy to it

polar acorn
# thick saddle

That is a default asset reference, it can't load anything that exists in the scene, it needs to be an asset.

You probably don't even need to assign a default just assign it on the instance you're actually using

thick saddle
polar acorn
thick saddle
gray rivet
#

This is my player and the camera is connected to the player so it follows it. But when the player rotates the camera follows and its really wonky, how do i fix this

#

this is what i mean btw

eager spindle
gray rivet
#

i think i know how to

#

ill try my idea and ill see what goes wrong

#

Would i say smth like
Transform.Position (PlayerPositionX - 30, PlayerPositionY + 30, PlayerpositionZ)

thats very crappy but smth like that

gray rivet
eager spindle
#

🎊

gray rivet
#

but would i need to make the transform of the player to public

eager spindle
#

You'll need a reference to the player's transform, yes. Whether you make it public is up to you, there's a few ways to do it.
Assuming you have a CameraController script attached to Player Camera, you can have a public Transform variable that will act as your camera's target. You can then set the camera's position to the targets position minus a number, like what you talked about earlier

gray rivet
#

Ive done it

#

is this what you mean

eager spindle
#

Yep

gray rivet
#

easy peasy

rare widget
#

"Hello, I’m trying to use the Endless Runner - Sample Game in Unity 6, but I’m getting the following warning. Does anyone know how to fix this issue?"

There can be only one active Event System.
UnityEngine.EventSystems.EventSystem:OnEnable () (at ./Library/PackageCache/com.unity.ugui@57cef44123c7/Runtime/UGUI/EventSystem/EventSystem.cs:462)

There are 2 event systems in the scene. Please ensure there is always exactly one event system in the scene
UnityEngine.EventSystems.EventSystem:Update () (at ./Library/PackageCache/com.unity.ugui@57cef44123c7/Runtime/UGUI/EventSystem/EventSystem.cs:557)

eager spindle
#

You'll want to remove the EventSystem from one of them

karmic valley
#

Can someone help me try to fix a bug in my code

#

When caught fish is true, and the colliders are hitting, then it should trigger the sell fish thing

#

And the money should go up and the fish should be destroyed

#

But the money isnt going up

#

and the fish isnt being destroyed

strong wren
karmic valley
#

wdym logged?

strong wren
#

Does it appear in the console

karmic valley
#

Sold fish isnt a variable

#

I just make the money counter go up and the fish is destroyed

strong wren
#

Talking about Debug.Log("sold fish");

karmic valley
#

Oh let me check

#

nope

#

one of the colliders has to be a trigger right?

#

I have one sphere collider and one box collider

strong wren
#

Yes. I would make sure the trigger is working by adding a log at the beginning of MerchantAndUpgrades OnTriggerStay. I would also print something about the other collider to see what sort of things are triggering it.

karmic valley
#

ok

karmic valley
#

It doenst print anything to log

#

why does the shop have a sphere collider

strong wren
fickle wagon
#

Hi, I am saving and loading time using PlayerPrefs, and getting time difference between current time and saved time but it can be tweked with changing the divice time and date, so is there any way which prevent users to do such things?

keen dew
#

no

little meteor
eternal needle
#

oh mb i didn't process that Thom said the same thing essentially

fickle wagon
#

@eternal needle Okay so there are no other options available without internet connections

eternal needle
short path
#

can anyone know how I assign material via code it it's have multiple elements

ruby python
#

And I would also look into using encoded json for storing the data as opposed to playerprefs.

short path
grand snow
#

you must assign it back for changes to take affect

short path
#

okay

eternal needle
ruby python
#

It was a very quick google search that brough up a StackOverflow post. Like I said, very very quick search.

https://stackoverflow.com/questions/43862205/how-to-get-real-date-time-even-user-changes-system-date-in-c-sharp-windows-app

naive pawn
#

the ever-faithful school computer drained cmos battery:

frail hawk
#

relying on anything that is localy accesible is the risk, so as it was mentioned savest way is to get the time from a remote location

naive pawn
#

also, timezone changes are a thing

grand snow
#

ugh timezones

naive pawn
#

also, leap seconds are a thing

grand snow
#

Living in the UK actually makes this worse because I cant tell the difference from utc and my local time most of the year 😆

naive pawn
ruby python
#

GMT - UTC
BST = UTC + 1

grand snow
#

yea non summer time is gmt/utc +-0

ruby python
#

It's great when all your clients are in different countries. lol.

naive pawn
#

gmt/wet = UTC±0
bst/west = UTC+1

#

beautiful naming

grand snow
#

greenwich mean time kinda makes sense for the origins of it

#

anyway c# date time is nice so i dont usually have trouble with date and time

naive pawn
#

i'd like to imagine yall accidentally write timezone-dependant code and don't realize it until it breaks 5 months later when you suddenly aren't at Z time anymore

gray rivet
grand snow
naive pawn
#

2025-08-01T12:00:00Z is the same time everywhere in the world
2025-08-01T12:00:00 is not

grand snow
#

unix time is where its at

#

tis how I store time always

naive pawn
#

zulu time my beloved

zealous flare
#

Hi, How do you play a video then transition into a scene ?

ivory bobcat
#

What have you tried so far? There should be plenty of tutorials doing both.

tiny bloom
#

If I have a game object with rigidbody called rotator
inside there are children

I rotate rotator, but I want the children to hold their rotation
meaning they stay facing upwards while moving to accomodate the rotation of rotator
how to fix that?

frail hawk
sour fulcrum
#

this is the right place for them to be tho

hexed terrace
#

not really, they're just asking vague questions which has been crossposted

hexed terrace
ruby python
tiny bloom
tiny bloom
hexed terrace
#

world up or screen up

#

pretty sure if you're rotating on Z, everything would just rotate around and still be facing the screen

ruby python
#

If your objects are children, they will always follow the parent rotation unless you tell it specifically otherwise. Unless there's something I don't know. lol.

hexed terrace
#

make sure you're not rotating on X

tiny bloom
tiny bloom
sour fulcrum
ruby python
tiny bloom
#

im doing fixedUpdate cuz everything is rigidBody

hexed terrace
#

show us a video of the issue and your !code

eternal falconBOT
ruby python
#

Try it, and see if it works. I really can't think of another way.

#

Do you child objects have rigidbodies?

bronze rock
#

how do i change background like in level 12 background changes in level 13 it changes again how to do that?

tiny bloom
# ruby python Do you child objects have rigidbodies?

yea
so far i did this in child objects and it works, it's a bit glitchy so i think if i move it in update it will be better
but im not sure about performance xD

private void FixedUpdate()
{
    transform.rotation = Quaternion.identity;
}
ruby python
frail hawk
ruby python
#

Ah okay. Then yeah, move that line into Update. I don't think it will have a massive amount of a performance hit tbh.

#

And they may not need rigidbodies#

ruby python
#

Depending on what they need to do.

tiny bloom
naive pawn
night raptor
#

@tiny bloom If you don't mind, could you show us what you are actually trying to do?

ruby python
#

Right okay, yeah they won't need a rigid body each iirc. The rigidbody of the parent object should govern their collisions.

night raptor
#

But they kind of do if they need to rotate in relation to the parent

dull wind
#

Did anyone know how to make like the cartoon effect ?

naive pawn
#

you're going to have to be more specific, also this is the code channel

tiny bloom
#

here's the script, it's attached on my player
don't worry about WeaponBase as it's just starting the coroutine

https://paste.mod.gg/dlwqkaiswlly/0

_projectile is a script of type ProjectileV2 ,and there i only have the following in Update:

private void Update()
{
    transform.rotation = Quaternion.identity;
}
naive pawn
#

this entire thing should probably just be part of the prefab

    GameObject rotator = new GameObject("Rotator");
    rotator.transform.SetParent(transform);
    rotator.transform.localPosition = Vector3.zero;

    var rb = rotator.AddComponent<Rigidbody2D>();
    rb.bodyType = RigidbodyType2D.Kinematic;
    rb.interpolation = RigidbodyInterpolation2D.Interpolate;
    _rotator.SetActive(false);
dull wind
#

Well when I import my object it's completely white (colourless), I send it from blender to my project in unity but idk why is it like that, I think it's because the colours are in emission but idk how to fix it

tiny bloom
naive pawn
#

yes, im saying to make it a prefab

tiny bloom
azure hemlock
#

where is the advanced code

#

is the channel deleted

naive pawn
bronze rock
#

how to add a animation to ui like sliding to right

silk night
median mortar
#

Hey guys, I'm trying to limit the rotation of a transform that is rotated on x-axis by world space and y-axis by self-space. When printing the eulerangles of the object, I'm only getting angles between 0-90 and 90-0 when exceeding 90°, while Z-Axis flips from 0 to 180. However I don't know why this happens and I can't read the actual value unity editor shows me of the object.

private void OnDivingState(ref Vector3 currentVelocity, float deltaTime)
{
    Vector3 inputVector = player.RawInputVector;
    float XInput = inputVector.x * _config.RotationSpeedX;
    float ZInput = inputVector.z * _config.RotationSpeedY;
    _transform.Rotate(0, XInput * deltaTime, 0, Space.World);
    _transform.Rotate(ZInput * deltaTime, 0, 0, Space.Self);
    Vector3 tempRotation = _transform.rotation.eulerAngles;
    // tempRotation.x = Mathf.Clamp(tempRotation.x, 0, _config.MaxDiveAngle);
    Debug.Log("Clamped Rotation X: " + tempRotation); 
    _transform.rotation = Quaternion.Euler(tempRotation);
}
#

Any idea how I can get the value from the inspector?
Referencing the transform by Transform _transform = Meshroot, while Meshroot is a public variable that's set in the inspector.

celest ore
#

im wanting to make a 2D game where a fluid type thing fills up shapes, like an elbow curved pipe. Can anyone help me get some ideas?

silk night
celest ore
#

simple and fastest way i need

silk night
rugged beacon
#

im a bit lost with var scene = loadscene async
there these 3 things:
yield return scene;
scene.oncomplete
scene.isdone
when the async operation is done what the called order? also which one is fired after scene is fully loaded?

celest ore
#

thats it

#

the simplest animation u can imagine

#

i am struggling to create a png fluid (fake fluid) that fills up a shape

celest ore
tight iris
#

I'm reading docs and I've found out again about ContentFile https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Unity.Loading.ContentFile.html
and ContentNamespace https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Unity.Content.ContentNamespace.html
there's a example usage here: https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Unity.IO.Archive.ArchiveFileInterface.html

The question is, can a ContentFile be anything? Like a .txt, .json, a content archive, a .fbx, etc? What would be the correct usage?

celest ore
silk night
# celest ore yes

mhh if you dont have the possiblity to switch to world space canvasses I can't think of anything that doesnt involve custom shaders

silk night
#

That doesnt mean there is no solution, i just dont know any 😄

naive pawn
rugged beacon
#

bet thanks

rugged beacon
celest ore
naive pawn
#

you don't need to resize them for tiled mode

celest ore
naive pawn
#

with what

#

just try it lol

celest ore
celest ore
#

i dont know it

#

theres no tiled mode in sprite masks

naive pawn
#

yeah, that wouldn't make sense

#

the tiled mode is for the spriterenderer

silk night
celest ore
naive pawn
#

that's pretty cool tho

celest ore
#

not from one end to the another

#

am i wrong

naive pawn
#

set the pivot to the point you want it to fill from

#

so probably bottom center

silk night
naive pawn
#

sprites have pivots

silk night
#

oh my bad

#

brainfart

naive pawn
#

also, non-UI is a spriterenderer

#

UI image components also use sprites

celest ore
naive pawn
#

also, like, this is the code channel

silk night
# celest ore can u brief me about this

following:

  • Get the current pixel position on the Y axis (Green channel) from UV (-1 to 1)
  • Remap to 0 to 1
  • check if current Y position is > fill
  • if yes -> white alpha (full visible), if no -> 0 alpha (not visible)
  • revert it and subtract from normal image alpha to retain normal alpha values
naive pawn
celest ore
silk night
#

i mean was a good shader exercise, wanna get better in that anyways 😄

naive pawn
#

damn yeah i should find time to do that

celest ore
#

a pipe which is curved lets say

naive pawn
#

it wouldn't. that's what the spritemask is for

celest ore
#

Ah yes

rapid fractal
#

i have an interface 'Item', should i name that interface 'IItem' or something like 'IBaseItem'?

teal viper
hardy wing
teal viper
hardy wing
#

Like, I don't care if a class is an interface or an ABC. I just need to know it has polymorphic compatibility and that it inherits its behaviour (whether it's implemented or not).

slender nymph
polar acorn
#

It doesnt ever "matter" what you name anything, it's just avoiding potential confusion either way

slender nymph
grand snow
#

it DOES matter if its an interface or not

tiny bloom
#

Why is this square with 50% alpha rendering above the player even tho it's behind the player on Z axis?

grand snow
#

render layer not code question

slender nymph
#

the Z position really only matters if they are on the same sorting layer and order in layer. but yes, not a code question

teal viper
tiny bloom
#

where do u ask? i only have code related channels

grand snow
slender nymph
faint sentinel
#

im trying to implement some velocity in the end of the dash, witch works for the y axes but does not work for the x axes because of the movement script i have (im assuming), theres any way of ignoring the movement script while the other code is working?

slender nymph
#

disable the movement for the duration of that process. or switch entirely to working with forces

hardy wing
#

from a OOP perspective it only matters that the thing is above my class

grand snow
#

what

hardy wing
#

thats like the whole idea of polymorphism

#

to not care what that thing is, just what behaviour it offers

grand snow
#

interfaces perform a specific job which is why every interface you see is named IInterface

ebon thistle
#

i get an error i dont understand so maybe someone smart can help me with this code it is meant to be just a simple ai that chases and attacks the player. The error is: Assets\scripts\enemy AI.cs(23,13): error CS0131: The left-hand side of an assignment must be a variable, property or indexer

grand snow
#

ew

#

!code

eternal falconBOT
ebon thistle
#

sorry

grand snow
#

plz format your code correctly

ebon thistle
#

didnt know

grand snow
#

@ebon thistle your if statement should be:
if (distance <= detectionRange && ac == true)

#

= is to assign, == is to compare

cold elbow
#

hey

#

do you guys do code reviews

grand snow
hardy wing
ebon thistle
#

thank you

grand snow
# ebon thistle thank you

the error explained it well and gave you the line number so next time try to see if you can find and fix it 🙂

eternal needle
hardy wing
#

I have read many talks about this topic and the things I presented earlier have just convinced me more than something being a convention.

thorn abyss
#

hi please can i have some help? i could not figure out what the error is

eternal needle
# hardy wing I asked for a reason. Not for statistical "evidence".

People already made it clear that its a naming convention and it exists for consistency. If you have issues with it, then name things whatever you want. you could name all your classes complete spam for all we care. You arent providing anything here other than attempting to appear smarter than others

alpine temple
rich adder
rich adder
#

unless you need things in generic namespace , sure you'd wanna be explicit but in this case they probably don't

eternal needle
#

It wouldn't be a case of one or the other anyways, you can use both namespaces

rich adder
#

true

thorn abyss
hardy wing
alpine temple
hardy wing
#

But we don't have to continue it, so all good.

rich adder
#

IEnumerator exists in both namespace, the Generic version is the one that asks for a T

thorn abyss
#

oh ok that makes sense tyvm

rich adder
alpine temple
thorn abyss
#

using System.Collections.Generic; so i just ddelete the generic part?

#

what difference would that make

#

like to other lines

rich adder
thorn abyss
#

oh so generic is inside the collection

rich adder
#

you don't need the Generic "folder" since thats the one with IEnumerator<T> you don't need

thorn abyss
#

ah tysm

eternal needle
# hardy wing Is somebody hurt? I just provided my point of view and was curious to hear if th...

Nobodies hurt, when you disregard something as "statistical evidence" which makes no sense in the context, its clear you didnt understand what people above were saying while actively putting out incorrect statements.
Its not a class which you were told above. Its an interface. people have mentioned it is for naming already. That is purely the reason
It doesnt affect how the program runs in the slightest

#

Sometimes people will even obfuscate their program and end up with random names like C17616

#

Naming only matters for us developers for consistency

hardy wing
#

Since we already agreed to drop the topic I will not respond but you just mispresented what happened, but it's okay. I can understand the consistency part at least but all good 👍

eternal needle
#

Its fine if you want to drop the topic but you stating we dont have to continue is not "we" agreeing.
Anyways glad the message was understood at least

rough granite
teal viper
rich adder
#

generics are funn

rough granite
#

Ahh i see (still lost 😭)

rich adder
#

GetComponent is a good example of a generic

#

You can put in any component in <T>

#

if you're doing a save system they are clean to save multiple different POCOs without making a method for each one

rough granite
#

Does c# understand what T is if i went and made my own type of GetComponent?

polar acorn
eternal needle
# rough granite Ahh i see (still lost 😭)

Its not that simple of a concept, to really understand how you would use generics you would need to go through a few examples.
GetComponent as nav said is a good example but you're on the side of using a generic system rather than implementing generics yourself

teal viper
polar acorn
#

public void GetComponent<T>() lets you use T which is provided when the user calls GetComponent<SpriteRenderer> or something

eternal needle
#

GetComponent essentially takes the type you give it, goes through the list of components and checks if that component is T

teal viper
alpine temple
#

my script seem to be behaving differently if i recompile it mid testing

#

why would that be?

zenith cypress
#

If you mean recompiling while in play mode, don't. Unity's version of a "hot reload" isn't really a hot reload and will just cause problems.

alpine temple
#

like this

#

the jittering is removed if i recompile the script

rich adder
#

The reason you're not getting spammed with other warning is because you only added a whitespace and thats probably ignored, still triggered compile action.

alpine temple
#

why is compile action removing the jitter?

rich adder
#

the usual culprits for jittering is Camera / Roation / Movement mismatch

alpine temple
#

after compiling its consistent 13

rich adder
#

looks like float imprecision somewhere, that doesnt mean the other isn't 13 (I see it often display as 12.97ish)

#

this is the strange behaviors you get when you compile while still running the sim

#

its possibly the first is running more parts of the code and causing a slight float imprecision

#

just a guess though

alpine temple
#

its flickering between 12.97 and 13.14

fickle stump
#

Hi o/ My brain isn't braining properly so I've once again have returned to you guys!
Right now I'M trying to create an Array of GameOJbects to populate the inside of an catalog (the gameobjects basically are the pages which i want to turn on/off, depending on the index of the current array).

I'm kind of struggling how to format that. My thought is to create a function that contains an index, depending on the which button is gettign pressed im exchanging the index with the current index. But I don't know how to write that in code, could someone point me my way?

#

Is it a simple for loop? foreach?

rich adder
fickle stump
#

Basically yeah, but how would i change the index? For loop? And how would i properly reduce the index aswell?

#

I plan on having a button that goes index++ and one index--

rich adder
rich adder
#

you can just check the array bounds, unless you want a "warp" behavior

fickle stump
#

Array bounds, havent heared of that yet

#

Will look it up!

#

Thank you!

rich adder
#

eg ```cs
public void NextPage()
{
if (currentIndex < pages.Length - 1)
{
currentIndex++;
ShowPage(currentIndex);
}
}

```cs
 public void PreviousPage()
    {
        if (currentIndex > 0)
        {
            currentIndex--;
            ShowPage(currentIndex);
        }
    }```
fickle stump
#

Wait

#

Its that simple

rich adder
#

mhm

fickle stump
#

No freaking way

#

I am overcomplicating things over here lmao

rich adder
#

usually thats the case lol

fickle stump
#

Thanks a lot man

#

Helped me our a lot 😄

rich adder
hardy wing
# eternal needle Its fine if you want to drop the topic but you stating we dont have to continue ...

Well, it's not that I want to. But the topic got unnecessarily heated which I blame mainly on myself and I didn't want any unnecessary drama in here. I came back after a long while so I don't wanna incinerate something instantly KEKW Regarding the discussion: my take on this was pretty much just that in my opinion and from what I took away from talks with people that are way more experienced than I am that it's more beneficial to look at type hierarchies in that exact mindset. It's a hierarchy. When I deal with an item, I only care about dealing with a returned value of type Item. I don't care how Item works. I don't care if it has implementations already. I only care about it being an Item that may or may not refer to types that override the behaviour. And people "always having named their classes like this" is not enough convincing material for me, that's all. And Java is an example of where people decided against that. I'm not saying I'm right or you are right. I'm just saying that not prefixing them convinces me more due to the reasons I provided.

naive pawn
#

hey real quick, i noticed there was kind of a gap in communication

#

you cited polymorphism as not caring about the interface - but that's about the runtime not caring about the specific implementation
the topic in focus was about you as a developer (and other devs, including your future self) being able to distinguish what a given type is for and how to work with it - that's what naming conventions are for

sour fulcrum
#

When you deal with an item you choose to care or not care about what it is

naming conventions provide information to support your decision, consistent naming conventions is just easy free built in info. do with it what you see fit

velvet moat
#

Is there a way in the editor to see which scripts use a specific tag?

sour fulcrum
#

scripts don't use tags, instances of gameobjects do

rich adder
#

also how would you even know its a tag since they are so fragile
you can only search
.tag == "
or
.CompareTag("

#

do it better on yourself and start using components, tags are kinda trash

velvet moat
sharp mirage
#

I wanna make a system where when my players ray cast touches the wall they can wall climb by alternating Q and E buttons to slightly increment their linear velocity Y but failing the combination would set it to 0, would a state machine be best for this

rich adder
#

but you could if you already have one

naive pawn
wintry quarry
velvet moat
sharp mirage
velvet moat
#

Also got that imposter syndrome, I guess? Because I wanna help but at the same time I feel like I'm being slowed by stupid things.

naive pawn
#

!collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

rich adder
# sharp mirage nah I dont

You dont really need a FSM to do what you listed , might make it easier seperating regular movement to the climing mechanic

#

FSM helps so you also don't have a shit tone of bools , and ontop of that multiple bools can be true that cause weird behaviors

#

Imagine if you had a bool "isClimbing" and "isRunning" , your whole character breaks if somewhere both become true somehow

sharp mirage
#

not home yet so I haven't actually implemented the system but I'd imagine the whole thing would just be a whole lot of embedded if statements

rich adder
sharp mirage
#

True

rich adder
#

I would honestly use a sepearte script so the feature can be disabled/enabled with ease and self contained

#

can go something like
ray with certain distance hits the wall, maybe do additional checks like if its a climbable one
player in that climbing state, do the rest from there with keys, if you jump off and ray isn't touching anymore you are in the other movement state

#

very similiar to how a ladder logic would work

sharp mirage
#

I thought u said I didn't need states unless that's just how u normally describe things anyways

rich adder
sharp mirage
#

alr

ruby drift
#

can someone recommend me anything to start learning how to code without paying? im tired of making games with chatgpt or tutorials or stuff

eternal falconBOT
#

:teacher: Unity Learn ↗

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

ruby drift
#

tyy

west stag
#

Is it valid to call UnsafeUtility.Free on the raw pointer of a nativearray?

scenic perch
#

Hey im on the unitylearn thingy, and whenever I try and do OnTriggerEnter in visual studio, it just doesnt complete or whenever I do it exactly the same as in the shown video/text, it just doesnt recognize it and gives me errors, any way to fix that? Also doesnt complete stuff like gameObject and such.

(Deleted the stuff that didnt work before but theres some examples)

rich ice
#

!ide

eternal falconBOT
rich ice
#

hehe, beat you to it

rich adder
#

double kill

scenic perch
#

Awesome thx lol

frail hawk
#

at least they know what intellisense is, most of beginners code without it when ide not configured properly

scenic perch
#

Trial and error, figured something was up when I had it perfectly copied and it didnt wanna work

gaunt cave
#

Hello everyone, I would like to program on Unity to be able to make small games; Do you have a course or videos to recommend for beginners ?

eternal falconBOT
#

:teacher: Unity Learn ↗

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

hardy wing
hardy wing
sharp mirage
#

@rich adder implemented the system but im not rly happy with how the if statements are laid out

#

feels like im complicating things

#

by writing more than i actually need to

tidal tide
#

I happen to have an issue with scene loading and awake/start order: scene A loads additively (sceneLoaded event fires), then awake and start for scene A fires. Then awake and start for scene B fires, THEN scene B loads additively (sceneLoaded event fires) ?????

I want to make sure all awakes are run before any start from any scene.

I'm using a scene group loader, that is, for each scene in the group, registering the async operation and setting its allowSceneActivation to false. then, after this loop, I wait in a while loop for all operations to reach progress of 0.9. After that, I set every allowSceneActivation to true. With my logging, I see that the allowSceneActivation activations are happening one after another, then scene A says it's loaded, fires awake AND start, then awake /start from scene B fires, then scene B says it's loaded ?

Is there any way to manage a bit better this order ?

#

after some more testing, looks like awakes run before the sceneLoaded event is fired, for any scene. That's fine, but I'd still want all starts to run only when ALL scenes are loaded. Is there any way to do that ? (without subscribing to sceneLoaded in all scripts or something)

bronze rock
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
atomic sierra
#
public float speed = 5f;
    private Rigidbody2D rb2d;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        rb2d = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        float horizontal = Input.GetAxis("Horizontal") * Time.deltaTime;

        transform.Translate(horizontal * speed, 0, 0);
    }
``` This is all I have
raw tulip
#

Any tutorials or guides on how to make a collaborative project in Unity/github? I merged n my project blew up n I lost 2 days of progress now

rich adder
tidal tide
#

Raw makes it all 0 or all 1

atomic sierra
#

let me do it right now

sharp mirage
#

whichever one they start with

atomic sierra
#

wait so

#

getaxis doesnt give 0 and 1?

#

or is getaxisraw like JUST 0 and 1, and getaxis is like 0 -> 1

tidal tide
#

nope, GetAxis is smoothly going from 1 to 0

atomic sierra
#

ohhhhh

#

that makes a lot more sense, thank you

tidal tide
#

it's pretty annoying to be honest and it's better to handle this kind of smoothing by yourself. I almost never use GetAxis, only the raw version

frail hawk
#

using non physics movement doesnt take collisions in consideration

atomic sierra
#

i am using it, im using the .linearvelocity property

#

or is there another way to use it

frail hawk
#

where exactly do you use it, cant see it in your actual code

atomic sierra
#

nevermind

#

I used to use it

#

now i dont

#

lol

frail hawk
#

aight

atomic sierra
#

lemme try using it this time, it sbecause originally instead of transform.Translate(horizontal * speed, 0, 0); I had rb2d.linearVelocity = new Vector2(horizontal * speed, 0);

#

but it didnt work

frail hawk
#

it has to

polar acorn
frail hawk
#

you are probably using the new input system and this code is using the old one

tidal tide
frail hawk
#

well they might have changed it too, cause they said they had it previously

tidal tide
polar acorn
#

If you're fully intending the game to be played primarily through digital inputs, use Raw (or use the new input system that lets you define smoothing on a per binding basis)

rich adder
sharp mirage
#

also i tried the code out it just completely does not work

rich adder
#

you probably dont even need the list lol

rich adder
sharp mirage
#

idk what enums are tbh but ive been using key codes all this time so yh

rich adder
#

Keycodes are also enum

#

pretty common are also used for simple FSM

sharp mirage
#

so I should create a last key variable which is initially just key code.none?

rich adder
#

sure that could work

rich adder
odd holly
#

confused

#

Confusement

slender nymph
#

start by fixing the first error

#

not the first one in your screenshot of the error messages, but the actual first error you see on your screen

odd holly
slender nymph
#

yes, now look very carefully at the method declaration

odd holly
#

I dont know how to fix this...

slender nymph
#

have you copied this from a tutorial or are you writing this code yourself

odd holly
#

This part of the code Im writing myself

slender nymph
#

okay and you've surely written a method before, yes?

odd holly
#

I dont know vocab Im sorry

slender nymph
#

you can google words you don't know

#

but you really should consider going through a beginner c# course to learn what things are called

odd holly
#

Ive done methods

#

I coded my entire weapon system myself

#

I just didnt know what they were called

slender nymph
#

so look at what you've done differently with regard to this method declaration than others you have written

odd holly
#

everything else has If statements in them

polar acorn
slender nymph
odd holly
#

it was this ';'

slender nymph
#

yes

odd holly
#

Im just dumb...

slender nymph
#

just remember to always start with the first errors, a lot of times you'll find that earlier errors actually caused the later ones

odd holly
#

how do I lock the movement on my player script?

#

I need to make it where you cant move after you die

slender nymph
#

if statement

polar acorn
#

Before running whatever code would move your character, check if they should be able to move. If they shouldn't, don't move them.

weak cedar
#

Does unity have built in dot and cross products

grand snow
#

Mathf

timber tide
#

It's part of vector

wintry quarry
valid needle
#

how should i go about learning c# for unity?
i understand c# to a bare minimum but not how to structure scripts from scratch based on what im trying to

eternal falconBOT
#

:teacher: Unity Learn ↗

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

silk night
#

should include some c# paths

valid needle
#

much appreciated

frigid lark
#

hey! how can i go about making a spotlight mask type thing? kind of like how the background blacks out but characters are focused on

grand snow
frigid lark
#

aight

#

thx

odd holly
#

I made my Enemy attack me by InvokeRepeating an EnemyAttack method that removes 40 from the PlayerHealth Integer every 2 seconds when you collide with the Enemy with OnCollisionEnter but currently its removing 40 every 2 seconds even when Im not collided with the enemy so how do I fix that?

rich adder
odd holly
# rich adder you should start by showing the code in question..
    {
        Debug.Log("Collided with: " + collision.gameObject.name);

        if (collision.gameObject.CompareTag("Player"))
        {
            Debug.Log("Attacking!");
            EnemyAttack();
            InvokeRepeating("EnemyAttack", 1f, 2f);
        }
    }
    public void EnemyAttack()
    {
        Debug.Log("Hit! -40");
        pc.PlayerHealth -= 40;
    }```
#

pc. refers to PlayerCombat

#

which I have PlayerHealth in

polar acorn
#

InvokeRepeating doesn't stop

#

Once you kick it off it runs as long as the object exists

odd holly
rancid tinsel
#

!code

eternal falconBOT
rich adder
odd holly
#

so using a Coroutine would be better?

rancid tinsel
#

https://paste.mod.gg/dpzmoeytapas/0 this is really weird - in playmode everything is fine and there are all 6 shop objects, but in built, there are only 5 (the top one is missing). how is that possible? everything else seems to be working fine

rich adder
#

coroutine or Update could also work

odd holly
#

Time to learn Coroutinessssssssss

golden junco
#

What are some reason that a gameObject that has a ridgidbody and a capsule collider would slowly float into the air. But then if you change its mass to 50 it slowly goes back down to the ground.

rancid tinsel
#

first screenshot is from built, and second from playmode (the colour change is irrelevant)

polar acorn
rich adder
rancid tinsel
golden junco
#

Neither of those there is no other Gameobject and no velocity on the Rigidbody

rough granite
polar acorn
golden junco
#

never mind apparently the animation i got for a t-pose had a vary small constant movement upwards.

rancid tinsel
#

resolution is 1920x1080 in playmode view, and its also forced that way (fullscreen and also forced to 1080p resolution) via code

#

but I added a scroll rect and physically checked - there are only 5 panels

odd holly
#
    {
        Debug.Log("Collided with: " + collision.gameObject.name);

        if (collision.gameObject.CompareTag("Player"))
        {
            Debug.Log("Attacking!");
            EnemyAttack();
            IEnumerator MyCoroutine = StartCoroutine("EnemyAttack");
        }
    }
    IEnumerator EnemyAttack()
    {
        while (true)
        {
            yield return new WaitForSeconds(2f);
            Debug.Log("Hit! -40");
            pc.PlayerHealth -= 40;
        }
    }```
#

I started it but now I dont know how to stop it and Im getting an error at StartCoroutine("EnemyAttack");

golden junco
rich adder
odd holly
rich adder
rancid tinsel
#

just confirmed it with a counter

odd holly
grand snow
#

Coroutine foo = StartCoroutine(nameof(EnemyAttack));

#

keep a reference so you can stop it later

#

you can also start a coroutine via StartCoroutine(EnemyAttack())

rich adder
odd holly
rich adder
#

youd wanna make it a field not a local var

grand snow
#

have a class member of type Coroutine

#

hopefully you understand this...

odd holly
#

my brain is not braining...

#

I really need to learn vocab

grand snow
#

do you understand scope?

rich adder
#

know what a field is ?

grand snow
#
public class Bike
{
  public Wheel wheel; //Class member / field

}
odd holly
rich adder
#

something you should probably learn before doing coding in unity lol

grand snow
#

I guess everyone skips the c# basics now

odd holly
#

well I dont really have time to learn vocab rn because Im doing gmtk jam :p

rich adder
#

gmktk jam ends in 2 days..

odd holly
grand snow
#

its usually recommended to learn BEFORE THE JAM

rich adder
#

you want to make an enire game 2 days before jam ends but dont know the basics. thats going to be a struggle

odd holly
#

all I need to do is make it where the enemy attacks in intervals while Im collided with it

#

then another enemy and one boss then its just art

rich adder
#

OnEnter startCoroutine
OnExit stopCoroutine

odd holly
#

so Im like 60-70% done

odd holly
fierce adder
#

hello

rich adder
fierce adder
#

can i get help with sum? im super new to this

rich adder
eternal falconBOT
grand snow
# odd holly where do I put it...

we told you, store the returned Coroutine from StartCoroutine() as a class member and then use that variable to stop the coroutine

#

google "c# class field" if you still dont get it

fierce adder
odd holly
odd holly
grand snow
#

we could spell it out even more but at some point you do need to learn this to understand things better

rich adder
rancid tinsel
#

had to remake the SO and now it works

odd holly
#

where do I put the class? do I just put it next to the other methods or am I supposed to put it inside something?

rich adder
#

the steps were to just make a field for Coroutine and store it when you call StartCoroutine so you can Stop it on exit

rocky canyon
#

methods go inside a class ```cs
using UnityEngine;

public class HelloWorld : MonoBehaviour <-- class
{
void PrintHello() <-- method
{
Debug.Log("Hello, world!");
}
}```

grand snow
#

dont confuse em

fierce adder
rocky canyon
#

how's that confusing?

grand snow
#

trying to get them to make a class field to store a coroutine

rocky canyon
#

im not trying to make them do anything..

fierce adder
grand snow
#

no worries

rocky canyon
#

with tons of resources linked at the bottom..

#

don't get confused tho

fierce adder
rich adder
fierce adder
#

alr

odd holly
#

I googled the class field but I dont know where to put the class

#

I know how to make it just not where to put it

fierce adder
#

when i hold a key to move on ground it moves and slows down until it reaches a stop

fierce adder
rich adder
#

its probably friction

fierce adder
#

ye

#

ty

rocky canyon
#
using UnityEngine;
using System.Collections;

public class SimpleCoroutine : MonoBehaviour
{
    Coroutine myRoutine; // variable to store the coroutine
    void Start()
    {
        // when you start a coroutine you can go ahead and store/cache it
        myRoutine = StartCoroutine(MyCoroutine());
    }

    void OnDisable()
    {
        // if myRoutine (the variable) is assigned
        if (myRoutine != null)
        {
            StopCoroutine(myRoutine); // you can stop the coroutine using that variable
        }
    }

    IEnumerator MyCoroutine()
    {
        while (true)
        {
            Debug.Log("Saying Hello every 1 seconds.");
            yield return new WaitForSeconds(1f);
        }
    }
}
rich adder
# odd holly

the steps are
make a field for Coroutine
assign the field a value on StartCoroutine located in OnEnter
use trhe same variable in OnExit to StopCoroutine(myRoutine)

rocky canyon
#

^ basically caching the coroutine when u start it.. (this specific coroutine)

grand snow
#

*storing a reference to the coroutine we started

rocky canyon
#

yea storing the reference

grand snow
#

otherwise you have to stop them all

rocky canyon
#

true true

rich adder
#

here's to hoping this isn't another case of the "just this thing and then I'm done"

rocky canyon
rocky canyon
rich adder
#

game jams are good if you actually have the baseline to test your skill live

#

not learning as you go for 2 days timelimit lol

rocky canyon
#

oh, 💯 and to push that skillset to its limits 🤣

#

heck, in 5 minutes you'll be a professional at coroutines 😈

odd holly
rocky canyon
#

the field would be put in w/e class is calling the coroutine (normally)

rich adder
odd holly
#

am I stupid...

#

when I was looking at the screenshots I thought public class was a kind of method...

rich adder
#

well this is why the basics are important..

odd holly
#

I knew what public class was I just forgot like a dummy

#

Im still getting an error

#
    {
        Debug.Log("Collided with: " + collision.gameObject.name);

        if (collision.gameObject.CompareTag("Player"))
        {
            Debug.Log("Attacking!");
            EnemyAttack();
            IEnumerator MyCoroutine = StartCoroutine("EnemyAttack");
        }
    }
    IEnumerator EnemyAttack()
    {
        while (true)
        {
            yield return new WaitForSeconds(2f);
            Debug.Log("Hit! -40");
            pc.PlayerHealth -= 40;
        }
    }```
rocky canyon
#

thats a local variable

odd holly
#

Im getting an error at StartCoroutine("EnemyAttack")

rich adder
#

error where

#

also you still copied wrong

odd holly
rich adder
rich adder
odd holly
rich adder
odd holly
#

huh...

rich adder
rocky canyon
#
    Coroutine attackRoutine;

    void OnCollisionEnter(Collision collision)
    {
      attackRoutine = StartCoroutine(...);```
and ur variable should be declared outside the methods.. (u want any method from inside the class to access it, for example some other method in the same class that could Stop it) so it would be a variable at the top of the class/ not inside (a) method
odd holly
#

wait no Im stupid

#

how do I make it stop after I stop colliding?

rocky canyon
odd holly
#

I forgot to tell it to stop...

rocky canyon
#

not sure how'd u go about that.. i just wanted to throw in my two cents on how to cache the coroutine reference

#

i dont believe there's a OnCollisionExit afaik that u could use to stop it..

#

but if u have the reference set up correctly its easy
StopCoroutine(coroutineReference); or attackRoutine
coroutineReference/attackRoutine being w/e u named the reference variable

odd holly
rocky canyon
#

yea, and i was told to "not confuse you"

#

it happens lol.. anyway now that u can cache a "specific" coroutine and know how to stop it.. i think ur doing pretty well so far 🍀 ¯_(ツ)_/¯

#

myself, i use Triggers alot.. so like a trigger a little bigger than the thing im colliding with

soo that way i can use OnTriggerEnter and OnTriggerExit to start and stop a coroutine for example

odd holly
#

you were pretty much right

#

its just OnCollisionExit instead of Enter

rocky canyon
#

not sure its suitable for ur use-case but i tend to have better luck with OnTriggerEnter and OnTriggerExit

rocky canyon
#

good stuff then 💪

odd holly
#

if I can get this enemy working than Id say Im like 70% done

rocky canyon
odd holly
#

yay it works... mostly

odd holly
#

like I was able to make my entire custom weapon system after just watching a few tutorials that partially had Raycast a little bit in them

naive pawn
odd holly
#

I learn pretty quickly and easily when I know the vocab

odd holly
naive pawn
#

i know what that means but it's a pretty direct message

#

it's part of a set

rocky canyon
#

i just dont use Collision very often to know if it did or not

odd holly
#

I think I have my enemy workingggggggg

naive pawn
#

/On(Collision|Trigger)(Enter|Stay|Exit)(2D)?/

rocky canyon
#

💪 ya, ill remember from now on both collision and trigger both have enter and exits

naive pawn
#

but don't forget the 2d and 3d versions have different rules entirely dissolve

rocky canyon
#

i banish 2D to the outerworlds

#

nope.. 3D bb!

odd holly
rocky canyon
#

hehe.. idk man.. i just work better in 3d spaces

naive pawn
odd holly
rocky canyon
#

could constrain everything as well

#

rotation positioning.

#

1 thing i do love about game-dev.. is theres dozens of ways to do everything
so one persons rubbish may be another persons holy grail

frigid lark
#

does any1 know what this error means?

#

or moreso how to fix it? ive looked online but its so confusing

rocky canyon
#

give Unity a quick restart?

#

parts of that make me think it may be just a bug.. but ive never seen it b4 so cant be certain

#

ahh after searching now i am also confused 😅

frigid lark
#

this is why i use unreal engine lol

#

thanks

rocky canyon
#

says abunch of stuff like: usually indicates that an AnimationPlayableOutput object, which is responsible for direting animation data to a specific target (Like an ANimator) component has not been properley initialized or assigned..

#

typically occuring when a PlayableGraph is created or manipulated 👀 ya, idk what any of that means.. possibly #🏃┃animation would have a better answer

frigid lark
#

legacy animations cant be in a blueprint

rocky canyon
#

if it is indeed related ot animation

frigid lark
#

in an animator

#

i mean

#

sprry

rocky canyon
#

seeing the same type of error there.. possibly a path to the solution

naive pawn
#

if it's just the legacy thing there'd be a warning iirc?

odd holly
#

yayyyyyyy! Enemy 1/2 complete

#

Enemy 2 is just going to use like 5 minutes from a 20 minute tutorial

#

then its boss coding...

#

uh oh...

rich adder
wide rivet
#

Following a tutorial, why some tiles block view of the character while some tiles are under the character?

remote lynx
#

Why dont unity serialize interfaces

#

There is SerializeReference but only works on non UnityEbgine.Objecy

sour fulcrum
#

it just be like that

polar marsh
#

can someone tell me why this code is not working it's working if i remove "* forwordInput/horizontalInput"

keen dew
#

Because it reads input only once at the start. Those lines should be moved to Update

worn peak
#

How do I rotate a gameobject into an absolute angle? I want the gameobject to point 40 degrees to the right, when my input on the x axis is positive and 40 degrees to the left, when x is negative. My current solution keeps adding the angle with each frame.

void Update() {
if (_moveInput.x > 0)
{
    _animatorPulseEngine.transform.Rotate(40,0,0, Space.World);
} else if(_moveInput.x < 0)
{
    _animatorPulseEngine.transform.Rotate(220,0,0, Space.World);
}
}
naive pawn
#

Rotate, well, rotates from the current rotation
you want to set the rotation, so rotation = ... or eulerAngles = ...

worn peak
#

I am sorry, but I don't quite understand how I am supposed to set the rotation

naive pawn
#

i just gave you examples

grand snow
#

Use Quaternion.Euler() and assign to transform.rotation

naive pawn
#

transform.rotation and transform.eulerAngles let you set the rotation
the former is a quaternion, the latter is a Vector3 of euler angles

worn peak
#

Ah so you meant it that way. I was confused, because I assumed rotation and eulerAngles like you said were meant to be values and not methods from transform.

grand snow
#

That doesn't make sense

#

Basically you should assign a new rotation to override it to what you want

#

Rotate() will manipulate the current rotation so won't do what you desire

worn peak
#

Like I said, I was just confused

naive pawn
worn peak
#

My bad

waxen glacier
#

I'm trying to make a character controller rn but i'm having an issue with jumping. It's inconsistent, every time I jump, the jump height is different and I don't understand why. Here's the code https://paste.ofcode.org/NVjv4ajrgNWYUWAL4X4xqf

keen dew
#

Don't multiply velocity by deltatime

waxen glacier
#

what should and shouldnt be multiplied by deltatime ?

naive pawn
#

it depends on the usage

#

if you have a value in x per second, and you want a value in x per frame, then you use deltaTime

#

if you aren't in that situation, you don't

#

that's what deltaTime is, a conversion factor - it's seconds per frame

waxen glacier
#

Ah ok, so multiplying the velocity by deltatime actually did the opposite of what I wanted right ?

naive pawn
#

you also shouldn't be using deltaTime on lookDirection if that's mouse input

naive pawn
#

with the mouse thing, mouse delta is already in x per frame

#

your player.Move should have a * Time.deltaTime, because velocity is being treated as per second, but Move is taking a delta position per frame

waxen glacier
#

Dam alright thanks, removing deltatime just amplified every movement by 1000, i'll add some multipliers to reduce that

waxen glacier
#

like this ?

naive pawn
#

(and also you don't need the isGrounded check to apply gravity, you should do so regardless so the CharacterController stays in contact with the ground)

#

(also btw Mathf.Max exists)

waxen glacier
naive pawn
naive pawn
waxen glacier
# naive pawn (also btw `Mathf.Max` exists)

I use clamp instead because i had an issue where if i simply set the velocity.y to zero when grounded i wouldnt be able to jump, so i made the minimum 0 and the max any positive number

naive pawn
#

yes, that's what Mathf.Max would achieve

waxen glacier
naive pawn
#

you mightve been using Min before, which is an understandable mistake - it reads like "with a minimum value of x"
but it's kinda the opposite in this kind of usage, Max takes the larger number so it is applying a minimum value

waxen glacier
naive pawn
#

ah

waxen glacier
#

never used min either, i just used clamp cuz it seemed more intuitive to me

#

thanks you so much though the jumps are now consistent

#

So i guess i'll only apply deltatime to the actual move function instead of the values it uses

#

Time to make the little bean actually move

gray rivet
#

so im trying to make it so the player is only restricted to only one jump and i keep getting errors that i do not understand

#

and also collisionInfo isnt working for some reason

rough granite
gray rivet
#

this is running off my little understanding so this makes sense

rough granite
north kiln
#

There will be more errors even if brackets are added to create the method scope, as you can't declare a public variable inside of a method

rough granite
gray rivet
#

alr lets start studying

rough granite
gray rivet
#

not to be a nuisance but im a little confused with problem 1

naive pawn
#

but mainly i just want to point out that == is a thing with strings.

rough granite
naive pawn
gray rivet
#

just collision

naive pawn
#

you can call it whatever

gray rivet
#

ok yeah thats what i though

#

its jsut ;

#

thats the problem

rough granite
#

the problem is what Chris said

gray rivet
#

so the lesson there is Methods dont have a ; to finish a line?

naive pawn
#

yeah, you don't need ; for everything

#

like i said above - just for field declarations and statements, and also with for

gray rivet
#

ok makes sense

rancid tinsel
#

any way to make it so that the sound plays when the TimerUpdate is a specific number, or is this entirely incorrect?

naive pawn
#

hover over the erroring code to see what it's trying to tell you

#

though, TimerUpdate can't be a specific number

rancid tinsel
#

wait nvm i get how to do it now

naive pawn
#

it's an Action

rancid tinsel
#

its an Action<int>

#

I have to wrap it like this basically

naive pawn
#

yeah i was intending to just mention the important part but yeah that's ambiguous to the standalone Action

vital vault
#

how can i transfer some values from one scene to another? (without PlayerPrefs and similar things, i dont want to crap in the registry or savefile)

naive pawn
#

scenes don't hold values, components do - this question is pretty broad, what are you trying to achieve?

wintry quarry
vital vault
#

but i think im simply not

wide rivet
#

unless it can fully be done with JUST UI game objects

#

in which mb

rancid tinsel
wide rivet
#

wrong channel

wide rivet
vital vault
#

how can i preload 2 scenes at the same time? i had the issue of one activating after another

grand snow
wintry quarry
light elbow
#

Hey fellaz

#

Where is help channel?

wintry quarry
vital vault
wintry quarry
#

Yep

#

They will always activate at different times

#

You need to rewrite your code to be able to handle that

teal viper
#

!collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

rich adder
odd holly
#

I thought I finally figured it out… I had it where GetComponent gets EnemyCombat… now it’s worse than before and literally NOTHING is happening

#

Honestly ts stopped being fun the second I started coding the enemies

grand snow
#

you lack core understanding of what a component is and how to get instances of components from other gameobjects to interact with them

#

as others said, following some learning courses will help you understand this but guess no time for that rn

odd holly
#

It would honestly be faster to just learn rn… if my computer wasn’t running the videos at 2 fps

rich adder
grand snow
#

maybe it cannot handle the unity editor and browser?

odd holly
#

I closed out of literally everything besides the browser and it was still lagging so Im just using my iPad

#

And I reopened everything

#

Because why not

#

Like the first 30 minutes of this guide I already know…

#

‘Can you open your project in Unity Hub?’ Hm… considering I have made an entire game before… this seems pretty tough

sweet pendant
#

im trying to make a grab system in unity everything is supposed to be good but i have this error

#

ill upload the code in js a second

frail hawk
#

js hmm

rich adder
#

!code 👇

frail hawk
#

bot is on holidays

sweet pendant
#

what

frail hawk
#

choose c# , press paste it and send us the link

sweet pendant
frail hawk
#

double click on the error where does it take you exactly?

rich adder
#

and you can delete the big wall of text

sweet pendant
#

it takes me to the drop object function to the Rigidbody rb = grabbedObject.GetComponent<Rigidbody>(); line of code in it

sweet pendant
#

how do i fix it the grabbed object isnt staying in the holdpoint position when i click e tho

rich adder
#

make it not null by assigning a value

frail hawk
#

the first if statement is really weird

sweet pendant
#

wdym assign a value to it to the rb?

frail hawk
#

if Key / else

sweet pendant
#

whys it weird

rough granite
#

yeah i think you are dropping it the minute you pick it up which then sets the second if to be false

sweet pendant
#

oh

rough granite
#

cause GetKeyDown is only for one frame so the frame right after calls
else
{
DropObject();
}

sweet pendant
#

i just noticed

#

let me see if i change it

#

i fixed it tysm idk how i didnt notice that

thorn abyss
#

how do i send codes?

frail hawk
#

!code

eternal falconBOT
thorn abyss
#

can i just copy paste it here

frail hawk
#

better use codeblock or one of the websites

rich adder
thorn abyss
mighty pilot
#

Making a game that involves placing tracks on a grid and I have UI buttons to switch between track type. Issue I am running into is that when I click a button it will place a track on the ground behind the button. The fix I am thinking of is affixing colliders to the camera in the button areas but is there a better way?

rich adder
thorn abyss
#

oh

#

i dont know what links

#

do i turn them into links

rich adder
#

paste it, and send

thorn abyss
#

ohh

rich adder
#

hard to suggest anything without context

thorn abyss
#

do i put all inside one all seperate them

rich adder
thorn abyss
#

the dialogue ui is not showing up. i know that the conversation works fine because i used debug logs. the problem is that i dont know why the variable is not set to true so it never shows up

mighty pilot
# rich adder show the setup

If you click green tile it places a track
I click the UI buttons on the top right to choose type
If a green tile is behind the button it will place a track when I attempt to switch
The white boxes are gonna have a collider so the mouse check hits them first

rich adder
mighty pilot
#

Correct

rich adder
#

otherwise you can try EventSystem.current.IsPointerOverGameObject()
or

    bool IsPointerOverUI(){
        PointerEventData pointerData = new PointerEventData(eventSystem){
            position = Input.mousePosition // Device.current.position.value -- for new input system
        };
        List<RaycastResult> results = new List<RaycastResult>();
        raycaster.Raycast(pointerData, results);
        return results.Count > 0;
    }``` 
which both essentially doing same thing using the Event System , which is what IPointer would use anyway
rich adder
thorn abyss
#

sorry i dont know how to

#

ill do it again

rich adder
thorn abyss
#

i deleted some irrelevant codes too

rich adder
upper summit
#

quick question, i know c# past the basics, some system IO, a bit more, where can i learn how to use C# in unity, like where to look for certain things ect

eternal falconBOT
#

:teacher: Unity Learn ↗

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

thorn abyss
#

this should work now

#

I did try debugging it and i know where about its gone wrong but have no idea why

rich adder
thorn abyss
#

Whats the thibg

rich adder
vast matrix
#

For some reason, if I move while jumping, my player character stays in the air for an unreasonably long amount of time and I have no idea how to fix it
here is my code

using UnityEngine;

public class PlayerMove : MonoBehaviour
{
    [Header("Movement")]
    public float MoveSpeed;

    public Transform Orientation;

    float HorizontalInput;
    float VerticalInput;

    // KeyCode 
    public KeyCode jumpKey = KeyCode.Space;

    bool Grounded;

    public float JumpForce;
    public float DownForce;

    Vector3 MoveDirection;

    Rigidbody RB;

    private void Start()
    {
        RB = GetComponent<Rigidbody>();
        RB.freezeRotation = true;
        Grounded = true;
    }

    private void Update()
    {
        MyInput();
        MovePlayer();

        if (Grounded != true)
        {
            Invoke("ReverseJump", 1.0f);
        }


    }

    
    // Gets Inputs
    private void MyInput()
    {
        HorizontalInput = Input.GetAxisRaw("Horizontal");
        VerticalInput = Input.GetAxisRaw("Vertical");

        if (Input.GetKey(jumpKey) && Grounded == true)
        {
            
            Jump();
            Grounded = false;

        }

    }

    private void Jump()
    {
        RB.AddForce(0, JumpForce, 0, ForceMode.Impulse);
    }
    private void ReverseJump()
    {
        RB.AddForce(0, DownForce, 0, ForceMode.Force);
    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Ground")
        {
            Grounded = true;
        }
    }

}``` (Had to remove some stuff cuz discord)
vast matrix
#

It works well if I stand still while jumping, just not while moving

naive pawn
vast matrix
#

It is set to -5

naive pawn
#

that's very low gravity

#

use a paste site and show the full code

vast matrix
#

How do I send the code from the paste site?

thorn abyss
# rich adder show the thing you expect

Player hits x, then it should trigger the conversation (in dialogue manager, talking()) then in the talking function it should set talk to true therefore triggering the code in the update function of DialogueManager if (player.talk) {dialogueBG.style = DisplayStyle.flex} , showing the ui, and set talk to false in the notTalking function(in player controller), after the dialogue is finished.

naive pawn
#

if you have an RB, just don't touch transform

rich adder
thorn abyss
#

Nope

#

It shows not displaying

rich adder
#

so player.talk is false

thorn abyss
#

So i think talk is set to false somewhere

#

Ye

#

But i have no idea where and why

rich adder
#

this is another reason not all variables need to be public

thorn abyss
#

Oh

rich adder
#

go to the player class it usually tells you in IDE where that var is referenced

thorn abyss
#

It just highlights them and its not really clear plus it doesnt show in another script

vast matrix
# vast matrix oh ok

Every jump is now a different height. And if I move while jumping the jump is twice as tall than if I stand still

thorn abyss
#

In visual studio

rich adder
thorn abyss
#

Oh

rich adder
#

not here the variable itself

#

or right you can right click it and do Find All References

thorn abyss
#

nvm i saw it

vast matrix
#

Same thing just changed the transform.position to RB.position

thorn abyss
naive pawn
vast matrix
#

Oh mb

naive pawn
#

you probably want to use linearVelocity or AddForce instead

#

that way you get proper interpolation and collision detection

vast matrix
#

Thats the only url thats showing up on My screen

naive pawn
vast matrix
vast matrix
rich adder
red igloo
#

I am trying to make it so when the player touches the wall it should send a debug.log but its not working. the wall is a child of an empty gameobject that has the script while the wall only has a mesh collider and a rigidbody. did I do something wrong? https://paste.ofcode.org/EfqZjqF96eNFGTeiagbqKt

naive pawn
vast matrix
#

yes