#💻┃code-beginner
1 messages · Page 359 of 1
SV_NORMAL is not defined by Unity's code
It's a semantic
Semantics can affect how the shader program deals with that input or output
a lot of them are more-or-less labels
the Learn site has a lot of information about HLSL in general
for ShaderLab, see https://docs.unity3d.com/Manual/SL-Reference.html
(ShaderLab is the language you use to write Unity shaders)
you embed HLSL code into it
if i take a vectors magnitude, normalize it, and then multiply the magnitude by the normalized vector, will it result in the original vector?
yeah it should, barring any floating point inaccuracies
awesome, thanks
seeing as you're here, do you think the KCC could possibly be interfering with this previously working code?
#💻┃code-beginner message
hi my top down movement script seems to be making me move upwards constantly and i dont know why
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
just FYI, line 27 is unnecessary and may cause some weird issues. you've already normalized your input and multiplied it by speed, now you're increasing it by that much (multiplied by deltaTime) which makes no sense
i'd also recommend printing your input to make sure that you aren't getting some vertical input from some unexpected source (like a controller of some sort plugged in)
that is a really good point cause i plugged in a controller to play animal well earlier
i diddnt know it would just automatically work on unity
will check
yeah its not that
Delete this
moveInput += speed * Time.deltaTime * moveInput.normalized;```
it is commented out but it still moves me up
have you printed your input to see whether unity is detecting some input from a source you are not expecting?
i did do print moveInput but im thinking you mean something else maybe
Coordinates
Which ones
at the end of update
We want to see the data
Ok my guess is you put a Rigidbody on your camera and your player isn't actually going up. Rather your camera is falling down
i took the cam off and it still happens
this seems too hard to solve in discord mb lol
Wdym you "took the cam off it"
What makes you think that the player is going up
i can see it go up and off the tilemap
Why not just look at its position in the inspector
change your Update method to this and show what it prints:
public void Update()
{
moveInput = new Vector2(Input.GetAxisRaw(Horizontal), Input.GetAxisRaw(Vertical));
var transformedInput = transform.TransformDirection(moveInput.normalized) * speed;
Debug.Log($"Input: {moveInput}, Transformed: {transformedInput}. Player will move up: {transformedInput.y > 0}. Current Velocity: {rb.velocity}");
moveInput = transformedInput;
}
Any other scripts or components attached to the player?
with that in update it dosent move atall btw
no its just that rn
That's not showing the log at all
that's not even the log i gave you so idk what you went and changed
the input without the speed multiplication is printed too and it shows 0 so that means no input
i did try wasd
Did you focus the game window
Hi, does anyone happen to know why in the video the sword continues to stay on the right when the mouse is on the left?
use mp4 to embed in discord. but also line 69 ... = Quaternion.Euler(0, 360, 0);
think about that for a second
if I do this activeWeapon.transform.rotation = Quaternion.Euler(0, -180, 0); the sword rotates but is far away it should be in front of the player
https://streamable.com/jhfqxw
then the point that it rotates around is not centered on the player
Following an old video, it shows Canvas->Text, in my current Unity is shows the Text with (Legacy), is this because its an outdated practice or?
Text Mesh Pro replaces Legacy
Okay, that's what I was thinking from how this was set up. Thanks for clarifying :) (Also sorry if this was wrong place to post, I was lurking and didnt pay attention)
for the scripting it'll be similar as Text...
but it'll be either:
TMP_Text myText; or
TextMeshProUGUI myText;
then it's the same.. myText.text = "Hello";
and you'll need the using TMPro; using statement in the head
That's really helpful, thanks for the heads up, was just about start googling :)
if u hold Control you can snap regardless of local/global
does someone know why the particle on the left doesnt look like the one in the right? the only thing i did was instantiate it as a child
they make u use global transform.. b/c if it were rotated at a weird angle.. it wont snap diagonally for example
oh wait i guess u can
i just use ctrl hotkey tho, easier and universal
ur scales are all over the place.. not sure if thats the cause.. but certain things might look off
make sure to test w/ ur scales set to 1 that way it displays properly
okay
it isnt the case
not sure why they look that much different hto
ya, i said thats probably not the reason.. but its a good thing to keep in mind.. having it set to 1x will show things truely how they'll look in the build
and also now it looks zoomed in (which makes sense) but what i mean is if its really that bad to have a 0.5x scale?
if it has 1x then the camera is a bit off to the left
even if the script tells it to copy the player pos
then u need to readjust it to work w/ 1x
and how did it change? i didnt touch anything related to scale i think
does changing the camera size affect it?
check in the Render settings of the particle
not sure what you'd be looking for but someone in the Unity forums mentioned to check out the settings there if the particle looks differently like htat
sometimes resizing the gamewindow can mess it up
i changed it to 16:9 and it is 1x scale and looks good
im going to just keep it like that to be safe
i keep mine set to 16:9 and scaled to 1
im looking for a trail-like effect
whenever a rocket launches, for example
oh wait i overlooked the ´d in you´d and thought you were asking me what i was looking for as in which effect
lol
mb
any particle can do that..
just make sure to use World Spaces
and you can also use the Rate over Distance.. in the Emission section.. so that it only spawns particles when its moving
yeah yeah i just completely misunderstood what you meant because i performed a skill issue while reading
the object is always moving so its no big of a deal yeah when i saw that function a jumping particle or something like that came in mind
that was the problem that i had
ty!
okay so now i have a scaling problem with the canvas
i dont know why but not it resizes and gets more "centered"
ur canvas isn't set correctly
i guess it has to do with render mode?
make sure its set to Scale with Screen Size.. and the reference resolution matches ur monitors resolution
also make sure they are anchored correctly..
you can see here how my cog gets off when i resize... thats b/c its anchored to the center of the screen...
once i anchored it to the bottom-left.. it stayed there no matter how i resized the window
it should have been attached to a new canvas when created.
it wasnt but i added it manually and went on to config to check my resolution
again ty for the help i dont know what i will do without you lol, it would have stressed me out a lot
thats what i love and hate about unity, everything has a premade system already
lol, no worries.. User Interface work can get complicated for new comers
so if you know it cheers, but if you dont....
for what i´ve heard ui is the worst aspect and the one who people dislikes the most
its easy to make crappy UI
people dislike it.. b/c its hard (takes some work) to make UI that looks and feels good
as seen in previous examples of non related matters, my UI is crappy as much as it can be lol
once you get familiar with the tools tho its not too bad
but i dont want to bother over it to much now
i been working on this UI for a while now.. finally got it looking/feeling pretty good
it matches with the "futuristic aesthetic" that the car presents
and has nice colors and size
im really bad at colors, i dont know what pastel colors are
a friend tried to explain it to me like 4 days ago but i cant get my head around it
these are pastels
those seem like normal colors to me to be honest
maybe they are a bit more "sad-like"
In love with colors, since 2002. A designer tool for creating color combinations that work together well. Formerly known as Color Scheme Designer. Use the color wheel to create great color palettes.
heres a website i use pretty often to get good color schemes
you can just play around with it.. and it outputs complementary colors automatically..
(you'll always get colors that work well together)
i use that one
ya, thats a good one too
i like that one b/c i think you can upload a picture or image
and it'll spit out a color pallete for it
yes
that feature is amazing
and even more if its for a small game like mine and i want to take heavy inspiration on other games
nothing wrong with that 👍
the game im doing is a copy of the game from a friend and im very proud of how its turning out
"muted" would be the terminology for it.
oh
but yea pretty much, gentle, subtle, soothing, etc
pastel is like faded colors . . .
sorta yea! lol.. but we've gotten off on a tangent.. any more coding problems u having?
did ur particles start working after using world space?
im stopping for today its 4:40 AM
they work completely fine
i even adjusted a bit so they look better
i started thinkin about it.. and i didnt realize before but the example u showd.. the particles that were working right.. were stationary..
do you want to see?
the reason the other ones didn't loook the same b/c they were moving
and they were moving in the same direction therefore just becoming a cloud?
lol.. ya, u were moving them upwards in their local space
and the clouds were moving upwards as well.. so they were just getting stacked on top of each other i htink
yes
i thought about that but i dont remember what conclusion i made for the fact that it wasnt the problem
which prolly was wrong lol
and now is confirmed to be wrong
im interested.. why did u say thats why u like / hate unity.. b/c of there being a preset system for everything..
how is that a bad thing?
because if you dont know it exist it just makes your live a living hell
ahh okay
for example friction and all that in the material for rigidbodys or colliders
oh yea, one thing u should do.. when ur not working on ur project.. is to just open a new project and just spend a few hours clicking thru the menus
i wanted to make something bounce and was doing formulas and like 7 hours later a friend comes by to my house and i wanted to show him, and he said there was a system for that
i did that my first few weeks. and took notes of everything i saw..
and my reaction to that was not very pleasing
it helped for sure when i wanted to look up something
i had in the back of my mind certain things that I had seen.. (i may not have understood what they did when i seen them) but when i started looking up how to do certain things.. it would help to have them in the back of my mind
smart approach
going on 3 years and im still seeing new things i havent seen before 😅
you seem pretty advanced for 3 years imo
lol.. i come from an artist background..
i make things look prettier than they actually are 😄
i can see that
the code that runs the stuff is less flashy
the game looks very pleasing
thanks! i been stuck on AI for a while now
i dont want to brag but i cant neither code or make things prettier efficiently
i want to learn procedural generation but thats for maybe 1 year from now on
my mind would just do a bunch of if´s statements lol
nah, u can learn about that stuff pretty early on..
ya, thats how i started..
and then i learned about state-machines..
but yeah its a pain in the ***
and im still learning about them
switch case?
well some of the logic uses switch statements
i learned about that and holy that was revolutionary
but what i mean is a state machine..
whenever im finished with this im starting to develop systems instead of full games, seems better to learn
and when they're allowed to.. and how and so on
ya learning how systems work help alot
i love those maps
b/c once u know how things normally work in games.. it helps you code it a certain way that makes sense..
im a statement map nerd lol
instead of writing code for say a week straight.. and then once u realize u need a certain system.. the code u wrote doesnt make any sense
so u have to go back and re-write it
yep
saw a gamedev explaining it and thought it was kinda smart
theres (2) choices most people use.. either a Finite State Machine.. or a Behaviour Tree
which the Behaviour tree is still outside my skillset
anyway im going to sleep its 4:50 am
see ya 👋
ty for everything!
no problem 🍀
and good luck with your game
u2
visuals look 10/10
How do I do transform.Rotate(endRotation);
equivalent
but with Slerp
Should I be using Quaternion or Vector3?
so like
Vector3 endRotation = new Vector3(jawAngle, 0f, 0);
//LowerJaw.transform.Rotate(endRotation);
I should be using EulerAngles right?
Like I dont understand which to use
to make the equivalent effect
" the equivalent effect" of what?
https://docs.unity3d.com/ScriptReference/Vector3.RotateTowards.html
This was the suggestion
you want smooth , not smooth
rotate can be done in dozens of ways
it rotates to a certain position
when I use Rotate Towards
it doesn't go to that target position, it over or under shoots
does Rotate use EulerAngles?
I have the mouth open like that
but I want that same effect
but it to look smooth
thats why im asking this
did you bother looking up the function on the docs
Did you read this? https://docs.unity3d.com/ScriptReference/Transform.Rotate.html
Both locking the mouse cursor and exiting the application aren't working. I don't know why
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
did you actually click inside the game view first?
unity needs you to do that
also no such thing as exiting application in editor
by exiting I mean an error log
Didn't think of that, one sec
alr everything works, my bad
thanks
wait, no
the cursor is locked, I need it to move around but not stop at screen edges
how do I do that
make sure you read the description
I see, but confined also doesn't work
gpt is saying something but half of it aint working
Standard for gpt 
how do I lock the cursor but be able to keep track of it's movement
I need to look around in-game
GetAxis("Mouse X") (or y, or the new input methods) will still give you a value even when the cursor is locked
How would I use that here? Can you show me on the code itself?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
So, you are using mousePosition. Instead of that, construct a vector from GetAxis with x and y
private void HandleMouseInput() {
Vector3 mouseDelta = new Vector3(GetAxis("Mouse X"), 0f, GetAxis("Mouse Y")) - lastMousePosition;
yTurn = (yTurn + mouseDelta.x * mouseSensitivity) % 360f;
xTurn = Mathf.Clamp(xTurn - mouseDelta.y * mouseSensitivity, -35f, 35f);
lastMousePosition = Input.mousePosition;
}
input, ok. Which value is 0f?
Z should be 0. A mouse exists in screenspace which is x and y of course
You have y as 0
Get rid of lastMousePosition entirely. GetAxis is a delta already
something's happening, might work
alright, it works very nicely
thanks a lot mate
now to add physics
Out of nowhere my project broke and I'm getting an 'unloading broken assembly' error 🤔
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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 tell from the objects perspective it is hit by a raycast
Have the script casting the raycast get a reference and call a method on the hit object.
GetComponent
Or TryGetComponent
How do I tell from the child of the objects perspective it is hit by a raycast
The object sending the raycast must inform it
raycast dont care about child or parent, only colliders
What component would I be trying to get to access the child?
One that you make
A script
shouldnt we be the ones asking you that
huh
which component do you want
Exactly what nav said. I don't really even understand the question
Sry I meant like, if i wanna access methods of the child, what component do I pull out of the raycast hit to access those method
GetComponentInChildren on the hit collider?
"what component do I pull out of the raycast hit"?
You should look at the docs for the RaycastHit struct
See what properties it has
So you want to access methods of the child of the object that the hit collided with?
if child has no collider then yes you need GetComponentInChildren
Oh they also have 5 instances of basically the same script
but I need them to react differently
public class ScriptA : MonoBehaviour
{
public void Update() {
if (raycast(out RaycastHit hit)
{
if (hit.collider.TryGetComponent(out ScriptB b)) {
b.GotHit();
}
}
}
}
public class ScriptB : MonoBehaviour
{
public void GotHit() {
//do whatever
}
}
some pseudo-ish code
its honestly unclear what you're trying to achieve here
Each part
of the neck
has a script
telling it to follow the one infront
I want it so
when I shoot it
Finish a thought before hitting enter
there is no need to like vertical spam each like word
sry
I want to be able to control each part of the neck when I shoot it, to make it react to being shot
so from the gun's raycast
did you see example #💻┃code-beginner message
I am confused on how to individually identify each part of the neck because they have so many similarities
create a string or enum
I just showed you above, assuming each bone has its own collider. ScriptB would be on each bone, and identify THEMSELVES to their parent
Yes
So i need to identify them by name then? Since trying to identify them this way would reference their parent?
I am not sure what you are asking. Each bone would likely need some identifyer for pattern matching. A string or enum like nav said.
The raycaster would just get the component on the gameobject. That component would have the identifyer and have a reference to its parent. In the GetHit method I made, the component would pass its own identifyer to its parent I guess
why would it even be necessary to "identify" them as you say
If Im being confusing it doesn't help that I am trying to figure out what half the methods you guys are talking about are doing while we are talking, I have never tried to do anything like this.
are you dong something different based on bone ?
Yeah, it is unclear what the identification would do. Do different thing happen depending on which bone is hit
So far all of this is extremely basic. Which parts do you not know?
If bone is shot I want it to move back a little, essentially to do a little animation
Then just have the bone do that itself. No identification needed
then you don't need to "identify it"
I have never used getComponent in my life, nor formated an if statement in any way like this
wym
You have never used GetComponent even!?
I get that some people miss out on TryGetComponent, but GetComponent should be one of the earlier things you do
say you put a script called Bone now you have a component called bone on each , gameobject bone
nuh uh
I recommend !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
yes you need to start from basics
Debug.Log , Referencing and GetComponent are the most essential parts you need in unity
mmmm I have definitly used any of those
Wait so this lets me check if what Im hitting has a script and call a method in that script instance?
If so I didnt know such things were possible
yes
Wow
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
So I have a game with a speedrun timer and I want to make it so that when the level is beat and the timer stops, the time that it stopped at is recorded in a different scene (like a high score scene). I dont even really know where to start though.
if (target && target.CompareTag("Enemy")) {
foundTarget = true;
Vector3 distance = (target.transform.GetChild(0).position - transform.position);
multiplier = 1.5f;
rb.AddForce((transform.forward + distance) / 2 * (speed * multiplier));
}
else {
foundTarget = false;
multiplier = 5;
rb.AddForce(transform.forward * (speed * multiplier));
}```
getting this weird bug where if i change the speed from 50 to 100 to 1000, the speed doesnt seem to change, but changing the multiplier does cause a change, why does that happen
add a debug to see what the vector actually is in that rb.AddForce when you are changing the speed
okay
vector seems to capping at 50 in any of the axes and it doesnt seem to change when i change speed
well it gets close to 50 but never gets to it
are you sure you're changing the right value then? maybe debug what speed itself is
ok
Just to test, did you change the rb mass to very low and also maybe use a physics material to avoid drag, so you see if the vector increases?
idk where to ask this but how do I find my unity project in my files/ how do I export it in a zip
Probably in #💻┃unity-talk
You may need to elaborate the specifics
Hey everyone. How can I make text appear on my screen? This isn't working
First be sure, that you get into that if statement. Because == against 0f might just fail because of decimals. So put a log in and see if it gets fired
is the gameobject active?
Ah, good point. And enabled is only for the component. Gameobject needs to be used SetActive();
Yeah, it defo gets fired
im watching a tutorial on an older verrsion of unity which has a 2D vector composite, how would i do this in the 2022.3 version of unity
nevermind i got it
Post that into #🖱️┃input-system. There they can help you faster and better.
I am creating a mesh at runtime, and I want to apply multiple materials to it, how do I do that
Yes but how do I set the areas each material is applied to
depends on how you setup your model
smth about submeshes
I'm not sure how you obtained your 3d model so not much I can help you here
I'm not sure what your mesh looks like
unless you seperate the parts you want to apply materials to into different submeshes, applying different materials don't work
And how do I do that?
how do i use vfx as attacks like if i have a vfx for raining arrows how do i make it so that when i click a button it uses that attack where im looking at
uh how viable would it be for you to just generate multiple meshes
I would like it more if I was able to simply draw the entire thing with a single draw call if its possible because its basically a chunk in 2D terrain
and there'll be, like, a lot of chunks visible on the screen at all times.
you can change the base map of the material applied to the mesh
to change the colour etc
applying a new material is another issue since that needs a new mesh
it's not possible to apply multiple materials to a single mesh that doesn't have submeshes
do you have the raining arrows effect in unity already?
yes i have a prefab
the goal is to instantiate the raining arrows prefab at the place that you click
using UnityEngine;
public class RaycastShoot : MonoBehaviour
{
// Reference to the VFX prefab
public GameObject vfxPrefab;
// LayerMask to specify which layers the raycast should hit
public LayerMask groundLayer;
void Update()
{
// Check if the left mouse button is pressed
if (Input.GetMouseButtonDown(0))
{
ShootRaycast();
}
}
void ShootRaycast()
{
// Get the camera's position and forward direction
Vector3 rayOrigin = Camera.main.transform.position;
Vector3 rayDirection = Camera.main.transform.forward;
// Perform the raycast
RaycastHit hit;
if (Physics.Raycast(rayOrigin, rayDirection, out hit, Mathf.Infinity, groundLayer))
{
// Check if the raycast hit the ground
if (hit.collider != null)
{
// Instantiate the VFX at the hit point
Instantiate(vfxPrefab, hit.point, Quaternion.identity);
}
}
}
}
this is the apporach just want it to spawn where the raycast hits
so I just put a texture and set the UVs?
use a program to put all the textures in an atlas and set the UVs of each vertice based on the atlas
so what's wrong with this code
i mean it feels like it not aiming right let me try to add a crosshair on a canvas n ill be back
I'm not sure how adding multiple materials helps you
Or what you mean by setting the UVs
my initial approach was to use a different material for each texture I want to use
Eg dirt
grass
my guess is that you're making a terrain system of sorts?
yes
how unity does it is the plane has all the textures laid on top of each other, and depending on the bitmap the texture of that area will show
I dont understand your explanation?
In your case you may need to write a shader that takes in multiple textures that does that
void ShootRaycast()
{
// Get the camera's position and forward direction
Vector3 rayOrigin = Camera.main.transform.position;
Vector3 rayDirection = Camera.main.transform.forward;
// Perform the raycast
RaycastHit hit;
if (Physics.Raycast(rayOrigin, rayDirection, out hit, Mathf.Infinity, groundLayer))
{
// Check if the raycast hit the ground
if (hit.collider != null)
{
// Instantiate the VFX at the hit point
GameObject obj = Instantiate(vfxPrefab, hit.point, Quaternion.identity);
Invoke(Remove(obj),5f);
}
}
}
void Remove(GameObject item){
Destroy(item);
}
cant i pass objects in invoke?
fair point
Trying to find a resource on this but I can't find any
What you're trying to do needs a shader and a good amount of work
This tutorial walks through creating a terrain shader in Blender and then creating a similar shader Godot that can use the assets you've just created in Blender. In addition to just creating the shaders, there is a focus on creating a bridge from your art assets to your game engine so that you can easily transfer your data from one stage of you...
This is a study on creating terrain shaders in other engines
The overall process is that you have terrain layers associated with a terrain. Each terrain layer has a texture.
Your terrain data is a bitmap containing which terrain should be shown at that spot.
[SerializeField]
private float damage;
private void OnTriggerStay(Collider other)
{
if (other.TryGetComponent<Health>(out Health health))
{
StartCoroutine(Pain(health));
}
}
void OnTriggerExit(Collider other){
StopAllCoroutines();
}
IEnumerator Pain(Health health){
while(true){
health.DamageTake(damage);
yield return new WaitForSeconds(1f);
}
}
what should be my apporach right now multiple coroutines are starting
you can make a Boolean, which becomes true once the ontriggerstay is triggered
and it will not start a new coroutine if the Boolean is true
Why not use OnTriggerEnter instead of OnTriggerStay?
Wait IM DUMB THATS WHAT I WANTED TO DO lmaoo thanks
why m i unable to add it here
public Camera cam;
Camera object
ok one sec
I wanna see what the Camera object has
also what are you using it for
using UnityEngine;
public class Attack : MonoBehaviour
{
// Reference to the VFX prefab
public GameObject vfxPrefab;
// LayerMask to specify which layers the raycast should hit
public LayerMask groundLayer;
public Camera cam;
void Update()
{
// Check if the left mouse button is pressed
if (Input.GetMouseButtonDown(0))
{
ShootRaycast();
}
}
void ShootRaycast()
{
// Get the camera's position and forward direction
Vector3 rayOrigin = cam.transform.position;
Vector3 rayDirection = cam.transform.forward;
// Perform the raycast
RaycastHit hit;
if (Physics.Raycast(rayOrigin, rayDirection, out hit, Mathf.Infinity, groundLayer))
{
// Check if the raycast hit the ground
if (hit.collider != null)
{
// Instantiate the VFX at the hit point
Instantiate(vfxPrefab, hit.point, Quaternion.identity);
}
}
}
}
yea thats not working
i tried that
like i set the camera tag to main camera
then used Camera.main
i delted it then made another camera
anyways i dont think i want to do it that way cuz i might add multiple cameras for different perspectives
<@&502884371011731486>
!ban 431671627101503498 bot
.zixio was banned.
just as a matter of interest, what is the difference between a ban and a softban, which I have seen here recently?
Softban is just a kick with purge. Actually turned this one into softban, they had previous activity.
interesting, thanks for the info
y this code doesn't writing something in the file?c# public StreamWriter writter; public Logger(string name) { writter = File.CreateText(path); } public void log(string text) { writter.WriteLine(text); }
file is creating but it's empty
FYI, a camera is considered main when a camera has the MainCamera tag
So creating a new camera also does this
https://docs.unity3d.com/ScriptReference/Camera-main.html
The first enabled Camera component that is tagged "MainCamera"
Best thing is to just use Camera.Main and avoid fiddling with setting components. If you have multiple camera's you should consider creating a camera manager that returns the current active camera instead
yes, you need to Flush and Close the Streamwriter
but now i deleted it how can i get it back?
Ctrl+Z
i deleated it in the heirn era
Or use version control and properly track changes 🎉
You can undo those changes
im not using a version contorl
but it will undo a lot i have done afterwards
Then just remake the camera 🤷♂️
If you are going to make silly mistakes, it is recommeded to do so
Or undo, copy the component, redo everything, and paste it
But I have no idea how well Unity does redoing content
how do i make it again?
isnt it as simple as just adding a camera?
i mean it would be dumb if we cant get it back if we delete it once
hey can someone explain to me why i have this bug?
I'm writing my movement code manually, with setting velocities and adding velocities. Problem with adding velocities is that there is no speed cap. How can I add a soft or hard cap to that speed? Problem with this is that I do want the player to go faster than the cap at certain points
What bug? What are you trying to achieve?
my character isn't looking at the cursor directly, i want to make my character rotate toward my cursor
Okk so i made a new scene just copied the camera from there 
how 2 do it?
Oh and the funny part still didnt work
Where is your red pointer looking at then? Because it seems to rotate with your cursor, but just not from one of the pointy edges.
Does it have the MainCamera tag, is it enabled and does it exist when the game starts (not instantiated later)?
let me check
it's looking to the side
Can you show a screenshot?
well it does have the tag
i cant check if it has the tag when the game starts cuz of the error
How do you expect this to work in general with an error?
@fossil drum it's in the video
in the script
okk so i commented the errors and it does have the main camera tag on start
I have seen that, that's not what I mean.
You made code that makes the right of the triangle look at the direction of your cursor.
right is the red arrow in your scene view when you have the triangle selected.
I want to see where that points.
Try UnityEngine.Camera.main
do you hqve your own script called Camera ?
it did fix it
Right then you do indeed have your own Camera class
Don't name stuff the same way unless you use namespaces
ohh
Well that's your problem...
how do i make the green arrow look at my cursor then?
do a raycast to the ground; this is where the arrow points to. set transform.forward to position - raycast position
Uh, in 2D you always make right your forward equivalent in 3D.
So just make sure the red arrow actually points to the forward of your triangle.
Or if you want to be janky, just make the code revolve around up instead.
i see thank you
if its 2d the more efficient way is to get the vector2 difference between your player and mouse position, and calculate the angle from there
transform.forward has saved me many times though
i'ts not what i'm doing?
transform.up = (target-startPos).normalized
Guys isnt this how to change a sprites color to 255,255,255,255
color is initialised properly
color = new Color(1, 1, 1, 1);
what are you changing color of, and how do you know code is running ?
also note that changing a sprite renderer's color just changes the tint applied to the sprite
btw there is a const with Color.white
debugged it and the color of a sprite renderer
and a perfectly white tint just makes the sprite appear as its own regular color
then yeah look what boxfriend wrote
could someone tell me why the raycast only detects the ground when my height is times 2 the real player height (1.8)
Please properly share your !code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
you aint gonna see much putting tint to white if it has a sprite
yep cause i made it darker
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
show your actual code
at no point are you assigning the sprite renderer's color in any of this code
oh i just realised
my bad 😭
start can be private
doesnt have to be
they likely have more than one
i keep all my MB method as protected
Ahh, that's the error then
did you debug.log what it is you're hitting ?
Im pretty new to unity but it says im in the air at the state machine in my code
well ray needs to be long enough to go from center to ground
you have to print what the ray is hitting , and check if the ground has the correct layer
This is useful because you get a warning if you clobber it in a child class
okay how do i get what the ray hits
raycast has an out param, it gives you info inside a RaycastHit object
And if you make it virtual, you can allow both the child and parent to run their own logic
it says true when the player height is 3.6 although the scale is 1.8
now i change it to 1.8 it says false
dont understand why
and this tells me what exactly?
idk man u asked me to do it
thats why debugging exists
no I did not, I asked you to print what it is actually hitting first
and write your Debug.DrawRay correct
if it doesnt match the same exact settings as your ray its pointless
like this?
also why playerHeight * 0.5f + 0.2f, these magic numbers instead of using actual variable
in my logic
if player height changes
its should be half the height + 0.2 for safety
cause i can crouch then height changes
*0.5 is not half the height
yes I know but that is only if its 1.
anyway, just draw the ray correct with the same height
so what u tell me is the when i do playerheight * 0.5 its not half of the player height?
okay ill try
yes correct, I confused myself for a second there lol
brain aint mathin this mornin
how does it work again?
ok
Debug.DrawRay(transform.position, Vector3.down * length, Color.red);```
hilarious how you didnt use length inside the raycast itself but whatever lol
ok so you see the problem ?
it doesnt make sens
my player scale is 1.8
ray starts from middle
1.8 * 0.5 +0.2
should be touching the ground
according to your Collider its hieght its 2
where did u see
var length = capsuleColl.height * 0.5f +2f
okay ill try
so how do i change the size
cause now your collider will be 2*1.8 factor
only resize the collider, if graphics must also stretch only resize it as a child of root
never touch scale of root object
I know that
i was saying if its not needed to visually see capsule shrink
just resize collider size
if you need to see capsule shrink for some reason, you would make the graphics only as child and resize that too. Collider should stay on root and resized through component itself not transform
okay so if i got u right you dont change the parent size only the children
yeah i need the capsule to shrink
why you dont even have a mesh
its hidden
cause the raycast was hidden iinside the mesh
ok but if you shift it as child you should only keep graphics on it, no collider
made it 0 , 0 , 0
at the collider i changed the scale
still doesnt detect the ground
again it only works when the playerheight at my script is 2 times the scale height
where is ur collider and where are u grabbing height from
and show how the ray is drawing now
what is even goin on here
your setup should be
-Player + Collider +RB
-- Mesh
the player obj
why is collider on child
followed a video
okay
then do this
if(grounded) Debug.Log(raycasthit.collider.name)
wait. first switch the scene gizmos from Center to Pivot
I want to see something
thats on you for not doing the unity path's essential lol
it shows where eeverything is
you still didnt switch it pivot
ok good just pull it out the ground, hit play and show where is the ray in playmode
okay
Hi i created a loading screen but i wanted to know how can i preload every videos of my project to avoid freeze on this loading screen.
make it async (somewhat)
why is player height 1 when the collider size is 2
you should assign it from collider size
indeed
i thought the script take the scale not the collider height
the scaling was making extra big than 2
np 
if you want to make it more dynamic assign it when it changes, or just use height directly
playerHeight = capsuleColl.height
yeah
thats what im gonna do
how can i code it ?
thats pretty much how you do load async sure
should be fine, you probably better not put it ina start tho
yeah but how can i preload the videos in the streaming assets folder ?
that I don' know as streaming assets is new to me sorry
alright thanks i'll check that
sometimes the video freeze at start and i want to avoid that
`private void Method_YawTurning(float inputValue)
{
// Convert Deg to Rad -------------------------------------------------------------|
float yawTurnSpeedInRad = yawTorqueSpeed * Mathf.Deg2Rad;
// Account for AngularDrag --------------------------------------------------------|
float dragTorque = sRigidbody.angularDrag * sRigidbody.angularVelocity.y;
// Account for Angular Turning "speed" --------------------------------------------|
float requiredTorqueForce = sRigidbody.inertiaTensor.y * yawTurnSpeedInRad;
// Calculate net torque (desired - drag) ------------------------------------------|
float netTorque = requiredTorqueForce - dragTorque;
// Aplly Torque only if the input is not equal to zero
if (inputValue != 0f)
{
// Change the vehicle rigidbody ( I do this because I like to personalize where the "rotation takes place" ) so I can create different behaviours to create variety.
sRigidbody.automaticCenterOfMass = false;
sRigidbody.centerOfMass = yawCenterOfMassOffset.localPosition;
// Check if players prefer to play with inverted steering controls
if(invertSteering == true) { inputValue *= -1f; }
//else { inputValue *= 1f; }
// Aplly Torque
// DESCOBRI UM ERRO : o torque esta em relação ao eixo do mundo e não dele mesmo,
// SE usar .right ao inves do .up pelo menos...
sRigidbody.AddRelativeTorque(gameObject.transform.up * netTorque * inputValue, ForceMode.Force);
}
else sRigidbody.automaticCenterOfMass = true;
}`
why does my rigidbody / vehicle seems to be rotating (yaw) relative to world axis?
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
If I find out something Ill send ya a ping
thanks 😀
Narveone i sat up like 18hours straigth to find the problem from yesterday
And i found out the problem
The "i" in The animator's name WAS NOT CAPITAL
18 hours debugging is 
sounds like an !ide problem
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
• Other/None
oh, animator
you mean the animation ?
woot
https://paste.myst.rs/3y6arldx
why does my rigidbody / vehicle seems to be rotating (yaw) relative to world axis?
a powerful website for storing and sharing text and code snippets. completely free and open source.
don't crosspost. and when adding relative torque use Vector3.up not transform.up
the torque applied will already be relative to the direction of the body, so by using transform.up in AddRelative torque you're basically converting that to relative to the world
what really? ok so just write Vector.up. I thought that is what it makes to be always be a world axis
you would use transform.up when using AddTorque because that does not convert it to be relative to the body's rotation. AddRelativeTorque does. so by passing transform.up which is the direction of the body relative to the world, you convert that from local space to world space which ends up being on the world's up axis
Hi guys can anyone help me ok so there are two scripts troubleshooting....first one has a method to enable the Hud on screen it And levels are generated here I'm taking index of levels in this script and passing it on to another method in 2nd script that takes a index of level and toggle on the certain panel i have debugged it the value is being transferred successfully .....problem is 2nd script has in on enable method that always runs before code so it always displays 0 value index how can I fix that
Script Execution Order
What's that
that is something you can drop into google with the word 'Unity' to prefix it
I cannot pass the value to on enable but I want the initial value of my variable that is inside the on enable to be equal to index from first script
indeed, which is why you need to ensure that the Execution Order of your Scripts is the way you expect
I know what u mean nothing is working start or awake because I cannot pass value
yup I have test it and it works perfectly thank you! I'll past your awnser to my code as comment
wonder how the Gemini AI didn't spot that issue
Simple, AI's can't write code
Someone kind enough can give me a hand with a possibly basic URP issue? #archived-urp message
completly out of topic... But what is a simple AI, I mean gemeni is simple, so I guess GPT-3 and 4 is also simple?
I´m new to unity sry
note the comma in my sentence
yup... thats a thing... 😅
so i didn't say 'Simple Ai's' . I said 'Simple, Ai's'. See the difference?
how would tagging people in a code channel help at all with URP ?
U can use ai for code they are really help ful now a days millions of people use them also pay for them they are not 100 percent accurate but with correct prompt 😉 u can get what u want also don't rely on chat gpt or something similar there are better options
millions of people live in poverty, does that make it a good thing?
Yes absolutely 💯
100 of ai apps are absolutely free sir
nonsense
and they are all of no use to a beginner whatsoever
We are not living in old age anymore
most people are dummies anyway so if you base your metric on the majority go for it
spoken like someone who has no idea how Ai's work
" or something similar there are better options"
most LLMS are just GPT wrapped in a different UI
Sir if u know more about Ai u would have been using it
Wrong, because I know more about them I do not use them
is this like the person or do people seriously always use that as their argument
"you just dont know how to use it"
"if you knew the correct prompt you'd know how valuable it is"
and more nonsense
Yes the one who searches the Google I guess they provide better answers
google forces you to do crital thinking and research, both benificial to you in the long run..
Yes that's correct even I'm not of expert myself but there is a whole subject like prompt engineer people are benefiting from power of ai there are lot of videos on that
there are a lot of videos about all kinds of illicit subjects, does that make them right?
" prompt engineer"
that fucking hilarious
more novelties to make people feel important
navaroneee!
as @rich adder said, the crucial point here is 'critical thinking', you do not appear to be doing much of it
hii so much time no see
Who says? Who would even watch illicit videos? And also if u watch a video it doesn't matter its right or wrong ...your thinking matters the most😌
That's not how things work
yes i did, I am in a redemption moment and have nitro for a while so i just went with it
is there any channel for particles or something related to that?
Same for u 💓 I guess u appear to be repulsive in every way ...its ok if u want to live that way I won't judge your thinking ...👍
anyone had issues with sprites being transparent for seemingly no reason?
thanks same to you ! and yes I did 😏
might do it again lol
My ocd itchin
real
Check the import settings, do you maybe have it set to "Alpha clip" instead of "alpha is transparency"
Always the response of the embattled. Shoot the messenger not the message
I've turned off everything that was related to transparancy that I could think of. The buttons are fine, but the panel behind it just refuses to not be transparent. Are these the import settings you are talking about? This is my second day using unity
Alpha source is None, Alpha is Transparency is also unchecked
Sir plz do some critical thinking 🤔 I'm not shooting anyone I'm only talking about time saving techniques beneficial for humans...thx have a great day
I've set it to RGBA 32bit for true color according to stackover flow but no hope atm
So, it's being used as a panel? Panels also have a transparency, check that. And any Panel Groups it might be part of
Okay if ad hominems are on board please learn to spell words it will make you look less like a seven-year-old who's tabbed over to the channel in between episodes of skibidi toilet
Why does it still want the sign after even tho i have it?
Whatever I have said that make u feel that way .....I have no idea ....but I wasn't even talking to u buddy....u can say what ever u want feel free to express ur self
who wants what now?
missing ;
I think I was pretty clear about what it was that you were saying that makes reading your messages obnoxious but I suppose it is actually possible that you just don't know how to spell three letter words
agent.transform.eulerAngles.yagent.transform.rotation
As far as the computer cares, this is how its reading it
the line never ended
C# doesn't know a line ends until it sees a semicolon. Combined with the fact that multi-line instructions are treated as being on their last line, you end up with the compiler thinking that line 47 is actually
var yRotation = agent.transform.eulerAngles.y agent.transform.rotation = Quaternion.Euler(0, yRotation, 0);
yeah this ^
the new lines are purely visual on IDE
the compiler knows nothing about spacing, indents or any of that
just looks for specific characters
Alas that's very racist 😕.... I'm not from America English isn't my first language...whatever I had said to make u feel I apologize ....
Yeah no panel groups knocking about either. I've looked through all my game objects and cannot see anything that could be affecting this panel transparency, are there Unity settings that exist that can affect this?
Oh? What language is "plz" from I didn't think that was from another language
Can you show the inspector for the panel object?
There you go. The tiny white bar at the bottom is opacity. It's set to half.
It's hard to notice when the color is white or black, which just so happen to be what the Color field on a panel is set to roughly 99% of the time, but that bar is much more prominent on other colors if you want to see what to look for in the future.
Noted, I know for next time now. Thank you
Slang for please
Why do I owe explanation to u
Who are u
Oh good you do know how to spell the word. Probably a good idea to do so in the future. Then maybe you can work on "you" next. You'll get it eventually I'm sure
Anything else
I don't want to overwhelm you, I'm sure your primary school will pick up the rest of the slack
Anything else sir
You just asked that. It's okay, Object Permanence can come later, mayber when you're older
Anything else
Oh no, the markov chain broke and it's stuck in a loop
I wanna hear how dirty u can get
This channel is for beginner coding questions related to Unity
I haven't said a word to u
We don't need to keep this going
Sir look at his comments decide ur self
I'm going bye
No thanks, if you're not asking a beginner related question for Unity, or helping anyone actively, we don't need to keep this conversation going. See ya.
What he started bullying me calling me names and being racist about my language and what did I say sir ....I want to contribute to community more and to keep it peaceful i want it to be over more than u....this keeps happening to me here....u should've taken action....but it's ok good day sir
You too, see ya.
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
Hey there! I know Unity may be slightly overkill for a text written adventure however its the engine I know and would love to create a text written adventure, how could I start this, to allow texts to be displayed and actions to be inputted.
its not overkill if you're comfortable with it, but your question is kinda vague.
You could use the InputField I suppose and add a text to a Scrollbar or Layoutgroup
I'm writing my movement code manually, with setting velocities and adding velocities. Problem with adding velocities is that there is no speed cap. How can I add a soft or hard cap to that speed? Problem with this is that I do want the player to go faster than the cap at certain points
If it's more "visual novel"-esque: https://github.com/daterre/Cradle
Otherwise can look at this https://www.youtube.com/watch?v=jAf1I1UWo5Q
ah my bad! I am just wanting to know how I could create something which allows the player to type a response and upon that response something happens.
So for example the player needs to collect something so the player types collect [item]
it then responsds with: "successfully collected [item] and stored it.
definitely take a look what Nomnom sent
Yeah, I am. thanks guys!
second link is what you want I believe
goodluck 🫡
Hi guys im changing the value of the currentLevelForHUD through another script then this value goes to on enable missions.transform.GetChild(currentLevelForHUD).gameObject.SetActive(isActive); problem is currentLevelForHUD remains zero i have debugged the code the value is successfully being changed but in on enable its just remains zero
Hey guys, how can i make enemies walk around the scenario and shoot TOWARDS the player? I know i have to instantiate the bullets and i kinda know how but i dont know how to make it so they do itTOWARDS the player.
and i dont know how to make it so the movement makes sense.
Am i need the "using System.Numerics;" line? I wasnt using this and it just created by unity.
Das a lot of coding to put it simply
Nope, you probably typed smth within that namespace where your IDE added it . . .
Yikes :(
Probably it auto added by rider, thanks
Start with a tutorial on how to shoot towards an object. The object can be the player or an enemy . . .
transform.LookAt(player.transform);
The lazy way
That'll work for 3d, but not 2d . . .
Oh he said 2d?
Dunno, just smth to address, in case . . .
im sure theres a 2x .lookat
Did you recommend using a single script or multiple scripts for a character? Can i passtrough the values between scripts?
In the video she shows she is using playerInput component but i didnt put it in awake (Because in the docs it was just shows like this and i trust docs more than a youtuber). My code is like this. Is it true?
{
InputAction moveAction;
void Start()
{
moveAction = InputSystem.actions.FindAction("Move");
}
void Update()
{
Vector2 input = moveAction.ReadValue<Vector2>();
}
}```
Have you enabled gizmos in your scene window?
how to make a 3D sphere follow my cursor in game?
Your code and the pictured code are doing two totally different things.
So I'm not sure what you're asking
or what you mean by "Is it true"?
With a script.
yeah but how
convert mouse position to a world space position and move the sphere to it
Several options here https://unity.huh.how/screentoworldpoint
Start with the basics then
What was she trying to do with putting player action to awake? I am just trying to get the Player > Move in Input thing. Then i will use the axis of the input
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
alright ty
ty
They're using the PlayerInput component. You are not using the PlayerInput component
I am trying to create a fps character, should i add PlayerInput too or is it just using this method okay?
THere's no way to answer that
there are many ways to use the input system
use whichever way you are comfortable with
there is no "should"
Oh okay I understand, thanks for you help!
Is there an easy way to get a persistent ID for objects to save data that stays the same between runtimes/quits or would I have to make the class myself?
make it yourself or find one on the internet.
A typical approach is generating and serializing a GUID
Okay I will look into this thanks
i don't understand anything
yeah because you haven't learned the basics of code yet.
That's why I said you need to start with the basics
what's the basics?
I linked you here #💻┃code-beginner message
ty
you are talking about System.Guid correct? just for clarity
Technically I just mean any https://en.wikipedia.org/wiki/Universally_unique_identifier
But System.Guid is of course an easy way to deal with them in C#
ah ok gotcha
doesn't guid change every editor startup?
You're thinking of some specific thing, I'm just talking about GUIDs in general
serialized fields do not change on editor startup
I am trying to change the speed of the Instantiated bullet and the spawnInterval but both if them are not changing does anyone know why. The bullet speed changes in the prefab but not the game objects.
You should not be changing anything in the prefab
leave the prefab alone
and why do you have two different variables called bulletSpeed? That's just going to lead to confusion
I dont think I have 2 variables called buletSpeed where are they
[Serializable]
public class GlobalIdentifier : MonoBehaviour
{
private Guid _id;
public Guid ID { get => _id; set => _id = value; }
private void Awake()
{
if(ID == null)
ID = Guid.NewGuid();
}
}
would something like this work?
no because you are not serializing the Guid
its the same variable from the same script I just tried to call it a diffrent way
you're referencing two different objects
or maybe not
it's impossible to tell from the code alone
anyway it doesn't make sense
you should not be changing the value on the prefab
You would want to change it on the spawned instances
Alternatively if they are all supposed to have the same speed, the bullet itself should not be keeping track of the speed variable, it should live in a central location somewhere that you can change in one place.
Good use for a Singleton
the speed isnt changing at all when I manually change it\
when you manually change it where
You're omitting so much detail about how all this works that it's really not possible to help much at the moment.
how does bulletSpeed even get used, for example?
And what exactly are you trying to accomplish? Changing the speed of existing bullets? Changing the speed of new bullets?
This is the script
Ok so again, where are you changing it?
Hey Guys, Im Making My Own VR Game And Im Not Sure What Template to use. Can someone help?
You would need to change it in the inspector for it to stick
in the asset
Ok but the asset is just a prefab
It's not a spawned instance in the scene
so how would I change it in the heirarchy
You're asking such vague questions.
If you mean at runtime, using code.
If you mean at edit time, in the inspector
ok im going to try to figure it out thanks for helping
Is it possible to create buttons that are different shapes?
like this:
Would you design it in photoshop, then import the entire bar into unity?
How do people usually design this kinda stuff?
yes of course
you just have to set the alpha around through code (other wise it uses the rect)
https://docs.unity3d.com/2018.4/Documentation/ScriptReference/UI.Image-alphaHitTestMinimumThreshold.html
for some weird reason there is no inspector option
Not really a code question. But a button will be whatever shape you set its image as
Thank you
How do I lerp rb.velocity so its not instanty zero if I set it to vector3.zero
Use Vector3.lerp to get the velocity and assign the return value from that instead of immediately assigning Vector3.zero
Hi guys, is there a way I can modify the pionts on the graphs that the AnimationCurves generate? For example the initial position of the graph is set to a diffrent place in the code if something happend (don't worry about the condition)
Well if you set it to zero it will be zero. Don't do that
Use Lerp the same way you would with anything else
Oh also
Anybody knows a way for my lerp functions to FINISH because like it like instantly stops
if (Input.GetKeyUp(KeyCode.W))
{Mathf.Lerp(forward_backward_angle, 0, Time.deltaTime * 10f);
}```
^ Like here it wont fully lerp back to zero
There's something missing from your understanding if you're running inside a GetKeyUp like that
Coroutine works?
Why wouldn't it
I dunno I thought they only ran once
They do. You just make a loop inside them
ok now its getting compex oging back to my bool idea
Loops are pretty simple, but Update is already a loop, so yeah that is simpler