#💻┃code-beginner

1 messages · Page 798 of 1

spare thunder
#

Guess something was wrong on that almost empty project

#

The new one is swift

swift crag
#

I saw you had some third-party packages in there. If they don't separate their code from your own (with an assembly definition), their code gets recompiled along with yours

spare thunder
#

They were small ones I though, just quality of life ones (in their own folders) But I guess so.

swift crag
#

You can test by introducing one package at a time

slim rapids
#

Hello! I'm a beginner in C# and I don't know where to start. Can anyone help me?

halcyon moon
#

why doesn't my script work?


public class PlayerClicks : MonoBehaviour
{

    public ParticleSystem ClickEffect;

    void OnMouseDown()
    {
        Debug.Log("Clicked");
    }
}

when i click nothing happens

#

i placed a circle with a circle 2d collider

#

im on 2d urp

#

im losing my mind to this

polar acorn
#

If you're using the new InputSystem, OnMouseDown no longer works.

halcyon moon
#

look for "how to make a game" playlist on his channel

halcyon moon
#

i forgot about ts

#

ok thanks

slim rapids
halcyon moon
#

but how can i revert it to the old one?

polar acorn
bitter herald
#

Quick question - Is it possible to make character controllers not pass through each other? When moving - my character controller can wiggle through other character controllers :/

polar acorn
radiant voidBOT
# polar acorn !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

halcyon moon
#

best advice, don't over do it and don't expect good results early.

halcyon moon
bitter herald
kindred blade
#

theres most likely a way to combined these 2 if statements into one line but idk how

rich adder
kindred blade
#

where would i be adding these

polar acorn
#

It means "Or"

rich adder
kindred blade
#

lol

rich adder
#

its good you should learn these basics of csharp
on a related note, unitys GetButton and new Input system can have the same action be for both a controller / or keyboard

halcyon moon
#

yo another problem.
when i click i suppose the effect should play? but it doesn't.


public class PlayerClicks : MonoBehaviour
{

    public ParticleSystem ClickEffect;

    void OnMouseDown()
    {
        ClickEffect.Play();
        Destroy(gameObject);
    }
}
#

isn't this like the easiest way to play the effect?

#

or is it bcs i have z axis and its 2d?

rich adder
polar acorn
#

that doesn't actually exist in the scene

halcyon moon
polar acorn
#

If you want to actually see it, it needs to be in the scene

halcyon moon
#

oh i need to put a prefab first?

#

in the scene

rich adder
#

you need to instantiate it

#

yes

halcyon moon
#

ok

#

im trying not to use and ai modules and asking you guys so i can improve abit and actually learn why im having these dumb small issues

#

also

#

is there another way i can instantiate this effect?

rich adder
#

why "another way"

bitter herald
#

Nav, I can't reply with an image for some reason but in regards to character controller passing through another character controller: I'm also doing multiple .Move within the update, not sure if that's alright?

rich adder
#

its common to instantiate an effect to play it

#

later on you can improve it with pooling and recycle them

rich adder
bitter herald
#

lol

rich adder
#

just post it here

#

!code

bitter herald
#

Nah posted directly to the channel

radiant voidBOT
rich adder
#

use the links

bitter herald
#

ah ok thanks

halcyon moon
#

well, i tried to put it in two different ways but still no effect.

bitter herald
halcyon moon
#

idk if im dumb or smth

halcyon moon
halcyon moon
#

can i use another way to like "emission" it?

#

i remember there was a way to make it false and true but don't remember the whole code

rich adder
rich adder
#

btw you shouldnt call .Move twice, combine it into 1 call

bitter herald
rich adder
#

is this local multiplayer / same screen multiplayer or something

bitter herald
#

Apparently AI says that is a downside of using character controllers lol:
controller.Move is kinematic and discrete; fast moves (dodge bursts) can tunnel through other bodies because there’s no continuous collision.

All same scene, no multiplayer

#

Suggests using rigidbodies on other objects and characters

rich adder
#

are they going to be controlled at the same time or do they "take turns" ?

bitter herald
#

Same time, it's weird though because even with a simple object that is not moving but has a character controller, I can still clip through

rich adder
#

oh I was gonna say , what you could do is switch it from CC-enabled to a capsule collider when not moving

halcyon moon
# rich adder in what way? did you not spawn it ?

well, i found another method to spawn it similar to mine but worked somehow.


public class PlayerClicks : MonoBehaviour
{

   [SerializeField] private ParticleSystem ClickEffect;

    private ParticleSystem ClickEffectInstance;

    void OnMouseDown()
    {
        SpawnClickEffects();
        Destroy(gameObject);
    }

    private void SpawnClickEffects()
    {
        ClickEffectInstance = Instantiate(ClickEffect, transform.position, Quaternion.identity);
    }
}

the problem is the effect continues to play after the click

halcyon moon
#

i disabled "looping" and set "stop action" to destroy

rich adder
#

also how come you're destroying the object with PlayerClicks rather than the spawned particle ?

halcyon moon
#

i don't understand

rich adder
#
SpawnClickEffects();
Destroy(gameObject);```
halcyon moon
#

ummmm, so?

rich adder
#

You're destroy object with PlayerClicks?

halcyon moon
#

elaborate this info

halcyon moon
#

im making a simple game about clicking on circles

#

smth similar to aimlab if you know it

#

just trying to test my skills which are none

rich adder
#

so PlayerClicks is on the object being spawned?

#

the naming was confusing

halcyon moon
#

its the only script there

rich adder
#

gotcha

halcyon moon
#

cool

rich adder
#

now did you modify the prefab for Effect in the project folder and reference that one

halcyon moon
#

the problem here i think is that i have clones after the circle is destroyed

#

clones of the effect

#

i need to destroy those

#

i think

rich adder
#

show which obj you put in the inspector for. ClickEffect

halcyon moon
#

this what you want?

rich adder
halcyon moon
#

yup

#

or the clone does

#

wait i gotchu

rich adder
#

how many appear in hierarchy when u spawn it

halcyon moon
rich adder
halcyon moon
#

where?

rich adder
#

in main module of partice

halcyon moon
#

nope

#

disabled

#

do i close and open unity?

#

maybe its bugged

rich adder
#

doubt

halcyon moon
#

im going crazy again

#

didn't work

rich adder
#

duration / time is probably too long

#

try shorten it

halcyon moon
#

doubt

#

didn't work

#

at this point we're trying anything to get this

rich adder
#

I mean duration can sometimes prolong it

halcyon moon
#

im looking up a guide for another way to emit this effect

#

maybe its smth in the code

#

idk

rich adder
#

pause the game when the particle Clone spawns , and inspect its properties

halcyon moon
#

didn't get any info with this

#

im hopin off to breath some air then coming back

#

sorry if i caused you troubles

halcyon moon
#

it has the same prop. of a regular effect

rich adder
halcyon moon
#

yup

bold viper
#

what about play on awake?

rich adder
#

thats how its playing in the first place

bold viper
#

so you need main looping off, main stop action destroy AND main play on awake false

halcyon moon
#

its on ON

#

i will disable it wait

rich adder
#

play on awake shouldnt be a problem cause looping

halcyon moon
#

it doesnt even play now

queen adder
#

hello guys i need help

rich adder
#

did you read any of the previous conversation

halcyon moon
#

yeah

queen adder
#

i cant move my character

bold viper
#

call play() explicitly

rich adder
bold viper
#

or reinstate play on awake and ensure you've set emision to burst (1)

rich adder
# halcyon moon yup

Try making a brand new effect that You know for sure ends, make a prefab out of it and spawn that instead

rich adder
#

!code

radiant voidBOT
rich adder
# halcyon moon ok

on the previous effect by the way, did you make sure Duration and Start time were both low number? like half a second or something

bold viper
#

you've mapped your movement to the world state not the player state

halcyon moon
#

type " ` " three times before and after the script
like this

