#💻┃code-beginner
1 messages · Page 757 of 1
i would give u a 7, u can make a paralaxx effect, and a small eye animation like he is closing hes i and open it. i dont know whats the name in englisch for that
Then those documents are no good in the meantime
I can try to list a few things u have to complete before programming in Unity
First is the syntax, types, loop, etc. specific to C#. Different languages have different settings
Second is OOP, understand what a class is, how to implement its features
Last is data structure and algorithm, this is a bit advanced so u can save for later, after u have a solid experience with Unity scripting. But u should take a look at some simple data structures at the beginning of the course.
hmm okay should i use that website they sent?
i believe it shows most of the stuff you listed
cause if not i wouldnt know where to find that stuff
it also seems easy to understand on the website
A few years
Yes, u can. It would be better if u can find detailed courses for each topic I mentioned
im guessing thats for mastering it like completely
but im also sure you gain knowledge over time scripting
Yeah, writing functional code is one thing. Optimizing it is another
There's no command called
if.
hmm well i wouldnt be sure where to find some ill just use the website
guys is there any way to block the access of our game if someone downloaded a mod version or downloaded our game's apk from anywhere other than google play store?
What do you mean by block the access of our game?
It's a waste of time.
like if game is moded then I want my game to stop access from servers
There are like millions pirated products out there
like my player data is stored on unity cloud
You'll need some means to identify if it's modded.
The only way to deal with this is to add a ready-made anti-cheat to the game.
What exactly would you be concerned about relative to cheating/modded?
players data like email is also on the cloud
Clients would only have access to client side data.
And hackers will simply bypass this check.
A few ways, you could keep a local copy in another encrypted file and compare them after each load, you could also keep a cloud file that you compare after and loaf
so all the unity cloud stuff is safe? even if someone makes a mod and stuff they can never access server data?
because I want to implement rewarded ads and IAPs
or should Ifind a publisher to handle security?
I doubt its hard to hv e the server check if files are consistent
Probably but that's what's necessary to prevent something from happening. For instance, if you're concerned about a certain data file being modified you could check that file during runtime.
and i also doubt it's hard to bypass a simple check like that
rn my game is simply writing game resources when game closed, and reading from cloud when game starts
if I use cloud code
will it be better?
so everything is client-side?
yeah , resource generations is happening on client
No
then that would be very easy to generate as much as you want yeah
hi guys, do you recommend buying courses to learn unity like this one? i want to learn at least the basics.
then .... cloud code to triggern resources from server or the unity economy will handle the things itself?
for basics goto unity learn
i would say it's not worth it, there are plenty free resources you can learn from
!learn
This is the beginner coding channel. Maybe try asking in #💻┃unity-talk (the more general channel)
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Don't feel like you're bothering
This is an open space to ask and learn
There is quite a lot written here about the fact that trying to protect your game from hacking is often not worth it. https://discussions.unity.com/t/how-to-protect-c-source-codes-from-being-decompiled/797506
this website is very helpful
thanks will read
Yeah, I actually started with that too. But overtime, it's not enough
good start?
im also reading the same page twice to get it implemented to my head
oh yeah im getting syntax down pretty good
Looks like that's simply trying to prevent source code from being decompiled and not about In-App-Purchase security where server side authentication would be different as it's not in the hands of the hacker. Relative to #💻┃code-beginner message
got the quiz right
could you link some stuff i could use in the future?
Any hacking starts with finding the right code
Not sure about "right code" etc but unless they simply want to ddos the server, they won't be able to do much without authentication - which would be dependent on the what's being used server side
I only have some documents in my local language. Once u finish this u should probably have enough knowledge to understand what other tutorials say
I'm rather talking about the fact that you can't write cheats if you don't know the address of the function that returns the position of the head
hey does sombody knows how to debug the force applyed to the Player, i build a knockback but its not working. i want to debug if the player gets any Knockback applyed => `
The force that you're applying to the player would seem to be the KnockBackForce and perhaps upwardForce. Try logging those if you're wanting to know the force.
my friend learned C# in 2 days😭
u mean after the "."??
i used chatgpt to create an game and i wanted a script for when if the player touches an object the screen will fade and change to another scene. using UnityEngine;
public class GlowingObjectTrigger : MonoBehaviour
{
public SceneFader fader;
public string nextSceneName = "DreamScene"; // change this to your scene
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
StartCoroutine(fader.FadeAndLoadScene(nextSceneName));
}
}
}
this is what it came up with. however i do not get teleported to the other scene
ahh wait i understand what u mean
i will try it
u right
i would not try to us AI
Then the problem lies in the FadeAndLoadScene function. This does not help debugging it
If you want to debug the force applied to the player, I'd start by logging the variable you named 'force' that has knockback, correct?
till now its been pretty good.
yeah but for a commercial game it would not be enaugh
yeah use ai but try to learn with it. im also new and im also using AI like here =>
Germany?
yeah
u see i have 0 experience with unity as well first im trying to learn and get familiar with the unity engine itself
good luck bro
ty
for now i just want to get finished with this project and then work on some of my OWN ideas and leanr with it
you should not use genAI at all as a beginner
it's a tool that needs experience to be used correctly - you don't have the necessary experience as a beginner
it will hallucinate, that is part of how LLMs are designed - you need extensive experience to be able to filter the bullshit
it will do far more harm than good. just use reputable sources instead
cc @wind apex ^
Ok
i mean most of the time i ask here, but somtimes i use Ai for the correct syntax etc. but i get what i mean#
90% asking here, 10/% AI
do 90% google, 10% ask here
hahaha
(not a joke)
i got a problem. I want to make a highscore label which correctly logs the highscore everytime the player dies. thing is, it does not work because it ends up starting from 0 all over again when i press restart. should i make the highscore a global variable outside of the public class player? will that work? or is it that everything in unity requires to be made inside the derived class
Facts. It has been proven that 90% of questions — here — can be answered through a Google search. The other 10% is where we actually get involved (and conduct our own Google search), lol . . .
wow
C# is so fun and easy to learn
well
the basics
ig
im learning about variables it is so easy
i dont even have to write code inside visual studio
I suppose all the method of ‘Physics’ must be kept inside FixedUpdate, right?
do i have to code this while learning the basics cause i honestly just have it stored in my brain
I never noticed when I use them in Update and now it’s causing some weird glitch when I ‘teleport’ my character
Yes, U should get used to your programming environment
alright ill make something basic rq with all my knowledge
tried implementing, but getting nowhere
Try PlayerPrefs
wasnt it console?
void CheckHighScore()
{
if (Score > PlayerPrefs.GetFloat("HighScore", 0))
{
PlayerPrefs.SetFloat("HighScore", Score);
}
}```
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Asteroids"))
{
HighScoreText = UIdoc.rootVisualElement.Q<Label>("HighScore");
HighScoreText.text = ($"High Score: {HighScore}");
PlayerPrefs.GetFloat("HighScore");
}
}```
U are setting the “HighScore” to the ‘Score’ variable
{
private Label HighScoreText;
private float HighScore = 0f;
}```
oh
No wait, I’m on phone. This is hard to look at
still not working
should i post a pic?
this might be a bit easier to look at
these are all the codes which work to make the highscore work
i might just be stupid
me too!!
it's a string?
Where are u calling the high score check function?
OH WAIT
do you want to print 15 or 76
(a lot)
inside Player class, outside of both void start() and void Update()
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
public class Player : MonoBehaviour
{
Label HighScoreText;
private float HighScore = 0f;
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Asteroids"))
{
HighScoreText = UIdoc.rootVisualElement.Q<Label>("HighScore");
HighScoreText.text = ($"High Score: {HighScore}");
PlayerPrefs.GetFloat("HighScore");
}
}
void CheckHighScore()
{
if (Score > PlayerPrefs.GetFloat("HighScore", 0))
{
PlayerPrefs.SetFloat("HighScore", HighScore);
}
}
void ReloadScene()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
@hot wadi
yup im getting nowhere
yesnt
but think about it, i have another variable called score
havent even heard of that
Yeah well they are not calling checkhighsore anywhere at the moment
All u did was defining the function
then why does ReloadScene() get called?
something calls it
that isnt shown in those screenshots
what do you do that makes it call?
wait a sec
ive fixed lua scripts before
oh ya, sry it is called
now that i think of it
so i need to make a call inside update?
call when its needed, which could or could not be update
when should checkhighscore run? logically
when collision occurs
because i have been updating score up until now, and then once the collision which ends the game occurs, i wanna use whatever is stored inside score to be stored in highscore
right
and that highscore needs to be stored globally
so you would want to do this check when score changes
which right now is in oncollision, hence not being wrong
but just in general try to think about the logic step by step here
wait lemme try
OnCollisionEnter -> Check if it's the interaction you want -> set score as a result of that check -> check high score as a result of the score being set
O_O
ok wait a sec
OnCollisionEnter is one of the initial jumping off points for code in unity but its not the only one (eg. start and update)
lemme try that
bruh, i haven't been calling checkhighscore up until now anywhere when a collision occurs
i am dumb
anyone trying to learn isn't dumb
i thought CheckHighScore worked like OnCollisionEnter2D(Collision2D collision)
im so confused
didn't know that OnCollisionEnter2D(Collision2D collision) is in-built
why what happened?
yeah its not uncommon for newbies to be confused by that
unitys kinda "magical" functions
im just not sure how to make the code work
im really new so
what's the code?
how do you end a line in c#?
which symbol do you use to make the compile know that?
; this
no cause some i dont see on
but you should right?
some
yes
first make that change
what is going to be the data type for x + y?
namespace?
what are the data types of x and y?
also, before anyone says, yes you should go to a C# server for this but just for now...it's aight
hey how would you go about getting a vector3 direction from the direction the camera of a player is facing in? I'm trying to implement a dash for my game but whatever I'm doing here --> https://blazebin.io/dlgxfcfkukvh/0 doesn't rly seem to be working
is there any easier way to do this or like wat's going on
i actually dont know
you need to go through a C# tutorial completely
also, this is for unity related question, go to a C# discord server...
i was told to go off a website but okay
that works too...whatever works out for you
Looks ok to me. Do u mean that u only want to dash on the ground, not into the air?
@sour fulcrum still doesn't work?
i did call CheckHighScore() when a collision occurs
#💻┃unity-talk message You'll have to redo the dash decay method
apologies btw i didnt finish the tutorial havent got to that stuff yet all ive been through is syntax, variables, output, comments
no prob, as long as you stick to it, it's gonna get easier
Either look up how to properly shorten the vector or have a separate multiplier
even i am new to this
@balmy vortex
oki
i got my highscore to work, but now it's appearing before the collision occurs.
i even changed when the HighScoreText was getting the visual but it's not working
It looks like your highscore ui is still enabled before starting the scene? maybe disable it first then enable it once collision happens?
i dont know which part of the code is even enabling it
sorry I have no idea how your UI works. Is it a gameobject in the hierarchy?
neither does anyone else if you don't share more than just the one snippet of code
and i dont touch it anywhere else other than the parts i sent before
This is a visual tree asset. I'm not familiar with this. Try looking it up
Not gonna lie I have no idea what a label is. Do you not use textmeshpro inside a canvas?
no
show the rest of the relevant code. we have no idea if you are reloading the entire scene, just moving things around, etc.
they are using UI Toolkit not UGUI
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
public class Player : MonoBehaviour
{
public float Thrust = 1f;
Rigidbody2D rb;
public float maxspd = 15f;
public GameObject boosterFlame;
private float ElapsedTime;
private float Score = 0f;
private float ScoreMultiplier = 10f;
public UIDocument UIdoc;
private Label scoreText;
public GameObject ExplosionEffect;
private Button RestartButton;
public GameObject CollisionEffect;
private Label HighScoreText;
private float HighScore = 0f;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
rb = GetComponent<Rigidbody2D>();
scoreText = UIdoc.rootVisualElement.Q<Label>("ScoreLabel");
RestartButton = UIdoc.rootVisualElement.Q<Button>("restartButton");
RestartButton.style.display = DisplayStyle.None;
RestartButton.clicked += ReloadScene;
}
// Update is called once per frame
void Update()
{
ElapsedTime += Time.deltaTime;
Score = Mathf.FloorToInt(ElapsedTime * ScoreMultiplier);
scoreText.text = ($"Score: {Score}");
if (Mouse.current.leftButton.isPressed)
{
//Calculate mosue direction
Vector3 MousePos = Camera.main.ScreenToWorldPoint(Mouse.current.position.value);
Vector2 direction = (MousePos - transform.position).normalized;
//Have player move in direction
transform.up = direction;
rb.AddForce(direction * Thrust);
if (rb.linearVelocity.magnitude > maxspd){
rb.linearVelocity = rb.linearVelocity.normalized* maxspd;
}
}
my bad I haven't used that before
{
boosterFlame.SetActive(true);
}
else if (Mouse.current.leftButton.wasReleasedThisFrame)
{
boosterFlame.SetActive(false);
}
}
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Asteroids"))
{
HighScoreText = UIdoc.rootVisualElement.Q<Label>("HighScore");
CheckHighScore();
HighScore = PlayerPrefs.GetFloat("HighScore");
HighScoreText.text = ($"High Score: {HighScore}");
Destroy(gameObject);
Instantiate(ExplosionEffect, transform.position, transform.rotation);
RestartButton.style.display = DisplayStyle.Flex;
}
}```
!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.
{
Debug.Log("Static was called.");
if (Score > PlayerPrefs.GetFloat("HighScore", 0))
{
PlayerPrefs.SetFloat("HighScore", Score);
}
}
void ReloadScene()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}```
done
thats the whole thing
instead of spamming a bunch of code blocks across several messages and flooding the chat, you are expected to share large code blocks via a link to a paste service
anyway, since you don't want to post the code correctly i'll just say this: make sure your scene is actually saved in the correct state before you enter play mode.
what the hell
why are you sharing an htm file
did you do something dumb like download the page instead of clicking the in-website save button to share the link?
ya xD, i thought it saved the thing as a file onto my pc
!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.
do this ^
i assume you are telling me to tinker smth in void ReloadScene() { SceneManager.LoadScene(SceneManager.GetActiveScene().name); }
no, i'm telling you to save the god damn scene before you enter play mode
oh, i don't know how to do that, lemme look it up
dawg
you've never hit ctrl+s before?
its file + save at the top left
oh saving the scene in the case means saving the code
Howdie! im making a flappy bird like game for practice and ive made the script and all works fine , but theres something weird happening
everywhere the score is set to 0 , but when i boot up the game it automatically adds 1 , and the first pipe doesnt give any points , it only starts adding points from the second one ```using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class LogicScript : MonoBehaviour
{
public int playerScore = 0;
public Text scoreText;
public GameObject gameOverScreen;
public AudioSource dingSFX;
[ContextMenu("Increase Score")]
public void addScore(int scoreToAdd)
{
playerScore += scoreToAdd;
scoreText.text = playerScore.ToString();
dingSFX.Play();
}
public void resetGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
public void gameOver()
{
gameOverScreen.SetActive(true);
}
}
and this is the call to the function
```using UnityEngine;
public class PipeMiddleScript : MonoBehaviour
{
public LogicScript logic;
public Birdscript birdscript;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (!collision.CompareTag("Player"))
return;
Birdscript bs = collision.GetComponent<Birdscript>();
if (bs != null && bs.birdIsAlive)
{
if (logic != null)
logic.addScore(1);
}
}
}
i thought it was smth to do in the unity hub
no, those are not the same thing
no. i am referring to saving the scene in the unity editor
the SCENE not the code
O_O
screenshot your entire unity editor then outside of play mode
in the hierarchy tab, does the scene name have an asterisk beside it
could anyone give a hand???
you don't need to initialise z because you don't end up using it
Heyyyy guys
are your triggers perhaps extending past the pipes
Does anyone know why i can't apply my physics material into my rigidbody? this is the first time i'm experiencing this.
this is not unity related
no way at all
make sure it's a physic material 2d
make sure you don't have 1 assigned in the inspector for that object. the variable is public which means it is serialized so the inspector value takes precedence over the default value in the code
- the second one and every one after that works perfectly
Thanks, yeah there was a 2D section
i clicked on the one below
in that case make sure the method isn't being called twice by having more than one collider on one of the relevant objects
Using Debug.Log in the addScore function to see if it's actually called. And check if the middle pipes are spawned correctly in the scene view
Also as you can see. i'm using frictions to fix the wall hugging you mentioned yesterday, i also added some raycasting!
wait a minute, you specified that only the second one starts giving points and you also only ever assign to the text property of your UI object when you start adding points, make sure the UI object doesn't already say 1 at edit time
Wait what??? can you explain it in dumber terms?
if the UI already says 1, then it won't be changed until the score reaches 2 because it isn't updated to say 0 ever and when the score reaches 1 it's just going to be updated to say 1
It's the default text u put in the Inspector of the UI text
ok it works now but why does the ding happen?
Its supposed to only activate the audio source on point added
make sure that Play On Awake isn't selected on the audio source
I guess i got fooled by my own code 😭
Unity is confusing in comparison to godot
but feels so much better
What seems to be code-related may not be code-related at all
Yeah that was the issue
yeah in this case it was stuff in the inspector causing issues
I need to learn writing tests in c#...
I sent it btw
oh mb someone answered
okay, well first off you circled the wrong thing. that's the project name, i was referring to the scene which is in the hierarchy. and show what is happening now
did someone ping?
This is happening
hey how can i progeamm a hit stop? like if the player attacks someone the Game frezzes for a short time
no you're imagining it trust
why dont you just disable the box
time.timescale
can u show me a short exapmle`?
ok
Thank U!
IEnumerator PauseTime()
{
Time.timeScale = 0f;
yield return new WaitForSecondsRealTime(Amount of time you want to pause for);
Time.timeScale = 1f;
}
your entire code, i dont see any place where you disable the box btw
Tank u this is what i need
!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.
and if i frezze the time? what happens with my swicht states? i increse values with time.deltatime
just for the future, makes it easier to read
they also get frezzed right?
📃 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.
they don't get increased, because Time.deltaTime is dependent on the time scale
says it pretty clearly
i meant i didnt know how to do it before
well now you do
yes
So there's a way to disable it just like I disable the restart button in void start?
disable it how you want
but you need to do something to make to hide it
i've been a bit stuck on how to make my pseudo-pathfinding system and i've realised that i could potentially use dijkstra's algorithm or a breadth-first search to find routes between nodes at the start and then store them for use, only changing them if the terrain changes (which probably won't happen). would this be difficult to implement?
HighScoreText =UIdoc.rootVisualElement.Q<Label>("HighScore");
and would it be possible to have it navigate through every empty/non-contact tile on my tilemap?
I am assuming this thing makes it visible
thats just you getting the text reference
No
why would it? you're just querying the ui document
Just reference the GameObjdct and set it to inactive
you're just getting the object, not doing anything with it
oh, I am just referencing the ui doc then
What part of the code displays it then??
Like for restart I get, it's setting false then true
from the video you sent, that thing already enable on the scene
but for label, that ain't the case...atleast not for the scoree
are you turning it off anywhere? ui documents are enabled by default
But how will it display when collision occurs?
Sure is, just reference the game object its on, or the text component
enable it back when you collide
The same way you get the restart to...
And how do I do that, that's the qs
Oh...same syntax?
idk uitk
Well that depends could i see your code & higherarcy (idk spelling)
it's hierarchy
I will try making code to enable it when collision happens then
you can just change the ui document's enabled property to show or hide the entire thing
Not of the ui i dont think
hello
Wow u can read the ui damn
or if you want to change an individual element, you need to change the style.display to either DisplayStyle.Flex or DisplayStyle.None
can someone provide me a decent example of dijkstra's algorithm or a breadth first search implemented in unity/c#?
That's gonna be my go to option for now
i want to make a flying enemy navigate to a good sightline towards the player through multiple vantage points
and i think if i can figure out how to do that properly i can find all the routes at the start of the game and then just use them until the terrain changes at all
which might happen but isn't guaranteed
i've kinda given up on a* because i had no idea how to implement it properly
so i'm thinking i might as well find a way to implement an easier but worse version myself
Let's learn how to make 2D pathfinding using A* with and without code!
● Check out Skillshare! http://skl.sh/brackeys17
● A* Pathfinding Project: https://arongranberg.com/astar/
·················································································...
Oh wait they arent using textmeshpro yeah got no clue either
there should be a bunch of premade implementations, why not use one of those?
it's for a computer science project
if i don't make it myself i have to document it
This line of code finds a VisualElement (a Label, to be specific) named "HighScore"
It does not do anything else
and i'm just looking for a really really basic pathfinding system
Listen, I'm trying to make a top-down restaurant game like penguin dinner, but I'm afraid I'm not pretty sure what to do next. I set everything up, so everything has collision and even the player moves. However, I'm not sure what to do next. I'll probably need to make the clients system, when like in Penguin Dinner when you click the client and next you click a table, the client walks to the table. However I have no clue how to do that in code, so any help would be appreciated
Ya, others told me
how do I disable itbthoguh?
Djikstra's is simple enough to implement, but you need to actually have a graph representation of your game world first. You need:
- A set of points the AI needs to navigate to
- A list of connections between those points
That's the more annoying part here
but i can't use it properly
i'd start out by just making the enemy fly towards the player and steer away from walls
it might get stuck in corners, but it's a reasonable first step
Bro mentioned the algo...
i could probably generate this with either tilemap shenanigans or raycasts
well why can't you do it? you just track which client the player clicks on, then which table they click on
i might just do it with all the tiles and their adjacencies, then make shortcuts based on what my enemy can directly see
make a route first and find shortcuts on the way
for flying enemies in a sparse level, you don't need much more than "charge the player"
It's not that I can't. It's that I don't know how, Idk what kind of code does this best (or even does this) , I'm pretty new honestly
the flying enemies shoot projectiles
does what? detect clicks?
and if they can already see the player, they run on different movement code
Detects click and goes to the table I think
Yeah, and moves the character
well for detecting clicks, google (or your search engine of choice) is your friend
as for moving the character, you can just change its position in a straight line towards the table or move it between a few preset key points, should work fine for a static map
hey can sombody pls help we why my player dont gets any KnockBack
everthink work like, damage or HitStop
have you tried debugging where the code gets to
what's your other code like?
i only debuged the value and i checked if the code really gets to the last ApplyKnockBack code
which codeo? u mean u want to see all code in the Script
what do you mean by "last ApplyKnockBack code"
well the player script
the AddForce call?
i maked a debug under the last line so i can see "does unity really exacute all of this code"
so does it?
i also get a Knockback but exremly weak even i set the vlaues above 5000
have you tried logging the resulting totalForce you're applying?
what's the mass and body type of the player RB?
how to learn unity ?
i wanted to do that but i dont know the syntax
it's the same
!learn 👇
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
thx
private Label HighScoreText; i have been searching for ways to make this Label visible and invisible but i can't find any method
what is Label here? what's it from
I literally already told you how to
it set to dynamic and i handle my own gravity
that wasn't the question
did not work, i set it to none, did not hapen
i did bro
did you query the correct label?
you still did not show the player script
lemme do it again and show you
its over 900 lines
i can u show how i handle the gravity in my player script if u want
how are you moving the player?
wiht Rigidbody2d
ok, yeah no
is it possible to make gta 6 in unity?
charactercontroller and rigidbodies are not meant to be used with each other
my bad
character controllers aren't even meant for 2d
no, due to trademark laws
i know i fixed my comment
that's not specific enough
i mean i only use a Rigidbody2d and a CapsuleCollider2D
i mean the graphics and stuff not an copy
how are you moving it though? velocity, MovePosition, etc?
are you modifying the velocity directly?
ahhhh wait
then yeah, you can make anything in unity. it's a general purpose game engine
probably, but it'll take a lot of work
thx
thx
hello i don't know if this is allowed
am looking to commission someone to make an anti-cheat protection
dm me
!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**
AFTER 5 FRIGGIN HOURS IT'S FINALLY WORKING!!!!!!!

you could reset your velocity before the knockback maybe.
U ARE A FUCKING GENIUS
i love u bro
i totally fiorget that
As far as i know you shouldn't use fixed update for rigidbody movement as it already has its own update timing
i do
I don't see you changing isCurrentlyInKnockback anywhere
that's what FixedUpdate is.
i read the values and inputs with Update and handle the movement with FixedUPdate
so i use both
Aint the timing different? Also same with deltatime no?
rigidbodies live on FixedUpdate (or more accurately, the fixed time step)
its allredy fixed. i just forget to change the player in "KnockBack"
i don't know what you're on about in terms of timing
i use a swicht that makes everthing ready if he is in KnockBack so i can add Forced etc
Me neither then
they have different purposes
i know, but i used for everthing if, now i learnd the difrence
for Enums they are great
also I think what you're referring to is a simple state machine
my first game is over
yeah definitely
can someone send me an example of someone using dijkstra's to find paths through a tilemap? i just want to make sure i'm doing this at least somewhat efficiently instead of instantiating one gameobject for every space in my tilemap
why do you need to instantiate a gameobject for every space
the nodes would just be Vector2Ints
ok can you send me an example of that
hey can i tell unity "Hey use the Rigidbody2D from the Player" without to say "u need to get the referenc from the Players Rigibody"?
thanks for any help
you want me to just write dijkstra off the top of my head...?
no, how do i access the nodes of the tilemap as vector2s
why are you trying to assign a Vector2 to a Rigidbody2D
the access is already fine
the assignment is not
i want to set the speed zo zero befro apply the Knockback
i mostly dont understand what they want from me
whats it say?
you're setting a rigidbody to be a vector
but i did somthing like that alot of time i just forget how, i did somthingf with vector.zero
you assign it to the thing you want to have that value
you probably want to set its linearVelocity instead
read your code
yeah i understand what u mean
you gotta put a little thought into it instead of just giving up every time you get an error
i only now setting the linearveloctiy to zero
i actually dont give op every time, i debug alot of the time.
is attachedRigidbody something or did you just type it
it's a prop of colliders
ok
must be new, never seen it before
it's not new, it's just.. relatively niche, i guess
"versions with this page" goes all the way back to the end of the list, 5.2
https://paste.mod.gg/yqzomgvfvlbd/0
I have named the Label ScoreOutline and its Label variable in code ScoreBorder. I reference the Label in the UI by ScoreBorder = UIdoc.rootVisualElement.Q<Label>("ScoreOutline"); and i display it using ScoreBorder.style.display = DisplayStyle.Flex;
A tool for sharing your source code with the world!
Should probably include a question if you're looking for help
the outline appears only when i crash
you should show the entire UI builder so we can see the actual hierarchy of elements
oh god, i'm guessing you are abusing tf out of absolute positioning?
not absolute, i aligned it
nice way to put it though abusing it
yep, so because it's positioning is based on the things around it, it will only ever be positioned correctly with that setup when your other objects are being displayed as well
then why is score displaying?
you should consider looking through the documentation pinned in #🧰┃ui-toolkit to learn how to actually use it
because that's the first thing in the hierarchy and therefore nothing else is affecting its positioning
oh
so i need to place both of them in the same hierarchy level or smth
in fact, i can see in that channel that someone already told you what to do an hour ago and you did something different anyway
i did not know what parent meant, i assumed that it meant that the label would have the same properties as what they said to be its parent, in this case, i thought they meant that score outline would have the same properties as its parent Scoretext in the inspector
You ask for clarification rather than assume.
hey, do u have a channel for posting game things for feedback
my enemy fells like shit and its not funny
like posing a short video
or if you have a specific issue you need help with, you can just ask in the appropriate channel
okay i will post there, i actually need some tipps
You can ask for feedback in the title for visibility (in #1180170818983051344 )
hey im trying to find a way to make an object go in the direction the cursor or joystick is facing using the new unity input system. Are there any tutorials?
which part are you stuck on? because the only difference between how it works with the new input system and the input manager which most tutorials teach is just how to get the mouse position, but even then it's still pretty similar
Be sure to check pinned messages in #🖱️┃input-system , in the package there are examples as well.
hey, i use for my Spider 5 Scripts, i need to Debug currently the way he is living, he AI better said. but, he hast Mutliply Attack Choices Like Spitting at the Player, or Bitting a the Player, He also hast a Survial wish to life, if he is low but currently this lays on him very week (under 5% to break out of his current Attack State) to run away from the Player. for Debug porpuse can i make a SINGELTON, that search in the Scene every GameObject maybe with the Tag "Spider" and make a list of "Scripts" he detect whitch hast a Specifall name like "SpiderBrain". and Disable them all and Enable them via Runtime, with a simple bool in the Inspektor?
i never did somthing like that but i think this would help me in the future ALOT
or are they simpler ways to achive that?
i dont want to make a bool for each Script that return the code if its fals, i maked my first enemy and my Code is Spagethi type shit
I'm going to be perfectly honest I did not understand anything you wrote
DAYUMN
bro i try my best englisch skills i have
is my englisch really that bad
From AI
You said "or are they simpler ways to achive that?"
But in your entire first paragraph I have no idea what the thing is that you are trying to achieve
Hey, I’m currently working on my spider AI. I use around 5 scripts (like Brain, Movement, Combat, etc.) and I need a way to debug how it behaves.
The spider can do multiple attacks — biting or spitting — and has a survival instinct (it should run away if its HP is too low). But right now, everything is kind of weak and spaghetti-coded since it’s my first real enemy.
For debugging, I was thinking: could I make a singleton that finds every spider in the scene (maybe with a tag like "Spider") and stores all their scripts (like SpiderBrain, SpiderCombatSystem, etc.) in a list — so I can enable/disable them all at runtime with a single bool in the inspector?
I’ve never done something like that, but I feel like it would help a lot in the future.
Or is there a simpler way to achieve this?
What's the motivation behind making the singleton that finds all the spiders and disables/enables them? How would that help you debug?
i want to make, "Enemy dont move"
"dont do somthing"
"Dont Attack me if in near"
Sure you could do that. But I wouldn't use tags necessarily.
Do you have some singleton that is spawning all the spiders int he first place?
That would be the best place from which to track all of them
i dont spawning them, i want to place them by Hands in the Scene
Ideally the manager system that creates the spiders would create the list and knows all about them, but if you wanted to have it such that each object is more independent, you would do a singleton with some subscription system that you would subscribe to on start
whats the best site that generate ai 3d models?
For debugging purposes it's totally fine to use tags I suppose. You could alternatively have the scripts register themselves with the singleton in Awake
Wrong channel
is that hard?
no
and how can i leanrn that
which thing?
what chennel should i use
#🔀┃art-asset-workflow maybe, or just #💻┃unity-talk
like searching all Scripts and disable them
i mean i now how to search scripts, but how can i use code to say "Disable u self"
thething.enabled = false;
i now this, i ony want to now how i can disable them via Script
this works for Scirpts?
if you want to do it in code you need to code it. If you want to just click that box, you are free to do so
its the same?, but i think im gona code that for learning
and if i do thatß? i dont need to make a Singelton?
i mean why should I?
I thought you wanted one central place to do it from
If you manually are clicking the boxes in the inspector, you need to do it for all the spiders manually
(or select them all at once)
yeah i want that, i need to use a Singelton
but i also should work with a normal MonoBeahvoir, i used this => FindObjectsByType for finding all active Scripts and maked trhem in a var Variabel. Than i used a "for" locig that enableas them all
Tanks for u Help!
can someone help me with this one i just dont understand why my script neverworks
!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.
?im using both to what should i change i to ?
Just use one
if you're using both, of the three options which is closest to the word "Both"
what ?
do you mean you're using both systems in your code/project, or do you mean you have it set to "Both" already
did you change it to both then prevent it from restarting the editor? because the restart is necessary
wait a sec ok ima trym that
yes!!!!!!!! thank you al so so so much
im like a begginer so thanks guys
hey is it normal to use a bool as a debounce, i have the feeling there are better ways to manage that the player dont revice more Damage as he should per collision, right now the player csn revice 2-3 times the Knockback and Damage in the Frames between
i want to understand some ways how to manage that, and are there better ways than bools?
whats wrong with the bools? what problems is it causing you ? or what do you want to improve about it
its totally working fine, but i want to improve if needed
i want to get my code better, step by step
for the most part, if its clear to you , and it works.. thats all it matters
so its dont harm me in the future
bools are pretty efficient as a starting point. If they are working, no reason to touch them
okay, i understand what u mean. i will use Booliens, Thank u!
remember the KISS principles still apply
Keep it simple...???
What is the last S?
Keep it stupid
Keep it stupid, simple
i think i understand it...
learn like you'll live forever
and live like you'll be replaced by Skynet tomorrow
then enslave Skynet and make it do the work for you
and don't take advice from pseudo-intellectuals
u mean me?
@regal isle we can do without the spam of offtopic
i mean myself
deep
I needed to pretend like I'm smart
thorfinn type shit
cool but this isn't the place
Spam is Debug.Log in IJobParallelFor
this applies to you too #💻┃code-beginner message
Hi can anyone help me with my game because the joystick doesn't work anymore and I don't understand why and chatgpt couldn't help me 😅
gonna need a bit more info than that.
- which input system are you using?
- how are you trying to read joystick input?
- do you have any errors?
- how have you debugged so far? (if any)
This is a code channel, post the code illustrating how you've attempted to debug the issue.
chatgpt couldn't help me
yeahh a spambot of words is not what its meant to solve problem.. It doesn't "think"
Someone can help me with this maybe https://streamable.com/we7h9o
Jittering when updateRotation is kicking in after yaw threshold is reached (cinemachine camera) (KCC + finalIK LookAtIK)
Code:
https://gist.github.com/Alwandy/e054c61ca06fecfa3c0843e50f79f36f
i use a costom joystick from the units assets store
i dont have any errors
i tryed to get consol logs if the joystick is moved but i dont get an input anymore from the joystick
is it an on-screen joystick?
yes
📃 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.
okey
where are those logs from?
i tested if i get an input from the joystick but i get always 0
right, but where
in the PlayerController
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[Header("Movement Settings")]
public float moveSpeed = 2f;
[Header("Joystick Reference")]
public Joystick joystick;
private Rigidbody2D rb;
private Vector2 movement;
void Start()
{
rb = GetComponent<Rigidbody2D>();
// Auto-find joystick if not assigned
if (joystick == null)
{
joystick = FindFirstObjectByType<Joystick>();
}
}
void Update()
{
// Get input from joystick
if (joystick != null)
{
movement = joystick.GetInputDirection();
Debug.Log($"Joystick Input: {movement}"); // Add this line
}
else
{
movement = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
Debug.Log($"Keyboard Input: {movement}"); // Add this line
}
}
void FixedUpdate()
{
// Apply immediate velocity-based movement (no acceleration)
if (movement.magnitude > 0.1f)
{
rb.linearVelocity = movement * moveSpeed; // Changed from rb.linearVelocity
}
else
{
// Stop immediately when no input
rb.linearVelocity = Vector2.zero; // Changed from rb.linearVelocity
}
}
}
again, see the "large code blocks" section in the bot embed
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class Joystick : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUpHandler
{
[Header("Joystick References")]
public RectTransform joystickBackground;
public RectTransform joystickHandle;
[Header("Joystick Settings")]
public float handleRange = 1f;
private Vector2 inputVector = Vector2.zero;
private Canvas canvas;
private Camera cam;
void Start()
{
canvas = GetComponentInParent<Canvas>();
cam = canvas.worldCamera;
// Center the handle initially
joystickHandle.anchoredPosition = Vector2.zero;
}
public void OnDrag(PointerEventData eventData)
{
Vector2 position = RectTransformUtility.WorldToScreenPoint(cam, joystickBackground.position);
Vector2 radius = joystickBackground.sizeDelta / 2;
inputVector = (eventData.position - position) / (radius * canvas.scaleFactor);
HandleInput(inputVector.magnitude, inputVector.normalized);
joystickHandle.anchoredPosition = inputVector * radius * handleRange;
}
public void OnPointerDown(PointerEventData eventData)
{
OnDrag(eventData);
}
public void OnPointerUp(PointerEventData eventData)
{
inputVector = Vector2.zero;
joystickHandle.anchoredPosition = Vector2.zero;
}
private void HandleInput(float magnitude, Vector2 normalised)
{
if (magnitude > 1)
inputVector = normalised;
else
inputVector = normalised * magnitude;
}
// Public method to get joystick input
public Vector2 GetInputDirection()
{
return new Vector2(inputVector.x, inputVector.y);
}
}
again, see the "large code blocks" section in the bot embed
Use the link bro
scanning across multiple messages on DC to read the code is annoying, and also mobile forces you to download a file
I have a feeling this ain’t gonna be code-related
lol
i dont understand how to send the code from the link
paste code on the site, save send the generate Link
that site also allows you to have multiple tabs / files in 1 link
A tool for sharing your source code with the world!
Hey, I need help unity says line 30 "Object reference is not set to an instance of an object" but Im 100% both aren't equal to null, heres the code if anyone could help https://paste.mod.gg/ypafweyvwhfb/0
A tool for sharing your source code with the world!
I'm also sure that lastHit isn't null because Im debugging it and its equal to anything I look at
where is rayCasting assigned
its at the top, its a script I can send
wdym at the top.
I don't see it assigned anywhere
It's declared as private RayCasting rayCasting;
in another script
not possible
well, that's not true.
its like saying " I want a box of Apples" but putting nothing in the box
did I not reference the script properly?
you did not reference it at all
you have a variable that can hold a reference
but it's not holding anything yet
it has no value right now
how do I assign the variable to a script then?
= or the inspector
Do I have to call the class?
computer : Okay you want a RayCasting to do stuff with
computer: Which RayCasting instance do you want ?
you can't call classes, that's not a thing you can do
Okay so would it be like private Script rayCasting = RayCasting;?
@fallen mountain have you debugged any of the methods inside Joystick to see if they're receiving events? are you perhaps missing an EventSystem or a raycaster?
also, what is up with all those usings
you're only using 2 there, and your IDE should be telling you that
I just haven't refined the code yet and deleted unnecessary libraries or fixing my nested if statements
your list initialization also seems.. off
no i didnt tryed to debugged the methods inside the joystick
hey is this a correct way to play sounds in Unity
i did some research and saw this, does looks really strange. Why do we use "UnityEngine"?
so i only can say Random.Range?
yes
right
it can help with sometimes ambiguity between UnityEngine.Random and System.Random
but thats easy to solve with adding using Random = UnityEngine.Random
ahhh its like i would say System.Collection.IEnumerator etc.
so its not necessery?
no
thank u!
Okay I was able to get it to work. Do you have any suggestions on how to better write the code in the Update() function to be more readable? https://paste.mod.gg/ayzyaahmzicg/0
A tool for sharing your source code with the world!
can sombody pls also expalain me why every time i try to use a Method like this it never actually worked
what exactlly do i wrong?
maybe using an early return pattern so you don't have to nest everything
depends.. You put a log to see if the method is being called at all
Hi everyone, I am new to programming and was starting out my beginner console projects in VS code. I'm now using visual studio and notice that the color of my code is not the same as VS code. is there an extension or a setting I need to change to get the same effect? visually its appealing and helps me when looking at the code.
!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
its not so much about the colors, yes thats a gauge usually but also when you type you should see Unity api stuff
excusy me nav, i just forget to add the Reference
why is it bad to make a fallback reference... i mean cant it not be that i dont no the Computer forget to use the References from Unity and dont find the Reference. i now u all tryd to expain that so me but i really need to understand that.
if you did all those and still have issues, check
https://unity.huh.how/ide-configuration/visual-studio#if-you-are-experiencing-issues
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.
what do you mean a fallback reference ?
like i used in awake a if(!abc) abd = get... etc, in Awake call to be sure unity dont have to 100% all references needed. i did that all the time but im not doing that, ´because alot of perople telled me thats not a nessery stepp i can use the Inspektor
This helps, thank you.
when its possible to do so, the inspector is always the cleanest, fastest way to assign a reference / value
cases where its not possible for example, the object is a prefab and needs scene reference
but doing Awake () myThing = GetComponent<>(); is unecessary and there is a very tiny performance cost, so multiply that with many components over many objects and they add up
but why does awake call even exist?
what would need to be load so fast, faster than start call
to setup objects usually
think of it as unitys component to a Constructor
You setup your values there, Awake run once, always (unless gameobject is disabled)
Start does not run if the Script itself is disabled (checkMark on the component only shows if you have Start, Update etc.)
for example You want to setup a singleton, You usually do that in Awake
so other scripts are ready to access it in their Start
if you did both on separate sripts Awake you will have Order of script cause a Null Reference, that objects Awake (singleton setup) may have not finished running before the other scipts tries to access it
AI
**“What if I reference everything in the first scene using the Inspector, but then I create a new scene — Unity will lose all those references, right? Let’s say I don’t have any fallback logic, so I’d have to manually set every reference again for each GameObject.
Would Unity actually save those references per scene? For example, if I build my game, does Unity understand that in the first scene, Field A is referencing the Player, but in the second scene, that same field should only reference a Transform instead of the Player?”**
Inspector references are saved per scene not globally
so unity also never new about the Player from scene 1
okay i understand what u mean
when you load a new scene, scene object references are lost unless you handle them manually
If you want persistent references across scenes use DontDestroyOnLoad.
when i change the scene? and unity losses all of the references? did this mean unity deletet them all of the memory?
so how can unity then switch from scene 1 to 2 and than back to 1 again
it creates a " new scene "
settings from scene 1 will not carry over to scene2 and when you switch back to scene1
as far as unity is concerned you are starting them brand new again
unless we implement data persistance / DDOL objects
void Update()
{
if (!Input.GetKeyDown(KeyCode.E)) return;
for (int i = 0; i < numbers.Count; i++)
{
if (rayCasting.lastHit != numbers[i]) continue;
for (int k = 0; k < openStatus.Count; k++)
{
if (k - 1 != i && k + 1 != i) continue;
if (openStatus[i]) continue;
numbers[i].transform.Translate(globalPositions[k]);
}
}
}
You can probably do it like this ?
what is continue
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/jump-statements
TLDR
it skips to the next iteration
thanks u bro
I am trying to use the collision sound when player crashes. I can't seem to be able to get it right.
📃 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.
A tool for sharing your source code with the world!
you knnow you can like bookmark the link so you don't have to always invoke the bot command
FindGameObjectsWithTag
hahaah i make this same alot of the time
FindGameObjectsWithTag
no s
O_O
ahh shoot me
i also make that too
pls
btw you can search directly for a component if only 1 exists
skips the GetComponent / tag search
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Object.FindAnyObjectByType.html
audioManager = FindAnyObjectByType<Audio>()
how right am i to say that this game is structured in an absolutely dog way?
I mean first projects are always gonna be like that
i feel u pain
this is a pain in the neck
that is a major reason why most first projects are meant more for learning than production ready
i will need to theory the shii out of that book for solids after this is over
SOLID are good concepts but they are not Law
you can break SOLID and still write good clean code
i mean yeah, but that's a good baseline for me. Do you think there's an optimal way to study architecutre?
or is it just experience?
imo practical uses
yes it comes with experience, you eventually create your own system based on those that have worked in the past such as SOLID
O_o
but understanding WHY you would even use anything in SOLID and alike, imo is much more important
You will not see a benefit if you start writing SOLID out the gate, it will not make sense
so everyone has a personal template they follow? how do people even begin collaborating then?
they establish a baseline / specific to the project and Team
oh...so its more standardised
yea, consistency is the real importance
even as basic as "lets write our variables with the C# standard" eg everyone writes Methods as PascalCasing etc.
so if you personally use camelCasing for everything, thats for your own consistency as solo. But in a team everyone conforms to the same standards
Can you help me on how to make a first person player with 3D capsule in Unity 6.2? The input system confused me a bit. While people were saying that it needed to be activated, I did not see the activation part in the tutorials.
so are you following a tutorial or wat
hey, have this dc a "Connect" channel, for finding somone for a game. I want somone thats want to draw for me.
: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**
Thank u!!
is triplanar UV calculation suppose to be glitchy?
public static float[] CalculateTriplanarUVs(Vector3 position, Vector3 normal) {
Vector3 absN = new Vector3(Math.Abs(normal.x), Math.Abs(normal.y), Math.Abs(normal.z));
if (absN.x > absN.y && absN.x > absN.z) {
return new float[] { position.y, position.z };
} else if (absN.y > absN.z) {
return new float[] { position.x, position.z };
} else {
return new float[] { position.x, position.y };
}
}
There is no optimal way for architecture it changes based on the project being built . . .
this looks like dark magic
They don't allow reaction gifs or off-topic pics . . .
what?
used to the triplanner mapping just applying in the shader
where you would do it with 3 texture samples and blend between then with your normal and mapping directions dot product
i thought UVS had to be built cpu side first when constructing a mesh
well what are you trying to do, but in my experience triplanner mapping is something you will be doing in the shader so you can blend things
and also so you do not have to worry about a meshes uv's since its most often applied in world space coords not object or uv
im trying to get UVS to apply a texture
ur if else statements cause (one) dominant axis -> causes snaps between axis and more visible seems
instead u could compute weights for all 3 axes and mix/blend the textures -> smooth transitions
its not really about the UVs b/c they are the same its how the final color is combined..
the blended one being in the back..
would i need to change the triplanar function or change how colors are applied
https://catlikecoding.com/unity/tutorials/advanced-rendering/triplanar-mapping
heres a good source
2.3 Blending Based on Normal
yeah 3 texture samples on the 3 different planes
blend by doting a normal with one of those plane normals
im just barely holding on 🤣 catlikecoding is boss-level material for me.. i don't get into shaders that much
basically what my clip up top shows the back cube doing 👇
i have to write shader code for this 😭
its simple to do in shader graph as well
^ i think they even have an awesome Mapping node that takes care of alot of it for you
i dont think its just a blending issue cause look at these weird spots
https://paste.myst.rs/30zo3pb3 its nothing crazy or anything..
just basic shader code 🤣
a powerful website for storing and sharing text and code snippets. completely free and open source.
ya, i saw that.. tbh i have no clue.. what those artifacts are from
the the shader approach no uv's are needed at all so would not use any of the previous stuff
i'd say try shader or shadergraph first ^ before beating urself up anymore
u say no UVs are needed but the document talks about calculating the Uvs in teh shader
just to see what the outcome would be
it does work and look better with more organic looking things
i mean the mesh needs no uv's since you are creating texture coordinates to sample with in shader
i thought UVS were texture coordinates
the terms get fuzzy, often wehn people here uv's they think of the uv data on a mesh
the input on texture sample is also called uv but also you can feed other stuff into it like world coords
so what data besides UVs would i be passing to the shader for the texture to latch onto
you do not need them for triplanner
with triplanar mapping you can basically generate them on the fly in teh shader instead of relying on any of the mesh's uv
the shader will calculate its own texture coords via world coords
every point in space gets a valid texxture coordinate automatically
so its the exact same thing as what im doing now but happening in the shader
i dont see how that fixes it
because it can blend
b/c they spend tons of resources making it work as good as it does..
its doing 3 texture samples and blenidng the result
but i could also blend in my cpu code right?
reinvents the wheel lol
cause i dont know shader language, i dont know how shaders work, i dont know what to put the shader on, and i dont want to define a fully custom material render pipeline node
we showed its literally a node
you can do it in shader graph with 1 node
to do this all cpu you would be rendering textures
and it would be much more complicted then doing it in shader
(Doing this kinda stuff on cpu is fairly expensive where-as gpus are designed to knock this work out)
you would just not computing blended coords not sampling 3 things and blenidng the resulting color
those are very different things
mk lemme try this
shader graph is nothing like doing shaders by hand, its more or less just acting as input to a more complicated shader
TL;DR: generating UVs is trivial; proper triplanar mapping requires per-pixel texture sampling and blending, which is why shaders are used.
it is meant to be useable even by just artists
you should really just learn and dabble in shader-graph regardless
opens up a whole ton of possibilities for you
ur over there re-inventing the wheel..
while shader-graph is 🎵 ridin' spinners.. lol.. just kidden ofc.. but yea it is a pretty awesome tool-set
crazy snipe
upping the scale factor makes it less grey. Thank you! ❤️
yeah has 2 blending modes too and a few other options
see.. ezsauce 🍝
can triplanar just not do sharp edges?
i had to use a pow(64) scale factor
i feel you are aksing for a impossible thing
like if you want things mapped in a 100% perfect to the shape way you have to do that in a 3d pacakge by hand
since triplanner its in the name its making 3 projections and blending them togeather
it works best on organic textures or things with more noise in them
well first i would need to know why you are doing this and its usecase
procedural meshes
welp, that rules out what i was typing..
yeah i would likly stick with the triplanner then for that
for other types of procedural meshes i would just make appriorate uv's when i generate the mesh
you'll probably just need to find a happy medium
this manifold contouring stuff looks wild lol
pros and cons of it all, have to find the best balance for the usecase then make the art work with the used approach
can triplanar sample from a texture atlas or does it need to use the same texture for the whole mesh
Abstract—Dual Contouring is a feature-preserving iso-surfacing method that extracts crack-free surfaces from both uniform and adaptive octree grids.
🫠 melted my brain there for a second lol
sorry I'm like really new, but I have the foundation for C# but I'm really lost for actual unity scripting, whats the best way to learn?
check the pins
fun fact: there is not a single open source version of it ever written
sure there is a workaround but not sure what it is. it would be hard to since it kind depends on the texturing being tiling in all directions
https://www.youtube.com/playlist?list=PLFt_AvWsXl0fnA91TcmkRyhhixX9CO3Lw this playlist really helped me get jump-started
so i'll share it to you 👍
tysm
assuming are a few papers to implement from though
unity learn is the most common answer.. u can find that in the pinned section ^
and that knowing other approaches like ray marching would help reason about it
just start with one of the pathways
do my maze generator looking good? using recursive backtracking algorithm
Looks like a maze 🫡
I don't see an exit though
same
you should check out the disjoint set maze generation algorithm
how do they escape? haha . . .
or do they start in the middle?
my sphere falls through the ground did i do something wrong?
does the ground have a collider
yeah
you made it a trigger
so yeah
it's a trigger . . .
its the point of triggers is they do not collide
here 😅
that's the entrance, no?
I would expect one entrance, one exit
that's the best algorithm for maze generator?
idk if its the best but its a really cool algorithm and beats recursion
that's the exit but i didn't add entrance because player is already inside the maze so i don't need entrance for that
i will try to check it out! thx for recommended
