#💻┃code-beginner

1 messages · Page 796 of 1

upper pebble
#

Personally, I think it's more embarrassing to misinterpret a bunch of clear-cut words rather than a video I watched while half-awake. You've not only not payed attention to what I was asking for in the first place but never listened to what I was saying throughout the conversation. That includes what I was mentioning with tutorials and my initial statement of wanting it to slow down to a stop and not immediately stop moving.

polar acorn
#

But it seems you never read it.

upper pebble
polar acorn
#

Again. Not reading what I write

upper pebble
#

My bad, not what I'm used to seeing when someone forwards something

upper pebble
polar acorn
#

Based on data

upper pebble
# polar acorn Based on data

BTW I did see that AS I STATED AFTERWARDS and I've been working with it (though not that much considering how I've mostly been typing here)

#

So again, you didn't read what I typed

#

Here's evidence :D

#

And this is what I was referencing by "not what I'm used to seeing when someone forwards something"

tulip herald
#

Ummm @upper pebble MoveTowards(A,B) and Lerp(A,B) will move value A to B over a certain amount of time I hope this helps lol

#

Let's say you wanted to "slow down" once you release a button you could use one of those methods to change the value over time
E

grand snow
#

lerp abuse detected

cosmic dagger
#

I'd go with MoveTowards over Lerp . . .

upper pebble
#

I already fixed the issue (It had absolutely nothing to do with what they mentioned)

naive pawn
#

jeez wth happened here

upper pebble
naive pawn
#

alright, let's tone that down.

tulip herald
#

Yeah it can be like that VCBraindamage I apologize don't let this situation deter you from making great games brother

upper pebble
upper pebble
tulip herald
#

That's good bro

naive pawn
tulip herald
#

Let's just move on from the situation

#

He said he got it solved

upper pebble
naive pawn
#

i'm seeing this as a learning opportunity tbh

#

the loop does continuously subtract 0.5, the problem is just that it does it all at once, and unity already has loops for doing stuff over time - Update/FixedUpdate

upper pebble
naive pawn
#

also btw, you can totally use tutorials that still use the old input system. the core logic will still be the same, you just change the input. the old system has been around for a long time, so a lot of tutorials will be using it

upper pebble
#

One used some random movement system that caused collision bugs with hitboxes and had no easy fix

naive pawn
#

digi tried to get at it here, and they specifically mentioned a part in your code where you're already doing it correctly #💻┃code-beginner message

upper pebble
naive pawn
#

and you didn't reply to it, so digi probably assumed you missed it, hence why they linked to it again

naive pawn
upper pebble
#

Fair enough on that part, but it still doesn't excuse how they ignored my originial intention that I stated several times

naive pawn
upper pebble
naive pawn
#

that's what digi's solution would do

tulip herald
#

Yeah that's why I mentioned the moveTowards() yeah lol

naive pawn
#

if the velocity is currently non-zero, and the corresponding key isn't being pressed, reduce the velocity by a bit. keep doing that every frame. if it's 0, stop reducing it

upper pebble
# naive pawn that's what digi's solution would do

Except it didn't. What's ironic is I managed to fix the issue by changing the linear dampening which I don't believe they ever mentioned. It definitely didn't help that they kept spacing out their answers and spamming different results which was wildly confusing

naive pawn
#

though yeah, movetowards would help you not overshoot and then get an oscillating/jittering effect if you end up at like, 0.25 -> -0.25 -> 0.25 etc

tulip herald
#

That's good VC

naive pawn
#

lineardamping is proportional to the current velocity, and that's about the only difference

tulip herald
#

If you found a solution that's good there's 1 million ways to achieve the same effect but as long as work as desired then good job!

#

The hardest part of game development programming isn't the programming but understanding geometry and algebra is what I find most confusing

naive pawn
#

although yeah, this absolute modification on each axis would mean diagonal damping would be a little wonky. you'd want to modify the entire vector anyways

naive pawn
upper pebble
naive pawn
upper pebble
naive pawn
#

"absolute beginner" can mean a lot of things

#

and to be honest, "i've been in this channel before" doesn't mean much. i know ive seen you before, i recall your username. but i recall absolutely no info about your skill level

upper pebble
naive pawn
#

so does that mean we should explain what mono behaviors mean or what files are? obviously no, right?

#

we see you're using those concepts already

#

and you are also using the concept of FixedUpdate as a loop with the ifs for your movement

tulip herald
#

It's all good guys

#

We should just move on

naive pawn
#

man i'm not trying to argue here... i'm trying to make it easier to get help by pointing out where the gaps in assumption were

upper pebble
naive pawn
#

right, so like, we don't know if those tutorials explain the concept of Update being a loop.
you're asking us to make an assumption that, while true for you, isn't true for everyone

#

or maybe they do and you've missed that - there's a lot of possibilities

upper pebble
# naive pawn man i'm not trying to argue here... i'm trying to make it easier to get help by ...

I'll definitely be working on some other things to get a better idea of how to do things such as movement and get a better idea of what I could do in the future. At the same time, when I ask for help on something, I don't want to be told to do more tutorials or look at the manual when that isn't going to help me with my issue. The people beforehand clearly could not understand that concept and that is how the argument started.

naive pawn
upper pebble
naive pawn
#

(just trying to explain what digi mightve been going for)

upper pebble
#

I'd say the reason why I was putting so many loops in the update "loop" was because it's what I've seen in most- if not all tutorials I have looked at. You could likely chalk that up to force of habit but that IS why I fiddle around like this. They call it a monkey on a typewriter but it gives more clarity into what the issue is rather than finding a niche tutorial that just tells you not to

naive pawn
#

good tutorials will explain why, just like i've done here

slender nymph
#

i'm not going to participate in the ongoing discussion, but i would also like to point out that if you do not understand something that someone has said, then you need to ask concrete clarifying questions and not just immediately dismiss what was said or ask something incredibly vague, or even worse, get mad at the responder

upper pebble
naive pawn
#

though, it is harder to figure out which tutorials are good or bad, as a learner, so i see how that might be easier said than done

naive pawn
#

(though there a few very popular channels that prescribe some not great practices, though i don't recall which exactly)

upper pebble
upper pebble
naive pawn
teal viper
naive pawn
cosmic dagger
#

i can't really get upset with a tutorial. whether good or bad, they made it to teach or help someone. some good, some bad, and some ugly; but that's why i recommend watching a few covering the same topic. you—hopefully—get a better grasp of the concept. it's seldom you find one that does everything you're asking for . . .

eager stratus
#

Ok, how am I supposed to handle an event where I mouse over an object in a 3d scene? It has a collider and neither OnMouseEnter or OnPointerEnter work.

slender nymph
#

for OnMouseEnter you must be using the old Input Manager rather than the Input System. for OnPointerEnter the component needs to have the IPointerEnterHandler interface where that method comes from and you need an EventSystem in the scene and a Physics Raycaster component on the camera

eager stratus
red rover
#

I’m losing my mind, do colliders have a characteristic where they don’t register by ray casts on the first frame they exist or something?

slender nymph
#

colliders aren't updated until the physics step which only happens on FixedUpdate frames. you can call Physics.SyncTransforms (or the 2d equivalent if in 2d) to force them to update immediately

red rover
#

Oh my god that was rhetorical, if this fixes my problem…

sour fulcrum
#

😛

#

Since technically it’s not their first full frame

red rover
#

THAT FIXED IT 😭😭😭

#

Thank you sm @sour fulcrum @slender nymph

sudden cypress
#

hey guys anyone here knows how to code a floating point vector system where game world adjusts to player position

#

cause of scale

teal viper
sudden cypress
#

based on distance

#

so as to not have much errors or anything

#

otherwise im locked in a very tiny space to work with

teal viper
#

You can easily have some 10km world without any issues though

sudden cypress
#

so what you mean is , find offset that is , if my character is 1k away from origin , i shift player to 0 and i shift the whole world to -1k

#

right

sudden cypress
teal viper
sudden cypress
#

i mean , all the objects with the player

teal viper
#

Yes

#

Basically.

#

It's not as simple on practice though. Moving physics objects could cause issues. And some other systems as well

#

Youd need some extra setup for such objects.

sudden cypress
#

ye gotta work on that , maybe make it so the screen refreshes instantly so player cant notice maybe

lilac coral
#

hi i dont know how to explain it but im following a tutorial as a beginer but in the tutorial his thing code is coloured and shows up mine is not

#

first pic is yt

sudden cypress
#

dont worry about it

#

i think it would work

lilac coral
#

😭

naive pawn
radiant voidBOT
bleak bay
naive pawn
lilac coral
bleak bay
#

if ur using vs do u have the unity integration installed

#

I dont know if it changes anything

lilac coral
#

i think so how would i check

bleak bay
#

u can check on the installer

lilac coral
#

here?

bleak bay
#

I was thinking on the ide installer, not unity hub

#

but I suppose that helps too

lilac coral
#

😭

bleak bay
#

when you go to the installer theres the installed versions, the first button on the right (I think its modify? unsure) lets you update to include depedencies and one of them is unity

naive pawn
#

configure your ide first, so the ide tells you where the issue is

naive pawn
lilac coral
#

dawg hoew do i get to the editor for unity

livid anchor
#

Hey folks, I had a question about the input system.
If you use the Move inputs, you get a vector2 that can have a value on X, Y or both right ? But what if you only want the player to go only sideways or forward backward ?
Like in the case of a snake game, you don't want to go in a diagonal right ? How do you do that ?

keen dew
#

You have to decide what you want to happen when the player presses both directions at the same time and then do that

livid anchor
#

So you arbitrarily decide on a rule when both keys are pressed ?

bleak bay
#

yes

keen dew
#

It's your game, you get to decide how it works

livid anchor
#

Ok. Then another question, if I make an abstract class inheriting monobehavior, can I make the update method virtual or something to pass on to the children ?

livid anchor
keen dew
#

Input can be negative so it needs to be !=

livid anchor
#

Ah right

#

And for the update ? Can I change the method from private to protected and have it inherited ?

keen dew
#

Any OOP things should work as normal

livid anchor
#

Right I can declare update as protected virtual no issue

cobalt pawn
#

Hello everyone. Im pretty much all done with my game, I just have 1 issue that I do not know how to fix at all. When Im playing on PC, the player moves fine, it doesnt collide early? I would say with the tiles but for some reason when I play it on my mobile, it collides with tiles WAYY easier (the videos that I sent explain it better) and I was wondering if anyone knowa why it does that and maybe could help me fix it. https://youtu.be/LKrtJtdku4E
https://youtu.be/fB6zbcak-r8

sterile path
#

I have a slight issue with my code, im a begginer and kinda need help

sterile path
hexed terrace
#

!code

radiant voidBOT
hexed terrace
#

use a paste site for big chunks of code

sterile path
#

one sec

#
using Unity.VisualScripting;
using UnityEngine;

public class Move : MonoBehaviour
{
    // L R, Jump 

    public float moveSpeed = 5f;
    public float jumpPower = 5f;
    public bool jumping;
    public bool onGround;

    public float jumpStartTime; // how long we want the player to jump for (fuel)
    private float jumpTime; // tracks time of when player started to jump

    public BoxCollider2D groundChecker;
    float xInput;
    float yInput;

    private Rigidbody2D rb;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        // Player CANNOT MOVE when midair
        if (onGround == true && !jumping)
        {
            xInput = Input.GetAxisRaw("Horizontal");
            rb.linearVelocity = new Vector2(xInput * moveSpeed, rb.linearVelocity.y);             // Linear is positional movement, angular is rotational.
        }



        // button pressed = jump
        if (Input.GetButtonDown("Jump") && onGround == true)

        {
            jumpTime = jumpStartTime;
            jumping = true;
            onGround = false;
            rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpPower);
        }


        // button HELD = higher jump (getbutton means when the button is held down)

        if (Input.GetButton("Jump"))
        {
            if(jumpTime > 0 )
            {
                rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpPower);
                jumpTime -= Time.deltaTime;
               
            } 

            if (Input.GetButtonUp("Jump"))
            {
                jumping = false;
                jumpTime = 0;
            }
        }

    }

    void OnTriggerStay2D(Collider2D other)
    {
        if (other.CompareTag("Floor"))
        {
            onGround = true;
            jumping = false;
        }
    }

}
#