queen adder
#

oh

#

okay sorry

rich adder
#

best use Links

#

as it says for Large Code

halcyon moon
#

ye this works too

queen adder
#

so if somebody can help me change something about that

#

it woul be extreme helpfull

rich adder
#

post the code properly first, then you have to show the object you put this on

queen adder
#

yes

#

wait

radiant voidBOT
rich adder
#

i would make my own praticle prefab first to ensure thats working fine and isolate the issue

halcyon moon
#

but yeah when i created another effect then instantiated it. it did spawn for sometime then die

#

so the problem is with the effect i got

#

soo gotta use another one ig

rich adder
#

yes most likely its that, can you show the Emission section rq

halcyon moon
#

like a vid?

rich adder
#

screenshot is fine too

halcyon moon
#

ok

#

you got anything with that?

rich adder
#

hmm Id try either applying the settings to the original prefab and use that instead of variant, or possibly set Emission in effect the same as the test effect you made, see if helps

halcyon moon
#

ok

#

yeah i would get another effect package

rich adder
#

hmm can you link this to me rq? now I'm curious to see what it could be

rich adder
#

its probably a child object since there seems to be multiple shapes playing

sweet mural
#

Huh

#

yo uh

#

dose anyone know how to use c#

rich adder
#

maybe

#

try asking a specific question

sweet mural
#

ok so I’m in a dev group for a gorilla tag vr fan game and we currently need scripters

rich adder
#

well this isn't the place for that then

#

!collab

radiant voidBOT
# rich adder !collab

: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**

sweet mural
#

oh mb

sweet mural
#

sorry I’m new to this discord server

sweet mural
polar acorn
#

Did you try reading it

rich adder
#

whats confusing ? its easy to understand if you read it

queen adder
#

I dont know why my cylinder is not moving?
[i am just beginner btw]

polar acorn
ancient jungle
#

can someone help me make this guy move he has a walking animation, and he just walks downwards by default but i want him to move with wasd

rich adder
#

You're going to have to learn the basics before anything else..

ancient jungle
#

the project is due tomorrow

rich adder
#

so you didn't learn anything from it and are trying to get last minute ?

ancient jungle
#

i learned blender

rich adder
#

then how is this "due tomorrow"

#

no one is gonna do the work for you

ancient jungle
#

but help

#

i didnt know movement was that hard

#

probably isnt

polar acorn
ancient jungle
#

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
[SerializeField]
private float speed = 5f;

[SerializeField]
private float mouseSensitivity = 2f;

private Vector3 moveDirection;
private float rotationY;

void Update()
{
    HandleMovement();
    HandleRotation();
}

private void HandleMovement()
{
    float horizontal = Input.GetAxis("Horizontal");
    float vertical = Input.GetAxis("Vertical");

    moveDirection = new Vector3(horizontal, 0f, vertical).normalized;

    transform.Translate(moveDirection * speed * Time.deltaTime);
}

private void HandleRotation()
{
    float mouseX = Input.GetAxis("Mouse X");
    rotationY += mouseX * mouseSensitivity;

    transform.rotation = Quaternion.Euler(0f, rotationY, 0f);
}

}

rich adder
#

this looks like copied from the dude who posted before..

ancient jungle
#

ok

#

but without any script my character already moves

polar acorn
#

Is your Animator using Root Motion

ancient jungle
#

bc of the animation

rich adder
#

probably because root motion

hexed terrace
#

this is a code channel, not a feedback channel.. delete from here

ancient jungle
#

ok

#

i will tick it

broken nest
#

Hello, I'm trying to access a class from another script but it says the name of the script doesn't exist, any fix?

rich adder
polar acorn
broken nest
#
using TMPro;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;

public class MenuBuidler : MonoBehaviour
{
    #region Singleton
    public static MenuBuidler instance;

    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogWarning("more than 1 MenuBuidler");
            return;
        }
        instance = this;
    }
    #endregion

    public float currentTotalMenuLength;
    public void CreateMenuPanelButtons(ActionData[] actionData)
    {
    }
}

[System.Serializable]
public struct ActionData
{
    public string actionDescriptionFrench;
    public string actionDescriptionEnglish;
    public Sprite actionSprite;
    public UnityCustomEvent actionEvent;
}```
#

If I try to access MenuBuilder.instance it says the name of the script doesn't exist in the current context

#

I tried regenerating the project but it did nothign

polar acorn
#

The script you've provided is for MenuBuidler

broken nest
#

Ahaha

rich adder
#

nice

broken nest
#

thanks

ancient jungle
#

ok now there is no more animation but when i move with my mouse the cam moves with looks like im floating around

slow blaze
#

I'm manually refreshing unity but the script is not updating
any idea?

slender nymph
#

did you save the file? do you have any compile errors?

slow blaze
#

I saved the file and there are no compile errors

#

I'll try restarting unity

hexed terrace
#

just right mouse click the file -> reimport

halcyon moon
#

why when i click on my circle it doesn't do anything?


public class PlayerClicks : MonoBehaviour
{

    [SerializeField] private ParticleSystem ClickEffect;

    private ParticleSystem ClickEffectInstance;
    public GameObject CirclePrefab;

    void OnMouseDown()
    {
        SpawnClickEffects();
        Destroy(gameObject);
        Vector2 randomSpawnPosition = new Vector2(Random.Range(-8, 8), Random.Range(-4, 4));
        Instantiate(CirclePrefab, randomSpawnPosition, Quaternion.identity);
    }

    private void SpawnClickEffects()
    {
        ClickEffectInstance = Instantiate(ClickEffect, transform.position, Quaternion.identity);
    }
}```
bold viper
#

because it hasn't picked up the script

halcyon moon
#

i put on the prefab the original circle prefab

bold viper
#

does the prefab have a collider attached?

halcyon moon
#

yup

bold viper
#

and is the new circle generated in the visible camera layer?

halcyon moon
#

but for some reason the clone have them disabled

bold viper
#

hmm interesting

#

check the z position of the 2nd circle

#

it needs to match the original

halcyon moon
#

ok

#

yup the same

#

the problem is the disabled collider and script

bold viper
#

are you using the new input suystem?

halcyon moon
#

can i hard code it?

halcyon moon
#

the old

polar acorn
halcyon moon
#

i thought of that too

#

will try to create another prefab

bold viper
#

and theres nothing else int he scene to desteroy the new circle wihtout it visually going

#

and the camera in use is unique and matches the collider so 2D for 2D ?

halcyon moon
grand snow
halcyon moon
#

and didn't have the script and collider enabled

