#💻┃code-beginner
1 messages · Page 798 of 1
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
They were small ones I though, just quality of life ones (in their own folders) But I guess so.
You can test by introducing one package at a time
Hello! I'm a beginner in C# and I don't know where to start. Can anyone help me?
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
If you're using the new InputSystem, OnMouseDown no longer works.
watch brackeys tutorials, its a good start.
look for "how to make a game" playlist on his channel
ohhhh
i forgot about ts
ok thanks
thanks! i'll take a look
but how can i revert it to the old one?
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 :/
!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.
good luck
best advice, don't over do it and don't expect good results early.
thanks
I switched my characters from using rigidbodies to character controllers to be more stable, but now they can move through each other which isnt great for combat. Advice? 😄
theres most likely a way to combined these 2 if statements into one line but idk how
you have to show more detail like code to move & inspector for both objs
||
where would i be adding these
It means "Or"
lol
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
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?
You're "Playing" a prefab.
if your project using new input system. onMouseDown will not work
that doesn't actually exist in the scene
i reverted to old
If you want to actually see it, it needs to be in the scene
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?
why "another way"
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?
its common to instantiate an effect to play it
later on you can improve it with pooling and recycle them
ok and whats the movement code look like?
Nah posted directly to the channel
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
use the links
ah ok thanks
well, i tried to put it in two different ways but still no effect.
A tool for sharing your source code with the world!
idk if im dumb or smth
yeah ur right
i got this effect from the asset store if it makes a difference
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
in what way? did you not spawn it ?
does the other player have any movement code? is it a character controlled by player ?
btw you shouldnt call .Move twice, combine it into 1 call
Yeah, just combined into 1 call- still happens unfortuntaly - the other character does have movement code, but I disabled everything on that gameObject in that video except for the charactercontroller and the clipping still happens 🙁
just combined into 1 call- still happens unfortuntaly
this isnt something to fix it, just something you should do in general
is this local multiplayer / same screen multiplayer or something
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
are they going to be controlled at the same time or do they "take turns" ?
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
oh I was gonna say , what you could do is switch it from CC-enabled to a capsule collider when not moving
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
do you have looping on ?
i disabled "looping" and set "stop action" to destroy
also how come you're destroying the object with PlayerClicks rather than the spawned particle ?
i don't understand
SpawnClickEffects();
Destroy(gameObject);```
ummmm, so?
You're destroy object with PlayerClicks?
elaborate this info
yup
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
player clicks is the script i assigned to the circles
its the only script there
gotcha
cool
now did you modify the prefab for Effect in the project folder and reference that one
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
show which obj you put in the inspector for. ClickEffect
this what you want?
i didn't get this one
i think yeah
and it still loops ?
how many appear in hierarchy when u spawn it
hmm check if it has subemitters maybe
where?
in main module of partice
doubt
I mean duration can sometimes prolong it
im looking up a guide for another way to emit this effect
maybe its smth in the code
idk
pause the game when the particle Clone spawns , and inspect its properties
didn't get any info with this
im hopin off to breath some air then coming back
sorry if i caused you troubles
i didn't really get anything useful with this
it has the same prop. of a regular effect
so you checked Loop is Off and Start/Durtation time is low there too?
yup
what about play on awake?
thats how its playing in the first place
so you need main looping off, main stop action destroy AND main play on awake false
play on awake shouldnt be a problem cause looping
it doesnt even play now
hello guys i need help
did you read any of the previous conversation
yeah
i cant move my character
call play() explicitly
not much anyone can help with without info
or reinstate play on awake and ensure you've set emision to burst (1)
Try making a brand new effect that You know for sure ends, make a prefab out of it and spawn that instead
ok
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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
you've mapped your movement to the world state not the player state
type " ` " three times before and after the script
like this
ye this works too
post the code properly first, then you have to show the object you put this on
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
yeah
i would make my own praticle prefab first to ensure thats working fine and isolate the issue
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
yes most likely its that, can you show the Emission section rq
like a vid?
screenshot is fine too
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
hmm can you link this to me rq? now I'm curious to see what it could be
I feel like there are just multiple things going on / spawning that might be overlooked
its probably a child object since there seems to be multiple shapes playing
ok so I’m in a dev group for a gorilla tag vr fan game and we currently need scripters
: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**
oh mb
I’m confused by this
Did you try reading it
whats confusing ? its easy to understand if you read it
I dont know why my cylinder is not moving?
[i am just beginner btw]
What is supposed to be moving it
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
so script that in
You're going to have to learn the basics before anything else..
the project is due tomorrow
so you didn't learn anything from it and are trying to get last minute ?
i learned blender
What does your current movement script look like
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);
}
}
this looks like copied from the dude who posted before..
Is your Animator using Root Motion
bc of the animation
probably because root motion
this is a code channel, not a feedback channel.. delete from here
Hello, I'm trying to access a class from another script but it says the name of the script doesn't exist, any fix?
you either have compile errors or nested it inside another class
ok mb
What is the specific error and code that you're seeing
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
Where do you define MenuBuilder?
The script you've provided is for MenuBuidler
Ahaha
nice
thanks
ok now there is no more animation but when i move with my mouse the cam moves with looks like im floating around
I'm manually refreshing unity but the script is not updating
any idea?
did you save the file? do you have any compile errors?
just right mouse click the file -> reimport
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);
}
}```
because it hasn't picked up the script
i put on the prefab the original circle prefab
does the prefab have a collider attached?
yup
and is the new circle generated in the visible camera layer?
but for some reason the clone have them disabled
yup
hmm interesting
check the z position of the 2nd circle
it needs to match the original
are you using the new input suystem?
can i hard code it?
Whenever a prefab has a reference to itself, it'll get updated with a reference to "itself" rather than the prefab file. You want to either spawn a different prefab, or do the spawning somewhere else, like a "CircleSpawnManager" object rather than having each circle spawn in its own replacement
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 ?
i duplicated it, then named it "Circle Copy" then tried running it. the first two worked well then the third was named "Circle Copy (Clone)(Clone)
If needed i recently made an example project on how to do mouse pointer events with new input system
https://github.com/rob5300/Unity-EventSystem-Events-Example
and didn't have the script and collider enabled
im on the old one
You'd need Circle to reference Circle Copy and Circle Copy to reference Circle
I know but moving forward you want to use the new input system
unless this is a one time thing thats it bye bye unity
Worked well!
thanks
will do
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
Visual studio is probably not set up correctly but id expect the newly made script to still open
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
^ follow these instructions to ensure visual studio is installed correctly
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.
because you need to update
to... 6.3?
If you want, or you can get the latest patch of 6.1
If i have a 2024 version of unity and a 2022 version of visual studio could it be a problem ?
no
As long as VS has the unity tools and your project has the VS package updated it will work fine. The guide linked should explain it all.
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

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
template doesn't mean its any easier
oh sweet child
this was never an issue with git
there is no "live" collab tho, like roblux or some shit
you add them as collaborator, depending where u host repo
yeah for some reason I havent been able to get that to work in the past
Yea they need permission to be able to push changes
I honestly think its an issue on their end
or lack of knowledge
Hmm well its pretty simple to change so probably your fault
if using github check the collaborators section for the repo and see if this user is added to the list as maintainer or admin
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
pretty much, they have a copy
oh ok
unity version control always has problems
thank you guys!
learn git, and use common hosts like github
will do
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?
You're trying to create a child object of a DDOL object so it's making it without a parent instead
I don't think I am tho
What line is the error on
panel = Instantiate(UIPrefab.instance.panelPrefab, this.transform);
And what object has this script on it
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()
best ask that again in a better way
Are you sure you're calling CreateMenuUI on the one in the scene?
And not the prefab?
Ho that might be the mistake
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
you mean player settings?
also not a coding question
That was the problem thank you
okey police
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
hey, im trying to learn c# for game development, does anyone have any tips on how to learn and how to get started?
Best to learn a bit outside of unity. Understanding some object oriented programming goes a long way!
id also recommend microsoft learn
okay, thanks a lot!
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
how , you didnt send the script
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
first thing - do not have a CharacterController AND Rigidbody on .. choose one
Root motion is probably overriding the movement code
i am very new to this what you mean by characterController
dont think i've seen one there
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
i found the issue
i was trying to move in the scane window not the game window
chat, does anyone use unity vivox ?
dont ask to ask
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
decal projector
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
oh cause you said this
like in siege when u shoot the wall it has a hole
ik that wasnt the problem
anyway, for hit markers you probably want to use either a sprite above enemy if you want it world, or UI for screen
so then whats the current problem, how about start with that
not getting the red hitmarker to display
ok this is where you show how you set everything up
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
if thats what you use for making things happen , then its relevant
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
Do you check the hit ray hits someone?
it is english..
You need a way to tell the script that you hit an enemy
so the script that controls hitmarker changes its color
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'
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
Hey if anyone wants to give me help in the input system channel tha would be great 😊
don't crosspost
if someone wants to help and/or knows an answer with input they visit the channel
Sorry king
Mh? I was just asking to like get an opinion because I was thinking of using it
makes more sense to ask that directly , also this is a coding channel so not really related
better off asking on the forums dedicated for it
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?
question, i've just begun learning about how the game architecture is structured, should I divide playerMovement, playerAttack and playerJump in different scripts?
Depends. Do you expect to have players that can't move or attack or jump?
What's your reasoning behind splitting it into several scripts?
to avoid interdependencies (?)
You can achieve that even if all of these features are in one script.
How exactly splitting it into several scripts gonna help you?
Besides, do you really want to avoid dependency of, let's say movement and jumping? These mechanics are usually closely interconnected for obvious reasons.
yeah you're right, thanks for your answer
Use the OnScreenControls feature of the new input system to make this easy
I want to. However I am using the Input Manager because there are two players on screen and each needs different controls (this is a pong clone) and input system doesn't allow me to do that (unless I am missing something)
input system definitely does
Input system definitely allows you to do that.
Different keys in the same keyboard?
you could even do it 1:1 with how you have it in the input manager
or you could utilize the local multiplayer stuff
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
afaik there's only GetAxis smoothing that isn't replicated in the new inputsystem
Oh, I see, I can just make actions for the two different players in the same control
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?
kinda the same way you did with the input manager
have them listen for different events or check different actions
as I mentioned using PlayerInput/PlayerInputManager or by making separate actions
I see, I'll check that then, thanks
Hello what is the name of this in code
Thank you
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
this is probably past beginner, but why do you need to interpolate them at all? Why not have 1 sample per vertex?
Can I just learn visual scripting if I don't wanna learn how to code?
Is it easier?
sure, you can do whatever you want
no
you have to learn to code even with visual scripting
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
You can have a threshold where it should stop and project the speed on that line. So if its below a certain distance, slow down and if its close to another distance, stop.
I would rather have a relative stable speed toward the player
(player pos - enemy pos).normalized * speed
yeh, thats what I meant. keep the speed stable until hitting the threshold and below that do whatever you want. full stop, slow down. up to you and your animation
Worked like a charm, they are more threatening now
can GetComponentsInChildren<Transform>() pick also the parent transform ? because it seems like it
"Gets references to all components of type T on the same GameObject as the component specified, and any child of the GameObject."
If you get the components its an array, you can just filter out the self transform after getting them
I have a decentlooking game now. Enemies spawning alright, running toward the player, feel like a real game now
what are you trying to do? if you're just trying to get all the children you can just.. get all children
haha, true, it can be as easy as
foreach(Transform t in transform)
Debug.Log(t.name);
Yeah ? How ?
Look up 😉
You can just iterate on a gameobject transform ?
Its basically a wrapper for GetChild(index) for all indexes within childCount
for more information, its the interface being used from c# https://learn.microsoft.com/en-us/dotnet/api/system.collections.ienumerable?view=net-10.0
I'll look at that later
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
Player settings -> other -> change input to old (I can't remember the exact name of the field)
!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.
Thanks ! will this problem be often there when i will code ?
okay thank you
hi my player sliding/drifting with any movement script after clicking play button it starts to slide how to fix that
Thank you man. It's interesting unity docs just say use the old system.
check off animate physics in player's animator component
thank u i will try
no its not working bro
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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
);
}
}
share it properly as described here please.
i added the code there too
see the "large code blocks" section
i added there too
what i wanna do now ?
if there's no movement input, don't move
So then post it
A tool for sharing your source code with the world!
that's much easier to read
u can refer this video too
pay attention to lines 47 to 49, read what it says to do
that's always walking forwards
ok
if there's no walk input, then you shouldn't walk
when i give input player walking if nothing is touched its going straight
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
transform.forward this gives the forward vector of the player. You should instead use the movement vector you created "m_Movement"
Can somebody say why my joystick isn't working when I build it
did you read what i said at all
how exactly isn't it working? is there an error, is it not working as expected, etc?
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
it not working as expected
it definitely is the code. if you read and understand the lines of code i pointed out to you, then that should be understandable
what's the behavior you're getting, vs what you're expecting?
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
you would make a class containing 3 public int, marked [Serializable] (though you'd probably want a struct instead of a class for something like that)
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 ^^
its not my code its from unity learn series...
I must be missing how struct work cause even like that it doesn't show and serializable can't be used on struct
and it is on my other script but it just doesn't show
you need [Serializable]
they can definitely be used on types
(also, that's not an array.)
on the struct itself or my int?
and it's working code, but it's not doing what you need
on the struct itself
Nonon i know it's just a temporary name i didn't modify yet
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
i'm not sure what exactly you're going for, but definitely sounds like there'd be an easier way to do that
Currently doing that, and i wanted to do an array of 3 int since when i will use the mesh and assign vertex i want to see the triangles more easily this way i can display it in the editore and have a preview
This way instead of setting all the triangles in a simple array i can do that and preview things more easily.
I know i could do without but it save me a lot of time managing my voxel faces and vertex
why not just use Vector3s for that
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
guys i restarted unity the bug fixed lol
really bro...
Yeah some bug just need a restart
nah im just calling him
oh do you mean the issue is with Vector3's being floats? you could use Vector3Int for that
Chris ur thoughts about this?
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
have you read the code you're using at any point during this argument
yeah, so you need 3 ints at a time? Vector3Int gives you a nice compact UI for that in the inspector
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
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
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??
uhhhh can you show the actual code that prints that log?
also how do you know that's in the dictionary?
foreach (var item in JumpTable)
{
Debug.Log('"' + item.Key + '"'); //But key is here
}
ExePos = JumpTable[Tokens[ExePos+1] + ":"]; //error here
it looks literally before using it
Tokens is a string array
the key is "start"
or atleast in that position, I can even confrim in the editor
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?
I just tried the code again, but removed the : and it worked...
-
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.
-
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^
I tried to do a Asm Interpreter for my game
and you include the colon in the label?
yes, cause I couldnt remove it so I just included it, for being easier
what do you mean you couldn't remove it
I was lazy, and just added it in the end. Technically these are the same strings
or should be
Ok, this is now being printed. There is some kind of invisible character
yeah i figured
try printing out the charcodes then
Is one of these strings being sourced from a UI Input Field by chance?
nope, from a file
here is the whole file: mov r0 1 start: int 1 jmp start
Technically yes, I saved the UI field to a file, but I also removed and added it via VS code again
Charcode 13???
Anyways, thanks for the help
Okay, so if the raw source of it was from a UI Input field, and you grabbed it from the text component, rather than the input fields .value, there's a non-printing character that doesn't get caught by Trim(). You might want to sanitize the input before saving it with this replace: .Replace("\u200B", "")
Ah, that's actually much easier than the one I thought it was. That's a carriage return, \r. "Newline" in most text formats isn't actually \n, it's \r\n. If you're separating your file on \n, it's leaving the \r behind
that one will get removed with a call to Trim(), so you can just trim the data before you put it into your dictionary
Thanks. I never knew this Character exsisted
newline in windows is usually \r\n/CRLF, newline in *nix is usually \n/LF
it's not really dependant on "text format"
Does WaitForSeconds pause when Time.timeScale = 0?
try it out
It doesn't
or read docs
mm definitely not
oof
thx
well, it doesn't "pause", it just never completes
if you want one that doesn't use scaled time, use WaitForSecondsRealtime
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
whats that?
well, that's new
I'm new 🫠
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
ooooh
I tried a lot, just very unlucky with fixing it up
nah this my only issue so far
hiw i leran unity fast
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
is good
ok thanks
learn c# basics
ok
then dive into unity editor and follow some easy tutorials such as flappy bird or temple run
👍
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?
it lets you be a little lazy and can help make refactoring easier sometimes. But sometimes it hides types and makes the code harder to read
so... it's a tradeoff
Lowkey I agree with that conclusion
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>>();```
I guess yeah in refactoring especially if you're changing from an float to a double etc?
in this casse you don't lose any information but you make it more concise
yeah exactly it lets you avoid changing variable types in multiple places sometimes
I agree with that example actually
it's like auto in C++ afaik. I'm not a C# guru but say you change the type of your return, then you have to change the type of every single invoke that uses that return
also saves you typing long types
but for example:
var x = GetSomeData();``` can be bad
because just reading this it's hard to know what type x is
Isn’t there a shorthand for the latter since the left half is defined?
yeah you can also do:
List<Dictionary<Dog, Cat>> x = new();
this is the "target-typed new"
I found out about this a few weeks ago but completely forgot the syntax lol
[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"
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?
Control schemes are tricky, especially with trying to do multiple players on one keyboard
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
I'd probably just ensure cam isn't null and then use cam.transform always, rather than having two extra variables
You may have to manually spawn and assign the players to the device like this:
https://discussions.unity.com/t/how-to-make-multiple-player-inputs-work-using-the-same-device/1572442
yeah it was really weird on our group project for mobile where we were testing it with WASD movement and clicking the mobile UI for attacks/abilities - it would switch between two control schemes
I would also probably separate the two keyboard key groups into two separate bindings
rather than separate composite parts in a single binding
Thats a good one thanks!
And talking about this (the picture) can I better use that or is this way fine?
like whats better Input system package or just the Input manager
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
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?
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
Perfect, forcing the association works.
why's that?
https://www.youtube.com/watch?v=ONlMEZs9Rgw this video might be useful
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...
Will check
nice, glad it was that easy
yep. Thanks a ton!
uh, idk i thought it would make it work better but I guess it doesn't matter
oh I see
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?
it's reading whatever the current state of that action is, it can't have more than one state at the same time
oh wait its move.action
thats what I get for skimming through the video
thanks boxfriend
the documentation doesn't really explain what the "Respawn", "Finish", and "GameController" flags do
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);
}
}
your player's collider is a trigger
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?
not sure what you mean exactly
also not sure what you mean by this
my player cannot move right now, but when im flying (not touching the ground) I can move around. How come?
not sure, potentially from friction
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
Yea did that and its fixed
Thanks for the help
just discovered this beauty, had no idea this was possible
I thought && was only for conditionals
Even || and <=> works
Hey so im trying to switch platforms with the 6000.3.5f1 and i dont have a switch platform button. What do i do?
Go to build settings and switch from there.
what on earth is <=>
Short for <=, >= and ==
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
Wdym
this is a conditional, it's literally just evaluating to a bool
this is literally just the same as like, ready = conditionA && conditionB
yeah
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
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); }
}```
My guess is that the actual bounding box of the text is big enough that it's showing up under the mouse, so your mouse "exits" the guy and "enters" the text, which hides the text, which means the mouse can now "enter" the guy's hitbox and re-enables the text, and so on.
Make sure the Raycast Target checkbox is unchecked on your text so it doesn't block the mouse
That fixed it. Thanks
plant is supposed to be dragable but it's not working, please help
what is supposed to be making it draggable
I am following a tutorial he didn't explain I think because I added a button to it makes it clickable
button makes it clickable, draggable will be with interfaces I believe
Yes, buttons are clickable. What are you adding that's supposed to make it draggable?
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
how do I make it dragable I followed the tutorial to a T he did everything the same
Show the tutorial
sorry not dragable it's just supposed to be clickable but when I click on it the script doesn't make a plant appear
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...
so the way buttons work in Unity is that they provide you with the ability to click them, but what they do once they're clicked is up to you
you need to provide the button component with a method to run when it is clicked
Nothing around 7:00 shows anything to do with buttons or clicking
you should share your code.
here's the script the tutorial didn't change anything about the button
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
please share your code properly
ah wait okay you are assigning the listener to the button in code
yeah we need to see your game manager script
I just realized whats wrong my left clicks arent registring debug log is coming up empty
on the gamemanager empty
yes it's at the center and it has the script
are you using the new input system or both?
both
so if you click anywhere onthe screen the log doesnt show up?
what
is there alternate script for mouse left click
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.
It can run as a private. It's private by default, actually
If this isn't running when you click, this script isn't on anything
bruh or am i misremembering
If it has no access modifier, it means "private"
yeah but i thought specifically adding "private" or anything else ceases to function
i might be missremembering something
or confusing it with s&box
Nah, they can be private, public, protected, doesn't matter. They're called via reflection so it bypasses the access modifiers
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.
Yeah if this isn't running, it's not in the scene
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
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"?
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
does the water require collision with anything?
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
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
that's basically what im doing, the player moves on the waves by sampling the same position height function
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
dumb question(s): what is that, how will it help me, and how do i implement it?
in a shader it has the fragment and vertex pass
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
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
do you have a shader for the water?
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?
yes, i have a shader and a shader graph
okay so for something like this
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
hey guys, is it possible to have different Render Scale values for different cameras? Trying to make certain elements look sharper.
i added this into my existing shader graph and it broke my waves lol
So why are gameobjects limited to only one tag?
for the final vector
It seems like a fairly arbitrary restriction
oh wait one sec i made a tiny mistaake
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
Tags are a relatively old and primitive concept, ideally you’d probably just not use them period and instead use components like tags
Mmmm. I will keep that in mind
Is the alternative like, a component that has a static hashset or something?
no like literally just if it has that component
Well sure but with tags you can also get all gameobjects with a certain tag
Unity also has a FindObjectsOfType function 😄
That it does
where should i add the position node?
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
anywhere
Yeah, seems like it
Requires a bit of setup though.
but what do i connect it to?
is it okay to reuse the existing psoition node?
to sample the height function you need world space coords
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
I'm making pong for a college class so I doubt that it truly matters
I'm already kind of going above and beyond, I think I can forgive myself for taking a shortcut and using tags u_u
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
its still not synced across separate instances and now it looks worse than before lol
send a screenshot
of the shader graph or my waves?
shader graph
just changed it and its still not synced
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
is that what absolute world is for?
yeah
no, i think im in URP
the waves would rapidly change as you move and rotate, so it'd be incredibly weird to look at
can you show what it looks like
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")
when i disable the "Wave" script the water disappears completely
well you must be doing something else because im using the exact same shader graph setup and it works
also i think your edits to my shader made my collisions not work
yes because its a different noise function
you'd need to add your c# height function and use that instead of the simple noise
Oh
I thought you meant you had problems with desync in multiplayer games, haha
lol yeah i thought someone might think that (i should have been more clear)
its a singleplayer game
ah, any idea how i can get rid of them?
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
before any of @lethal meadow 's suggestions, they were exact repeats of one another
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?
alright i have to go but this is my final setup this i use in my own water
i think so but its hard to tell
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
unless i did this wrong, it did nothing
can you export a unitypackage containing your shader graph?
I can see how it looks on my end
uhhh how do i do that?
right click the asset and hit Export Package
this'll give you a .unitypackage
you can drop it into the chat
here you go, let me know if you need anything else!
(fyi, i stole my water from a youtube tutorial)
HUH???
These are two Plane objects side-by-side
no i get it
are you also using two planes?
im just confused why its not working
are you planes children of something?
i think im using emptys
show the inspector for one of the water objects
is your Waves script still doing stuff to the mesh?
yeah but i turned it off earlier and the mesh disappeared entirely
notably, my water does not look like your water
that's because your object has no MeshFilter on it
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)
btw, when i make a plane object and apply my shader, it syncs with other plane objects but the waves arent animated
Yeah, the shader does not change over time right now
the wave height is purely a function of the world position
#💻┃code-beginner message this graph makes the waves change over time
gnarly! i tried what you said before and it looks just like the plane object i made (with no collision) should i use the empty + plane mesh filter or just create aa plane mesh?
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
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
you should probably make a thread in #1390346492019212368
but you havent actually asked anything.
ok, rad! thanks for the help!
well i am asking for EVERYTHING tbh. i have no clue what the right aproach is without breaking stuff
so you want to learn the basics of networking?
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
hello, can someone help me with my project?
This may be weird but is it possible to have visual scripting and c# code assets in the same project and still working?
!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
yes
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

youre going to have to clarify a lot more
you have the code but youre not a dev?
is this someone elses project?
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
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
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
yikes
i can show you the whole conversation as to what happened, for the logic, calculation etc
before writing the code itself
🙁
thats simply not how development works
especially not in unity
whatever you have wont work
how does it work if you dont mind me asking
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
for the design?