what happens is when i jump the timer stops counting down, therefore causing my player to double jump until the playertime variable reaches the number its set to

#

the variable is currently set to 0.3 seconds, so whats meant to happen is the player is meant to jump higher depending on how long hes holding the jump button

#

right now that DOES happen but once the player lets go of the key, he can jump again until the value of the timer reaches 0, which isnt supposed to happen, the timer itself is meant to countdown regardless of me holding the button

#

any ideas?

rose rock
#

hi,

I am making a game where you need to extinguish burning buildings.
every time a building gets burned down, the player loses a heart.
for the loss of hearts, there is a short animation where it ascends.
I succed on that, but it happens a lot that a building gets destroyed while one of the hearts is still being removed.
I added a boolean, IsRemovingHeart, for preventing another building from dying until the heart is completely removed.
It works, but now the last heart will not be removed.

can someone help me?

sour adder
# sterile path any ideas?

An idea is something like this:

jumpTime -= Time.deltaTime;
if (Input.GetButton("Jump"))
{
    if(jumpTime > 0 )
    {
        rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpPower);
    } 
}
if (Input.GetButtonUp("Jump"))
{
    jumping = false;
    jumpTime = 0;
}

At the very least you can't detect ButtonUp while holding the button down. There are probably other problems as well, think it through.

sterile path
#

does this have to do w unity's new version tho? i tried looking up a solution on yt and they all seem to use my concept

elfin pike
#

Static classes is okay to use? For example, class SavePlayerSession, receives and handles data to save in JSON file

boreal sonnet
#

my player is moving very slowly ? how should i fix it?

sour adder
sterile path
hexed terrace
#

increase the speed

boreal sonnet
sour fulcrum
#

Thats not related to your player moving slow

#

i don’t know why you think it would be

boreal sonnet
sour fulcrum
#

if it’s not related to the player moving ask about that issue

#

if you have two issues you have two issues

boreal sonnet
#

see the picture i send earlier

elfin pike
hexed terrace
#

that screenshot has no relevance to movement speed

elfin pike
boreal sonnet
elfin pike
boreal sonnet
#

see the error in meta file.

naive pawn
boreal sonnet
elfin pike
naive pawn
#

warnings aren't errors

#

and inputmanager is still perfectly usable

#

it's the reason for the warning, yes. it's not the reason for the issue that he asked about.

boreal sonnet
#

what to do with the meta file. issue?

elfin pike
#

@boreal sonnet Are you using txt for setting values for tank?

naive pawn
boreal sonnet
#

imported it

#

i just started this tanks tutorial

#

i did as they asked

naive pawn
#

given that it's just documentation you could probably just delete the .meta file and have it regenerate

#

it's probably not being referenced by anything

boreal sonnet
#

but then this error shows up

cloud agate
#

Can someone explain why this is happening?

    IEnumerator LoadLevelAsync(int sceneIndex)
    {
        PrepareGame();
        SceneManager.LoadScene(sceneIndex, LoadSceneMode.Additive);
        Debug.Log("LOADED SCENE: " + sceneIndex);
    }
    void PrepareGame()
    {
        Debug.Log("Current player is: " + playerPos.position);
        Debug.Log("Player position set to: " + initPlayerPos);
        playerPos.position = initPlayerPos;
    }

PrepareGame sets the player's position to a specific spot
Then Additive load scene happens

So why doesn't it FIRST set the player where they're set to be and instead not do it at all at times?

twin pivot
cloud agate
#

(The player is not part of the scene that is loaded)

wintry quarry
#

I'd guess the scene loading is totally irrelevant

cloud agate
wintry quarry
cloud agate
#

Yes, I'm just not sure how it works

wintry quarry
#

How what works

cloud agate
#

The charactercontroller

#

I just move the playerObj with a transform reference

#

(In this case)

wintry quarry
#

As I mentioned, that doesn't work since you have a CharacterController

#

I also mentioned how to fix it

cloud agate
#

Yeah trying this right now, just kind of taking too long to respond sorry

#

(me)

#

This worked

#

Thanks a lot

naive pawn
devout sluice
#

how do I make the jump more snappy? I want to increase the speed when going up
and any other suggestion to improve this?
2nd if statement checks for the linearvelocityY

stone heron
#

usually you would have the jump be extended if you hold the key

#

often this is done by increasing the gravity after you release jump

wintry quarry
stone heron
#

otherwise i would just play with the gravity and jump height until you like it yeah

#

animations and particle effects also will go a long way here

devout sluice
devout sluice
slender nymph
#

also reset the Y velocity to 0 right before applying any upward force (assuming you are adding force and not just assigning a value to the Y velocity)

wintry quarry
devout sluice
#

is adding force better than changing velocity?

wintry quarry
#

they're physically equivalent

#

the end result of adding force is a change in velocity

devout sluice
#

I want it to be little faster when going up but jumpspeed does not change that

wintry quarry
#

but you mentioned "snappiness"

#

and that will only come with increased gravity

keen dew
#

Or make the player character smaller and decrease jump speed

#

large things jumping higher take longer time

stone heron
#

just play with the jump force, and gravity

#

if you cant get something u like with those two, then add the jump height control mechanic

devout sluice
#

okay then Ill just play around with it

#

thanks a lot

stone heron
#

jump force will only increase the height

#

gravity will increase the overall speed but will decrease the height

sterile coral
#

yo i am trying to make a clickable sprite but its not working and i dont know why this is the script:

wintry quarry
#

Instead of OnMouseDown You need:

  • A collider2D on the sprite
  • A Physics2DRaycaster on your camera
  • An EventSystem in the scene
  • To add the IPointerDownHandler interface to your script
versed mural
#

Soooo how to learn?

solar hill
#

!learn

radiant voidBOT
stone oar
#

hey guys, question - how would you handle a ceiling collision using a character controller? currently when i just the velocity just keeps me stuck to the ceiling up until it drops down with gravity.

wintry quarry
wintry dew
#

is it a good idea to make a scriptable object singleton to for example store a list of like 20 prefabs that should be accessible from most scripts?

#

as i dont need to change the prefabs and as an asset it stays throughout scene changes

frosty hound
#

As in a database? If it works it works. 🤷‍♂️

wintry dew
#

yeah database

#

i mean i dont really know how else because non-destroy on load singleton gameobjects feels super janky

#

if theres better methods i wouldnt mind changing

teal viper
naive pawn
#

would need to reference assets though