polar acorn
halcyon moon
#

ahhhhhhhh

#

mb

#

mb

grand snow
#

unless this is a one time thing thats it bye bye unity

dire ocean
#

Hi could someone help me, im trying to create my first ever video game with a youtube tutorial in which i have to set up a script for player movement. But when i try to open it to edit it on visual studio theres nothing and i cant edit

#

Im french so my english might be bad sorry

grand snow
#

!ide

radiant voidBOT
grand snow
#

^ follow these instructions to ensure visual studio is installed correctly

dire ocean
#

Thanks

grand snow
# dire ocean Thanks

If you have visual studio set as your code editor in the unity editor when you double click a script in the asset window it should open that up in VS. Once you correct the install. Close VS then do this.

quiet pollen
#

guys what is happening

#

it says I need to update

#

does that just mean get 6.3

polar acorn
quiet pollen
#

to... 6.3?

polar acorn
#

If you want, or you can get the latest patch of 6.1

quiet pollen
#

oh ok thx

#

Im so happy that there is a new LTS version

dire ocean
#

If i have a 2024 version of unity and a 2022 version of visual studio could it be a problem ?

wintry quarry
#

no

grand snow
quiet pollen
#

new 2d physics???

#

bet

#

and 3d display with 2d graphics

halcyon moon
#

how can i make it so if the player took 0.5 sec the object will be disabled and another is spawned? ```using UnityEngine;

public class PlayerClicks : MonoBehaviour
{

[SerializeField] private ParticleSystem ClickEffect;

private ParticleSystem ClickEffectInstance;
public GameObject CirclePrefab;

void OnMouseDown()
{
    SpawnClickEffects();
    Destroy(gameObject);
    Vector2 randomSpawnPosition = new Vector2(Random.Range(-8, 8), Random.Range(-4, 4));
    Instantiate(CirclePrefab, randomSpawnPosition, Quaternion.identity);
}

private void SpawnClickEffects()
{
    ClickEffectInstance = Instantiate(ClickEffect, transform.position, Quaternion.identity);

}

}```

#

or what args do i use

quiet pollen
#

also multiplayer template

#

also did they ever make multi person development easier with unity 6

#

Ive been trying to get it to work with my friend forever

#

but I havent managed

rich adder
quiet pollen
#

yeah

#

but it can help teach me stuff

rich adder
#

oh sweet child

quiet pollen
#

What

#

I havent tried multiplayer before

#

im sure it could teach me something

rich adder
#

there is no "live" collab tho, like roblux or some shit

quiet pollen
#

yeah I know

#

but idk how to let them make edits on it

#

how do I give them access

rich adder
#

you add them as collaborator, depending where u host repo

quiet pollen
#

yeah for some reason I havent been able to get that to work in the past

grand snow
#

Yea they need permission to be able to push changes

quiet pollen
#

I honestly think its an issue on their end

rich adder
#

or lack of knowledge

grand snow
#

Hmm well its pretty simple to change so probably your fault

quiet pollen
#

I guess

#

idk

grand snow
#

if using github check the collaborators section for the repo and see if this user is added to the list as maintainer or admin

quiet pollen
#

oh

#

thats what you meant

#

so would they just.... download the project from github

#

for some reason ive only ever tried unity version control whatever

rich adder
#

pretty much, they have a copy

quiet pollen
#

oh ok

rich adder
#

unity version control always has problems

quiet pollen
#

thank you guys!

rich adder
#

learn git, and use common hosts like github

quiet pollen
#

will do

broken nest
#

Hey, I'm trying to instantiate a prefab and I get the error "Cannot instantiate objects with a parent which is persistent. New object will be created without a parent."

#

Any idea where that could come from?

polar acorn
#

You're trying to create a child object of a DDOL object so it's making it without a parent instead

polar acorn
#

What line is the error on

broken nest
#

panel = Instantiate(UIPrefab.instance.panelPrefab, this.transform);

polar acorn
#

And what object has this script on it

broken nest
#

public class MenuPanelButtonsDescriptions : MonoBehaviour
{
public RectTransform panel;

public void CreateMenuUI(ActionData[] actionData)
{
    panel = Instantiate(UIPrefab.instance.panelPrefab, this.transform);
}

}

#

The object is an instance of a prefab itself

#

I instantiate MenuPanelButtonsDescriptions, then call CreateMenuUI()

grand snow
#

best ask that again in a better way

polar acorn
#

Are you sure you're calling CreateMenuUI on the one in the scene?

#

And not the prefab?

broken nest
#

Ho that might be the mistake

arctic ridge
#

so I have finished my project, but worked on it under the name my project now I want to change it and cant figure for the life of me how, did it from the web dashboard too it still shows as my project

rich adder
#

also not a coding question

broken nest
arctic ridge
solar hill
#

If you want help youre better off asking in the correct places, rather than getting mad when someone suggests something that should be obvious to you

worldly mural
#

hey, im trying to learn c# for game development, does anyone have any tips on how to learn and how to get started?

grand snow
#

id also recommend microsoft learn

worldly mural
#

okay, thanks a lot!

uncut gulch
#

hi, going to make this short, i am starting learning unity , having issue with this tutorial i made a script and applied it to the character and set the keys for the movement yet when i press play character does not move

#

what i am doing wrong here

rich adder
uncut gulch
#

sorry i did not want to spam this place

#

here this is it

rich adder
#

use links

#

!code

radiant voidBOT
hexed terrace
rich adder
#

Root motion is probably overriding the movement code

uncut gulch
rich adder
#

dont think i've seen one there

rain solar
#

when generating terrain with fractal noise how do i interpolate between noise samples? when i do linear interp the terrain looks low quality cause its just a bunch of squares and i cant use bicubic because it creates wavy terrain

uncut gulch
stone narwhal
#

chat, does anyone use unity vivox ?

rich adder
jovial gust
#

so im making a game in unity, its a shooter game, i have leaning (q/e), sprint, crouch, prone, sliding, and i have the gun models, the crosshair, I need help making hitmarkers like bulletholes

#

like in siege when u shoot the wall it has a hole

jovial gust
#

wait thats smth else, rn im working on the hitmarker on an enemy, like if i hit them it will display a red dot or smth and i cant seem to get that to work

#

the bulletholes i js figured out

rich adder
#

oh cause you said this

like in siege when u shoot the wall it has a hole

jovial gust
#

ik that wasnt the problem

rich adder
#

anyway, for hit markers you probably want to use either a sprite above enemy if you want it world, or UI for screen

jovial gust
#

ik im selecting knob fgor the source image

#

and its red with alpha at 255

rich adder
#

so then whats the current problem, how about start with that

jovial gust
#

not getting the red hitmarker to display

rich adder
#

ok this is where you show how you set everything up

jovial gust
#

thats everything i have

#

its kind hard cus i got a lot of scripts in it already

#

idk if thats what u needed or not

rich adder
#

if thats what you use for making things happen , then its relevant

jovial gust
#

is there something specific ui want me to send

#

im new to this stuff

rich adder
#

the setup should be fairly easy..
you Invoke some type of event OnEnemyHit and something like a UI /hitmarker controller listens for it

#

if you need to demystify hitinfo, send that too in the event

