#💻┃code-beginner
1 messages · Page 808 of 1
Get them oriented correctly first, then rotate things as needed
is there a way to do that without having to tinker with the values?
You want them to look like this in the 2D view
Select all of the knots at once and then give them a rotation of :
0, 0, 270
That will get them oriented reasonably. You can then adjust the handles.
how do i do the code block thin in discord ?
!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.
```cs
like so
```
note that my Bezier mode is "Continuous" here
which is probably what you want
the "Broken" mode allows for the handles to be positioned arbitrarily
public class GoblinUnit : EnemyUnitParent
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Awake()
{
maxHealth = 2;
currnetHealth = maxHealth;
}
}
using UnityEngine;
public class EnemyUnitParent : MonoBehaviour
{
public float maxHealth;
public float currnetHealth;
public float attackSpeed;
public float attackDamage;
public float moveSpeed;
public float resistance;
public void Death()
{
if (currnetHealth <= 0)
{
Destroy(gameObject);
}
}
public void TakeDamage()
{
if (Input.GetKey("t"))
{
currnetHealth -= 1;
Debug.Log(currnetHealth);
Death();
}
}
public void Attack()
{
}
void Update()
{
TakeDamage();
}
}
any idea as to why my enemy isnt dieing when i hit "T"... im stuggling... to me the logic makes sence
if i put the death in update it insta kils them tho
I'm not sure if GetKey accepts a lowcase letter like that
Try using KeyCode.T instead of a string
the KeyCode enum avoids the ambiguity
It's not exactly code, but has anyone worked with VFX graph and Shader Graph together? Im having trouble making my VFX Tile properly. Even though its showing up in all the previews as it should
Thank you!
(if you want to go the extra mile, export a .unitypackage with your VFX graph and shader graph assets)
ok i think i may have fixed the not deing when i tell them to but they still die on enters anyone know why
anyone know how to get svg files to import into a project to e used as a sprite?
Rasterize them directly and import the resulting image or use https://docs.unity3d.com/Packages/com.unity.vectorgraphics@3.0/manual/index.html
in pm it says i have vectorgraphics installed is that what i need
yes
any idea why it doesnt work then?
wdym by it doesn't work?
How are you expecting it to work and what's happening instead?
i assumed youd need to assign the svg to a game object before using it yet that still doesnt work
That's really vague
svg files are asset files
unity creates assets from asset files - in this case it will create textures from them
you can use those textures or sprites in SpriteRenderers or other renderering components
alright
You'd have to show exactly how you tried to do it and I can point out what you might be doing wrong
in the inspector i should set the generated asset tyupe to texture 2d im assuming
Not if you want to use it with a sprite renderer
How do you want to use it?
In a SpriteRenderer?
As an albedo texture in a material?
In the UI?
in a sprite renderer yes i just want to be able to use it as a sprites texture not for a material or anything
okay, so you need the importer to produce Sprite assets
I think you probably don't actually have the vector graphis c package installed
if it's not showing you sprite as an import option
In the package manager do "Add package by name" under the + sign and enter com.unity.vectorgraphics
Then you should see all these options
i have that in my built in pm and it says its installed
com.unity.modules.vectorgraphics
that's not the same
do what I wrote above
that module only gives you ui toolkit and texture2d capabilities
you need this one for sprites
About this package
For Unity 6.3 and later, this package works on top of the built-in Vector Graphics module to provide additional import types:
Sprite Import: Import SVG files as Unity Sprites for use with Sprite Renderer. uGUI Import: Import SVG files as UI Images for Unity's uGUI system.
tysm man
are all packages installed through unity safe i can see this one is just for future use
what do you mean by safe?
The Registry packages are official
nice
if it's through the unity registry it's official.
If you're installing from a github url or a third party registry, you should be careful to only use trusted sources
alright thanks for the help
Hey Guys!
Could someone Rate my Script that makes an Inventory :)
https://paste.myst.rs/clone/7k1yfnkc
a powerful website for storing and sharing text and code snippets. completely free and open source.
Hello, how do you make a Monster fly and attack smoothly, like in hollow spirit, can i post a video to explain what i need?
go ahead
@oak remnant
but i doubt anyone will give you the working code for that
you might want to ask for something particular instead
i dont want to know the working code, but to know if they have any idea how to do it, in the sense of what command to use, not exactly the exact algorythme but some clue maybe i dunno
Are you unsure of in Hollow Knight Silksong how to beat bird boss in Greymoor or how to navigate Craw Lake in Hollow Knight Silksong? This Hollow Knight Silksong Greymoor bird boss fight guide will exemplify in Hollow Knight Silksong how to beat the bird boss in Greymoor. Follow along for a brief Hollow Knight Silksong Craw Lake guide as well.
...
it is the way the flying monster moves around smoothly
guys im so confused with the new input system
i cant understand a single video for touch controls
where should i go to ask for help with optimization? i have a script that causes a massive use of memory and im trying to fix it
Here is fine
If you think its above a beginner difficulty, then probably make a post in code general. Also use/show the profiler to see whats exactly causing memory issues
whats the profiler; where do i find it?
Google unity profiler, I dont remember where it is exactly tbh. I haven't opened unity in some time
share your code in a code channel
if it's obvious, someone will tell you what's wrong
if it's not obvious, someone will show you how to use the profiler
Hello everyone. Can someone explain the difference between world direction and local directin?
Depends on context but normally in Unity, local would be relative to the parent whereas world would be not.
ty
I like to think of it like this:
World directions are things like "north, west, east, south"
Local directions are things like "in front of me, behind me, to my left, to my right"
So if I want a sprint to go false bool isSprinting if the player moves back I should be using local direction, correct? is it possible to do the same with global direction?
Do you've got any parenting? What's the situation that would call for needing to differentiate between the two in your case?
If the object isn't a child of anything, moving relative to world or local would produce the same result.
What do you mean by "back"?
This isn't true exactly. Most movement stuff is in relation to the object's own rotation.
Yeah I'm seeing that now that I'm trying it. I guess I should get the player's input to cancel sprinting
It's not clear to me exactly what you are trying to do
We don't even know what kind of game this is exactly so it's hard to visualize anything you're talking about
Action RPG. Third Person Camera with first person controls. Rotation is restricted to Look(mouse delta / right stick). Movement is WASD and left stick. holding sprint will increase the player character's speed. I want sprint to cancel if the player moves backward (S / left stick down).
Sounds like you already have the answer - this is something you just look at the input for
Hey, i am having a bit of trouble, so i figured i should ask (maybe wrong channel, not sure): how do they make it in pixel art games so that all the characters flip around seamlessly? I am trying to make one and the pivot points are just messed up, if i set them in the middle, when i use flipX on the characters they look SO weird
Almost like they are taking a step backwards
make sure your sprite is centered
flipX flips around the center of the sprite
but yes, wrong channel
ehh I wouldn't fix it with code
you can manually adjust the pivot point in the sprite editor
I have thousands of animations and characters tho
ideally you would create/slice your sprites in such a way that their pivot is automatically in the center.
this is really on you if you didn't do that in the first place
i.e. adding empty space so the middle pixel is your pivot
How do i do that?
depends on your software
So is there anything i can do?
manually fix it
How
depends on your program
but you can just do it in the sprite editor
#💻┃code-beginner message
or edit the actual textures with whatever your preferred raster image editor is
Aha. I have libresprite
then that would mean expanding the canvas until the middle pixel is your pivot
probably more effort than just doing it in the sprite editor
not really but ok
no idea, why it console logged twice with one input, but strange error shows up.
i desperately need help. i have a tilemap, which by default uses the sprite lit material, but i used to see screen tearing in play mode. i switched to a material i manually created, and the screen tearing was gone, so i thought i was finally free to continue development in my game, but when i tried making a build, the screen tearing is still there and it is even worse. i have tried everything from different materials to pixel perfect camera to deleting and recreating my tilemap, to a combination aof all the above, to using chatgpt, to i dont know i have lost track. please help me
Tearing between tiles?
its rendered taking next pixel from tilemap (commonly its white). Look up SpriteAtlas
i cant say i understand what you just said, but i will look up "sprite atlas"
im suprised you didnt find it with google. its first thing to pop up about your topic
i made a sprite atlas, tearing is still there
in the build i mean
play mode still works alright
did you try maximize in playmode?
no
wait]
lemme try
i did now
no tearing
it is only exclusively in the build
oh god i have spent so much time on this project if it just gets trashed because of that i am going to literally crash out
please someone help me how do i remove screen/ tilemap tearing
Where is this from
source? trust me bro. Chatbot. Dont judge, they are good way to search in internet.
Posting ai responses without saying its ai is against the rules afaik and in general discouraged here
@fresh fern how it looks? lines or delayed pixel movment?
it is grey lines
most of them horizontal
some vertical
the sprite atlas did nothing
and i tried all of its settings
but i think its must have in 2D games
what do you mean
i Hope @sour fulcrum this isnt against rules
Steps to repro:1. Open original project "New Unity Project.zip"2. Enter Play Mode and notice that there is no screen tearing in Game...
That’s a different problem i believe
i dont know if it is, but it didnt help me
give screenshot for people to understand issue better
okay i will later, i have an idea for something to try first
Maybe, im assigning function to inputaction incorrectly? Changed naming to be easier understand.for (int i = 0; i < _List.Count; i++) { int index = i; _InputActionRef[i].action.performed += ctx => _Function(index); }
OnDestroy i unassign function from input action, but doesnt unassigns, getting errors
sounds like you're indexing _InputActionRef out of bounds
why are you looping over _List but using _InputActionRef
assuming the error is actually from that code, since you didn't specify any line numbers
on start of class assigning to Referenced inputs function with index. buttons from 1 to 0.
hm wait the stacktrace seems to be from inputsystem.. i don't think i can help much past basic debugging as im not at my desk right now
i have no idea what you mean by this
keep in mind that i'm not looking over your shoulder and i'm not psychic, i have no info about your project, code patterns, or this specific script outside of the small snippets you've shown
i think, issue is with editor firing 1 function on 1 call 3times. 1 out of 3 times.
{
Debug.Log($"Index: {index}");
//For setting selectedIndex to clicked slot.
BlockSlot selectedObject = EventSystem.current.currentSelectedGameObject.GetComponent<BlockSlot>();
if(selectedObject)
{
selectedSlotIndex = LoadoutList.FindIndex(slot => slot == selectedObject);
}
else return;
LoadoutList[selectedSlotIndex].SetRune(blockTypesOrder[index]); //127 line
selectedSlotIndex = (++selectedSlotIndex) % LoadoutList.Count;
//Sets selected slot
if (eventSystem != null)
{
var baseEventData = new BaseEventData(eventSystem);
eventSystem.SetSelectedGameObject(LoadoutList[selectedSlotIndex].gameObject, baseEventData);
}
}```
{
for (int i = 0; i < blockTypesOrder.Count; i++)
{
int index = i; // For input function not referencing the loop variable
runeSlotInputs[i].action.Enable();
runeSlotInputs[i].action.performed += ctx => HandleRuneSlotInput(index); //76 line
}
}```
Can you give a summary of what the issue is?
Is it the argument out of range error that you had before? #💻┃code-beginner message
yes, and also i tried to remove function onDestroy, but it didnt remove on scene load. Summary: Range error, even if list is constantly 10 size. Doesnt unbind on destroy. on 1 button press function is called 3 times (no error, error, no error)
I'm going to assume that it not removing on destroy is a guess. You can verify by logging something on destroy to see if it's occuring.
If the error is with cs LoadoutList[selectedSlotIndex].SetRune(blockTypesOrder[index]); //127 linethen likely the selectedSlotIndex value is invalid. Log the value and the size of the load out list.
just did and it called on destroy. for (int i = 0; i < blockTypesOrder.Count; i++) { runeSlotInputs[i].action.performed -= ctx => HandleRuneSlotInput(0); }
So destroy is functionally correct.
What the error is stating is that selectedSlotIndex isn't a valid index for the LoadoutList collection.
You need to verify the value and the collection size.
so before it debugs valid index it becomes invalid?
No. The value isn't ever valid.
Log the value
this is incorrect
Log the collection size.
you can't unsubscribe a lambda used directly like that
it's not "the same delegate", so nothing is being unsubscribed
You need to unsubscribe the instance.
usually you would have a method that you can easily subscribe/unsubscribe instead
i subscribed incorrectly?
you subscribed in a way that makes unsubscribing properly impossible
If you cache the lambda with a field, you can subscribe and unsubscribe using the field.
is there better way to subscribe to inputaction.
What do you mean? How you had it initially would be perfectly fine if you aren't planning to unsubscribe
the ways me and dalphat just described
but im planning to unsub, because class will be destroyed
If you're planning to unsubscribe, you'll have to reference the instance to unsubscribe.
if you don't understand, just say so instead of ignoring the answer
i dont konw how to save reference.
it's just assigning some field to the value you want to keep
same as if you were to save an integer value across methods, you would assign to an int field
i have no idea what you mean by that last part
what field type i would need
try hovering the thing you're subscribing to 😉
it'll tell you the type
though since you have multiple inputactions you'd also have to save multiple actions, probably with a list/array
im brain dead or i dont understand this part.
in your ide, hover over the word performed in ...action.performed += ...
it'll tell you what the type is
it says Action<InputAction.CallbackContext>. but when you try to save to that field variable says "cant covert to void"
Probably Action<InputAction.CallbackContext>
what exactly is the code that's giving that error?
if i guess, i cant do this Action<InputAction.CallbackContext> _action = runeSlotInputs[i].action.performed += ctx => HandleRuneSlotInput(index);
you aren't saving the event listener there, you seem to be trying to save the entire act of subscription
(you also would not be doing this all as one statement, you would need this to be a field, not a local variable)
Action<InputAction.CallbackContext> _action;``````cs
_action = ctx => HandleRuneSlotInput(index);
runeSlotInputs[i].action.performed += _action;//Subscribe
runeSlotInputs[i].action.performed -= _action;//Unsubscribe```
int attack = /* ... */;
int bonus;
``````cs
bonus = /* ... */;
attack += bonus;
// later
attack -= bonus; // same value as when you did `+=`
The breakdown...
HandleRuneSlotInput(index) is simply a function from this instance that you're wrapping in a lambda.
A lambda generally looks like (/* parameter */) => {/* statements */} where the parameter type does not need to be define - lambdas.
You're expecting a parameter of type InputAction.CallbackContext. The parameter name ctx implies it's the callback context that the Unity input system provides. In your case you aren't doing anything with ctx. The funciton is expected to have a return type of void so you'd want to use the delegate Action instead of Func. You'd cache the instance of the lambda (an anonymous function) with a field and subscribe the instance (using the field). When you need to unsubscribe, you'll use that instance stored in the field to unsubscribe. What you had initially was the creation of new lambda instances when subscribing and unsubscribing. They were two different instances. The second instance wasn't found so nothing was removed. @elfin pike
What are common use cases of lambda. I always used it to shorten and not use {}. Also for actions from input manager
I'm actually using them right now. They make certain code alot more convenient.
ah, deferred evaluation like in WaitWhile/WaitUntil or in pooling too
as well as callbacks
Oh right, like.
bool myBool = false;
yield return new WaitUntil(() => myBool);
I use that all the time. It's very nice.
First time see delegates. Thanks for another. Maybe, one day I'll find use for it. Sometimes find game changers like composite class, event channels
delegates can also store function parameters. It's pretty dope.
you're already using them, Action is a delegate type
is this safe? or should I just remove it
this is a unity bug, update your editor
so quick question about this;
if i have a project in a bugged version, would i lose anything by upgrading?
nope
I'm trying to make a pong game, but when the ball touches the enemy paddle, it gets stuck in place instead of reversing its x velocity. It also doesn't bounce off the walls. Here is my code:
private void OnCollisionEnter2D(Collision2D collision)
{
// For the walls, reflect Y velocity
if (collision.gameObject.CompareTag("Wall"))
{
rb.linearVelocity = new Vector2(rb.linearVelocity.x, -rb.linearVelocity.y);
}
// For paddles, reflect X velocity, add some vertical deflection, and increase level if the ball hits the player paddle
if (collision.gameObject.CompareTag("Paddle"))
{
float yDiff = transform.position.y - collision.transform.position.y; // Difference in Y position between ball and paddle
float bounceAngle = yDiff / collision.collider.bounds.size.y; // Normalize offset
float currentSpeed = rb.linearVelocity.magnitude; // Get the current speed
Vector2 dir = new Vector2(-rb.linearVelocity.x, rb.linearVelocity.y + bounceAngle);
rb.linearVelocity = dir.normalized * currentSpeed; // Use current speed, not base speed
if (collision.gameObject.name == "PlayerPaddle")
{
GlobalVariables.Instance.Level++;
}
}
}
I'm guessing that the physics engine already reverses the velocity, and then your code reverses it back
If you want to make your own collision system you shouldn't be using the physics engine at all, or at least only use triggers. And if you just want to make a pong game, just let the physics engine handle the collisions
I can use multiple functions with delegate by only inputing function parameters once?
I don't really understand. I commented out the lines that change the ball velocity (basically only leaving the Lever increase) and it still gets stuck on the enemy paddle.
I'm thinking, could it be that the physics engine stops the ball dead before my script hits, and then, because the ball velocity is 0, it just stays at 0?
Why do you need a script at all? The physics engine will bounce the ball automatically
Because I have other stuff in my Ball script
for a patch version, generally no, but it's always to have backups or vcs for the case where something gets messed up
a delegate basically is a function, just as a value
you can use it however you might use another method
What does that have to do with anything
You asked why I have a script at all. I have a script because I need it to do things, like resetting the ball to the middle, or launching it.
Obviously I wasn't suggesting that you should throw out all your code. I meant the part that messes with the physics
Oh that, I assumed that I'd have to do that, because usually when hitting a wall your motion stops, as it does with everything commented out.
My collision code is this right now:
private void OnCollisionEnter2D(Collision2D collision)
{
// For the walls, reflect Y velocity
if (collision.gameObject.CompareTag("Wall"))
{
//rb.linearVelocity = new Vector2(rb.linearVelocity.x, -rb.linearVelocity.y);
}
// For paddles, reflect X velocity, add some vertical deflection, and increase level if the ball hits the player paddle
if (collision.gameObject.CompareTag("Paddle"))
{
//float yDiff = transform.position.y - collision.transform.position.y; // Difference in Y position between ball and paddle
//float bounceAngle = yDiff / collision.collider.bounds.size.y; // Normalize offset
//
//float currentSpeed = rb.linearVelocity.magnitude; // Get the current speed
//Vector2 dir = new Vector2(-rb.linearVelocity.x, rb.linearVelocity.y + bounceAngle);
//rb.linearVelocity = dir.normalized * currentSpeed; // Use current speed, not base speed
if (collision.gameObject.name == "PlayerPaddle")
{
GlobalVariables.Instance.Level++;
}
}
}
```As you can see, I commented the physics changing stuff out, but the ball just stops all X movement when it hits the paddle.
I'm going to try re-enabling the commented out lines, and removing the Kinematic rigidbody from the paddle.
That's not going to help
Either you have code somewhere else that affects the ball, or the physics setup is wrong
Possibly setting the ball velocity every frame
I am completely new to unity what should I start with
Check pins
What?
You asked in a coding channel so it's the assumption that you want to learn code . Check the pins in the channel?
hi
Ohh pins in discord
I tought you guys would help
Additionally they have pathways on https://learn.unity.com
in which channel we can post for people to connect with?
We help with specific issues
:/ so it's not a community?
Like i wanted to know how to start
It's a community for helping with specific unity editor issues
Right, see the pins.
ok then which server we can connect with people to build game dev groups?
Probably a general gamedev discord server ?
Does unity have any other home server?
There are non official ones floating around , dunno which
: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**
Will do. Thank you
Is there book or website with words I should know?
!docs
Giving unity documentation doesn't help
What did you need then?
are you looking for a glossary?
i don't think unity has an official one
oh no way
Yes. Why in unity variable type is called field?
It’s not
variables declared in a class are referred to as fields
field and variable are kinda different, not only in unity but in c# in general.
field is declared in the class and a variable is declared somewhere in class' methods
the field can be used anywhere in this class, but local variables declared in a method can only be accessed from this exact method
"target" itself is a field, not variable
the line "public Transform target" is a declaration of the field, but not the field itself
Its both a field and variable
You are correct on this though but was trying to just get the point across that field is just kinda contextual
target is a field, which is a type of variable . . .
You make it more confusing
the truth usually is (joking) . . .
it's really not though. a field is a type of variable that belongs to the class or struct, that's all . . .
a variable holds a value.
a field is a variable that lives in a class (or other type)
a local variable is a variable that lives in a method (or a narrower scope) (it's "local" to that scope)
basically, the main difference is the scope the variable was created in . . .
Not logical. i would class can have methods and fields. Fields contain stack or heap. Method can also have them.
class can have methods and fields.
this is correct, these are collectively called members (along with some other stuff)
Fields contain stack or heap
this makes zero sense.
Method can also have them.
"fields" inside methods are called locals.
huh? fields don't contain stack or heap, but a field can be stored on the stack or heap depending on where the field is located . . .
this is also now not beginner stuff
A field is a variable that belongs to a class. As opposed to a local variable that belongs to a scope
no, i would consider this beginner as it's the first thing they should learn about variables . . .
No a beginner learning c# does not need to know about the stack or heap
right, they brought that up themselves, the main topic was trying to explain what the difference between fields and locals was
Yeah I don't even know where those came from. No one was mentioning them
he better know
eventually, yes. but there are more important things for a beginner.
information overload is not conducive to learning
-
value types are stored on the stack
Pro-Tip: value types are stored on the heap if they belong to a reference type (array, class, struct, etc.) -
reference types are stored on the heap (the actual object)
Pro-Tip: the variable holding the reference can be stored on the stack (local) or heap (field of an object)
personally, i never knew this was intermediate or advanced learning. i thought it was a part of learning about variables and what types there are (which is one of the first things you learn, imo) . . .
it's advanced knowledge of a beginner topic imo. implementation details that can be abstracted away at the beginner level
It matters more in c/ cpp where we need to care and think about how we are allocating objects
damn, realizing my training was harsh. why master?
in a managed language its not as important
yeah stack vs heap alloc is almost never mentioned in eg js or python in the context of learning to use the language (for comparison)
implementation detail that's interesting for nerds and important for optimization but you'll get a lot more knowledge leading up to that by the time it becomes important
you mean just for a beginner, right, not in general?
yea in c and cpp you kinda do need to learn about that up front. In c# you could never learn and do just fine
You have to. If you do Array1 = Array2 it then Array1 === Array2. They would be same, because they reference types
comparing equal is not becuase they're reference types
if you do num1 = num2 then num1 == num2 too
What does this have to do with stacks or heaps?
🤦♂️
I don't think that you really need to worry about any of that in a garbage-collected language like C#. You don't need to allocate any memory, so you don't really have to care about how that memory is managed.
but muh bragging rights!
You can't pass value with reference type variables. You would pass only reference.
ref would like a word
passing by reference is a different concept (see ref/out, or c++ &)
all of this started from fields and local variables...
Okay, but, like, what does that have to do with stacks and heaps? It just seems like your spitting out a bunch of non sequiturs that have nothing to do with the previous statements
We can move on to another question once we've adequately solved the last one
value types are stored in stack and ref types are stored in heap
i think we could drop this tbh. i'm not sure it's going to be of much use
this is incorrect
see previous explanation above #💻┃code-beginner message
yea i mean there are some exception for that
values of value types are stored entirely inline, whether that's in the stack or in the heap.
values of reference types are stored as a reference (inline) to some object in the heap.
Basically, you won't need to care about how the data is stored in C#. You just need to know if it's a reference or value type, and if you need it to be the other one, you have ways of doing that
What about fields? How people explained inside field we have field and field type?
a field is a variable that belongs to an object, and yes, a field is associated with a type . . .
though, I don't understand what you mean by, "inside field we have field" . . .
That I also don't understand.
you said it...
a field declaration has the field name and the field type, are you thinking of that
Yes, I think guys got confused by trying to explain
In any other language Its called global variable, because all functions in class can use it
no, this is not the same as a global
globals are in the global scope
fields are in class scope
c# doesn't have globals
compare: c, c++, js, and python have both globals and fields. they are separate concepts
So global > field > local
Scope doesn't end there but it's the major ones
What can be higher then global?
global is the highest scope
I mean the other way. You can have local functions, lambdas and even start new scope within any but that's not as useful in c#
quick qeustion: how do i remove the paths in visual scripting? the white ones
you don't, those are what direct the flow of your code
removing the paths just means the code doesn't run
i dident mean to connect it to "on start"
ah, wait, did you just.. mean that
yeah ok i assumed you meant visually remove them... that's on me, i need to go to bed lmao
probably some right-click action
ask in #1390346878394040320, they'd know how to work with visual scripting
you could also probably just google this though
Does anyone know why I get this error for this script? InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. UnityEngine.Internal.InputUnsafeUtility.GetAxis (System.String axisName) (at <5d83d7fd54814220974154076485b684>:0) UnityEngine.Input.GetAxis (System.String axisName) (at <5d83d7fd54814220974154076485b684>:0) CameraControllerFPS.Update () (at Assets/movement/Movement.cs:15)
public class CameraControllerFPS : MonoBehaviour
{
public float sensitivity = 2f;
private float xRotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * sensitivity;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
transform.parent.Rotate(Vector3.up * mouseX);
}
}```
The error message pretty much tells you exactly why and where you can go and fix it
Switch input handling to use both.
You can either use both, or start using newer active Input System, I prefer the newer but it's a little less intuitive in setting up
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.8/manual/Installation.html
You can find the corresponding setting in Edit > Project Settings > Player > Other Settings > Active Input Handling. If you change this setting you must restart the Editor for it to take effect.
guys is there a better way to achieve this?
if (cameraFinger != null)
{
Vector2 delta = cameraFinger.currentTouch.delta;
cameraInput = delta * sensitivity;
}
got some more context for us?
reading touch/mouse delta is normal for getting input for this frame
srry, so whenever im using the touchdelta using the enhanced touch it does this, worked fine when i was using input actions but i couldnt get the "camera finger" thru the input actions now im confused
You need to share how you use the input to then rotate the camera.
An input action with mouse and touch delta should work fine.
its basically just a fancy way to adding the delta to the camera rotation, its being called in late update
This also looks fine but I think the "window space" for delta is a bit shit
nvm that should then equate to screen space. Id try to use an input action instead of enhanced touch and see if its better. Im going to try to find what I did when I used enhanced touch last...
Dang I was using Touch.activeTouches[0].screenPosition
If an experienced coder is familiar with the game RuneScape can u please DM me. I have a few questions
damn was it working?
Yea but this was for having a graphic follow the touch position hence use of screen position from the active touch (with enhanced touch on)
i see
i tried the input action again, its definitely the enhanced touch
i looked into the official documentary a bit as annoying as it is i couldnt find an alternative with only the input system
because i wanna identify the finger too
If you want only some area of the screen to do this camera movement you can use the IPointer events in UI to read mouse/touch input
using a configured input action is better than doing direct device data reading (and enhanced touch is there really to half replicate old input stuff)
not really id have the ui changing but even if i set the drag area below all ui its still going to cause issues with gamepad support etc
Then 1 action for both should be best
id still need to constantly use the joystick to move lol
another action for that
*mapping sorry
you can map touch delta and gamepad input
then read as vector2
If you have coding questions you should just ask here
but Runescape is also not a unity game
if you want to know how to recreate anything from Runescape in unity you should also ask here
Ok well I guess I can ask a few of the questions here. In RuneScape there is a tick system that I believe is when the server registers game data of events happening. I think all video games are tick systems but RuneScape is known for its big 0.6 second delay. Question, does implementing this in a DnD combat system which is not turn based have any utility for single player games? From my surface knowledge I thought the tick system existed in RuneScape because of hardware constraints and being a multiplayer game. If this tick system would be useless for modern DND real time games. What system should replace it
You can either process events as the occur or queue up things to handle at some fixed timestep but unless you have a very good reason to do this (such as a server) then dont bother
You really dont need a custom tick rate for a game that isnt multiplayer
i cant really think of any productive reason for one
tickrates for multiplayer games are basically just how frequently is the server getting all the client sided information and vice versa
to put it simply
yea exactly, we can already tell pretty well how much time passed since the last frame so we can keep things consistent time wise
Isn't the body of the player desynced from their actual coordinates? Like it's all animation interpolation or something. I think that's because of the tick system and I am not sure how different the DND combat system would feel if it was too responsive I guess? It's just kind of hard to imagine what it would look like in a different game genre
are you thinking of physics interpolation?
Anyway if you were doing some turn based system you would still process input right away and handle things by the time they take
I think you are chasing some idea for no good reason
Runescape and Wow use tab targetting, which is sort of close to a mix of real time and turn based combat, but that was born out of nescessity, action rpg mmos werent a thing back in the day.
For an actual turn based combat system, you dont need tick rates of any kind
Perhaps I shouldn't have said DnD. It's just RuneScape is technically a DND combat system. I am not exactly sure how the registry of data for far away fog of war units works (perhaps they don't spawn at all before the player can see them). But I feel if u wanted an authentic RuneScape feeling game u would not want a continuously fast updating tons of data immediately because it would be unnecessary and a waste of CPU resources that u would want for a big map game with many units. If all units have some sort of like minimum 0.6 second attack timer. I am not sure what is lost not just having the game "click absolute time" over the entire game
I think you are still missunderstanding both the nature of tick rates, what runescape does and why, and what we are telling you...
Youre confusing multiple different unrelated things here
Its true that processing a bunch of things each frame (on the main thread) would be slow but threading, jobs and entities can be used to solve this.
An easier method would be also to stagger when updates happen (some one frame, others the next)
whats the best way to learn how to program overall as a COMPLETE beginner
check the pins here
Anyone check out my code of parts disamble
!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.
if i have building sim type game and i need to make like 50 exteriors and interiors, whats the best way to organize things as far triggers collisions etc from going outside to inside
organize? in what sense... this is a very open ended question
they do have a ton of units loaded at once, i think there was an update where they stopped updating certain units if no one was around (which caused its own bugs). But they generally dont spawn/despawn much. Dead npcs are sent to (0,0), not destroyed or anything, which also came with its own bugs. Object pooling would be the term for doing this in unity. Other than the 0.6 second tick rate, the stuff you're describing don't actually correlate to a "RuneScape feeling game".
Though you're wasting efforts even trying to compare your game to runescape. If there's a feature you want to recreate, ask about it specifically. Just thinking about implementing a tick system because another game has it will get you no where. Their fundamental systems like the ticks and queue had crazy bugs that have existed for years, you really don't want to copy it anyways
Yo wsg gangs
Is there way to see class used memory and performance? I know it's not beginner's topic
What the hell?? Why isn't it filling out the field?
I'm trying to fill out an InputActionReference in my player prefab using unity's new input system.
public InputActionReference move;
Apparently it's a problem specifically with version 1.16.0 and 1.17.0 of the input system. Switching to 1.18 fixed it but now apparently the signature of the package is invalid
!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**
how strongly baked into Unity / C# ecosystem is the PascalCase naming convention? I am going crazy without my snake_case variable names 🙁
very
🥹
You'll get used to them, and then your code will be more readable for everyone so don't feel bad about leaving snake_case behind
its just unfortunate because i really hate camel case lol
but yes, it is what it is
you practically aren't going to see snake case outside of python and constant variables in certain languages
its a good thing to leave behind
the lower case feels much easier on the eyes to me
but i guess it's easier to just go with a language's conventions or its an upstream battle =\
hello guys I wanna know can you only call this One time?
interface IInteractable { public void Interact(); } I wrote this a second time to make a second function in an other script but this apparently makes an error
Show where and how you've written it the second time.
are there still website to paste the script like blaze bin this website is down
First image is the second implementation and the second one is the first one (The error should be in the first script.
You've already defined that interface in your project. Remove one of the two.
It's available project wide.
ohh okay
thanks
Hey everyone,
I'm going through a difficult time through my life but since I'm doing a bit better now I'm trying to finally get into codding
I already follow the very basic tutorial to learn how unity work and I was able to start a small project by my self, asking chat gtp how I could improve my code or how I could do this or that (telling him how I would do it first so he doesn't just do all the work for me)
Thing is I'm pretty sure chat gtp isn't the best way to learn programing and I was wondering if there are other ai out there made for programing that could direct me or answer my question better than him
Thank you for your answer or redding my question ^^
(I know there is tutorial for everything out there, but the sheer amount of them and finding the right one for the right situation is a bit intimidating for me and for the stage of my recovery that I'm going through rn, Someone already told me I should look for those instead and I plan on doing too hopefully since they should be better than ai, but I can't really manage to do it rn ^^;)
No one here is going to recommend you any ai
Oh yeah i have no idea why i wanna implement a second Interaction this is just dumb 😂
i'am thinking too hard i dont know 😭
i like your color scheme
its an extension its called Doki Theme
vscode?
visual studio 2022 but it might exist
I really gotta reinstall visual studio 2022 But i suppose 2026 is less buggy nowadays with unity.

oh is 2026 like 2022?
i stopped using vs cus it took too much processing power
I can understand lol
It's pretty much the same but more buggy for unity. 2022 is a much smoother experience.
Oh alright i might give it a try in a few month then
Maybe not a bad idea. It's certainly getting better over here. Worst of the bugs are gone but you still can't see errors half of the time
it's pretty annoying.
Oh you cant see errors ?
Yeah. Sometimes it just decides to not signal errors. You gotta reopen the script and all.
tedious process.
What I want:-
- Based on the mouse position, I want the Forward Vector of the Spaceship to rotate towards the Mouse Position
- In this scenario (acute angle), the spaceship should rotate clockwise
- In a scenario (obtuse angle), the spaceship should rotate counterclockwise
I want to know how it would be possible for me to find out:-
- Forward Vector
- Angular Velocity required to rotate the spaceship (I have done a few calculations and I don't think finding this will be much of a problem if I have the Forward Vector)
For 2d rotation we can make use of Atan2 https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Mathf.Atan2.html
You can use this to get a target rotation and use RotateTowards to slowly rotate the ship towards this new rotation.
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Quaternion.RotateTowards.html
If needed can give an example of how to use it
sure
suppose Mouse Position is mouse_pos and spaceship position is spaceship_pos
0 at the top seems wack lol
Vector3 dir = mouse_pos - transform.position;
float zRot = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
targetRotation = Quaternion.Euler(0f, 0f, zRot + 90f);
@tired python This shows us getting a directional vector from the object to the mouse position (presuming this is world space too)
Then we figure out the z rotation and make a quaternion!
You can then use rotate towards to keep rotating to wards the latest target rotation
in unity a character will have a rotation of 0 when the player is pointing forward
Oh and this example presumes that X+ is forward (hence the +90 correction)
this did not make sense to me
Its based on which direction your ship points with 0,0,0 rotation
If it looks right (which is positive X) then we need to add 90 degrees to the calculated rotation to correct it
O_O
wha?
Im confused what are you trying to convey to me?
I have used Atan2 many times to impement similar "rotate thing to look at mouse" behaviour
Please use words instead to tell me what you dont understand or if you think I miss understand your desired behaviour
wait, i will explain what i understood
oh wait
i messed up
it is Vector3 dir = mouse_pos - transform.position;
not Vector3 dir = mouse_pos - forwardvector.position;
The current forward vector is not important. If we get the target rotation using the previous example and use Quaternion.RotateTowards() to keep rotating to it each Update then we get it to work
We need a direction from the object to the mouse world pos
And just incase, unity provide a function to get an angle between 2 vectors https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Vector2.Angle.html
i don't have forward vector 😭
Then why not try what I suggested? Its what I would do to keep rotating an object to look at the mouse
Transform has properties for up and right so you do have options for a "forward" direction in 2D
i can't seem to get a grasp of the last step
is the up supposed to be normalised?
Quaternion target;
private void Update()
{
transform.rotation = Quaternion.RotateTowards(transform.rotation, target, 90f * Time.deltaTime);
}
Yes. Also i forgot to add a normalise for the "transform to mouse" direction too (which is needed)
wait then none of this is needed?
i can just use var angleToRotate = Vector2.SignedAngle(transform.up, mouse_pos);
I am soo confused what you understand or dont rn
suggestion: read the doc pages on these things
if you did not open the links i sent earlier then that explains this
i did open the links before and I do know that that euler rotation is supposed to add absolute rotations to the object (spaceship)
Euler is an alternate easier way to represent rotations
Quaternion is what is used for rotation. You can get and set rotation in world or local space.
RotateTowards() is a helper function that returns a rotation that has slightly moved from one rotation to another by some max amount so it makes it easy to keep rotating towards some goal rotation.
Its similar to Vector3.MoveTowards() which helps moving towards a goal position by some max delta
wait a second. the zrot just finds out whether i need to rotate clock wise and anticlockwise, whereas the 90f is just supposed to be some magnitude which can be used to increase the rate of this rotation?
i can't be this stubid 
zRot + 90f if the sprite looks right
zRot if the spirte looks up
zRot is angle in degrees
Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg
Atan2 returns an angle in radians so we need to convert it to degrees
hello, I'm using a simple throwing script which basically uses MainCamera.transform.forward as a direction but the object gets thrown towards the transform.up forwhatever reason https://paste.ofcode.org/LTnbNfhxxzXPigkSzbQSCN
you may think reading this script I have only upwardForce but no I have 0 throwUpwardForce and I have a throwForce
managed to make it work. had to use gpt, but what it suggested was very similar to what you said. rly sorry that i kinda wasted your time
Where is throwUpwardForce set, and why would you want to have it?
it's set in the forceToAdd, it multiplies the transform.up so I can eventually have a little upwardforce but here in this case it's set to 0, so that shouldn't be an issue anyway
Then it must be the if-statement?
Well I guess it was able to respond quickly to whatever you asked but yea the main parts used would be good to understand.
Do try to check the unity docs closely as their examples are good
got it
if it's set to 0, it will not matter anyway bruh
it will be equal to 0 and do nothing
When you copy code from a tutorial or the internet, you can be certain that your result will likely match their result - the final result. With AI generated code, there is no certainty. The result is simply generated. If there are mistakes, the AI will not be able to find the solution without curation. There are no promises with AI. The final result is non-existent. The generated result can be wrong. The solution can be wrong. It becomes a really deep rabbit hole of frustration. If you aren't comfortable with scripting but want to make games, your best bet is to look for assets in the asset store (free, paid ect) and find tutorials on how to implement simple mechanics/features that you absolutely need. If you aren't building the entire system yourself, keep the mechanics simple and few. Unity has been around for a long time. There are plenty of fancy ready made assets out there. Integration will be your limiting factor. You might not get exactly what you'd want but with enough iterations (games made) you'll become more familiar with what's acceptable and what you may have to learn or pay to acquire. Reminder that game development consists of more than just programming - there's going to be some compromising on quality: https://en.wikipedia.org/wiki/Project_management_triangle
"Good, fast, cheap. Choose two."
this is what the guy had been writing all this while damn
forceDirection is set in two places and it is not 0 if the throw is upwards.
Hey guys uhh there is something that i really dont understand so i just want to change a value from another script and its just doing something weird, so why the hell am i getting those types of result , the second script is in an object that get duplicated over and over but how can it show a value of 0???
Did you want the value to be the same for every duplicate?
Yes , so i'am really confused about the 0
Where do you assign player info?
In an empty object and i drag it in the duplicated gameObject
Normally you'd want to assign player info when you spawn each duplicate object so that they share the same player info:cs var something = Instantiate(...); something.playerInfo = playerInfo;
Can you show how you're instantiating the object
sure
Which object did you drag in? Was it a prefab object?
Its an empty object just so the script start
man, are you sure you understand my code? the forceDirection obviously isn't zero, I have a throwForce positive but the transform.up is 0
have you debugged if the if is passing (and changing the forceDirection?)
have you debugged the final forceDirection and forceToAdd?
but it mean that each time that i instantiate it would take the script from 0 ?
Replace your print line with this: cs Debug.Log($"Banna : {banana}", this);Run the application by pressing play. Pause the game (not stop) after some 0's appear. Click on the console log once and observe the scene/asset-folder for an object that will become highlighted yellow.
noo
I didn't know you could do that, it's interesting.
and you found my problem i guess😭
Was it the prefab asset that was being highlighted yellow?
i had 2 script that would play the same script
Ah, okay.
no
i'am so mad at me its not the first time it happen and i passed like 2 hour trying to find the issue 😭
i hope it wont happena again lol
yes I have, the forceDirection is upwards
tysm tho !
Why would transform.up be 0?
it would not
BECAUSE I'M MULTIPLYING IT BY ZERO
that does not make transform.up be 0
huh?
how ?
transform.up is just a normalized direction vector
multiplying by 0 results in a zero vector
it doesn't change transform.up
exavtly what I meant
i think you have the right idea but you're phrasing it extremely confusingly
multiplyijg it by zero applies zero force towards the axis
if works
is this log from inside theif?
Hello, when i am working with cinemachine i am getting something wrong it pissed me off, like when using the third person aim camera it's just not rotating and i am trying to add pan tilt it just rotates around it self and not like beside the player so it will get that aiming style.
Any idea?
yes
so forceDirection isn't the camera's forward direction then
it's whatever (hit.point - attackPoint).normalized is
yes, but the ray's direction is cam.forward, so whatever the hit is, it should be something in face of the player and the forceDirection would be something sent forward, no?
Hello i made an animation for Fire and Idle in Idle the weapon keeps flashing around anyoe knows why
you aren't getting the direction from cam.position to hit.point, are you
this is the code channel, that doesn't sound like a code issue unless you're doing the flashing from code
but also, you need to provide much more info than that
attackPos almost is the same as the cam position
we aren't psychic
ok, validate that then
log out hit.point, log out attackPoint.position, log out forceDirection
Thank You in wich Channel should i ask
the relevant channel
thx
you've already posted in #💻┃unity-talk so just stick to that, don't crosspost
if you actually provide more info, where we'd be able to help, then you may be redirected if necessary
I've debugged all of them, the issue is the hit transform I think, it's weird but it looks like the hit is the throwObject itself
the if is to make sure the direction will be the center but I think I'll just remove it and use the cam.transform.forward only, the issue looks too complex
So, it was the if-statement.
yes, but I kinda needed it though
I feel like I'm the only one having these weird issues everytime
so add a layermask
or make it start outside the throw object
!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**
no, you just need to get better at debugging
oh , sorry
but how would it fix the issue? if it hits the throwObject(whatever object) using as a direction the cam.forward and then calculating the normalized direction, it should have still been thrown forward and not upwards
real, but I've debugged everything as you told me, and we haven't found the issue
the layermask would make it not hit the throw object
if the throw object is on a different layer from whatever you want it to hit of course
we have though...
Thank you for your more details answer I appreciate it, have a good afternoon ^^
it's that your raycast was hitting an object you didn't want it to hit
yes, that's why I said (whatever object), the direction will be the same, won't it?
i have no idea what you're asking
Oh yeaaa wait, I'm dumb lol
maybe the throwPosition is a bit more elevated than the cam position so yea I should just exclude it from the layers
I mean, if it hit the throwObject using cam.transform.forward, the normalized direction shouldn't have been upwards
but it wasn't using cam.transform.forward
oh whoops misread
why wouldn't it be upwards
it was, the raycast
because the hit would be forward, then the direction would be forward too
no it wouldn't
why?
the raycast direction (cam.forward) and the direction from attackPoint to the hit are not related at all
So basically i am creating a simple script so when the player hits the enemy, the player resets back to their spawn point. However, when the player does touch the enemy, it doesnt do anything at all.
thank you so much
Show the inspectors for the player and the enemy
do debugging. is the message being called? if it is, is the if passing?
Where's the SpawnPoint component?
so the Spawnpoint is here, so hopefully when the player hits the enemy, it should go to this spawn point
That's the gameobject. Where did you attach the SpawnPoint script?
to the player
Ok well show it
then the player is the spawnpoint
thats just a gameobject named SpawnPoint, it doesn't do anything
so it does work on a normal sphere but not the actual Enemy? Is it because it is a prefab?
okay okay
how can I switch controls between two gameobjects that both have the player input component?
enable/disable controls being read and used and also move the camera over
If using cinemachine that is easy
Thanks
If you read input in update you can use the enabled property of your component
I don't but I've got an idea
If using events or something else then it can check the enabled state or some other field/property. Nothing complex really
So you're saying that I should just disable the Player input component?
yea that should work, or your functions that respond to input can check a bool to either do stuff or stop early
check the playerinput doc page for more info
Thanks!
hello, I am currently trying to implement networking into my 2d fighting game but there seems to be a problem regarding knockback. I use server authoritative movement and the knockback only works if player 1 attacks player 2. If player 2 attacks player 1, there is a small chance of knockback being applied but generally nothing happens.
in a normal setup the client players are kinematic rigidbodies
I tried changing it from dynamic to kinematic rigidbody but i still have the same problem
should i send the script?
that wasnt at all the point.. the server is automatically making dynamics to kinematic.. Do you know the difference between kinematic and dynamic ?
not really
should probably learn about that before even getting into networking, you can't just Apply Force from another RB to another if they are kinematic, they are not affcted by external forces
server is the only ones who process the dynamic collisions to keep things somewhat consistent across clients
physics isn't exactly trivial thing to get correct on net
make a thread in #1390346492019212368 if you want but imo, you need to learn more about these things before implementing physics in a netgame
alright, thanks
Can I use VS code debugger for unity?
haven't tried it myself, but ive heard of people doing so, so pretty sure you can, yeah
vs, vs code and rider have working debuggers for unity.
Unity will ask to re compile code in debug mode first time
I'm person who puts debug.log
Then congrats on advancing to real debugging
i set up the blend tree and the parameters like how Game Code Library showed. Here's my script. Why is it getting stuck, and how can I fix it?
FREE animation package on my Patreon!
Hi! This video shows an easy way to animate your 2D platformer character. We'll animate their Idle, Running and Jumping animations! We'll use a blend tree to keep the controller super clean.
We'll also be using blend trees to create the cleanest animator controller for your project.
I start off with th...
...ok... do you have a question
oh wait sorry i forgot
What's the speed set to in the Jumping state?
you mean the thresholds?
Nah when you have the state selected but i saw it's 1 in the video actually
your transition from Any State has "Can Transition To Self" enabled, so it's continuously restarting the jumping state
this is a code channel btw. for issues like this in the future, ask in #🏃┃animation
my bad
I’m building a city/building sim in Unity with around 50 buildings, each having an exterior in the main world and a separate interior.
What’s the best way to organize transitions between exterior ↔ interior at scale?
Specifically:
– How should I structure triggers and colliders for doors?
– Should interiors be separate scenes or prefabs loaded additively?
– What’s a clean way to manage building IDs so I’m not writing custom logic for every building?
I’m trying to avoid creating 50 unique scripts or messy scene setups. Looking for a scalable architecture approach.
should there be a loading seam when entering/exiting a building?
yeah the interior should prob be a separate scene
so the gpu doesn't try to render useless stuff
While that’s not technically incorrect that’s not really why you would make that decision
You don’t need separate scenes to avoid redundant rendering
Its possible to dynamically load in the interior content and unload it later
This is easier when using addressables but can still be done other ways
ok i was reading about addressables but im still trying to wrap my head around it, ill keep studying
am i braindead, or is this what you asked me to do
i swear, the damn ducks they are teleporting across the z axis as if they are on crack
is there a way to create a new spline in 2d, without any z component
What I want:-
- To use only 2D colliders for particle collision detection.
Problem I am facing:-
- The enemies which move across the spline are supposed to have their transform's z component as 0, instead, the z component keeps on changing continuously. Due to this, the 2d collision does not work as intended
I remember you asking about some duck thing ages ago
yes
wait, that was yesterday
oh wait, yeah, prolly, i am still working on the same game rn
This is not a code question.
oh ok sorry, my bad
I have some questions. How do I know what I should be making myself and what I should be using asset packs for? Like I cannot think of a reason why I would ever make my own RTS camera since a camera is a camera. The thought of programming complicated things I didn't need to scares me. Are there some kind of "asset packs" for scripting, perhaps slightly complicated sim economies based on resource collection and then expenditure on various things. I feel like this might have to be tied to the particular registry data system ur using so not sure how that would work. Perhaps the scripts come as a set time/registra data pack that has a sim economy built on top? I mean these are the essential kind of questions for me right now
I cannot think of a reason why I would ever make my own RTS camera since a camera is a camera
Except that... not every RTS game has the same camera behavior. Almost every game has some unique things in it or unique feel etc. \
perhaps slightly complicated sim economies based on resource collection and then expenditure on various things
Yes an economy simulation would certainly be something bespoke to your game you would write yourself
Theres also rarely any "complete game asset packs"
Even when you have "asset packs" or libraries, you will almost always be writing custom code to "glue" those things into your own game systems
Yeah you still need to understand how those systems work at the end of the day
you cant avoid that
Anything that claims to be a "complete game pack" is lying to you and is basically useless
unless the game you're making is just an asset flip reskin of an existing game that you have the project for , you're going to be writing your own custom code
Yea I was looking at it more like patchwork. Having at least an RTS camera and pre built grid and unit moving setup would be huge to expand on
You would probably want a full turn based system instead
U mean like a civ end turn button
No I think the parts you describe wont exist separately as you expect.
Unity already had grid components. Cinemachine is very versatile and moving units isn't super hard when you have a grid node system
For a beginner id then just suggest a larger pre made system if you want to go that route
Can't find anything like that beside maybe like topdown engine. But not even sure if that's something I'd even have use for. I must be looking in the wrong place. Is this all on itch io or private websites or something. Cinemachine I found and seems to be a cutscene maker but I don't think my game idea would even have cutscenes
that is not what cinemachine is...
The regular camera is bare bones. Cinemachine is a very robust camera. Same applies with the old Text vs Text Mesh Pro and old vs new Input system etc https://docs.unity3d.com/Packages/com.unity.cinemachine@3.1/manual/index.html
They're acceptable tools.. but lack certain QoL features.
I wish something in the tutorial said this stuff. I found cinemachine is even already in unity tools so I guess u can drag and drop it as a unity cam replacement. Do u have any tutorial videos that aren't the useless
Like a general unity tutorial that is actually good and can show me pre built starting systems etc
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I'm not on a workstation right now. Your best bet is to check the official Unity Learn. Select what you want and need but make certain to go over the basic intro setup-description for any of the tutorial groups you're going to use.
Its very well featured, it provides many ways to introduce advanced camera movement/framing and more
750 hour sheesh. This is really offtopic but do u guys think getting into this stuff is a bad use of my time? I am suppose to be looking for a new job after being laid off but Im technically not in a hurry or at risk of losing my living arrangement. I was trying to do a simple thing in Godot using my knowledge of Python but now it's all spiraled into an almost aching demand to make a particular game I want. Im not sure if it's a bad idea
I guess it would be a less pressing issue if I knew c# already or was familiar with unity
I dont think game development is ever a waste of time as a hobby
just dont go into it expecting much success, because it is quite rare
Financially every other job in the development field is probably a safer bet, but otherwise its really fun and you get to learn a lot.
Yea websites and stuff is where the developers are right? Tbh I was kind of shocked seeing how unreal engine discord only had 40k members. It felt like barely anyone even tries to make video games
not "websites" haha, SAAS mainly
It would take months to gain the knowledge needed to be hireable in this field. Just do it as a hobby
I mean I have enough money saved to be unemployed for like 3 years. Just not sure
Then if you want take a little bit of time to learn and experiment and make something to have on your portfolio
Industry is currently insanely competitive
Honestly years depending on region
Yea, I am lucky to have like 5+ experience professionally
Once you get the first job its easier but before that you can only rely on education or a strong portfolio
yups
Im still waiting to see one of those "common" remote work game-dev jobs every single person keeps asking about here 🙃
I started working with Unity in 2019 and still looking for first position (not to scare anyone off)
I think i started with 4.5
I havent even tried my luck professionally tbh, still in college but even with a degree i feel as if im better off just building up the portfolio first
Most places do not care about your degree at all
I'm surprised this field is even competitive. The truly fun parts of video games seem only a niche small part of the development
this field is competitive because of recent mass lay offs and an oversaturation of developers
basically you have 1000 people for every 1 position
There are an abundance of people deeply passionate about every single aspect of development
So companies will naturally gravitate towards the people who already worked in the industry and have experience
Then I have some tips. Make sure to learn source control like git and have some projects on github.
Make sure you know all major areas, dont ignore things like UI (UGUI and/or UITK) or particles or material set up.
If you want to do a dev/programmer position then do prep for the dumb coding questions you will get too
And just general way the world is going lol
portfolio review channel would be nice here
Dont worry, some rich ceo just got a 3.2 million dollar pay package for laying off 40 people
so all is better in the world in the long run
Lmao u guys are making me feel like I should be programming a nuclear sub radar system instead or something. Much less competition I would guess
If you wanna develop games
you should
we are just telling you that financial success is seldom achieved
so go in it with the expectation to have fun developing and learning, and not that it might make you a lot of money
something like 70% of all games released on steam last year made less than 100 bucks iirc
they didnt even recoup the 100$ deposit lol
Lol wtf there's no way that's even possible
I feel like the statistics that show game development success is rare are flawed. A lot of games hit success because they're actually fun, polished, and unique. Literally every game I've played that isn't is full of major issues, and they shouldn't be counted in stats that say "this has the same chance of success as ___"
Ill point out that unity is very widly used in mobile games and those cover many genres
That should put the sheer volume of game developers making games in perspective
Success is only really defined by sales
Good ideas and good execution = monayy
doesnt matter if your game is like the greatest game of all time
if it doesnt make money
its not successful
Yeah the quality & gameplay leads to that
And marketing
you would be surprised lol
Maybe I should just make a game stealing an American IP and release it on the China market
instant brand name product
Ive seen some absouletely garbage top the steam charts, while ive seen actual masterpieces get less than 100 players
Often times when people consider a game very good in gameplay, to me it just looks extremely complex which is probably why it didn't make it
Means those games probably aren’t all that garbage
Schedule 1 is very simple but extremely successful
You would think
But no....
your game can be super shit if it hits the right gameplay spot
Flappy bird. What a disgrace to human ingenuity
eg. Only Up
its more so accumulative hype that gets them where they are, they make the money
and then off to the next big thing
Nothing wrong with flappy bird
that guy is not only still a multi millionaire, he also cemented himself as a gaming cultural icon for decades
That was like the #1 app store game that was 1 week in game development 
Ok
It’s a cool little game
unique is a bit strong but yeah
Would rather more games like flappy bird than the current direction mobile gaming is going in
Some of the stuff featured on Apple Arcade is cool
Marketing, influencers etc. Certain games like Mega Bonk perhaps got lucky or were strategically aligned with media and blew up in popularity (although mainly momentarily)
https://www.pcgamer.com/games/roguelike/vampire-survivors-like-megabonk-makes-megabucks-selling-a-million-copies-in-2-weeks-and-currently-has-more-daily-players-than-borderlands-4-on-steam-ill-be-eating-spaghetti-with-extra-sauce-tonight/
there are sleeper gems for sure
but the more popular games are straight garbage
Yeah current mobile games are terrible but have very simple and understandable gameplay, which is why they thrive especially with the target audience
Mega Bonk didnt really get "lucky", it helps when a well known online personality is behind a game
its free marketing
its also generally received as a fun game
What is modern mobile like I don't play those games. I'm guessing gone are the days of subway surface. I thought that one was very good
Subway surfer
I'm pretty sure subway surfer is still very popular
gambling™
But yeah don't bother trying to make a mass market free to play mobile game, if you want to make any money
that field is wayy too saturated
especially if it's a skinner box
I will explode every game with gacha mechanics with my mind
Tbh... if you can get someone popular to play it, I'm pretty sure you'll get tons of their audience to play/hear-of it 😉
Yes I imagine the current method of game advertising is tricking some streamer into playing their game
I'd say a good way to make money is creating simple games (Quality, environment) but with great replayability and unique gameplay
gorilla tag & schedule 1 are prime examples of non-complex games, but they're so simple it's basically impossible to not understand, and I don't see the games ever not reaching success
I think we are going a bit off topic here atp
and marketing it well like getting streamers/gamers to play your game, and having good social media reach
oh wait this is coding chat
lol
Made me lol out loud
A good way to make money is to write accounting software. If you want to make money making a video game is the worst thing to do with programming skills.
Make games because you want to make games. You might be successful, but probably won't. This isn't a get rich quick scheme.
As a mobile dev in a company currently marketing a free to play game, you need money to make money, without atleast monthly 10k in advertising + once 10k for sampling usergroups you can't even really start to advertise and 100% ROI is usually only reached >30d in, so you dont get enough money back quick enough to reinvest, so expect to have atleast 4x that in the bank account to start off
Does anyone know of a solution that could fix this kind of bug?
Basically wats happening in the video is that you can put the boxes into one another and when doing so the script thinks your inside a wall so it stops the movement script. I made it like this to prevent weird glitchy movements inside the walls but in doing so it made the boxes glitch out if they went inside eachother like in the video. I've tried implementing systems where if the box collides with something it'll go back to its last known position but I can't seem to get it to work so hopefully someone here can help me with this ty.
!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.
What do you want to happen when the boxes collide?
I just want them to not glitch inside eachother
and the way my movement script is setup the movement system stops working becuase their inside eachother
I jus don't want them to go through eachother. I want them to act like walls
yes, so.. collide with each other
ye
do they have colliders?
ye
and rigidbodies?
ye
looks like you're moving via transform anyway, so it doesn't matter
ye plus the movement has a animation type movement which is prob the main issue with y they glitch into eachother
its not an actual animation its an IEnumerator
private IEnumerator MovePlayer(Vector3 direction)
{
if (CheckForCollision(direction))
{
yield break;
}
isMoving = true;
AudioSource audio = GetComponent<AudioSource>();
if (audio != null && moveCrate != null)
{
audio.outputAudioMixerGroup = sfxMixerGroup;
audio.clip = moveCrate;
audio.PlayOneShot(moveCrate);
}
float elapsedTime = 0;
origPos = transform.position;
targetPos = origPos + direction;
while (elapsedTime < timeToMove)
{
transform.position = Vector3.Lerp(origPos, targetPos, (elapsedTime / timeToMove));
elapsedTime += Time.deltaTime;
yield return null;
}
transform.position = targetPos;
isMoving = false;
}
can you share code the proper way, using a paste site like the bot msg you've read told you to
however you check for walls , do the same for crates
i used the last link
cause the others didn't work
you didnt use anything you just send a .txt
this is not the proper way to share code here
thats wat the last website did when I put the code in
a powerful website for storing and sharing text and code snippets. completely free and open source.
this is the website I used and put my code in. Clicked create paste it did stuff then I clicked copy
now copy the url...
.... so you copied your code... pasted it, then copied it again and pasted it here
what do you think that did....
😅
mb
a powerful website for storing and sharing text and code snippets. completely free and open source.
does that work?
you can test that and see for yourself it does ;p
I'm not rly used to sharing large scripts so mb
you need to debug as to why the crateTag isn't being caught
Well I believe the reason is to why they get glitched into eachother is that they both are moving but once the movement starts it can't be cancelled and so they end up inside eachother and that triggers the collision detection and so that ends up disabling the movement altogether
do not "believe" something, test and confirm ..
you go into MovePlayer coroutine -> check collision -> if wall, movement ends
That is also what should be happening for the crate, but it's not .. debug it and find out why.
also check the crates are tagged correctly (case matters; crate != Crate)
that's not very useful is it
XD
log out the tags
Alrighty, Im here.
k, now which errors?
FPS Controller
We need to know the Errors in question
Ok gimme a min ima do somthin first.
Lets not encourage screenshots of text
Haha, good luck everyone. May your phsycic powers be of use
XD
😆
@versed cove ```using UnityEngine;
using UnityEngine.InputSystem;
public class MovingNewInputSystem : MonoBehaviour
{
public float mouseSensitivity = 1f;
private float xRotation = 0f;
private float yRotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Vector3 angles = transform.eulerAngles;
xRotation = angles.x;
yRotation = angles.y;
}
void Update()
{
Vector2 mouseDelta = Vector2.zero;
if (Mouse.current != null)
{
mouseDelta = Mouse.current.delta.ReadValue();
}
float mouseX = mouseDelta.x * mouseSensitivity;
float mouseY = mouseDelta.y * mouseSensitivity;
yRotation += mouseX;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.rotation = Quaternion.Euler(xRotation, yRotation, 0f);
}
}
Perhaps i should copy it or smth. But, what about Project Settings of Player?
this is not about you...
this is another convo entirely
pls tell us your errors
Just wait a min
you're clamping the x rot .. why?
well, so you don't do a 360° rotation
Its better to rotate your "player" on y and the camera on x
that too
I only have a camera
this should work fine then tbh
just be wary of getting the initial rotation like that as it will be in the 0-360 range
ive had funky bullshit thanks to that (as yes its much easier to work in -180 > 180 when doing such mouse input)
@naive pawn
oh god the convo's crossposted
and im trying to have a convo with sidia, this is not viable on mobile lmao hold on
solve this first and ping me when you are done with that 😄
im busy for another 5 min anyways
ah welp i suspected mousedelta * deltatime, nice to not see that for a change i guess
Just as a quick thing, if you are doing any calculations that move stuff or anything in update, always factor in Time.deltaTime
uhh wait, am i getting this wrong here? xD
things in update should be in units of x per frame
I heard I shouldnt do that
when you have eg speed, that's in units of x per second
multiplying by deltatime turns that into x per frame
but mouse delta is already in x per frame
ah right, mouse delta will adjust anyways if you have constant mouse speed, right, yeah wrong thought there
so ye pretty much I've come to the conclusion that its the weird animation effect I have with the boxes. Which I kinda already suspected and i don't rly know how to debug for it aka jus knowing that its the animation. But heres a video of me doing the bug rly easily which its jus me holding down the s and w key and they glitch into eachother
also it gets fixed if i un tick the freeze position x and y but then I get another bug which makes the crates go off the grid and may end up breaking the game more
ik its kinda hard to see in the video but thats basically what happens, the boxes going off the grid
you talk about "animation", but there's nothing in the shared code using that word, so.. clear that up
ye I jus say animation because the way the boxes move is in my mind an animation but of course its not and i jus don't know wat else to call it. Maybe jus like a movement effect ig
..movement 😄
then you're not confusing terms, as unity has animation and an animation component, etc.
yee
what's the current issue? the boxes moving into the same cell/tile?
lowk a solution I have in mind for the bug I have is that if ur boxes do get stuck it jus auto resets the level but thats not rly ideal but I'm just not that advanced in code to think of something else
ah, damn.. I removed vscode from my mac because it's too old to run it. Was going to tidy up your code
you can keep using previous versions and just turn off autoupdate
(i had a 2012 mac running mojave because i didn't feel like using catalina that i used up to 2 years ago)
I cba with that, I don't use my mac for any dev
pretty much. They get stuck inside eachother and when that happens my movement script disables the boxes movement script so they can no longer move
your collision check for walls and crates is at the same time and is BEFORE the movement. I think you're wrong in your assumption at the issue.
yeah it seems like they're just moving to the same "empty" cell at the same time
you should calculate the final position of the previous move
and use that to calculate the collision of the new move
is that not what they're currently doing...
that's... an interesting way make a "grid", i guess
ngl if I did check for collisions before moving, it wouldn't rly do anything since the collision check is on the crate thats moving so by the time the crate begins moving it will detect the box thats in the detection zone and it wouldn't cancel the movement so they get stuck
what should happen? should one crate enter the cell arbitrarily, or should both cancel, or something else?
you could probably make them detect collision with each other and kinda "bounce back" pretty easily, if that's what you want 
one crate goes into the cell while the other stays in its position and doesn't move
The first thing you do in the MovePlayer coroutine is to call the CheckForCollision
```cs
private IEnumerator MovePlayer(Vector3 direction)
{
if (CheckForCollision(direction))
{
yield break;
}
thats kinda wat it was like when I first had the script but then changed it cause they would get put off the grid cells I wanted them to be on
one solution i see would be to have a levelmanager that maintains a dict over Vector2Ints for what tiles are occupied, and when crates move they would "claim" the tile they're moving to. you would need a stronger notion of tiles though
then you didn't implement it well while keeping grid cells in mind
I already had that.
private IEnumerator MovePlayer(Vector3 direction)
{
if (CheckForCollision(direction))
{
Debug.Log("Movement blocked due to collision in direction: " + direction);
yield break;
}
isMoving = true;
AudioSource audio = GetComponent<AudioSource>();
if (audio != null && moveCrate != null)
{
audio.outputAudioMixerGroup = sfxMixerGroup;
audio.clip = moveCrate;
audio.PlayOneShot(moveCrate);
}
float elapsedTime = 0;
origPos = transform.position;
targetPos = origPos + direction;
while (elapsedTime < timeToMove)
{
transform.position = Vector3.Lerp(origPos, targetPos, (elapsedTime / timeToMove));
elapsedTime += Time.deltaTime;
yield return null;
}
transform.position = targetPos;
isMoving = false;
}
already had what..?
if (CheckForCollision(direction))
{
yield break;
}
check for collision is done on the crate that is still on the previous "grid" space, no?
if you do it fast i mean
I know.. I'm telling you that it's done before movement and you said it isn't.
you could have a "cancel" flag that when set makes MovePlayer move back to origPos which you've already set
ah mb
which is why I said that is what you are doing, and didn't word it as a suggestion.
heyyy wait these crates have a collider and potentially also an rb? you shouldn't be moving via the transform then
ahh ok
ye they have both
You're using raycasts for detection, rb can be removed, just have one on your bullets
then you should be moving via the rb, not the transform
normally the x and y are frozen but I have them unfozzen for testing
you should still use the rb to move the colliders, otherwise they get recreated in the physics scene every time you move
Yeah, ok fair enough, especially when you couple that with all the GetComponents happening all the time in this code
Really wanna make sure to have that AudioSource
ngl I'm so confused XD... So if I use rb as the movement it would fix the issue?
instead of transform
That one single change will not necessarily be the only thing required
But a step towards it
i don't think this would fix the issue at hand, i don't think it would change anything related to the issue at hand
but it would be more correct and more reliable and easier to work with
eg if you wanted to make this, this would rely on collisions between crates, and it most likely just would not work correctly at all if the colliders were desynced.
how would I even implement rb as movement instead of transform?
the current code would map closest to MovePosition on kinematic rbs
(though, that wouldn't have collision between crates)
I've got some errors