teal viper
#

Load from resourcesthinksmart

naive pawn
#

magic strings with lazy loading does not sound fun lol

teal viper
#

Making the best suggestions lol

wintry dew
# teal viper Why?

in some scenes i for example dont want certain managers, and i mean i dont necessarily need to see the object in hierarchy if its sole purpose is database

wintry dew
#

is it like a weird strategy or is it reasonable

teal viper
wintry dew
#

data design oriented layer? what is ddol

teal viper
#

Don't destroy on loaf

wintry dew
#

oh ok

teal viper
#

Have a separate database singleton in every scene you need it.

wintry dew
#

wouldnt i have to manually place that object in every scene though

teal viper
#

Then just reassign the static reference.

wintry dew
#

i dont see how a singleton asset isnt just simpler to deal with

teal viper
teal viper
wintry dew
#

Its good to know options, but i was wondering if there were options which were better in some sense, does a gameobject allow for more storage or something?

teal viper
#

As Steel said, if it works it works. Don't think too hard.

wintry dew
#

ok that makes sense

teal viper
wintry dew
#

If there isnt any blatant drawbacks im not aware of imma keep doing this then lol

teal viper
#

You mentioned loading from resources. That's generally considered bad due to having to deal with manually inputted strings.

#

Also, poor control of what's getting loaded.

wintry dew
#

Ah i see yeah

#

strings are definitely a downside

teal viper
#

That being said, it doesn't mean you should stop doing it. It's just one argument against it.

wintry dew
#

With larger scale builds it would definitely be troubling, but im just loading in one single scriptable object from resources which exclusively holds scriptable objects for now

waxen adder
#

Is there some way to get the current state an animator controller is in?

boreal sonnet
ivory bobcat
boreal sonnet
#

everytime i move them they rotate...i haven't wrote the code ...it came with the when i downloaded the assets.

ivory bobcat
spark ruin
#
using UnityEngine;

public class BulletBounce : BulletModifier
{
    public int maxBounces;
    public float damageOnBounce;

    private int currentBounces = 0;
    private bool justBounced = false;

    public BulletBounce(int maxBounces = 3, float bounceImpactDamage = 5f)
    {
        this.maxBounces = maxBounces;
        this.damageOnBounce = bounceImpactDamage;
    }

    public override void OnCollision(Collision collision)
    {
        if (currentBounces >= maxBounces)
            return;

        // Ignore enemies
        if (collision.gameObject.GetComponent<IDamageable>() != null)
            return;

        currentBounces++;
        justBounced = true;

        Vector3 incomingVelocity = projectile.GetVelocity();
        Debug.Log($"BulletBounce: Incoming velocity: {incomingVelocity}"); //Usually something like ( +/-0.50, 0.00, 0.00)
                                                                           //on a straight wall shot perpendicularly

        Vector3 surfaceNormal = collision.contacts[0].normal;

        Vector3 reflectedVelocity = Vector3.Reflect(incomingVelocity, surfaceNormal);


        projectile.SetVelocity(reflectedVelocity.normalized * incomingVelocity.magnitude);

        projectile.transform.rotation = Quaternion.LookRotation(reflectedVelocity);
    }

    public override bool ShouldDestroy()
    {
        if (justBounced)
        {
            justBounced = false;
            return false;
        }

        return currentBounces >= maxBounces;
    }
}
``` So basically i'm making a top down 3D shooter and I encounter this problem, when my bullet hits a wall the bullet seems to "stick" to it and slide along the wall, It also decreases the magnitude to really small values so the bullet does not keep any momentum. Bellow are the rigidbody values
#

If anyone knows what's happening your help would be greatly appreciated

spark ruin
#

Mb I fixed it, it was the physics material that had friction set to to a value above 0

pure raven
#

Unity is so bad

leaden lion
#

Hi

chrome apex
#

do people really not like using switch-based state machines?

leaden lion
#

Is there a really easy way I can create my own Discord nuke bot? I don't want to nuke any servers with it, I just want to know for myself that I've accomplished something like this. That's one of my goals, simply to create such a bot, but I don't intend any harm with it.

#

How can I create such a bot without programming knowledge?

fickle plume
naive pawn
naive pawn
chrome apex
# naive pawn why do you say that?

I've heard people say that online. Might be true for many states and/or combination of states, but there's no reason it shouldn't be used if the cases are simple and there's like 5 of them, right?

naive pawn
#

generally if you want to validate or question a claim, you have to provide the context and reasons given for said claim

hexed terrace
#

The use of them will depend, yes, if you're going to have a thousand states.. a switch is not gonna cut it, it's not scalable or maintainable. If you're gonna have 10 states.. then, sure, go for it.

naive pawn
#

otherwise we're just disputing some random statement that probably isn't even the original claim

steady horizon
#

Hey, i want to make a hypercasual game where i drag my finger from one 3dobject, it spawns an obirope from that object and then i let it go over another 3dobject, the rope will attach to that one. I can't wrap my head around the steps i would need to go through to make a prototype of this

#

Can someone help me break this problem down

#

I come from godot. Is it normal to attach a lot of scripts to an object as components

#

I dont know what the good practices in unity programming are

hexed terrace
steady horizon
#

Like 5-10

hexed terrace
#

not a problem

steady horizon
#

Because you can only attach 1 script to another node in godot

hexed terrace
#

once it starts becomming unmanagable (too much scrolling/ etc) then would be a good time to look at splitting it up

steady horizon
#

I see

#

Could you help me figure out the logic for my game

#

The click to drag sort of thing

hexed terrace
#

tapping first object -> spawn obirope and assign tapped location to end of rope -> assign draggin pos to other end -> update drag pos -> check for 3d object on touch end -> assign new pos to rope end OR dangle/destroy it

steady horizon
#

Riight

hexed terrace
#

the logic of that would be the same for any game engine

steady horizon
#

Destroy if the finger doesn't reach another object

#

Thank you

rough granite
# hexed terrace not a problem

Interestingly enough it bacome a problen on my poor little laptop after 20 scripts with dozens of serialized properties each, though i feel that this was also thanks to odin inspector (it would drop my frames from ~150 to ~30 when i had the object selected and the inspector shown

hexed terrace
#

I used an asset once, that had a heavily customised inspector, editor fps dropped significantly with anything selected that had it (even scrolling the inspector was sloooowww).

The entire asset was very, very, poorly made (repeated code, string searches, string searches for game object names, etc) and I wish I'd not bought it.

north walrus
#

Any advice on some reads/video/repository study?
I'm at a point where I'm struggling on planning architecture within an unity project

hexed terrace
north walrus
sour fulcrum
#

Yeah just doing it poorly is honestly a pretty reliable way to get better at it

#

I personally have my own package with generic, reusable ideas that i constantly use in projects which has been good for iterating on ideas in the same place and getting in a good headspace about architecture

mint flicker
#

hey douse anyone know how to fix the bug where i cant add modules it wont apear its just shows in the explore or pach notes

hexed terrace
mint flicker
#

but how do i make it add modules again it sounds risky replacing files

frosty hound
#

When you installed it, did you use the Install > button to do it from Unity Hub? Or did you manually install it yourself?

hexed terrace
# mint flicker let me check

If you don't install a version through the hub, then you cannot use the hub to install extra modules.

You will have to go back to the download archive and grab the installer for the version you're using, then use that to add more.

mint flicker
hexed terrace
#

no

mint flicker
#

ohh okay i get it now im putting the version like desktop into the project

#

Manley

hexed terrace
#

that makes no sense, and doesn't sound right

mint flicker
#

okay never mind xD

#

i will keep ckecking

hexed terrace
#

A project is not affected by the install at all. You can completely remove Unity from your computer and the project is still safe, until you delete it, or have a tech issue with your h/w

#

and this is a code channel, so any further questions on this should be moved to #💻┃unity-talk

balmy vortex
#

hi is there a list of common code optimizations lying around somewhere for unity?

frail hawk
#

code optimization begins on your side

balmy vortex
#

wat does this mean

red pelican
#

Hello chat! I have been making cronus zen scripts and have been learning along the way. Im absolutely stuck on the menu. I've tried to follow everything I've found to integrate it through out the script but it constantly throws a redline error on a line that im 100% is correct. Rendering the menu useless. Anyone have experience in cronus zen?

naive pawn
naive pawn
keen dew
red pelican
#

The main will show no errors but when I put the menu and add the weapons and variables to it a redline error saying invalid space or invalid name "Weapons_Menu" or it will even reject const string_name "NIGHTMARE"

#

Its like the whole menu code is wrong and corrupting because my zen screen its self with bug out. I remove the menu and its ba k working fine.

naive pawn
#

uh is this related to unity?

red pelican
#

Im using visual studio to build it and a compiler to check for errors

naive pawn
#

that doesn't answer my question

#

this is a unity server

red pelican
#

In a code beginner section of a discord server.

#

Hense "code beginner"

naive pawn
#

this entire server is dedicated for unity

red pelican
#

Where creators can connect, learn and grow.

naive pawn
#

the people here wanting to help are proficient in unity. is your question related to unity? if not, we won't be able to help.

red pelican
#

Didn't know it was specific my bad I'll leave

naive pawn
#

try a server specific to cronus zen, if one exists - you'd probably be able to get help there

red pelican
#

Bunch of scammers, im good. Thought this was a learning community.

naive pawn
red pelican
#

Scammers on cronus servers

naive pawn
#

well, try their forums then i guess, or maybe dive into docs yourself

red pelican
#

They dont want to teach you. Only charge you to do it.

frosty hound
#

A tool for cheating has a community full of scammers? Shocking

stone heron
#

lmao

red igloo
frosty hound
#

You're probably setting a new velocity directly when you jump a second time.

wintry quarry
#
        if (!isGrounded && isFullJump && !doubleJumpUsed && jumpBuffered)
        {
            Vector3 v = rb.linearVelocity;
            v.y = 0f;
            rb.linearVelocity = v;

            rb.AddForce(1f * jumpForce * Vector3.up, ForceMode.Impulse);
            doubleJumpUsed = true;
        }```