jovial gust
#

english?>

#

😭

midnight tree
#

Do you check the hit ray hits someone?

rich adder
#

so the script that controls hitmarker changes its color

jovial gust
#

on the bottom left earlier where player state was it had a thing where it said enemy hit

#

ill try and find if i can make it happebn again'

rich adder
#

before worrying about UI feedback you should probably already have that type of system setup
if you can't tell enemy was damaged whats the point of hitmarker

fervent lagoon
#

Hey if anyone wants to give me help in the input system channel tha would be great 😊

rich adder
#

if someone wants to help and/or knows an answer with input they visit the channel

fervent lagoon
stone narwhal
rich adder
vale robin
#
using System;
using UnityEngine;
using UnityEngine.UI;

public class PaddleInput : MonoBehaviour
{

    [Header("Controls")]
    [SerializeField] private KeyCode keyUp = KeyCode.UpArrow;
    [SerializeField] private Button upButton;
    [SerializeField] private KeyCode keyDown = KeyCode.DownArrow;
    [SerializeField] private Button downButton;
    [SerializeField] private KeyCode keyPower = KeyCode.Space;


    // Variables
    public Vector2 input { get; private set; } = Vector2.zero;
    public event Action powerKeyPressed;

    void Update()
    {
        input = Vector2.zero;

        if (Input.GetKey(keyUp))
        {
            input = new Vector2(input.x, input.y + 1);
        }

        if (Input.GetKey(keyDown))
        {
            input = new Vector2(input.x, input.y - 1);
        }

        if (Input.GetKeyDown(keyPower))
        {
            powerKeyPressed.Invoke();
        }
    }
}

Is there any way to check constantly for the direction UI buttons to be pressed so I can use them with the input?

tropic haven
#

question, i've just begun learning about how the game architecture is structured, should I divide playerMovement, playerAttack and playerJump in different scripts?

teal viper
#

What's your reasoning behind splitting it into several scripts?

tropic haven
#

to avoid interdependencies (?)

teal viper
#

Besides, do you really want to avoid dependency of, let's say movement and jumping? These mechanics are usually closely interconnected for obvious reasons.

tropic haven
#

yeah you're right, thanks for your answer

wintry quarry
vale robin
naive pawn
#

input system definitely does

wintry quarry
vale robin
#

Different keys in the same keyboard?

naive pawn
#

you could even do it 1:1 with how you have it in the input manager

#

or you could utilize the local multiplayer stuff

wintry quarry
#

for on screen controls you could bind the UI controls to different device inputs and if you use control schemes PlayerInput can use those to disambiguate between the players

#

or you can just have separate actions per player

#

either way

naive pawn
#

afaik there's only GetAxis smoothing that isn't replicated in the new inputsystem

vale robin
#

Since this will be a mobile game anyways, I don't think there will be a difference then

#

But how do I make the players respond to different controls then?

naive pawn
#

kinda the same way you did with the input manager

#

have them listen for different events or check different actions

wintry quarry
vale robin
#

I see, I'll check that then, thanks

native widget
#

Hello what is the name of this in code

rain solar
#

when generating terrain with fractal noise how do i interpolate between noise samples? when i do linear interp the terrain looks low quality cause its just a bunch of squares and i cant use bicubic because it creates wavy terrain

stone heron
#

this is probably past beginner, but why do you need to interpolate them at all? Why not have 1 sample per vertex?

spare saddle
#

Can I just learn visual scripting if I don't wanna learn how to code?

#

Is it easier?

slender nymph
slender nymph
naive pawn
livid anchor
#

What are the ways I can use to make an enemy follow my player ? I'm using the linear velocity right now, using the player pos - enemy pos, but the issue is that my enemy is fast at first then becomes sluggish while closing in

midnight plover
livid anchor
#

I would rather have a relative stable speed toward the player

keen dew
#

(player pos - enemy pos).normalized * speed

midnight plover
livid anchor
#

Worked like a charm, they are more threatening now

#

can GetComponentsInChildren<Transform>() pick also the parent transform ? because it seems like it

midnight plover
#

If you get the components its an array, you can just filter out the self transform after getting them

livid anchor
#

I have a decentlooking game now. Enemies spawning alright, running toward the player, feel like a real game now

naive pawn
midnight plover
#

haha, true, it can be as easy as

foreach(Transform t in transform)
  Debug.Log(t.name);
midnight plover
livid anchor
#

You can just iterate on a gameobject transform ?

midnight plover
livid anchor
#

I'll look at that later

sour nest
#

You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
Hi i was doing the C# tutorial from Unity and when i did the code for jumping it said this

hexed terrace
radiant voidBOT
# naive pawn !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

sour nest
#

Thanks ! will this problem be often there when i will code ?

naive pawn
#

no

#

this isn't related to code, this is project config

sour nest
#

okay thank you

pseudo laurel
#

hi my player sliding/drifting with any movement script after clicking play button it starts to slide how to fix that

civic anvil
#

Thank you man. It's interesting unity docs just say use the old system.

pseudo laurel
#

it sliding without any input

civic anvil
pseudo laurel
pseudo laurel
naive pawn
#

how are you moving the player? show the code there

#

!code

radiant voidBOT
pseudo laurel
#

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

public class PlayerMovement : MonoBehaviour
{
public InputAction MoveAction;

public float walkSpeed = 1.0f;
public float turnSpeed = 20f;

Rigidbody m_Rigidbody;

Animator m_Animator;
Vector3 m_Movement;
Quaternion m_Rotation = Quaternion.identity;

void Start ()
{
    m_Rigidbody = GetComponent<Rigidbody> ();
    MoveAction.Enable();
    m_Animator = GetComponent<Animator> ();
}

void FixedUpdate ()
{
    var pos = MoveAction.ReadValue<Vector2>();
    
    float horizontal = pos.x;
    float vertical = pos.y;

    
    
    m_Movement.Set(horizontal, 0f, vertical);
    m_Movement.Normalize ();

    bool hasHorizontalInput = !Mathf.Approximately (horizontal, 0f);
    bool hasVerticalInput = !Mathf.Approximately (vertical, 0f);    
    bool isWalking = hasHorizontalInput || hasVerticalInput;
    m_Animator.SetBool ("IsWalking", isWalking);

    Vector3 desiredForward = Vector3.RotateTowards (transform.forward, m_Movement, turnSpeed * Time.deltaTime, 0f);
    m_Rotation = Quaternion.LookRotation (desiredForward);
    
    m_Rigidbody.MoveRotation (m_Rotation);
   m_Rigidbody.MovePosition(
m_Rigidbody.position + transform.forward * walkSpeed * Time.fixedDeltaTime

);
}
}

naive pawn
pseudo laurel
#

i added the code there too

naive pawn
#

see the "large code blocks" section

pseudo laurel
naive pawn
#

you did not do it correctly

#

you aren't using your input to move at all

pseudo laurel
#

what i wanna do now ?

naive pawn
#

if there's no movement input, don't move

polar acorn
pseudo laurel
naive pawn
#

that's much easier to read

pseudo laurel
naive pawn
#

pay attention to lines 47 to 49, read what it says to do

#

that's always walking forwards

pseudo laurel
naive pawn
#