#

what do you think that v.y = 0f; bit is doing?

#

Did you write this code?

red igloo
wintry quarry
red igloo
wintry quarry
#

what in particular needs fixing?

#

How would you like it to behave?

red igloo
wintry quarry
#
        if (rb.linearVelocity.magnitude > accelMaxSpeed)
        {
            rb.linearVelocity = Vector3.ClampMagnitude(rb.linearVelocity, accelMaxSpeed);
        }```
#

try removing this temporarily

stone heron
#

you want to treat your vertical and horizontal velocities as separate

red igloo
stone heron
#

theres not much of a reason to clamp overall velocity

wintry quarry
stone heron
wintry quarry
#

also simply reducing the vertical force will make it jump less too

onyx musk
#

Hey all

#

New coder here

red igloo
# wintry quarry also simply reducing the vertical force will make it jump less too

OK so now the jump is smooth but when I am moving and double jumping it doesn't really work together and when jumping and when getting close to the ground then going for the double jump how would I make it reach the double jump height instead of it moving up a bit.

Updated Script : https://paste.ofcode.org/fSR8sLjdmJNdzUyB42ZTZD

covert sinew
#

Question, can someone give me a brief bit of advice, I'm thinking about how I want to handle buildings in my game, and whether I want each interior to be its own scene, or just a hidden part of the current scene.

I already have a system made for transitioning between scenes via doorways, of course, but I'm curious if I should spool out another system for transitioning into areas within the same scene too.

ivory bobcat
red igloo
ivory bobcat
edgy tangle
#

I think you probably want to keep the zero-out of y linear velocity for a double-jump

#

It looks like since you’re falling then when you add force you’re adding to a negative y velocity

ivory bobcat
#

I would set the vertical velocity to zero if negative when attempting to jump

red igloo
edgy tangle
#

So you get a smaller visible impulse

ivory bobcat
edgy tangle
#

That’s a good point as well. Might only want to zero-out if you’re falling

#

If you’re already going up don’t zero-out

#

Depends on what feels right for what you want

split remnant
#

can someone help me with the new input system for getting my mouse to work with keyboard, the mouse left click doesnt work if i bind it to mouse, if i bind it to a keyboard input it works, and if i bind it to mouse and change some control schemes around to mouse and keyboard it works with the mouse but the movement keys start to stop and catch on nothing

split remnant
#

thx

limber gazelle
#

is the unity documentation a reliable source for a complete beginner?

#

talking about this

slender nymph
#

this is not a comprehensive tutorial that will teach you all of the necessary fundamentals if that is what you are asking

limber gazelle
#

it would be better to follow a yt tutorial?

slender nymph
#

consider following a structured course like the pathways on the unity learn site

limber gazelle
#

thank you

pastel cave
#

Idiomatic Unity - say there's a GameObject with a Hitbox Component that is parented to a GameObject with a Health Component.

What would the best way to communicate to the Health when the Hitbox determines it should take damage?

#

My first thought was something like public IDamageable damageable; on the hitbox, but that doesn't appear in the editor

frail hawk
#

by referencing the Component

slender nymph
pastel cave
#

Hmm. Okay, but say I want to have a different type of damage listener. Like a damage logger or something. Would I have to create some base class DamageConsumer : MonoBehavour that Health and DamageLogger both inherit?

#

Or is that just more "bad idea"

frail hawk
#

you are confusing things rn.

#

just create a reference to the component of interest

pastel cave
#

I'm aware you're suggesting something like public Health health;

frail hawk
#

or explain it better so we can recommend something better

pastel cave
#

Okay

#

So IDEALLY I would like to have a Hitbox component that generically informs whatever component is provided to it so long as it implements an interface

#

I'm aware I could just provide the hitbox with a reference to the Health component, but that feels inflexible to me

slender nymph
#

use an event instead

pastel cave
#

An EventHandler?

ivory bobcat
slender nymph
#

no, there is almost no reason to use the EventHandler delegate. either use an Action or a UnityEvent

pastel cave
#

Alright I'll look into UnityEvent

frail hawk
#

you can assign all listeners via inspector it is a nice solution provided by unity

pastel cave
#

Oh, perfect

#

Great, thanks

#

Yes this is exactly what I need
What's the advantage to Actions? These seem to overlap, except UnityEvent also is assignsble in-editor. Is Action just considerably lighter so it's preferable for events that will only be programmatically assigned to?

ivory bobcat
red igloo
ivory bobcat
pastel cave
stone heron
covert sinew
stone heron
#

if its all in the same scene it would be worse performance, unless you disabled the interiors or something. If you put it in another scene then you could just load what you need. Do you want there to be a clear transition (like in pokemon/zelda games) or do you want it to be seamless? Do you want to be able to see inside buildings from the outside?

#

without a clear goal theres no approach thats "better" it depends on what you want for this game

#

what problems are you trying to solve? performance? level design? game flow?

grand snow
red igloo
inland crystal
#

Mind if I ask a sort of related question - I'm going to move on to Input Actions so its not important, but not knowing what causes the following issue has been irrationally annoying:

bool a = Gamepad.current.aButton.IsPressed();

... Occasionally, it just gets stuck on a true or false state. eg, it goes true when pressed, then when released, it doesnt go back to false.

I must be using it wrong, but... how?

polar acorn
#

Where are you running that line of code?

inland crystal
#

Update

rough granite
inland crystal
#

It's just right there every Update. Now that I think about it maybe I should try FixedUpdate see if that makes any difference.

From what I've read, it seems like Gamepad class polls the device on a schedule, so I tried varying the polling interval and the application target framerate but nothing seems to stop it from happening.

grand snow
inland crystal
#

Thanks, thats interesting! Even the input debugger doesn't always register the change in input.

#

Wonder if my controller is gubbed... I'll try another

grand snow
inland crystal
#

I forgot about the visualiser too, thanks. Welp, its definitely my Unity project at fault

grand snow
inland crystal
#

Thanks again, do appreciate the help btw; but I've already tried messing with the polling rate, to no avail.

true pasture
#

Does anyone know how to keep unitys context while not opening the entire project in vscode. So for example If I open the scripts folder without unity it doesn't link for debugging and unity imports seem broken. But if i open through unity it opens the entire project. I only want to see my scripts folder.

grand snow
#

no you need vs code to open/detect the c# project unity generated to get all features

#

Use search to find types/files instead (ctrl T, ctrl P)

zenith cypress
fringe sinew
#

Hi everyone, I want to have a scrollable menu that has 1000+ different items in it.
I used a editor script to fill it with the items I need since theyre always the same just to test if it would be a simple issue but it takes too long to start up the project now since there are assets each one needs to get.

How would people recommend doing this / how is it usually done?

queen adder
#

I been coding all day first time ever had to watch alot of videos and chatgbt to help fix things

grand snow
queen adder
#

@grand snow is it good to use chatbgt to help with scripts?

grand snow
queen adder
#

Chatgbt lol

#

I made a bunch of scripts today by watching videos and using chatgbt

#

For help

grand snow
#

Did you learn anything? i guess not

queen adder
#

A little bit lol

fringe sinew
queen adder
#

using UnityEngine;

[RequireComponent(typeof(CharacterController))]
public class PCBO4Movement : MonoBehaviour
{
public CharacterController controller;

[Header("Speed")]
public float walkSpeed = 6f;
public float sprintSpeed = 9f;
public float slideSpeed = 12f;
public float airControl = 0.6f;

[Header("Jump & Gravity")]
public float jumpForce = 8f;
public float gravity = -20f;

[Header("Slide")]
public float slideTime = 0.8f;
public float crouchHeight = 1f;

private float normalHeight;
private Vector3 velocity;
private bool isSliding;
private float slideTimer;

void Start()
{
    controller = GetComponent<CharacterController>();
    normalHeight = controller.height;
}

void Update()
{
    HandleMovement();
    HandleJump();
    HandleSlide();
    ApplyGravity();
}

void HandleMovement()
{
    float x = Input.GetAxisRaw("Horizontal");
    float z = Input.GetAxisRaw("Vertical");

    Vector3 move = (transform.right * x + transform.forward * z).normalized;

    float speed = walkSpeed;
    if (Input.GetKey(KeyCode.LeftShift)) speed = sprintSpeed;
    if (isSliding) speed = slideSpeed;

    if (!controller.isGrounded)
        move *= airControl;

    controller.Move(move * speed * Time.deltaTime);
}

void HandleJump()
{
    if (controller.isGrounded && velocity.y < 0)
        velocity.y = -2f;

    if (Input.GetKeyDown(KeyCode.Space) && controller.isGrounded)
        velocity.y = jumpForce;
}

void ApplyGravity()
{
    velocity.y += gravity * Time.deltaTime;
    controller.Move(velocity * Time.deltaTime);
}

void HandleSlide()
{
    if (Input.GetKeyDown(KeyCode.LeftControl) && controller.isGrounded && !isSliding)
    {
        isSliding = true;
        slideTimer = slideTime;
        controller.height = crouchHeight;
    }

    if (isSliding)
    {
        slideTimer -= Time.deltaTime;
        if (slideTimer <= 0)
        {
            isSliding = false;
            controller.height = normalHeight;
        }
    }
}

}

#

My movement Script

grand snow
queen adder
#

I tryed to make it like black ops 4 and I had chatgbt to check it

fringe sinew
grand snow
#

Manual initialization is just better when you need to control things

fringe sinew
#

So with a Coroutine probably right?

#

just have it start on awake/start and end after X iterations / all done?

polar acorn
radiant voidBOT
grand snow
queen adder
grand snow
fringe sinew
polar acorn
queen adder
#

I said I made it I watched YouTube videos all day and worked on it lol

#

I used chatgbt to check it

grand snow
fringe sinew
grand snow
plain forge
#

Hello everyone,
I am trying to implement a custom post processing renderer pass into my game but I have a problem. I want to check if the component is enabled or disabled but this code doesn't work? What am I doing wrong?

grand snow
#

is this what you mean?

plain forge
# grand snow is this what you mean?

let me rephrase my question, currently my render pass is rendering no matter if the VolumeComponent is enabled or disabled. I check it like this in my RendererPass. I want to check if the second image's checkbox is checked or not in the RenderPass' RecordRenderGraph method. I hope this is better. Thanks

grand snow
#

active sounds right but ill be honest the docs are not great at detailing render graph and volume stuff

plain forge
grand snow
#

Aha then the description for active is accurate

#

meaning its not actually meant to be used for "should this pass be executed or not"

#

fuckin shit name thou

civic palm
#

how can i give objects more than one tag?

#

my terrain can be 2 types (safe or danger), but i want another type (drillable) that both of the original 2 can be but i only want certain parts to be drillable

grand snow
edgy tangle
#

Yes that’s the way. Otherwise the answer to your original question is “you cannot”

#

You can get crafty with how robust you make your tagging system, but otherwise could just make an enum with the [Flags] attribute so you can use a bitmask and have the nice check mark drop-down

#

That also means you’ll need to use a bitwise operator to check the tags, but you can make a helper function so it’s easier to read in the code

slender nymph
#

bitwise operators aren't entirely necessary to determine if an enum instance contains a specific flag, there's the HasFlag method

grand seal
#

!docs

radiant voidBOT
mortal bluff
#

hi all,

for a small project, i want to load a procedural mesh (1k-ish vertices) into canvas. the naive solution of pushing every individual vertex in OnPopulateMesh works well enough. sadly, this implementation is so slow that it causes noticeable lag. im pretty sure there is a faster way with AddUIVertexStream or FillMesh, but the documentation for VertexHelper and UIVertex is incredibly sparse, so im having a bit of trouble understanding what im supposed to do here. could anyone show me the way?

(please ping me if you choose to respond)

teal viper
mortal bluff
teal viper
mortal bluff
#

excuse me, i meant gpu buffer

#

ill post some data when i get back at my pc

teal viper
#

GPU buffers are not subject to GC collection, so you're probably misinterpreting the data.

mortal bluff
#

very likely :P

#

i imagine that the AddVertex method is creating some kind of temporary data structure thats spiking garbage, but thats just a suspicion

teal viper
#

Or you're recreating a vertex helper every frame

mortal bluff
#

i dont really know how OnPopulateMesh works behind the scenes - again, the documentation is not helpful - but im just using the instance thats passed by the callback

teal viper
#

If it's a minimap or something, you might want to consider drawing it to a render texture and displaying via a raw image in the ui.

mortal bluff
#

yeah, i might eventually settle for something like that

livid anchor
#

Hey, working on a snake type game. I have an issue I'm not sure how to resolve it.

I want to spawn pick ups for the snake to eat, but I don't want it to spawn either on the snake or on an obstacle.

Just to spawn at a random position is easy, buct checking if a position is valid is another issue

queen adder
#

what is the world is the unity player input component used for

#

i checked there offical input videos and there they directly used the input system in the script rather than adding using the player input component

chrome tide
livid anchor
#

The issue I think is that I have no variable tracking where is what. I just have the snake moving in space righ now

chrome tide
livid anchor
#

Yeah i have a list with all the snake transforms. I could indeed check the position of each segment before instantiating a pickup. But generating random numbers and checking availability seems inneficient.

chrome tide
#

it depends on how you implement it. if you simply roll a dice until a specific condition is met, then that is of course very inneficient because in the worst scenario you could NEVER meet the condition. that's why i recommend you to instead collect the positions that meet the condition (e.g. don't store food and aren't any of the snake's segment's position), and then picking a random one of those.

livid anchor
#

So I would create a list of all available choices, remove the one already taken and pick from those ? Yeah that can work

chrome tide
#

yeah, something like that.

#

you might also need to check if the .Count == 0, as you'll get an error if you try to index an empty list

livid anchor
#

Can you compare two Transforms ?

rotund sandal
#

How do I align the circle with grid snapping it to the box's circle?

chrome tide
livid anchor
#

Yeah

chrome tide
#

yes, you can just check if TransformA and TransformB positions are similiar. just make sure to not use == because of floating points, it's better to check if the difference between two values is less than an epsilon (e.g. 0.001f)

nocturne kayak
#

Hello guys i'd like to "restrict" the x axis so you cant fully turn your camera around when you are sit but i'am really unsure on how to do it ( i did something for the y axis and it work but i just dont think it would work for the x axis ) https://paste.mod.gg/fanatlfevdme/0

chrome tide
keen dew
#

Make a variable yRotation and change the look system to work the same way with y rotation as you already do with x rotation

nocturne kayak
broken nest
#

Hello, can I change the shape of a 3d object? Like putting a hole in a cube?

#

At runtime, not in blender

sour fulcrum
#

Not easily

broken nest
#

Guess I'll do it myself

chrome tide
grand snow
#

You can cheat using the stencil buffer but doing realtime boolean operations is not easy and would be best via a pre existing mesh lib

broken nest
grand snow
#

@broken nest ^

broken nest
#

Thanks a lot 🙂

broken nest
#

Kind of a follow up question, is there a 3d object by default that's only one triangle? cos there's a quad with 2 triangles. Do I have to get blender for that?

night raptor
broken nest
night raptor
# broken nest Thanks, how do i do it via code?

You can search up ”procedural mesh generation”, but it’s definitely not the easiest way. If you only need one kind of triangle, you should use one of the former options. Mesh generation is mostly useful for meshes that will change between runs of the game

sour fulcrum
broken nest
#

thanks a lot guys

narrow plover
#

"Where is the best place to start learning Unity? I already have some experience in programming.

radiant voidBOT
rich adder
#

!docs

radiant voidBOT
dire halo
#

Hi all, I am new to code and i am already stuck. i figuerd i could use some help lol. Can someone tell me why my code is not working atm?

naive pawn
#

seems like you have an error - make sure to read what the error is saying and where it's coming from

solar hill
naive pawn
#

if you're following a tutorial, make sure to follow it accurately

broken nest
#

How do i setup visual studio again?

#

I followed the guide but component don't show highlighted and stuff

slender nymph
broken nest
#

I did that already

slender nymph
#

read the entire page

broken nest
#

Got it working i was missing something in visual studio

fringe sinew
grand snow
fringe sinew
#

Ive been using debugger and what I put in above is what they have

wintry quarry
#

also make sure p.name is actually the field you want

#

name is the builtin one from UnityEngine.Object

grand snow
#

oh yea, for scriptable objects its the asset name

fringe sinew
#

Yea I understand its the asset name

stone oar
#

im trying to set up bloom on the unity's toon shader but i cant make it work. i had followed the code monkey tutorial and a bunch of other tutorials with post processing and whatnot and nothing seems to work. and i have enabled post processing in editor, every other effect like motion blur works, but not the bloom. HDR is also enabled. Intensity of the bloom is also cranked up to like 50

fringe sinew
#

thats how I want it to be

wintry quarry
sweet fern
#
using UnityEngine;

public class BirdScript : MonoBehaviour
{
    public Rigidbody2D myRigidbody;
    void Start()
    {
       
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) == true)
        {
            myRigidbody.linearVelocityY = 5f;
        }
    }
}

why wont the linearvelocityY work?

grand snow
# fringe sinew

This should work just fine and i trust c# so lets presume its doing its job and there are infact 0 matches

#

therefore verify the data its looking though is what you expect

wintry quarry
sweet fern
fringe sinew
wintry quarry
#

your code is trying to use the old input system

#

but your project is using the new input system

#

(the new system is the default in new projects)

sweet fern
#

How can I change that

sweet fern
#

What's teh new input system

wintry quarry
sweet fern
#

how can i use the new input system

stone oar
wintry quarry
grand snow
fringe sinew
fringe sinew
grand snow
fringe sinew
#

Ill look into it more but Im like 99% sure its all right. Thank you for the help anyway!

grand snow
#

My example on dot net fiddle was to demonstate that yes we get the expected result from Contains() so that works as intended

naive pawn
# fringe sinew

perhaps check if there are any invisible characters in there

fringe sinew
grand snow
#

something else is up or these characters are some weird other unicode character

keen dew
#

I'm guessing it's the good old wrong type for an input field instead of TMP_InputField

dense mica
#

Howdy folks. For a few years now I've been plagued by an issue where, after loading the title screen of my game, and choosing new/load game, everything pauses for 5-6 seconds while the scene loads. This happens about 1 out of 20 times, as normal scene loading is instantaneous. Its a simple 2D game with very little in the way of assets on a 7800X3d... so this is quite unusual. No errors are being thrown during this time and the PC is otherwise idle.

I notice it occurs with editor->play and when released and installed on iOS and Android. On mobile the delays can take 20 seconds or more even in release mode. Its rare, so not too disruptive. But given things normally load instantly I've not added loading bars. And even if I did, given the length of the pause the bars wouldn't do much. So my problem is I've struggled to identify just why things are locked up for so long. Even deep profiler debugging hasn't been too useful in highlighting where all the CPU time is going. Curious if anyone had thoughts about how to debug such a thing?

dense mica
#

I'd mentioned I use the deep debug profile capability. It also locks up and is unable to give any insight into things.

#

Rather, Unity is so busy its not sending packets to the profiler.

fringe sinew
#

Also updated contain to use the trim and all but same result

rich adder
keen dew
dense mica
#

I mentioned I do both. I run it in the editor AND I've deployed on iOS and Android.

fringe sinew
keen dew
#

It should be TMP_InputField

dense mica
#

I've tried every combination of optimizations (most of which remove profiling obviously). Its random, and is rare, hence why its difficult to track down.

keen dew
#

Input fields have an invisible control character

grand snow
dense mica
#

I'd thought perhaps there was some caching going on. Because like just now, I loaded up Unity and it happened right out of the gate (which is why I thought to come ask about it). But it probably won't happen again today. Is there a cache I can go delete to see?

fringe sinew
dense mica
#

Library folder doesn't exist for a released/installed game.

grand snow
rich adder
dense mica
#

Thank you. I'll see if nuking that allows the pause to happen consistently so I can sort out what is up.

rich adder
dense mica
#

Real devices.

#

My iPhone generally outperforms my 7800X3D slightly, so the pause is present but 4 seconds to load isn't horrible. On my Android devices it can be over 10 seconds though. In some cases I believe it has locked up and then just pop, goes. And since the pause doesn't happen the rest of the day its like...well that sucks. Will certainly give a first bad impression to folks though if I can't optimize it out.

rich adder
#

Android Studio and iOS has one forgot what its called

dense mica
#

Hmm. I've not tried to get the native tools going. Given how debug packets stop being sent/received during the lockup to the Unity Profiler, I just assumed the native tools would get no updates either. Generally all higher level debugging is taking place over TCP/IP which is what seems to be getting trashed.

#

In my dayjob I do embedded development. There is benefits to having hardware level breakpoints haha.

rich adder
#

ya true.. I'd still give it a try see if they yield some better results than unity over tcp

red igloo
#

I'm honestly getting confused with rb.linearvelocity. when I hold the jump button to jump higher how can I get the exact peak height? I want to get the exact height and make it so if the player is at this height just for a few seconds the double jump will be available.

naive pawn
#

a hang time of a few seconds is crazy

red igloo
naive pawn
#

i wouldn't make double-jumping a timing skill check

#

but i don't know what you're going for

wintry quarry
red igloo
naive pawn
#

could just have those be separate actions, and make the skill check in the output, not the input
if you time the double-jump poorly, you don't get enough height
if you don't get enough height, the ground slam might not work or might not do as much damage - but you'd still be able to input that, and fall to the ground faster

nocturne kayak
#

Hello again i want to rotate the player so when he sit there is a great view , i just want to center the camera i have tried a couple thing but it dont work on the player gameobject , is there a way to directly rotate with something like transform , vector

#

oh wait i just cant rotate the player

#

okay i found the problem

#

As i this is my problem and i also guess its the wrong way to move a camera is there better way than this ? **Vector2 currentMouseDelta = Vector2.Lerp(previousMouseDelta, m_lookAmt, smooth);**https://paste.mod.gg/eoodmqjoomic/0

naive pawn
nocturne kayak
naive pawn
#

i mean, you aren't lerping. it's reusing the math behind lerp with different inputs to get a different result

nocturne kayak
#

alright thanks

naive pawn
#
if (yRotation > 360f) yRotation -= 360f;
if (yRotation < -360f) yRotation += 360f;
```this part isn't super necessary, but if you'd like to restrict it to a range, you would need `while` instead, or better yet, you can use `%` instead to not have any looping
red igloo
rich adder
#

Why not just a raycast/cast down from player to ground

naive pawn
#

if you continuously accelerate for the slam, sure (probably with a terminal velocity corresponding to a max damage)
but that's up to your design

#

also up to level design for what you need to support

#

a raycast could also work but would break if you do it above a platform that moves out of the way before you hit it

red igloo
#

The more ways I think of to do it the more issues that come with it. How would you personally do it?

rich adder
#

everything in development has compromises you are willing to live with

#

there is no "correct way" you have to make it work for your design / tolerance to pros-cons with each solution

#

personally I'd start simple with a ray check if I have enough / min distance height, maybe check some Y velocity for enough momentum . Some ignore layers could help weed out moving objects unrelated if you need

naive pawn
#

could also store the y position you started and compare against the y position you hit the ground at

rich adder
#

(thats for the damage amount - not initiating the slam in the first place)

red igloo
rich adder
#

is the slam a consistent speed ? is it faster/stronger when you're higher ? etc. those are also playing part into comparison

red igloo
rich adder
#

so yeah i'd start with a height check doing a cast from your current height to ground

nocturne kayak
red igloo
rich adder
zealous talon
#

guys, i created a build web gl for my game but when i try to start the server in local it doesnt finish loading. does anybody know why?

#

this is the repo where i started the server

#