if there's no walk input, then you shouldn't walk

pseudo laurel
#

when i give input player walking if nothing is touched its going straight

stiff birch
#

!learn

radiant voidBOT
civic anvil
queen adder
#

Can somebody say why my joystick isn't working when I build it

naive pawn
naive pawn
pseudo laurel
#

bro actually everything working fine i didnt modified anything it showed up randomly

#

i just added cinemachine after that this happened before that it worked fine

#

i dont think the problem is with the code it could be something else

naive pawn
naive pawn
magic crown
#

Hey hell i have a small question, how could i make a class containing 3 public int so that in the inspector i can have my class with the 3 field i can write in, like a vector3

naive pawn
magic crown
#

eah i was looking through how the vector 3 was made and i noticed it used struct and not class

#

litteraly at the moment i was looking into it, thanks tho ^^

pseudo laurel
#

its not my code its from unity learn series...

magic crown
#

and it is on my other script but it just doesn't show

naive pawn
#

they can definitely be used on types

#

(also, that's not an array.)

magic crown
#

on the struct itself or my int?

naive pawn
naive pawn
magic crown
#

okay yeah it works, i thought it was needed on my int

#

what i'm gonna do is an array for my struct which is why it's named like that. ik it shouldn't be but just to test an idea

naive pawn
#

i'm not sure what exactly you're going for, but definitely sounds like there'd be an easier way to do that

magic crown
#

I know i could do without but it save me a lot of time managing my voxel faces and vertex

naive pawn
#

why not just use Vector3s for that

magic crown
#

A mesh use int that represent the index of the vector3 i can't directly use the vector 3 for that

#

This way i just have to do that

#

and same for my mesh component

#

but instead of using drawline well i just fill out the array automatically with that

pseudo laurel
#

guys i restarted unity the bug fixed lol

pseudo laurel
magic crown
#

Yeah some bug just need a restart

magic crown
#

did he say something bad?

pseudo laurel
#

nah im just calling him

naive pawn
pseudo laurel
magic crown
#

No it's not like that, if i want to assign triangles to a mesh i have to use the index for each of my vertex, like i would have to put in the triangle array 0 1 2 to connect those 3 point

naive pawn
naive pawn
magic crown
#

oh didn't know

#

well now that it's done i'm gonna use what i did, still see some nice things i could use this for atleast for next time i didn't know

naive pawn
#
struct intArray
{
    public int num1;
    public int num2;
    public int num3;
}
``````cs
struct Vector3Int
{
    public int x;
    public int y;
    public int z;
}
#

it's not just the fields, there is other stuff related to geometry, but you could just ignore it

magic crown
#

yeah

#

thanks then ^^

random slate
#

Is there something special with : in strings???

at first I needed to use Debug.Log($"First Tk: '{Temp[0]}'; Does it ends on ':'? {Temp[0][Temp[0].Length-2] == ':'} Cause it ends on: '{Temp[0][Temp[0].Length - 2]}'"); to get, if the : was the last char. (See first Screenshot). Like for every other string it would give the second last char but when there was a : as a last char, it would give the last one.

Second: There is clearly a start: in the dictionary. This is not only visible when it was added, but in the function where I use the dictionary, I check it even again, like this:

foreach (var item in JumpTable)
{
    Debug.Log('"' + item.Key + '"'); //But key is here
}
ExePos = JumpTable[Tokens[ExePos+1] + ":"]; //error here

Is there something wrong with :, that I never heard off??

wintry quarry
#

also how do you know that's in the dictionary?

random slate
#

it looks literally before using it

wintry quarry
#

What is Tokens?

#

is that also a dictionary?

random slate
#

Tokens is a string array

#

the key is "start"

#

or atleast in that position, I can even confrim in the editor

wintry quarry
#

I would try this:

foreach (var item in JumpTable) Debug.Log($"Key: '{item.Key}' with length {item.Key.Length}");
var keyToCheck = Tokens[ExePos+1] + ":";
Debug.Log($"Checking key: '{keyToCheck}' with length {keyToCheck.Length}");
ExePos = JumpTable[keyToCheck]; //error here```
#

if that doesn't tell us anything new you can resort to printing each code point individually

#

I would say as a general rule this kind of string manipulation and indexing seems a little sketchy

#

like.. putting a string with a colon as a dict key for something - why is the colon there?

random slate
#

I just tried the code again, but removed the : and it worked...

wintry quarry
#
  1. The Standard Colon (ASCII)

    Symbol: :

    Unicode: U+003A

    Usage: This is the standard punctuation mark used in writing, coding, and general text input. It is what appears when you press the colon key on a standard keyboard.

  2. The Ratio Symbol (Mathematical)

    Symbol: ∶

    Unicode: U+2236

    Usage: This is a distinct character specifically intended for mathematical ratios (e.g., 1∶4).

    Appearance: It looks almost identical to the standard colon, but in some fonts, it is vertically centered on the plus sign or the equal sign, rather than sitting on the text baseline.

#

There are two different characters that are maybe getting mixed up^

random slate
naive pawn
#

and you include the colon in the label?

random slate
#

yes, cause I couldnt remove it so I just included it, for being easier

naive pawn
#

what do you mean you couldn't remove it

random slate
#

I was lazy, and just added it in the end. Technically these are the same strings

#

or should be

random slate
wintry quarry
#

yeah i figured

naive pawn
#

try printing out the charcodes then

polar acorn
random slate
random slate
polar acorn
polar acorn
#

that one will get removed with a call to Trim(), so you can just trim the data before you put it into your dictionary

random slate
#

Thanks. I never knew this Character exsisted

naive pawn
#

newline in windows is usually \r\n/CRLF, newline in *nix is usually \n/LF

#

it's not really dependant on "text format"

random slate
#

Thanks

#

Ok, Trimming actually fixed even another Bug. Thanks

north walrus
fast fern
#

Does WaitForSeconds pause when Time.timeScale = 0?

frail hawk
#

try it out

fast fern
#

It doesn't

naive pawn
#

or read docs

naive pawn
fast fern
#

oof

fast fern
#

thx

naive pawn
#

well, it doesn't "pause", it just never completes

#

if you want one that doesn't use scaled time, use WaitForSecondsRealtime

fast fern
#

that didn't work for me as well

#

I used coroutine to wait 60 seconds and play an animation every minute, but if I pause the animation changes before its 60sec completes

naive pawn
#

that sounds unrelated

#

have you tried some debugging?

fast fern
#

whats that?

naive pawn
#

well, that's new

fast fern
#

I'm new 🫠

naive pawn
#

debugging is the process of investigating some specific issue to determine the cause and viable fixes

#

here, you could use Debug.Log to verify what code is being run

fast fern
#

ooooh

#

I tried a lot, just very unlucky with fixing it up

#

nah this my only issue so far

swift lichen
#

hiw i leran unity fast

prime goblet
#

!learn

radiant voidBOT
prime goblet
#

is good

swift lichen
#

ok thanks

frail hawk
#

learn c# basics

swift lichen
#

ok

frail hawk
#

then dive into unity editor and follow some easy tutorials such as flappy bird or temple run

swift lichen
#

👍

rancid tinsel
#

could someone explain var to me? It seems like bad practice that makes the code less readable at no benefit - but surely I must be wrong?

wintry quarry
#

so... it's a tradeoff

sour fulcrum
wintry quarry
#

but like

var x = new List<Dictionary<Dog, Cat>>();``` is a little nicer than
```cs
List<Dictionary<Dog, Cat>> x = new List<Dictionary<Dog, Cat>>();```
rancid tinsel
wintry quarry
#

in this casse you don't lose any information but you make it more concise

wintry quarry
rancid tinsel
pastel cave
wintry quarry
#

but for example:

var x = GetSomeData();``` can be bad
#

because just reading this it's hard to know what type x is

sour fulcrum
wintry quarry
#

this is the "target-typed new"

rancid tinsel
#

I found out about this a few weeks ago but completely forgot the syntax lol

harsh tartan
#

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour {
    public float movementSpeed = 5.0f;
    public Transform cameraTransform;  

    private Rigidbody rb;
    private Camera cam;

    void Start() {
        rb = GetComponent<Rigidbody>();
        if (cameraTransform == null) {
            cam = Camera.main;
        }
    }

    void FixedUpdate() {
        Transform camToUse = cameraTransform ?? cam.transform;

        // Camera-relative directions (flatten Y)
        Vector3 camForward = camToUse.forward;
        camForward.y = 0;
        camForward.Normalize();

        Vector3 camRight = camToUse.right;
        camRight.y = 0;
        camRight.Normalize();

        // Input axes
        float horizontal = Input.GetAxis("Horizontal");  // A/D
        float vertical = Input.GetAxis("Vertical");      // W/S

        Vector3 movement = (camForward * vertical + camRight * horizontal).normalized * movementSpeed;

        rb.linearVelocity = new Vector3(movement.x, rb.linearVelocity.y, movement.z);

    }
}


``` Made own walking system any improvements I can make? (its following the camera where you are looking is "forward"
pastel cave
#

trying to make a split layout "WASD/arrow keys" input map and I thin I have configured it incorrectly

I have this as the map, with the Keyboard1 scheme being WASD and Keyboard2 being arrow keys
however it appears that the two are... Mutually exclusive? Or, by default PlayerInputs themselves are? auto-switch is off, both gameobjects are from the same prefab and the only difference between the two is that PlayerInput default scheme is set to Keyboard1 on one and the default scheme on the other is set to Keyboard2.

The keyboard is set as a required device on both schemes, is that the issue?

wintry quarry
#

you actually will need some custom handling for that

#

the input system sees the whole keyboard as one device, and each device can only be assigned to a single player

rancid tinsel
pastel cave
#

oh god...

#

alright, how do I go about doing this

wintry quarry
rancid tinsel
wintry quarry
#

I would also probably separate the two keyboard key groups into two separate bindings

#

rather than separate composite parts in a single binding

harsh tartan
rancid tinsel
#

input system is better if you want the player to be able to change their controls later

#

I wouldn't bother if you're doing a tiny project, but if you're making a commercial one I'd recommend doing it

#

or one you're planning to publish rather

harsh tartan
#

Ahh, wanna make it also multiplayer but thats for later, so its better that I use input system package?

Do I need to change alot of my code or?

rancid tinsel
#

probably not - it's really just listening to click events I think, but honestly I always procrastinate/don't do it, so I'm not sure on how it works with code

pastel cave
rancid tinsel
# harsh tartan Ahh, wanna make it also multiplayer but thats for later, so its better that I us...

In previous videos, we've already talked about how we ditched Rewired in favor of Unity's new input system. In today's video, Thomas goes over the basics of the new input system, and how you can get started with it on your own.

Timestamps:
00:00 What's an input system?
00:28 Why not the old?
01:29 Setting up movement
09:47 Setting up actions
1...

▶ Play video
harsh tartan
#

Will check

wintry quarry
pastel cave
#

yep. Thanks a ton!

wintry quarry
pastel cave
#

oh I see

rancid tinsel
#

How does Unity know what vector2 it is meant to read? That's really confusing to me

#

or does the input actions not let you have two vector2s?

slender nymph
#

it's reading whatever the current state of that action is, it can't have more than one state at the same time

rancid tinsel
#

oh wait its move.action

#

thats what I get for skimming through the video

#

thanks boxfriend

pastel cave
#

the documentation doesn't really explain what the "Respawn", "Finish", and "GameController" flags do

harsh tartan
#

What am I missing that my player goes thrue the ground?

using UnityEngine.InputSystem;


[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour {
    public float movementSpeed = 5.0f;


    public Rigidbody rb;
    private Camera cam;

    private Vector3 _moveDirection;

    public InputActionReference move;

    private void Update()
    {
        _moveDirection = move.action.ReadValue<Vector3>();
    }

    void FixedUpdate() {
        rb.linearVelocity = new Vector3(_moveDirection.x * movementSpeed, rb.linearVelocity.y, _moveDirection.z * movementSpeed);
    }
}
wintry quarry
harsh tartan
#

oh, so if u also wanna use trigger u need 2 box colliders?

#

and now if I play I cannot walk around only when im in the air? is it because im "stuck" in the ground?

wintry quarry
wintry quarry
harsh tartan
#

my player cannot move right now, but when im flying (not touching the ground) I can move around. How come?

wintry quarry
#

I will say it's very weird that your Ground object has a non-kinematic Rigidbody

#

that actually means your ground object is going to move around when hit by other objects like the player

#

Almost certainly you should just remove the Rigidbody component from the ground object

#

assuming it's not supposed to move

harsh tartan
#

Thanks for the help

rancid tinsel
#

just discovered this beauty, had no idea this was possible

#

I thought && was only for conditionals

merry fiber
frigid fern
#

Hey so im trying to switch platforms with the 6000.3.5f1 and i dont have a switch platform button. What do i do?

merry fiber
#

Go to build settings and switch from there.

rancid tinsel
merry fiber
rancid tinsel
#

oh lol

#

that makes a lot of sense

#

wait actually I knew that

#

I mean that you can use those

#

so why is my example so confusing

merry fiber
#

Wdym

slender nymph
rancid tinsel
#

this is literally just the same as like, ready = conditionA && conditionB

rancid tinsel
#

OH

#

ok I get it

#

if I think about it as if it's an if statement

#

it makes a lot more sense

#

just condensing that made me a bit confused

eager stratus
#

So is there any reason that the display might be flickering when I mouse over the enemy instead of staying consistent? It doesn't do this with the four player characters who use functionally the same code

#
{
    if (conditionDisplay is not null)
    {
        print("Entering " + _statBlock.name);
        conditionDisplay.gameObject.SetActive(true);
        if (nameConditionDisplay is not null) { nameConditionDisplay.text = _statBlock.name; }
    }
}

public void OnPointerExit(PointerEventData eventData)
{
    if (conditionDisplay is not null) { conditionDisplay.gameObject.SetActive(false); }
}```
polar acorn
mild citrus
#

plant is supposed to be dragable but it's not working, please help

polar acorn
mild citrus
rancid tinsel
#

button makes it clickable, draggable will be with interfaces I believe

polar acorn
solar hill
#

you also need to get in habit of not screenshoting code

#

and sending it properly

radiant voidBOT
mild citrus
mild citrus
#

We gaan in Unity game engine een Plants vs Zombies clone maken. In dit deel maken we het dat de planten kunnen schieten en de zombies dood kunnen gaan, ook kan je zonnen collecten.

Files: drive.google.com/drive/folders/1_oJ8ZOKzr1lbPYYkP1LEDai-kXAI66sC?usp=share_link

song credit:
https://www.youtube.com/watch?v=Qi9ECXZopns
https://www.youtube...

▶ Play video
rancid tinsel
#

you need to provide the button component with a method to run when it is clicked

polar acorn
solar hill
#

you should share your code.

mild citrus
#

here's the script the tutorial didn't change anything about the button

solar hill
#

istg these bot messages are like

#

invisible sometimes

radiant voidBOT
solar hill
#

please share your code properly

rancid tinsel
#

ah wait okay you are assigning the listener to the button in code

solar hill
#

yeah we need to see your game manager script

mild citrus
#

I just realized whats wrong my left clicks arent registring debug log is coming up empty

solar hill
#

where is this being called?

#

what script on which gameobject

mild citrus
solar hill
#

is the gamemanager in the scene?

#

does it have this script on itself.

mild citrus
solar hill
#

are you using the new input system or both?

mild citrus
#

both

solar hill
#

so if you click anywhere onthe screen the log doesnt show up?

mild citrus
#

yes

#

is there an alternate script

solar hill
#

what

mild citrus
#

is there alternate script for mouse left click

solar hill
#

i mean yeah if youre using the new input system but this should still work

#

add this "Debug.Log("Update running");" to the top of your update above the mouse input line

#

and see if it shows up in the console.

#

wait

#

your update is private?

#

that shit wont run.

polar acorn
solar hill
#

what really?

#

i thought they couldnt have access modifiers

polar acorn
#

If this isn't running when you click, this script isn't on anything

solar hill
#

bruh or am i misremembering

polar acorn
solar hill
#

yeah but i thought specifically adding "private" or anything else ceases to function

#

i might be missremembering something

#

or confusing it with s&box

polar acorn
#

Nah, they can be private, public, protected, doesn't matter. They're called via reflection so it bypasses the access modifiers

solar hill
#

huh, i guess i never thought about it, i must have been confusing it with something else then

#

but regardless i still think the script isnt actually in the scene

#

so either check with that debug i gave you, or double check you have the correct script attached to your game manager

#

ensure you actually attached it as a component, and not a reference inside some serialized field.

polar acorn
#

Yeah if this isn't running, it's not in the scene

mild citrus
#

i figured it out I am sorry I had the grid disabled because it was invisible in the tutorial so I thought the code would activate it but it's just invisible when activated. im an idiot

rancid tinsel
#

dw it happens

#

and you'll spot it faster next time

distant escarp
#

hey! i have some code that generates a wavy ocean for my game but i want the waves to use the global coordinates instead of local coordinates (so the waves will sync between instances); does anybody know how i would do this? (code posted below)

#

is it literally as simple as replacing "local" with "global"?

queen adder
#

Heya, has anyone had the bug where it's download for the editer download for the latest verison where it's stuck on 99% Because mines sat on 99% for atleast 2 hours now

lethal meadow
distant escarp
#

kind of, the mesh doesnt have a collision but my player interacts with it by reading the same code
otherwise, it doesnt require a collision

lethal meadow
#

the player "floats" or can interact with the water by sampling the same position height function?

#

but it doesnt actually need a collider component

#

because thats unnecessarily expensive

#

i'd use a subdivided flat plane with a shader that displaces the verticies

#

or if you really want to generate the mesh probably a compute shader

distant escarp
#

that's basically what im doing, the player moves on the waves by sampling the same position height function

lethal meadow
#

yeah you should probably use vertex displacement in the water shader then

#

you need to implement your height function in it though

#

this will be much much faster

distant escarp
#

dumb question(s): what is that, how will it help me, and how do i implement it?

lethal meadow
#

vertex plots the actual vertices

#

its done per vertex

#

and the fragment pass is what draws the colors and is done per pixel

#

so in the vertex pass, you can get the vertex position and then offset it a little

#

this is drawn HOWEVER is just a temporary GPU value so does not technically exist

#

which is why you cant have colliders with it

distant escarp
#

to be clear, i already have the "collision" working (my player can move around on the waves)
im just trying to sync the waves across multiple instances

lethal meadow
#

do you have a shader for the water?

broken nest
#
    public ActionData[] actionDataSecondMenu;
    public MenuPanelButtonsDescriptions menuPanelButtonsDescriptionsPrefab;
    List<MenuPanelParent> activeMenuPanel = new List<MenuPanelParent>();
    int menuIndex =0;

    public void Start()
    {
        CreateMenuPanelButtons(actionDataBaseMenu, false);
        //currentTotalMenuLength + = 
        CreateMenuPanelButtons(actionDataSecondMenu, false);
    }

    public void CreateMenuPanelButtons(ActionData[] actionData, bool descriptionOn)
    {
        activeMenuPanel.Add(Instantiate(menuPanelButtonsDescriptionsPrefab, this.transform));
        activeMenuPanel[menuIndex].descriptionOn = descriptionOn;
        activeMenuPanel[menuIndex].CreateMenuUI(actionData);
        menuIndex++;
    }```
Hey, MenuPanelButtonsDescriptions which is instantiated inherits from MenuPanelParent. I can't access descriptionOn ( in MenuPanelButtonsDescriptions ) because I add it to a list of MenuPanelParent. Any ideas?
distant escarp
#

yes, i have a shader and a shader graph

lethal meadow
#

it samles the worldposition.xz and then inputs it into a height function (the noise block) and then uses that for the vertex .Y position

#

this is what you're doing on the cpu

#

but this is much faster and more scalable

stone oar
#

hey guys, is it possible to have different Render Scale values for different cameras? Trying to make certain elements look sharper.

distant escarp
pastel cave
#

So why are gameobjects limited to only one tag?

lethal meadow
pastel cave
distant escarp
#

oh wait one sec i made a tiny mistaake

lethal meadow
#

you need to put vec3(ObjectPosition.x, ObjectPosition.y + HeightValue, ObjectPosition.z)

#

the vertex output requires object space

#

you need to sample with world though

#

just add another Position node

sour fulcrum
pastel cave
#

Mmmm. I will keep that in mind

#

Is the alternative like, a component that has a static hashset or something?

sour fulcrum
#

no like literally just if it has that component

pastel cave
#

Well sure but with tags you can also get all gameobjects with a certain tag

sour fulcrum
#

Unity also has a FindObjectsOfType function 😄

pastel cave
#

That it does

distant escarp
sour fulcrum
#

checking for a component at minimum is the same amount of functionality a tag offers but of course with the further ability to actually do stuff with the component reference if needed

#

It’s genuinely just superior

lethal meadow
pastel cave
distant escarp
#

but what do i connect it to?

lethal meadow
#

the position element on the Vertex node

distant escarp
#

is it okay to reuse the existing psoition node?

lethal meadow
#

to sample the height function you need world space coords

sour fulcrum
# pastel cave Yeah, seems like it Requires a bit of setup though.

If your just starting with it perhaps but if you keep it in mind from the start of the project it’s pretty chill as you don’t usually need to make/add any classes specifically just for tag checking, rather you probably just end up having components on these objects for other functionality based reasons that you can just check for

lethal meadow
#

for thhe output you need object space coords

#

so you need 2 nodes

pastel cave
#

I can definitely see how Godot was influenced by unity lmao
In some ways unity has felt archaic

#

In others it has also felt very nice though

#

I do love me some components

distant escarp
lethal meadow
#

send a screenshot

distant escarp
#

of the shader graph or my waves?

lethal meadow
#

shader graph

distant escarp
#

(i can zoom in if you need me to)

lethal meadow
#

are you sure the noise scale is not wrong

#

try 10

distant escarp
#

just changed it and its still not synced

lethal meadow
#

alright show this one

#

on the left

swift crag
#

one important thing is that, in the HDRP, at least, a Position node set to "World" mode will give you a camera-relative position

#

i'd expect for the noise to change as you move around, in that case

lethal meadow
swift crag
distant escarp
lethal meadow
#

they should still sync though

#

not sure

distant escarp
#

no, i think im in URP

swift crag
lethal meadow
#

can you show what it looks like

distant escarp
#

the game, you mean?

#

this is two "ocean" tiles next to each other (what i want is for waves to move between the tiles, ie "synced")

lethal meadow
#

can you disable the previous script used to set the mesh each frame

#

and then try

distant escarp
#

when i disable the "Wave" script the water disappears completely

lethal meadow
#

well you must be doing something else because im using the exact same shader graph setup and it works

distant escarp
#

also i think your edits to my shader made my collisions not work

lethal meadow
#

yes because its a different noise function

#

you'd need to add your c# height function and use that instead of the simple noise

swift crag
#

I thought you meant you had problems with desync in multiplayer games, haha

distant escarp
#

lol yeah i thought someone might think that (i should have been more clear)

#

its a singleplayer game

swift crag
#

I'd call those "seams"

#

the bane of my existence

lethal meadow
#

i dont know what hes doing

#

im using the same setup and its working

distant escarp
swift crag
#

yeah, given what you've shown, the edges that touch should be computing identical values

#

It almost looks like the right side is an exact repeat of the left side

#

but it's not quite the same

distant escarp
#

before any of @lethal meadow 's suggestions, they were exact repeats of one another

lethal meadow
#

he was computing all the vertices on the cpu before

#

every frame

swift crag
#

oof

#

that'll get painful quick

#

This shader-based approach should be working perfectly

#

I've done stuff like this quite a few times

#

if you place both tiles in the same position, do they match?

lethal meadow
#

alright i have to go but this is my final setup this i use in my own water

distant escarp
lethal meadow
#

dont know if you can see it but it displaces it fine

#

try just having the mesh you're using as a new gameobject

#

dont add anything else to it

distant escarp
swift crag
#

can you export a unitypackage containing your shader graph?

#

I can see how it looks on my end

distant escarp
#

uhhh how do i do that?

swift crag
#

right click the asset and hit Export Package

#

this'll give you a .unitypackage

#

you can drop it into the chat

distant escarp
#

here you go, let me know if you need anything else!

#

(fyi, i stole my water from a youtube tutorial)

swift crag
#

looks fine over here

distant escarp
#

HUH???

swift crag
#

These are two Plane objects side-by-side

distant escarp
#

no i get it

swift crag
#

are you also using two planes?

distant escarp
#

im just confused why its not working

solar hill
distant escarp
swift crag
#

show the inspector for one of the water objects

distant escarp
swift crag
#

is your Waves script still doing stuff to the mesh?

distant escarp
#

yeah but i turned it off earlier and the mesh disappeared entirely

swift crag
#

notably, my water does not look like your water

swift crag
#

I presume that the Waves script added one

#

that's what actually holds the mesh

#

delete Waves, add a MeshFilter component, and plug in the Plane mesh

#

(or just make a completely new Plane object)

distant escarp
#

btw, when i make a plane object and apply my shader, it syncs with other plane objects but the waves arent animated

swift crag
#

Yeah, the shader does not change over time right now

#

the wave height is purely a function of the world position

distant escarp
swift crag
#

if you want a genuine mesh collider, then you're going to have to compute a mesh on the CPU

#

However, if you don't really need a collider, and just need to know the water height, you can do the same math

#

exactly recreating the Simple Noise node sounds a bit annoying...

#

in theory, you could lightly adapt this code into C#

#

(the Unity Mathematics library would make it particularly easy – it has types like float2; it's designed to match the types seen in HLSL)

#

in fact, I think this would compile with minimal changes

#

you'd remove the inline keywords, and then you'd replace frac with math.frac, etc.

#

but this still sounds a bit challenging

#

this would be a lot better than computing a mesh in a C# script – you'd only be doing the math for the points you care about

#

(e.g. where the player is)

#

the GPU can easily handle moving the vertices around

boreal ingot
#

i have this game that i have designed for multiplayer and i want to actually make it multiplayer. as of right now i have invested aroundf 20 hours into doing that with ai and this is the 3rd time i git hard reset because they mess up everything. honestly fuck copilot. anyways i have logic on what you should and shouldn t see as an individual player in my game which i see can work because i had a player switch mechanism in it. i want those rules to work with multiplayer. what do you recommend guys. i really am getting pissed at working 20 hours and no results

solar hill
#

but you havent actually asked anything.

distant escarp
boreal ingot
solar hill
#

so you want to learn the basics of networking?

radiant voidBOT
#

:teacher: Unity Learn ↗

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

ivory dove
#

hello, can someone help me with my project?

true vector
#

This may be weird but is it possible to have visual scripting and c# code assets in the same project and still working?

solar hill
radiant voidBOT
# solar hill !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

ivory dove
# solar hill !ask

im not a dev, i have the code for a game im trying to build, but idk how to implement it and if even the code is correct

solar hill
#

youre going to have to clarify a lot more

#

you have the code but youre not a dev?

#

is this someone elses project?

true vector
# rich adder yes

Oh thank you! I’m working on a group project and I only know how to code with visual scripting and I was worried that I may effect the game with certain assets I may create using vs

ivory dove
#

not really, dont lash out on me, but i used an ai to create the game for me, after intensive detail, but i dont know what to do next, im trying to fully implement it and have it running to send it to my friend as a gift

solar hill
#

you kinda screwed yourself over

#

youre saying ai made a game for you but youve never actually ran any of the code inside of unity?

#

that game wont work because the ai was basically shooting blind

#

theres also a whole lot more set up to making a game than just writing the code itself

#

especially stuff you have to handle in editor

ivory dove
#

i can show you the whole conversation as to what happened, for the logic, calculation etc

#

before writing the code itself

solar hill
#

it wont be nescessary

#

because i can tell you

#

it wont matter

ivory dove
#

🙁

solar hill
#

thats simply not how development works

#

especially not in unity

#

whatever you have wont work

ivory dove
#

how does it work if you dont mind me asking

solar hill
#

its hard to explain but the fundamentals are pretty much the same

#

the important thing is that you are actually working inside the editor itself

#

not just on the code

ivory dove
#

for the design?

solar hill
#

not just the design

#

the foundation of your entire game lol