idk if there are supposed to be more files

robust tiger
#

Hey yall I am new to all this shit and I am trying to upload a vrchat model to unity so I can put it in vr would anyone be able to help me?

keen dew
solar hill
radiant voidBOT
terse hatch
#

can someone help me with the tilemap
idk why this happens

rich adder
#

most likely camera / pixel perfect needed

untold shore
#

Hey! Currently Im having a problem with enemy attacking - primarily Ranged attacks not hitting near the player. The main issue is it going almost haywire, and going into different directions. Im thinking its because of rotation either in the bullet or the object transform, but I cannot find where my script would cause that. Attached are the two scripts that control the Enemy Firing:
EnemiesHandGunFire: https://paste.ofcode.org/TSXGphH4rZqQBRku6Nzp8E (Controls when the gun should fire - as you see there is a current issue with it firing multiple times in quick succession, but I'll focus on fixing that up later).
EnemyFiringProjectileScript: http://paste.ofcode.org/7sRXYbXdDuPFDPwJYt47j8 (Controls the actual creation of the bullets, the main thing that I think causes it. Is called by the EnemiesHandGunFire Script.)
Does anyone have any idea as to why this might occur? I've checked different ways as to fix it, including making the time between bullets extremely long and turning the gun (and attackPoint), but they haven't had success.
If you do help, please @ me. Thank you so much! UnityChanSalute

fast fern
#

so I have this to run different codes depending on having 1 or more elements in a list, for some reason else if condition causes stack overflow, is .count not good for this case?

if (Clip_Name.Count == 1)
{
    RandomClip = Clip_Name[Random.Range(0, Clip_Name.Count)];
    PlayAnimation(RandomClip, FadeDuration);
}
else if (Clip_Name.Count >=2)
{
    if (PreviousClip == RandomClip) { PlayRandom(); }  
}```
rich adder
#

show the entire code in context

fast fern
#

thing is it worked fine before I added the conditions

rich adder
#

probably something you changed, depends where you call this code & PlayRandom does

#

doubt its .Count itself tho

#

PlayRandom is probably constantly calling itself cause of condition causing overflow

fast fern
#

the project is a bunch of cards(buttons), when clicked it adds to the list of cards, and I don't want it to repeat the previous card to I tried writing this

public void PlayAnimation(string AnimationClip,float FadeDuration )
{
    Animator.CrossFade(AnimationClip, FadeDuration);
}

public void PlayRandom()
{   StartCoroutine(SearchPreviousClip());
    if (Clip_Name.Count == 1)
    {
        RandomClip = Clip_Name[Random.Range(0, Clip_Name.Count)];
        PlayAnimation(RandomClip, FadeDuration);
    }
    else if (Clip_Name.Count >=2)
    {
        if (PreviousClip == RandomClip) 
        {
            PlayRandom(); 
        }  
    }
}

IEnumerator SearchPreviousClip()
{
    yield return new WaitForSeconds(2f);
    PreviousClip = RandomClip;

}
fast fern
rich adder
fast fern
#

yiks

rich adder
#

instead of recursion use something like a while loop

#

do / while

fast fern
#

I'll see (still new to this lol)

rich adder
#

do note that start coroutine doesnt pause the function its in , the code under it runs immediately without wait

fast fern
#

ooof

rich adder
#

maybe you can try

public void PlayRandom()
{
    if (Clip_Name.Count == 0)
        return;

    string newClip;

    if (Clip_Name.Count == 1)
    {
        newClip = Clip_Name[0];
    }
    else
    {
        do
        {
            newClip = Clip_Name[Random.Range(0, Clip_Name.Count)];
        }
        while (newClip == PreviousClip);
    }

    PlayAnimation(newClip, FadeDuration);

    PreviousClip = newClip;
    RandomClip = newClip;
}```
#

probably is a better way, my brain aint fully braining right now but give it a try lol

fast fern
#

lol and thanks

rich adder
untold shore
# untold shore Hey! Currently Im having a problem with enemy attacking - primarily Ranged attac...

Wanted to also note without having a large spew of text on my first message:
The scripts are similar to my normal player scripts, which work without having the weird direction mess ups. Here are the player HandGunFireScripts and the FiringProjectileScripts in case you wanted to look at them:
Player FiringProjectileScript: https://paste.ofcode.org/NLZXBG6CmstaruCb7AEnGN
player HandgunFire: https://paste.ofcode.org/JzEenqDFU4P7nLYkNMQXg5

tulip relic
#

The last few times I've made a new Unity project, it's had compiler errors immediately upon creation, and I've had to remove whatever Unity packages were causing the error. com.unity.collab-proxy is the biggest offender. Is this a known issue?

timber tide
untold shore
sterile coral
#

someone pls help i've been trying to fix this for hours now i can jump but the game doesn't detect the raycast:

using Unity.Mathematics;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
public Rigidbody2D rB;

public float playerSpeed = 1.0f;
public float jumpForce = 5.0f;
public float playerHeight = 2;





void Update()
{
    //playerMovement

    transform.rotation = quaternion.Euler(0, 0, 0);

    if (Input.GetKey(KeyCode.Space) && GetIsGrounded() )
    {
        rB.linearVelocity = new Vector2(rB.linearVelocityX, jumpForce);
       }

    if (Input.GetKey(KeyCode.A))
    {
        rB.linearVelocity = new Vector2(-playerSpeed, rB.linearVelocityY);
    }

    if (Input.GetKey(KeyCode.D))
    {
        rB.linearVelocity = new Vector2(playerSpeed, rB.linearVelocityY);
    }



}

//groundedCheck
private bool GetIsGrounded()
{
    return Physics2D.Raycast(transform.position, Vector2.down, playerHeight, LayerMask.GetMask("Grounded"));
    

}

}

radiant voidBOT
solar hill
#

also start off with basic debug lines

#

specifically in your grounded check and then in the jump function

sterile coral
#

I tried debug.log in GetIsGrounded() but it doesn't say anything in console

untold shore
#

Oh I see where you called it- I’m blind

rough granite
sterile coral
#

the line under return physics2d.raycast

rough granite
#

return ends the function right there, if you want to log the bool value of return Physics2D.Raycast(transform.position, Vector2.down, playerHeight, LayerMask.GetMask("Grounded")); you'd need to do something like

bool Grounded = Physics2D.Raycast(transform.position, Vector2.down, playerHeight, LayerMask.GetMask("Grounded"));
Debug.Log(Grounded);
return Grounded;
#

for example here what you had would have the ide practically yell at you saying hey no

solar hill
#

also is your ground layer called "grounded"?

sterile coral
solar hill
#

and you assigned it to the ground gameobjects in the scene?

sterile coral
solar hill
#

what does the debug tell you then

sterile coral
solar hill
sterile coral
#

yeah it says true

solar hill
#

you still havent explained* the actual issue here, you said the game doesnt "detect the raycast" but if its returning as true then it is?

#

so whats the problem

sterile coral
#

the problem is that i can walk and jump i added the raycast but it doens't work while i typed if (Input.GetKey(KeyCode.Space) && GetIsGrounded() ) and now its returning something

solar hill
#

so now it works?

#

this sounds like a classic xy problem to me

sterile coral
#

it still doesn't work

solar hill
#

what doesnt work....

#

you still havent actually told us

#

whats supposed to happen and what is happening instead

#

first you said its the raycast but now you said its returning true

sterile coral
#

groundcheck so i can't triple jump

solar hill
rough granite
#

The ground check does work though, as you've said the log is saying "true" which means the GetIsGrounded is also returbing true

untold shore
rough granite
solar hill
#

some people dont make it easy to actually help them

#

we arent mindreaders, we cant guess whats going wrong without knowing what is happening that isnt supposed to.

sterile coral
#

I try to add a raycast for a groundcheck so i can't infinitely jump i added that in the script but i still can infinitely jump that is the problem

rough granite
halcyon moon
#

hi
i have 2 players in my game and added a mechanic that if i click on a player it selects them then right click somewhere else it moves there.
i just wanted to add a visual effect like a "highlight" when i click on him. smth for like half a second.
how can i do that?

#

yk "highlight" isn't the best word for it. smth better would be a "glow"

grand snow
#

An easy way would be some outline post effect

halcyon moon
#

hmm. i think if its easy i can go with it. but it isn't really what i wanted.

#

wait a mom. i will search for an example

grand snow
#

If you want a VATS like "highlight" then you can achieve that with a post processing effect or cheat and do it on the shader itself

sterile coral
halcyon moon
grand snow
#

Oh well just making a sprite "brighter" is easy with a shader

halcyon moon
#

ok thanks

elder hearth
#

Hi! Does unity 6.3 support VS 2026?

#

Wrong channel sorry

sterile coral
#

BROOO the problem was that i put the player layer on grounded accidentally 3 hours ago or something😭 tysm for your time♥️ @rough granite

red igloo
#

I am trying to make it so when you double jump and between the red and blue lines I want the height check to trigger only around that specific height and I am going insane. idk if the y velocity value is right at this point .

solar hill
grand snow
#

Yea if you track the amount of jumps taken and the position where the first jump happened you can probably do this a lot easier

cosmic dagger
icy wolf
#

can i ask something ? to someone (its a very basic problem but idkn how to fix)

solar hill
#

you can just ask yes

cosmic dagger
icy wolf
#

im doing a blend tree with the float Velocity,
even if i start the game scene i try to edit the velocity by the blend tree but the float does not change

#

it change only if i manually input on the parameters

icy wolf
slender nymph
#

show what you tried

cosmic dagger
#

yeah, we need to see the code to get an idea of what is wrong . . .

icy wolf
#

so the velocity it dosent change if i simple move the bar?

#

cause i just wanted to se some blend animations

#

everyone i saw on yt it dosent assign a script to move the bar and modify the float

cosmic dagger
#

did you see or watch what they followed to achieve that?

icy wolf
#

yeah

#

Learn how to animate characters in Unity 3D with dynamic animations from blend trees!

This beginner-friendly tutorial is a complete walkthrough of one dimensional blend trees and how we can use blend trees to create new animations for our characters using float parameters

ACCESS PROJECT FILES & SUPPORT THE CHANNEL:
💛 https://www.patreon.com...

▶ Play video
#

his parameter move when he drag

#

idkn why mine dosent he dont have any script attached to his blend tree

slender nymph
#

this is a code channel

icy wolf
#

ok sorry

#

where i can type about this problem?

slender nymph
cosmic dagger
icy wolf
#

thanks

somber narwhal
#

Today is my 19th birthday!

pliant dome
#

To anyone who is somewhat acquainted with fg generally like hitboxes and framedata and all that. Would using box colliders be better for hitbox and hurtbox detection or box cast?

rough granite
pliant dome
#

Oh crap lol

#

I meant fighting games

#

Im sorry

rough granite
#

Ah lol

pliant dome
# somber narwhal Today is my 19th birthday!

You think you could answer my question? I try not to @ random people but I couldnt help but notice you are aware of games like Melty Blood and so I thought you be kind enough to help out rq?

pliant dome
#

ok

grand snow
#

its not 2004 anymore so you are not forced to use boxes

pliant dome
#

Yeah I dont mean Mesh colliders

#

I mean if I should base my hurtbox and hitbox system using a box cast or use colliders. Like cast seems more customizable and fit better for stuff like hit box and hurt boxes in fg

#

I just dont fully know

grand snow
#

Box/Sphere casts are for when you want to "sweep" the shape along a path and detect intersections

#

But triggers attached to objects moving over time should work just as fine (with the right settings)

pliant dome
#

Okay cool

#

One more question

#

While Im here

#

Can you change the color of colliders?

#

Like making specific groups of colliders in the scene red or white?

grand snow
#

No but you can draw a gizmo yourself with different colours

pliant dome
#

Ohhh for some reason I just assumed that gizmos only work in tandem with cast

#

Ok cool thank you

grand snow
#

Gizmos are the visual thing shown in scene view

grizzled spoke
#

Hi does anyone know if it's safe to assign list values in the inspector?
one time i did that with a list of color objects and unity domain reloaded or smthg (the game WAS saved after i inputted the color values) and the list reset and became empty in the inspector
I had to look through the .unity file in my github push history to retrieve the color values I set earlier so I can add them to the list in code

is this a common issue or just a bug? it was in 2022.3.8f1 btw

grizzled spoke
ivory bobcat
grizzled spoke
#

is there a way to avoid that from happening?

#

or is the best habbit to just get references to everything in code

#

because when i searched it up online it seemed that everyone said that assigning stuff in the inspector is fine and efficient
no one really mentioned the possibility of the values resetting

grand snow
#

Assets and scriptable objects will keep their state and can be saved regardless of play mode

grizzled spoke
grand snow
ivory bobcat
#

I don't recall exactly when or why but if there's enough change, the inspector values are reassigned to their default values (they're re-serialized)

grizzled spoke
grizzled spoke
grand snow
#

Modifications in play mode do not matter.
The only other thing I can think of is the use of [ExecuteAlways] meaning you modified the data in edit mode

grizzled spoke
#

thanks for the advice ill be more weary about messing with inspector assigned values in code

grand snow
#

At runtime (play mode) its not a concern at all (except for assets)

grizzled spoke
ivory bobcat
#

If it's resetting outside of play mode, it may be due to some changes made to the members. For instance, changing the type of something exposed to the inspector would default the value. I don't recall if changing other signatures like the name of the member would though.

strong wren
pastel cave
#

I am attempting to create Pong.

Pong has a "spin" mechanic where the ball receives some of the velocity of the paddle when it collides with it.

This requires me to accurately be able to discern when the ball is being hit by the paddle. My thought was to completely disregard RigidBody2D and use the Cast method to get back collider infomation.

However colliders don't seem to collide with objects that don't have both a body and a collider. And RigidBody2D kinematics seems to plow through other kinematics and is entirely unhelpful.

Am I missing something?

#

I'm aware of full collisions mode on kinematics, but they still penetrate colliders (and even collide with stuff behind them). I'm also aware of Physics.Distance, but It's rather unusable if I don't have complete control over every movement the body makes.

#

Ideally, I would like a body that collides with everything else in a predictable and sane matter that I have complete control over. That is to say, I can call a method on it and it will go as far as it can in that direction, stop if there is a collision, and report it back.

ivory bobcat
# pastel cave I am attempting to create Pong. Pong has a "spin" mechanic where the ball recei...

A Kinematic Rigidbody 2D can still move via its velocity, but the velocity is not affected by forces or gravity. A Kinematic Rigidbody 2D does not collide with other Kinematic Rigidbody 2Ds or with Static Rigidbody 2Ds and will only collide with Dynamic Rigidbody 2Ds. A Kinematic Rigidbody 2D behaves like an immovable object (as if it has infinite mass) during collisions, and mass-related properties are not available with this Body Type.

pastel cave
#

The documentation promises something called a CharacterBody in 3D, which is a combination rigidbody and collider.

#

I have no idea how this thing works, but it implies that building what I want is possible.

#

Unfortunately unity is closed source so I have zero idea how it functions, and no guarantee that the tools to make it possible are exposed

rich adder
#

there are functions like Vector2.Reflect that are useful

ivory bobcat
pastel cave
#

Collider2D.Cast is FRUSTRATINGLY close to what I need

ivory bobcat
#

If you're just wanting kinematic behavior for movement, you could have some object with a kinematic rigid body and have some joint to connect it with a non-kinematic object

pastel cave
#

I... See...

#

Technically I suppose I could do that

#

It seems like a very roundabout solution for something that I don't imagine is a particularly rare want

#

Okay, perhaps I'm approaching this from the wrong angle.

#

How would a unity developer create the spin mechanic in pong?

pastel cave
#

I could certainly try to force a dynamic body to behave how I would like it to, but the concept of this sounds like a lot of wasted calculation. Not that it would matter for Pong, but I am ATTEMPTING to learn good practice.

fast fern
# rich adder if same clip is chosen repeatedly, PlayRandom() calls itself forever

Apparently I forgot to copy the block of code from the if statement, "else if" was repeatedly telling to re-run without randomising the clip, so PreviousClip=RandomClip the whole time without changing

It was simple and it slipped under my nose lmao

if (Clip_Name.Count == 1)
{
    RandomClip = Clip_Name[Random.Range(0, Clip_Name.Count)];
    PlayAnimation(RandomClip, FadeDuration);
}
else if (Clip_Name.Count >=2)
{
    if (PreviousClip == RandomClip)
  RandomClip = Clip_Name[Random.Range(0, Clip_Name.Count)];
    PlayAnimation(RandomClip, FadeDuration);
}```
cosmic dagger
fast fern
steady horizon
#

Is it normal to use an invisible 3dobject with a onCollisionEnter function to detect collisions or is there a better way of doing it

keen dew
#

If by invisible you mean has no mesh renderer then yes

vague charm
#

Can Somone Tell me how you can get better at scripting I cant do anythink how do I start😩🤌

naive pawn
ivory bobcat
ivory bobcat
vague charm
naive pawn
#

there are resources pinned in this channel

#

this is a code channel

floral garden
#

okk

hoary ruin
#

anyone know how to stop the piston from phasing trough? this is the code: using UnityEngine;
using System.Collections;

public class XYPushRetract : MonoBehaviour
{
public Vector2 pushOffset = new Vector2(-0.3f, -0.2f); // X, Y movement
public float pushTime = 0.05f;
public float returnTime = 0.1f;

private Vector3 originalPosition;
private bool isMoving = false;

void Start()
{
    originalPosition = transform.localPosition;
}

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space) && !isMoving)
    {
        StartCoroutine(PushAndReturn());
    }
}

IEnumerator PushAndReturn()
{
    isMoving = true;

    Vector3 pushedPosition = originalPosition + new Vector3(pushOffset.x, pushOffset.y, 0f);

    float t = 0f;
    while (t < 1f)
    {
        t += Time.deltaTime / pushTime;
        transform.localPosition = Vector3.Lerp(originalPosition, pushedPosition, t);
        yield return null;
    }

    t = 0f;
    while (t < 1f)
    {
        t += Time.deltaTime / returnTime;
        transform.localPosition = Vector3.Lerp(pushedPosition, originalPosition, t);
        yield return null;
    }

    transform.localPosition = originalPosition;
    isMoving = false;
}

}

naive pawn
#

!code

radiant voidBOT
hoary ruin
#

wait mb

naive pawn
#

is this supposed to be physics based

hoary ruin
#

no i just use a collider for it

naive pawn
#

that's physics...

hoary ruin
#

kk

naive pawn
#

do the player and piston have rigidbodies?

#

if so, they need to be moved via the rigidbody, not via the transform

hoary ruin
#

piston is the child of the sphere, sphere itself has rigidbody

fast fern
naive pawn
hoary ruin
#

ye when i tried rigidbody on the child it jus broke the game, ty ill try that

livid anchor
#

I have a question about this line of code. Does it copy the list or does it grab a reference to it ?

List<Vector3> tempBoardList = _boardPositions;

keen dew
#

reference

grand snow
#

You can make a new list and pass another as an argument to make a copy

teal viper
livid anchor
#

I figured it must have been a reference

arctic ridge
#

I am really new to unity, and trying to use and create wind based grass for my terrain but can't do it, tried to follow a tutorial ,I don't understand , tried a script don't know how to use it

verbal dome
#

Or is it a code issue?

arctic ridge
#

I actually don't know...more like a skill issue

verbal dome
#

Also for beginners: !learn

#

!learn

radiant voidBOT
arctic ridge
#

thank you

#

I tried searching for procedural wind grass before and I know it's not on the Unity Learn Wiki

stone glacier
#

its easier to maker some cave model, and cut a hole in the terrain?

grand snow
#

Im not going to look at these random scripts you sent though

stone glacier
#

can a terrain go to -y?

grand snow
#

Terrain uses height maps which can only go up/down

#

To make a cave properly you need to use terrain holes to make a hole and then join up a real mesh or other terrain.

night raptor
#

If it is a procedurally generated terrain, I would assume it would be quite difficult to smoothly connect the caves to the terrain holes. Especially if you want to enable terraforming or other such advanced features, you probably want to look for other ways to generate proper 3d terrain like the marching cubes algo.

solar hill
#

Yeah continous terrain generation struggles with caves and overhangs, youre just displacing a plane on the y axis in certain spots

#

Youre either going to have to do what rob said, cut out a hole and join it up with a cave mesh

#

Or use discrete voxel based terrain generation, which can create caves and overhangs without issue

#

Use a small voxel size and some kind of reconstruction algorithm like marching cubes or dual contouring.

stuck palm
#

how can I remove an object programatically in a build?

#

so like if its a build, get rid of debug objects

stuck palm
#

i thought i needed some special script

#

thank you!

winged vault
#

hello, I was making project and studying form Unity official studying program and I switched to scene1 to scene2 and after switching back to scene1 it doesn't works and animals that were moving are gone and I can't place them either while running game either, how can I fix it?

wintry quarry
#

without seeing the exact code causing this issue, we can't say much more

#

but you're probably doing something like having a DDOL object that is keeping direct references to objects in the scene it starts in which is being unloaded

winged vault
wintry quarry
#

It will contain a stack trace telling us the exact file and line number where it's happening

wintry quarry
#

(when you have it selected the fullmessage will show at the bottom of the console window)

#

yes

#

actually this looks like an error in the editor/inspector

#

like perhaps you had an object selected that was unloaded

winged vault
#

but scene 2 works well, I deleted scene 2 but it didn't help

wintry quarry
#

the code and scene setup will have some issue

winged vault
#

a project contains animals coming down at random directions, player moves left and right and shoots pizza to feed them, if animal and food makes contact they both get destroyed, if animal gets past player animal gets destroyed

#

should I send screenshots of codes I've written?

grand snow
#

!screenshots

radiant voidBOT
grand snow
#

!code

radiant voidBOT
winged vault
junior saddle
#

Hello team, I was wondering if anyone has a example script or game source files