#π»βcode-beginner
1 messages Β· Page 416 of 1
me neither, bookmark is a pretty common word on the internet world..
not in the places iΒ΄ve been for what it seems
yeah im sure no one uses bookmark where you're from
i dont mean in my country i mean in the places ive been on the internet
for example game-forums or in game chats arent usually a place where the word bookmark is used
havent seen someone use it in a league game
alright lets move on cause thats just stupid.. its literally built into your browser..
what is your code issue ?
i want to compare the vector2.dot for each vector2 in the array with the mouse direction vector, so i know which one is the one that fits the most
but i cant think of a way to do that without making it a living hell to write with lots of random variables that would just be for that precise thing and i wont use again
and iΒ΄ve been thinking for an optimal way(or atleast one that isnt bad) and cant think of it
what exactly is the end goal here , what are you trying to use it for
i want to make a dash towards the enemies
let me represent it with a paint so its easier to see
yes
btw Vector3.dot returns the value of the operation
im in 2d
same thing
i basically have each enemy with a child that is just a bigger trigger collider,
but for example in this case im most looking at the last one, but if i just make it a simple raycast without comparing it would launch at the first one
giving an unpredictable and not pleasing result
i dont know if i explained myself
Hello guys! Is there anyone here who would like to introduce me into game dev?
isnt this suposted to hide the other 2 maps?
!learn
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
you have a pretty big error down there where it says "Projects"
might have to do a Generate Project Files in External Tools page in unity
Thank
this is just a recommendation, but when you finish the learning procces dont try to make a big game, go for arcades or small scope games
because the learning procces never ends
so you want to dash towards the one you're looking the most even if its further than the closest ?
exactly
you could probably just use vector2.angle as well
i would need to look into what that is
but dot should be fine too
but i think i would run into the same problem where i would need 300 lines for checking which one is closest to it
maybe
foreach (Collider2D collider in colliders)
{
var directionToCollider = (collider.transform.position - playerPosition).normalized;
var dotProduct = Vector2.Dot(playerDirection, directionToCollider);
if (dotProduct > highestDotProduct)
{
highestDotProduct = dotProduct;
bestCollider = collider;
}
}
return bestCollider;```
i would need to look what return does exactly because i only have a vague idea but it seems fine
only 1 thing
the collider changes with each foreach loop?
i guess so because if not it wouldnt make sense
this just assume the function returns a Collider2D forgot to add that
but you can easily just store the bestCollider at script level too
names are inconsequential also
script level?
yes a field
oh okay
not a local variable from a function/ loop
yes yes
okay
imma try that because it seems to make sense
btw
idk how much a game scales, but how many raycast would cause lag?
because im scared and im only using like 10 rn
raycast are quite performant
i imagine
but, if i scale the game, and spawn lets say 10 enemies, each with 5 raycast, it would be 50 casts
Overlaps and things that return multiple of something you should opt in for the Fixed version
aka nonalloc
but it can get worse
i made it nonalloc i think
thats peasant numbers lol
i imagine
but like
10k is a lot of raycasts?
or is it like
average?
how much would be considered a lot
because im scared of using even more than 20 per script
i suppose
but im scared that it gets to laggy from one day to another
lmao
ofc everything you do has impacts but rays in not something I'd be most concerned performance drops from
okay
ty navarone!
hope everything is going well
ill report back if i somehow mess up
I haven't tested but it should work, I will try it as soon as back to see if didn't miss anything
imma test it rn np
which one? lol
I havent tested it but it should work
navarone do you ever take a break? i was last on here months ago and you were ther still
keyword *should *
im not here that often
your brain must be big brain now
fr he be helping me make half my games
This IS a break πΈ
literally me steaming off my crap going on
let me help these childrens so i can relax
and what about doing a 2D indie game?
thats ideal
i started w/ 3D b/c i actually find it easier and more intuitive than 2D
but it is more work in the long run imo
for a plane mesh used for water. does it need to be discrete or might having shared vertices work better for that?
you can do fun arcade indie games, it teaches lots of things, like working around a mechanic, having a good scope, quality over quantity, game loops, and so on
you can do either 2d or 3d imo, the only thing you should look out for is to not trying to make overwhelming games, start low and easy
as i said, this is just what i think is the best option, you are free of doing however you find it more suitable
Don't understand what I am doing wrong. Why would this not set the MarkerPanel/Text in this way?
private void SetPathMarkersAlongPath()
{
foreach (GameObject marker in pathMarkers)
{
Destroy(marker);
MarkerPanelUI.SetActive(false);
}
pathMarkers.Clear();
foreach (OverlayTile tile in path)
{
GameObject marker = Instantiate(PathMarker, tile.transform.position, Quaternion.identity);
pathMarkers.Add(marker);
if (tile == EndPathTile)
{
MarkerTurnText = marker.GetComponentInChildren<TMPro.TMP_Text>(); <--- Here
MarkerPanelUI = marker.transform.Find("Panel").gameObject; <--- Here
MarkerPanelUI.SetActive(true);
marker.GetComponent<SpriteRenderer>().color = PathMarkerColor;
MarkerTurnText.text = path.Count.ToString();
}
}
}
My goal in starting learn game dev, is to make my own game
As it's a dream since very young
Have you tried using Debug.Log to see if and when the code is actually running?
making your own game is good, but just think that it will probably not be possible to make your dream game as your first game
probably more depending on how big it is
but you will feel it once you have a feel for how big games are, and how hard it is to do them as a solo developer
https://pst.innomi.net/paste/qf3u2utv569dozh3w5gzyp7b i followed a tutorial for flappy bird and this part is spawning pipes but i dont realy get how the gap calculation works and why can someone explain please
Yes, even used Debug.Log("End Path Tile: " + (EndPathTile == path.Last())); To verifiy the tiles are indeed the same. End Path Tile: True
Do you have made big games before?
nope, im myself a starter developer
it makes sure it has a specific gap inbetween
i made an arcadelike-game but i wouldnt even consider it a game
wow really
but i dont get how the calculation works
Ok I see
break it down into smaller parts
the code is messy in the first place
how is it messy
well not messy exactly, just lacks comments not everything is clear right away tbh.
oh
camOrthoSize * 2f - gapY - gapSize * .5f, xPos, false scary line of code π
its not too bad tho, since its small, and the function definition is directly below it
its totally possible.. albeit it might be a really really long time before release ready
is there a way to break 2 statements with 1 break?
whats ur starting code?
i have a forloop inside an if
can i break the forloop with a break inside the if
That would be pretty fast, but definitely doable as long as the scope isn't too much
wait no
which if ?
this if is inside the forloop
yes you can use if to break inside for loop
if >forloop >if
can i break the first if with a break in the 2nd?
like double break?
what
or should i do something like goto?
lmao i was gonna say goto as a troll comment π
what are you trying to do exactly
lmao
ya, i wish i could see the entire code block so i can wrap my head around it
did the dash thing work?
im on the proccess
fixing some other things related (this is one of them)
basically the raycast detects enemies and walls, so it can break if it hits a wall and take the enemies closer than the wall
if(condition)
{
forloop
{
if(secondcondition)
{
// you want a break here? [1]
}
}
// that would skip this? [2]
}```
indeed
maybe someone knows.. but thats more complex than anything ive done thusfar
if you want to skip the rest you need a return
could u use a flag u set true when u first break? that returns later on?
i see
true..
if its a wall i dont want it to be considered as a possible objective, and neither any ongoing objects that are further away than the wall (behind it)
if you only want to seek enemy colliders user layermasks
yes, but then it would consider even the ones that are behind a wall if the raycast hits
thats how i do it..
true
if u find an enemy behind a wall
then raycast a regular cast to see if its obstructed
then put the enemies behind a component if statement
so my idea was to include walls, and whenever it reaches a wall, to break the loop that goes throught the iterations
no just filter out the walls
its ok to grab solid colliders, but an additional if statement in loop
hm im understanding what you mean but im not wrapping my head completely around the idea
could you elaborate a bit pls
instead of breaking you want to continue
if(!longDashHitsArray[i].collider.TryGetComponent(out Enemy enemy)) continue
this will skip doing anything below
anything below in the same if or forloop or whatever right?
not like the whole function
In the loop
the surrounding loop
oh thats why the ! at the start
not.. yea
yes its same as == false
yes ik
but i was thinking like you want that and if that is true to procced
but no, the continue skips if not true
which makes sense
if its not enemy then skip this iteration
my favorite kinda code questions
why is that so? if i may ask
Best to always lookup the docs after learning something to acknowledge and thoroughly understand it
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/jump-statements#the-continue-statement
but then i would still get the enemies that are after the wall right?
yea but i still dont understand how that works tho
oh wait
i write it b4 the debug.log(bestObjective.gameObject.name);
so it skips in that moment
or maybe i just found a different solution
RaycastNonAlloc still captures the walls
but now you're filtering further via if statement component check
if u find another solution i'd love to hear what u came up with π
i basically check the layer/tag/whatever identifier, and if its an enemy i use the debug.log in line 25
(which will not be a debug.log later on)
so its the same but inverse
i think
that makes no sense why would you only be checking dot on 1 then breaking
yeah
wait that wouldnt work, because in case the wall is the bestObjective, even if there is a good objective, it wont take it into account because it will take the wall as bestObjective and not work because of the if statement
yes bestObjective would never be a wall if you put that filter i told you about
component is the best method imo, but ofc layers work too
component is literally the script you use with enemey
btw is there a way to have multiple colliders in a gameobject, my solution is to create a child and give it a collider, but i havent tried having 2 colliders on the same object
whats scared about it
they both work
u can.. just adjust their center and size parameters
the Enemy enemy confuses me a bit
pog
then imma just remove the child and give it another trigger collider
Enemy is the <Type> and enemy is just a name of the reference.. could be anything
and what type is enemy?
it is the same as writing
MyScript myEnemey = collider.GetComponent<MyScript>();
if(myEnemy != null)
//do stuff```
out MyScript referenceOfScript
it could be anything
ur just checking if that gameobject has a certain script/component
and if there is one u get the reference as the out
and the bool becomes try
thats what i use for my attack https://gdl.space/jutemobayo.cs
TryGetComponent returns a bool but out is the result if true
i was just using it unsconciously lmao
that happens sometimes π
always has been π§βπ π« π§βπ
gotta stay sane somehow
im more artist than coder.. so i guess im okay π
both are good
what kinda game u making btw?
but my artist friend told me that he is scared of programmers, because they are like sisyphus, since no one valorates their work
i dont know how to categorize it
but i would say like a dungeon crawler mixed with hotline miami or katana 0
well, good luck anyway π π
ty!
i want it to be adungeon crawler but with the high activity of hotline miami and the cool parrys and dash like katana 0
or something like that
weird mix i think
unique is good
just keep learning, if u get stuck take a break re-evaluate and get back at it later
learning + developing at the same time can be very organic.. and u can end up w/ something even better than u started w/
i will, i have a complicated situation right now since i am travelling a lot because of work (being a teenager is like being a slave) but it helps me keeping my mind fresh for when i have time to work on my project
Yes probably I know, but gonna also learn along the way I developp my game, no ?
true.. focused practice
if u practice bad habits.. u just get good at bad habits π«
btw this is what we were talking about earlier right?
if(BestObjective.GetComponent<EnemyMovementScript>() != null)
{
Debug.Log(BestObjective.gameObject.name);
}
ohhhh
i understand
but i think this also works
and since i dont need the component for anything besides checking if its true imma rock with this
Well yeah, that was of course assumed.
trygets are actually preferred over this.. even if u dont use the component
it depends on what issue u were having
if (currentHealth = deathvalue)
{
Destroy(this.gameObject);
}
its telling me i cant do int into a bool asnyone got a fix?
Why are you trying to set currentHealth to deathValue
can you send me some screenshots of the game you are making? (in case you are doing one)
== is the correct comparison
hey nav how could i get it to stop lerping entirely once its at the target position? it seems to always be doing it after i pick it up
jittering that is, not still lerping
yes it was with you, i remember the floating car
spawn camp games you are the goat!
whats jittering?
if( distance < a thrshold){snap it to 1)
sounds kinda sus lerping to me if its jittering
oh, i just noticed, you already know all this stuff
yea one sec, i stepped away for a sec ill send a vid
i feel like it only enables the lerp or movement when its "used" or has been touched. Soon everything thats pick upable is gonna be jittery
My game is crashing everytime I ender play mode
Must be an infinite loop
Does it actually crash or freeze?
freeze... I just wrote a while loops
Yep, sounds like an infinite loop
You need to make sure that the condition is changing during the loop execution
increment isWaveGoing up by something until it goes over 1
im brand new to coding im not 100% sure what that means
While loops are pretty hard to use if your unsure how they work, I still dont use them for that reason lol
Then perhaps go over the C# basics and/or beginner pathways on unity !learn.
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
Im trying to get an enemy to spawn every 2 seconds is there a betterway to do that?
a timer, or coroutine
I wish there was something like wait(4); rather than having to mess with coroutines
what is a coroutines π
That's what you can do inside of a coroutine
try a timer using delta time, but its better to learn the pattern
Making it possible outside of a coroutine would basically require changing the whole language and no one would appreciate that
dlich i need ur help bigdog106
so should I use a timer or a cororoutine?
coroutine
Trying to understand what the issue is in the video. What should I be looking at?
Alright ill try to learn it
Yes sure. And I'm not planning to be alone in all my journey
Just until I find a good partner on the way
You seem to be taking what I said as discouragement. It was not meant to be...
As I said, it is definitely doable
make sure you don't ever destroy the object your coroutine's script is a component of. took me ages to figure out why my coroutine was never ending and it was because i was destroying the object before it finished executing
https://pst.innomi.net/paste/qf3u2utv569dozh3w5gzyp7b i followed a tutorial for flappybird and i get how the gap calculation works but i dont get why it works and why those values work can someone explain
Specifically what part do you not understand?
does anybody know how can I attach left lower arm to the weapon too but I dont want it to affect it physically.Or I can completely change the way I position sword. I use this script to rotate shoulder and elbows(elbows are only rotated when weapons are one handed)https://hatebin.com/rzpasthrvj. I tried to make weapons follow mouse cursor but couldnt.So if you know any solutions for one of these problems help pls.
some people suggested inverse kinematics but even if I watched tutorials I couldnt implement in for this character.
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.ProfilerWindow.SaveViewSettings ()
IConnectionState was not Disposed! Please make sure to call Dispose in OnDisable of the EditorWindow in which it was used.
UnityEditor.Networking.PlayerConnection.GeneralConnectionState:Finalize ()
I got these two errors ive never seen before, and cant get rid of. I undid all the scripts past the last point of testing so im not sure what this is
i dont get why subtracting half of the size of the gap from the y of the gap gives a size for the pipe (hoop in my case)
How do i turn off when I let of of the movement key the player moves slightly i want him to stop imediatly
rigidbody ?
you can slow the velocity to your liking or set to 0, you can also increase the drag up a bit you would have to bump move speed too
I don't know the intention behind the code,but I can assume that gapY is the position of the center of the gap, and gapSize is obviously the size of the gap. Subtracting half of the gap size from its center would give you the position where a bottom pipe would start.
wouldnt that just give you the bottom of the gap
Yes. And the bottom of the gap is where the bottom pipe starts, is it not?
I'd assume it has to do with inverting the sprite. Not entirely sure. Hard to say without having access to the whole project and seeing the pivots and stuff.
its for the bottom pipe tho and its for the height so i dont get how it returns the height between the bottom of the gap and the bottom of the camera
i would think it would give you the distance from the center of the gap to the bottom of the gap
o nvm i understnad now thx
Hey guys, I know this is probably a pretty simple and elementary question but I've been completely stuck on this issue for the past couple of hours. My platformer game has three levels, and each level has 3 - 4 different rooms. I have created each room as a seperate scene and added all of them to the build settings. Then, I created a scriptable object in C# called LevelSO which just has [SerializeField] List<Object> rooms = new List<Object>();, and added the room scenes for each level to their own scriptable object. Finally, I created another scriptable object in C# called LevelListSO with a [SerializeField] List<LevelSO> levels = new List<LevelSO>(); , and added my three LevelSO scriptable objects to it. In my game manager script, I want to:
- Get the levels[index]
- Get the buildIndex of the first room room[0] of the selected level
- Load the first room.
How would I go about doing this? Is this possible? If not, what's the correct way of implementing the functionality I desire?
Please let me know if you need the scripts themselves.
where is the code question ?
yes use a game manager
I have a game manager
I'm trying to figure out how to use it correctly
in what way?
#β¨βvfx-and-particles probably
I'm trying to rotate my gameObject on its z axis based on the direction it traveling from the player. So if the position is left, i want it rotating to the left.
The problem is im setting the target position after it gets spawned, and it seems to always to default to left.
if (targetEnemy != null)
{
Vector3 directionToEnemy = targetEnemy.transform.position - Player.Instance.transform.position;
float dot = Vector3.Dot(directionToEnemy, Player.Instance.transform.position);
rotationSpeed = (dot < 0) ? 360f : -360f;
transform.Rotate(new Vector3(0, 0, rotationSpeed * Time.deltaTime));
}
is where I'm at now, but it seems be choosing a rotation at random honestly. Any help or direction would be great.
Currently these are my scripts that I explained in my message above. I know I'm not doing it correctly because of this error message relating to LevelSO.cs line 18 ||" 'Object' does not contain a definition for 'buildIndex' and no accessible extension method 'buildIndex' accepting a first argument of type 'Object' could be found "|| but I have been tirelessly trying any change I can think of the past few hours to implement this functionality and can't !code
!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.
ah okay, sorry about that
well your rotation speed is always 360 or -360. So itll have to choose one, if the dot is 0 itll still be -360
you should not name a class Object
thats already 2 specific base classes that exist
UnityEngine.Object and System.Object
using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public struct LevelData
{
public string sceneName;
public List<string> roomSceneNameList;
}
public class SceneManager : MonoBehaviour
{
[SerializeField] private LevelData _levelData =new();
}
maybe u can try something like this
I've tried a lot of other ways of getting the direction to the enemy position, and had never come across the Dot function before so was trying it.
it says 0 is only when the objects are perpendicular, which shouldn't happen that often with the random spawning, but maybe that is the issue.
would there be a simpler way of figuring out if an object's destination if going to be traveling -/+ on the x axis?
So how would I make a list of Scenes? if I use [SerializeField] List<Scene> then the elements of the array show up blank in the inspector with no way to drag on a scene
u can use string if u eant
want
I'm not familiar with structs yet. How should I go about implementing this
Try not to use reserved class names. Unity already has a struct named Scene
Thanks I figured it out I needed to use GetInputRaw instead of GetInput
thanks for the info. that looks very useful, although the only thing I'm not sure about is that it says on the page that you can only access a scene reference if the scene is loaded?
so does that mean I can only access the current scene?
okay, i think i found out where i was wrong lol. I was using my player's transform.position for the Dot method, but using the player.transform.right has it rotating in the way i expected it to.
pretty sure a scene can be accesible as long as it is in the build settings and is enabled
Alright then I think the plugin should work. I'll install it and follow up with you about how it goes shortly. Thanks!
struct is just a different version of class and if u use the code it will give u something like this in inspector where it lets u to put in the scene name and the list of room it have where u can access it later
u might want a list/array of level data tho instead of just one
well better approach might be having serialized dictionary of level dictionary where u have the scne as key and list of room scene as value
https://assetstore.unity.com/packages/tools/utilities/serialized-dictionary-243052 using something like this
I am working on a fishing game and I would like to implement a system of animations that looks like Roblox fishing sim (You can cast the rod and still move around) I already have movement sussed and it just runs off a blend tree like so:
I don't really know what to do next. Any Idea what I sould do?
Here is my controller script and what is the begining of the fishing logic
@echo hamlet Please don't crosspost. You can leave your question here.
I'm not sure if I should have posted my question in this channel instead but I posted something in #βοΈβeditor-extensions message that might maybe belong here instead.
Additional question:
I'm following a tutorial and have noticed that his code does not contain the "0 references" indicators. Is that just a setting one can turn on and off?
yes it is
Thanks.
@young warren
(In reference to the help/answer you gave me here #βοΈβeditor-extensions message so we can continue in the proper channel)
I already followed the steps there previously to asking my Q but that's exactly the issue: Having the Visual Studio Code set as my External Script Editor and having the Visual Studio Editor's package installed in the Package Manager did not resolve the issue and I'm unsure how to proceed. Everything it up to date.
I've also tried deleting the scripts, closing everything, and reopening everything
Anyone know of anything else I can try to get my IDE to autocomplete code if those steps did not work?
I've got 3 questions right now:
- The above question.
2. How does one post code here in that easy-to-view format that others were using before my comments?(Q2 answered) - I completed code that should have shown a grid of "rooms" appearing on my Scene window but the rooms did not appear. Assuming everything was coded correctly, what else could be the issue? (I did not have any compiling error messages in Unity, Unity loaded the new code fine, and I was copying a tutorial's code).
Below is my code and a photo of what I *should * be seeing in my Scene (but am not):
- !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.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RoomManager : MonoBehaviour
{
[SerializeField] GameObject roomPrefab;
[SerializeField] private int maxRooms = 15;
[SerializeField] private int minRooms = 10;
int roomWidth = 20;
int roomHeight = 12;
int gridSizeX = 10;
int gridSizeY = 10;
private List<GameObject> roomObjects = new List<GameObject>();
private int[,] roomGrid;
private int roomCount;
private void Start()
{
roomGrid = new int[gridSizeX, gridSizeY];
}
private Vector2Int GetPositionFromGridIndex(Vector2Int gridIndex)
{
int gridX = gridIndex.x;
int gridY = gridIndex.y;
return new Vector2Int(roomWidth * (gridX - gridSizeX / 2),
roomHeight * (gridY - gridSizeY / 2));
}
private void OnDrawGizmos()
{
Color gizmoColor = new Color(0, 1, 1, 0.05f);
OnDrawGizmos.color = gizmoColor;
for (int x = 0; x < gridSizeX; x++)
{
for (int y = 0; y < gridSizeY; y++)
{
Vector2Int position = GetPositionFromGridIndex(new Vector2Int(x, y));
Gizmos.DrawWireCube(new Vector3(position.x, position.y), new Vector3(roomWidth, roomHeight, 1));
}
}
}
}
To further clarify what my Scene is showing: It's just the single white Camera rectangle.
Do I need to be using ".NET SDKs?"
where to get knowledge and hlep about assets?
do not cross post
im flabbergasted
it should rotate on the z axis right?
by "angle"
that angle is the same angle that the rigid body turns
problem
it only rotates if i click fast enough???
what is going on??
and even then it doesnt rotate right
the first row is supposed to be me clicking in bigger invervals and the big smorgasboard in the middle is me clicking rapidly
you can see it rotates SOMETIMES
@winter tinsel how can i make a clicker game
do not ask me lol i am near beginner
i suggest game makers toolkit
he has a really good unity starter tutorial
can i get the link
overall the channel is useful
Ehh, sounds like a different issue
Perhaps share the whole file
the whole code file?
If possible, prevents unneeded lack of context
Please use a paste site for 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.
ok done, do i just paste the link?
float angle = Mathf.Atan2(look.y, look.x) * Mathf.Rad2Deg - 90;
transform.Rotate(0, 0, angle);
you are rotating by that amount but that should be the current angle.
also if the object faces up when not rotated at all you can just set transform.up to look, or if it faces right when not rotated you'd assign to transform.right, no need for that extra math.
also you could just use the (targetPosition - currentPosition) as the direction from this object to the target rather than the InverseTransformPoint call
thats not the problem
the problem is in the instantiate code
the last argument just wont work
the one that calls the rotation
it "works"
but only if i click fast enough??
well for starters, is there a reason that you are using Unity.Mathematics.quaternion instead of just UnityEngine.Quaternion? (not that it would make much difference, but like why are you doing that)
to jsut match the "transform.Rotate(0, 0, angle)"
cause then it should be the same thing, a rotation around the z axis
unless theres some difference between degree rotation and euler angles
that's not what i asked but okay
the reason is so i can simplify it for myself by just doing the same thing
also
that doesn't answer the question i actually asked
i dont understand quaternions lol
but it is inconsequential. so since you clearly don't understand what i asked don't worry about it
but just try what i first suggested and use transform.rotation instead of creating a quaternion from that angle you calculated (since it isn't going to actually match the rotation of the ship for the reason i already pointed out)
ok so the position of the projectile - the position of the target is a vector2 right?
it's a Vector3
but you're not getting the position of the projectile. you're using the position of the ship, no? becuase this is the "shipscript"
yes but look in the instantiate code
the position of the projectile will be equal to the position of the ship
thats where it starts
then i need the right rotation (towards the mouse) and add the speed
your entire issue is that your ship is not rotated the way you expect it is
yes
the ship rotates fine
when i try to use the same code of the ship
for the projectile
things get whacky
i changed the sprite of the projectile to the ship for troubleshooting
quaternion.EulerXYZ(0, 0, angle) this does not produce the same rotation that your ship is at because you are not rotating the ship correctly. you rotate by the angle rather than setting the ships current rotation to the angle
so fix the ship's rotation like i suggested then you just use transform.rotation as the rotation for the instantiated object
the BEST way to make a ground check in unity2d? raycast? ontriggerstay? physics2d.overlapcircle? i dont know which one to choose
there's hardly ever a "best" way to do something. but physics queries like raycasts and overlapcircles are going to be better/more reliable than trigger messages
i guess ill just use raycast
note that a raycast has no volume so if you only raycast from the center of the object straight down it will only be considered grounded if the exact center of the object is over ground, so if the center is just ever so slightly off the ground, but you still have a decent amount of surface area touching ground it won't actually be considered grounded. you could use more than one raycast, or some cast with volume
or if that behavior is perfectly acceptable then a single raycast would be fine
I recall seeing in some projects that people have all of their script variables organized into neat sections in the editor. How do they do that?
i.e.
Movement:
speed
velocity
custom inspectors or attributes like Header, Space, etc
Ah, gotcha
there are also third party libraries that implement a bunch of organizational attributes for the inspector like NaughtyAttributes and OdinInspector
Will have to look into those, getting some more organization into the editor is something i like
hi, just a question. do you guys use some generic movement system or your own?

you use whatever makes the most sense for your project
i just need a simple wasd first person movement :D
Use the Unity FPS starter asset from the store
there are also dozens of tutorials for that
well this is what i found
i think im goind with the modular fps controller
since it is free
What are the different ways to detect the beginning of collision? I know there's OnTriggerEnter and OnCollisionEnter. Any others?
the specifc one I suggeted is free, it's made by Unity.
couldnt find it :/
wait actually why is that an issue? not setting the rotation to that but rotating by that amount?
wherever i am on the screen the ship has no issue rotating
the ship and the projectile both look up at start
let's say your ship is currently pointed to 90 degrees on the Z axis. if the angle is 90 degress, rather than just not rotating it would rotate by 90 degrees
all you really need to do is this:
transform.up = target.transform.position - transform.position;
wait cant i just somehow find a way to nullify it?
would fingerID always be equal to i in this case?
im finding a way to see if the current touch is over a UI object before raycasting into world space
https://docs.unity3d.com/ScriptReference/Touch-fingerId.html
However, the array index is not guaranteed to be the same from one frame to the next. The fingerId value, however, consistently refers to the same touch across frames. This ID value is very useful when analysing gestures and is more reliable than identifying fingers by their proximity to previous position, etc.
π«‘
ok that works, what about in instantiate?
use transform.rotation for the rotation like i told you earlier
unity outdone themselves on this one... the materials
today I learned about touch.phase; I didn't need to make a check for when the first touch is made 
finally
thanks
this is a code channel. but it looks like you've probably switched render pipelines without converting your materials to use shaders that are compatible with the pipeline you've chosen
now if i just give it forward velocity itll keep going in the direction of its current rotation right?
i have no idea what you just said except for the first sentece. this is imported from a unity starterpack asset
not forward, you want to give it velocity along its transform.up axis
what
forward is along the Z axis. but the projectile points along its Y axis. you're in 2d so if it starts moving along z you won't actually see it moving
you should start with the pathways on the unity !learn site to learn how to use the engine.
but the asset you've downloaded is not made for the render pipeline your project uses so it needs to be converted
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
but again, this is a code channel and that is not a code question
Is it normal for an object to collide with itself?
I could do some filtering to make sure something isn't colliding with itself, but want to make sure
a collider won't collide with itself but that doesn't mean that colliders on child objects can't collide with the parents or vice versa
The child objects of the one I'm messing with don't have colliders at all. I even have debugs firing off saying that it's colliding with itself for some reason
show the setup and relevant code
K 1 sec
Hello im stuck at reloading domain in unity on my macbook pro. Tried switching to another wifi. Tried deleting temp and library files. Its a consistent error anytime i try to go into play mode. I recently wiped my drive because of another issue in unity. Redownloaded the hub, editor 3.8f1, recloned the project from github desktop, and setup ide for visual studio code. Im at a loss. someone help me please. Still no official solution on this huge problem refering to https://forum.unity.com/threads/getting-stuck-on-domain-reload.1377126/
Still have not tried to move everything to another clean project, cause im looking for another potential fix. Last time i asked about this, i got no help, so please i would appreciate if someone could help me
if you disable domain reloading does it still get stuck?
its disabled by default
no it isn't
This is everything I believe is relevant to the problem. If you need more info, let me know
mine was, tried to enable it, didnt help
no it wasn't. just because the box is not ticked doesn't mean it is disabled, the Enter Play Mode Options box needs to be ticked and Reload Domain needs to be unticked. otherwise it is enabled
But if the editor still gets stuck with that disabled then most likely you have an infinite loop in your code
oh ok ill give it a go, but if this solution works, and i cannot reload domain, that means i cannot update inspector/code etc correct?
Change that last log to this and show what it prints:
Debug.Log($"{name} ({GetInstanceID()}) is colliding with {other.collider.name} ({other.collider.GetInstanceID()})");
well no, that's not what disabling that does. but if that does fix it somehow, then you'll need to read this page to learn about how disabling domain reload will affect your project and the extra work you'll need to do: https://docs.unity3d.com/Manual/DomainReloading.html
Erm, having trouble with the syntax there. Do you mean this?
Debug.Log(this.gameObject.GetInstanceID() + " is colliding with: " + other.collider.gameObject.name);
no, literally just copy/paste what i provided
i did just edit it to fix something though so try now
are the numbers swapped in the other one
I recall this is a tell tale sign of... something wrong with how I'm doing the collisions.
No, they're different?
it means a prefab is colliding with a game object
yeah but that doesn't make any sense at all because prefabs don't exist in the scene so they cannot collide
Ok it fixed my issue. have one question when reading this link. does all prefabs count as static?
one thing i will point out that is wrong with your setup is the use of both a CharacterController and a Rigidbody on the same object, they don't play well together and you shouldn't need both
the information about statics not being reset is referring to static members in your code and has pretty much nothing at all to do with prefabs
Ah, I had a feeling that would be the case. Originally used the character controller to handle movement, but wanted to use things like OnCollisionEnter and OnTriggerEnter, which needs rigidbodies and colliders
the charactercontroller has its own collision message, and it can also work with OnTriggerEnter
this is a code channel, please delete and ask in #π»βunity-talk
my bad really new to this, thank you!
Read the channel names and their topics before posting
in that case #πβcode-of-conduct #854851968446365696
Got it thank you!
In the old CinemachineConfiner there was the property CameraWasDisplaced. I cannot find it in the CinemachineConfiner2D. How can I check the displacement using the CinemachineConfiner2D now?
anyone tell me whaat to do?
where have you declared checksphereRadius
heree!!
no that's checkSphereRadius, i was asking about checksphereRadius
i dont know what does "," in C# just tell me how to fix it
if it wasn't obvious from my previous message, your spelling is wrong
can i send you whole script ? then you can identify
um what should i do?
have you considered spelling it correctly?
you can see the screenshot.
yes. and checksphereRadius is not spelled the same as checkSphereRadius
what should i select checksphereRadius or checkSphereRadius on all lines?
where do i ask my problem?
if you cannot figure out what you need to change from the information that has been provided, then for the love of god stop what you are doing and go learn the basics of c#. there are beginner courses pinned in this channel that will cover the fundamentals of the language, such as the fact that c# is case sensitive
β Thanks Sire. It is Fixed Now .
not to learn C#
i dont want to create documents etc for my office etc i want to use C# as a game deev.
to make games you'll need to actually understand what you are doing. therefore you need to learn c#
give me any course
where you started?
ahm broken english
i already told you that there are beginner c# courses pinned in this channel
!bug
which link i should click?
Beginner scripting?
please don't spam irrelevant commands across the server
if you need help with something then read #πβfind-a-channel to determine where to ask your question. then actually ask the question in the most relevant channel
now what is this?
previous issue was fixed β
sorry, i don't help people who refuse to learn the basics
ugh okay where?
Why do you call yourself an experienced developer when you cant even figure this out on ur own?
where i said that?
ur bio
well its about discord and minecraft
hey im making a tank control using wheelCollider and to turn im just powering 1 side. however its super slow due to the sideways friction. im just wondering if i should multiply my rotationSpeed to maintain the physics or just lower the friction?
sorry smart guy i just want help to fix my bug i know stack and other don't reply this fast so m using discord now find a channel does not really tell chanel it just say find it yourself so please mr smart guy tell me where do i seek my help from?
I have seen people giving you links to learning materials like 4+ times already
have you bothered actually putting literally any effort into reading that channel to find where you should be asking your question? because you've not even bothered to say what you are having trouble with so how the fuck should literally anyone else know where your question belongs?
damn thanks i found it
saviour fr
π bro go away i hate people who dont treat beginner well you all just give me links and say goto this web and learn not telling me that which course i should select
i asked every single time that how to learn tell me now how to
"Show me how to learn C#"
Gets shown how and where
"No I want you to spoonfeed me all the answers"
you go away..
if you expect spoonfeeding you are in the wrong server.
!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 idk if its the right chat but i try to let the maincharacter throw the Shuriken and trigger the bool IsShieldActive in the Shield Script. After the Deactivation the mainCharacter Should be able to destroy the ShieldEnemy by dashing threw him how can i make it work. Im very new so please explain like im 10
You dont want to actually reference the scripts, but rather reference gameObjects that hold those scripts
Hey, Sir i expect that you will guide me to learn C# properly and i hope you dont act like others... just tell me is that video okay for the first
-
Does your shield script have a
IsShieldActiveproperty? -
If you are checking if something is false, you use
== -
You can't put your OnTriggerEnter function inside another function. It's inside of your Update function right now.
so how do i do that or is there a good tutorial on youtube or sth
cant find anything on the community hub
public void Start()
{
// instance = this;
sceneindex = SceneManager.GetActiveScene().buildIndex;
if (sceneindex != 0)
{
LevelRecords();
}
}
public void Update()
{
LevelRecords();
}
public void LevelRecords()
{
int LevelCompleteScore = ((int)saveLevel.IncreasingTime);
PlayerPrefs.SetInt("level " + sceneindex, LevelCompleteScore);
print(LevelCompleteScore);
Debug.LogError(PlayerPrefs.GetInt("level " + sceneindex, 0));
Debug.Log(PlayerPrefs.GetInt("level " + sceneindex + "record", 0));
if (PlayerPrefs.GetInt("level " + sceneindex, 0) >= PlayerPrefs.GetInt("level " + sceneindex + "record", 0))
{
Record = PlayerPrefs.GetInt("level " + sceneindex);
PlayerPrefs.SetInt("level " + sceneindex + "record", Record);
print(Record);
recordTxt.text = Record.ToString();
}
}
okay so i am trying to save my highscore using this code but its not RUNNING like compiler just skip LevelRecords() funtion
is it your first time unity and c#?
public GameObject Shield;
public void Start()
{
Shield.GetComponent<ShieldScript>().ToggleShield();
}
the only reason this code would not run is if the component is not enabled and on an active object in the scene or you have exceptions in your console that you are ignoring
For example
You expect wrong, I'm not even sure why you would expect that. As for tutorials, I have no idea, I do not do tutorials
yep i just learn the all basics of unity everything just wanna learn scripitng
https://learn.unity.com/project/roll-a-ball
Use this, good luck!
Welcome to Roll-a-ball! In this learning project, youβll: Use Unity Editor and its built-in capabilities to set up a simple game environment Write your own custom scripts to create the game functionality Create a basic user interface to improve the game experience Build your game, so other people can play it!
You can have script references just fine, it's even recommended to do so
well just say i dont understand your message dont say anything without gaining knowledge about that... i was saying that is this website and course okay
it can teach me all the basics?
i am ashamed tho dont wanna roll a ballllll i wanna make games AHEM AHEM well well well i should learn everything everyone started from that stage am i right?
correct
so i corrected the == thing but the rest i dont really understand. I sent the whole script in the first message
okay so what to do here
everyone started there
like the right one
So nothing to be ashamed off
I'd recommend you starting with plain C# without Unity first
the underlined error in your code is due to a misspelling
i just attached my unity to observe but i saw all other scripts is working just fine and logical error is occuring as you know its the most difficult shit to find i don't know why its not working
well is the component attached to a gameobject in the scene?
well dont talk about unity ...
i know how to use unity if i dont there is alot of tutorials about unity not on c#
its wriiten write but i think its due the missing connection
no it isn't. it is misspelled
you have to even i started with roll a ball just go with flow also watch tutorials but not that much search on google on i.e i want to know current scene search the code on google and see all other things . but i think you should see BRACKEY GAME TUTORIAL
the scripts are on a different gameobject if its important and i copy pasted it and its still wrong
can i follow the all steps to roll the ball?? or just learn on website means can i execute after learning
that has nothing to do with what i said. show me where in your code you have declared a public variable or property called IsShieldActive on the Shield class
let me tell you first just understand what they doing do it step by step. then give yourself challenge like making menu or loading specific. as i said go with flow you will learn it your self
I do not see a variable or property called IsShieldActive here
Hey, guys! I am making a First-Person Horror game and I am dealing with a serious in my opinion issue. It is related with character controller and how to move actually the player down the stairs. Is there someone available to help me because I will have to create a thread?
isShieldActive != IsShieldActive
sure
this is a code channel. also you'd need to provide some actual details
Aight, I was about to edit the above message. Do you think it would be appropriate to post in #π»βunity-talk . Sorry bout this
there or #π²βui-ux which is likely the most appropriate channel for the question
okay, thank you
what can i do against the 3.
Move the function outside of the Update function
erm... im trying to disable "Allow unsafe code" in project settings but... it doesnt uncheck.. π i keep getting "Build interrupted" error
public class MyClass : MonoBehaviour
{
private void Update ()
{
}
private void OnTriggerEnter (...)
{
}
}
? like this
i had a project on unity version control. So i wanted to work on my new PC so i donwloaded unity on it and opened my project on that PC however the download is taking so long its been 2 hrs is this normal?
I don't know what that has to do with dashing, but if you want the trigger to only handle code if you're dashing then yes you would check if IsDashing inside of the function.
so the player is running normaly, but when he is dashing he should do the dmg. when not the player itself should die yk
but im too stupid do it like i think i cant connect these 2 scripts
like i think this is the problem i cant fix because i just dont know how
no what they said was incorrect
This is not a problem
yeah no sorry
you need to read what Osteel has told you
OnTriggerEnter2D should not be nested inside of another method
and you can put a boolean condition inside of that method if you only want its contents to run in a specific circumstance
look at this #π»βcode-beginner message and then at what you did
its still wrong but is it the right way to start
so as you can see, my character has a bit of delay when he hits the ground and also when he walks. im using a raycast to check if its grounded. how do i fix this?
it's better than what you had, yes
Note the difference
its still not working
so it kinda is cause he dies but he dies when i dont dash, he dies when i dont throw the shuriken he just always dies
on my shield script its printing tho
So now you have the structure of the code correct =, you need to start debugging
can i ask for a bool status in update?
that question makes no sense
do you have a variable called status?
i have a bool calles isShieldActive
then, yes, you can Debug.Log that in update
Debug.Log($"isShieldActive {isShieldActive}");
you'll need to provide relevant code for help with this. #854851968446365696
well it looks like the issue is probably that you are trying to get input inside of FixedUpdate, but i don't have any info on what InputManager.GetInstance().GetJumpPressed() is doing
get jump pressed() simply just returns a bool value of if the jump button was pressed
so i should get the input in update but handle physics in fixedupdate?
typically yes. but it also depends on how you are handling the input in the first place
simply saying "GetJumpPressed returns a bool" isn't helpful at all with regards to explaining how the input is actually being polled
its using "invoke unity events" with a player input component
public void JumpPressed(InputAction.CallbackContext context)
{
if (context.performed)
{
jumpPressed = true;
}
else if (context.canceled)
{
jumpPressed = false;
}
}
then that should be just fine. you need to actually do some debugging to find out what is happening
private void Update()
{
if (IsGrounded() && InputManager.GetInstance().GetJumpPressed())
{
canJump = true;
}
else
{
canJump = false;
}
animator.SetBool("isJumping", !IsGrounded());
if (!Mathf.Approximately(rigibody2d.velocity.x, 0f))
{
animator.SetBool("isWalking", true);
}
else
{
animator.SetBool("isWalking", false);
}
}
private void FixedUpdate()
{
velocity = new Vector2(xVelocity * InputManager.GetInstance().GetMove1Value(), rigibody2d.velocity.y);
rigibody2d.velocity = velocity;
if (canJump)
{
rigibody2d.AddForce(new Vector2(0.0f, yVelocity), ForceMode2D.Impulse);
}
}
here, i split them up into FixedUpdate and Update, should that help?
or does it not make a difference
you need to actually do some debugging to find out what is happening
what should i debug exactly though?
anything relevant. make sure that everything is in the state you expect it to be
debug a raycast?
yes obviously that is something that would be relevant to your issue
π
but how do i debug a raycast and set a specific height for it
because it doesnt let me set a height it just goes on forever
<@&502884371011731486>
i looked at the thing in visual studio that shows you the necessary parameters
try looking at the documentation so you can see how it actually works
ok
oihhhhhh. direction AND length
didnt know that
thanks
hello guys!
why does CombineRanger (3) not get removed from the agentsWithSight list, even though line 35 runs?
https://hastebin.skyra.pw/goqekadosu.csharp
your hastebin file is empty
mb, fixed it
[moved to a pastebin]
so you remember how i said you should post a link to the !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.
I didn't know that was a thing, sorry
you're also still not providing all of the relevant context. there is nothing you've shown that would actually cause unity to freeze. you don't even have any loops or recursive methods (at least that we can see). so you need to provide all of the context. not just what you think it is
Hi, can someone please help me? Why using forward or left Vector2s in the path object makes my editor freeze?
https://hastebin.com/share/dihequpoba.java
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
push
I don't have any recursive method
how can i make something happen every 1 to 2 minutes in unity
is there any other way beside coroutines
either a coroutine or a timer in update
wait nvm i forgot about InvokeRepeating
haha
that's one of the worst ways tbh. but i suppose it's technically an option, yes
I cant really see anything wrong with this, have you narrowed down what part exactly makes unity crash? Like are you sure its the setting of those vectors?
Yes
If I just use Vector2.forward it works
you should try some proper debugging instead of trying random things. you can attach the debugger and break all when it freezes then inspect what the main thread is doing to see where it is actually getting stuck
why is it bad?
But I need to use forward which is a Vector2 in the path direction
Ok I'll try to understand how the debugger works
it uses reflection to call the method, you have to rely on the string name of the method so no local methods, no parameters. stopping it is not nearly as nice as with a coroutine
oh i see. i assume i cant input a coroutine name into the string?
in that case i will have to use a for loop
i don't know wtf you mean by that
Thanks
i mean instead of it being a function name its a coroutine name. will it work like that?
InvokeRepeating("MyCoroutine", 1f, 5f)
coroutines are functions. but you cannot start a coroutine with InvokeRepeating because it doesn't actually start the coroutine
yeah thats what i thought
thanks
for (int i = 0; true; i++)
{
yield return new WaitForSeconds(Random.Range(90f, 120f));
StartCoroutine(InitializationCoroutine());
}
would this line of code be any dangerous?
Well for one, there's no reason it shouldn't be a while (true) loop instead of a for. If this is the InitializationCoroutine then yes it would indeed be a problem
why though? i want it to spawn an enemy every 90 to 120 seconds
i was thinking of calling it in the update function
So, is this in the InitializationCoroutine then?
No its in another coroutine called SpawnRandomly that I call every frame
you can just run the code
you dont need another startcoroutine
Okay, so then this timer is fine. It can just also be a while loop
true. thanks!
Should I use object pooling as a beginner ?
yes, why would being a beginner mean you shouldn't?
maybe the fact that I don't really understand what it does behind
so learn?
idk if i will understand it but i ll try
You had to know it in some way to even ask the question of using it though?
a little bit
I found, I had forgotten to normalize the vector so sometimes it made super long road which can be really laggy while it's creating the mesh
Hey, guys! I am making character controller movement and for one reason I am getting a bug when I am getting downwards the stairs. What issue is it because I think I have no collider there at that altitude, where my player actually is.
cant even tell whats going on here. do your character even have gravity ?
Of course! I am handling movement with character controller actually and I am applying gravity as well. Wanna see the code?
wouldn't hurt
Btw, I don't think it is a coding issue because it happens only at that place. alright wait
rogue collider perhaps
yea the collider there is obviously the problem u can see it
The mesh collider I have?
oh its because of convex
there is a pretty steep angle you dont see it
I did everything I have unchecked the colliders to see how it behaves the same thing
Give me a sec
nope, its def the collider
I will send the code
100 %
Do you think I have to make my own box collider and change its rotation and put it there
I did that for all game objects inside the house btw
Otherwise my player couldn't move on floors etc
its only odd-shaped colliders that act out
b/c convex wraps around the out-most sticking edges like bubble wrap
for stairs i tend to use ramp pieces and hide the mesh-renderer and put them inside the stairs
lol, which is why we dont use unity physics for 3D tetris
Ramp pieces you mean to make my own right?
theres prototype kits i use from the asset store
these here
that way, my stairs look like stairs.. but the collider is actually nice and smooth
Btw, I ve changed from mesh collider to my own box collider place it there and the same happens
I really saw everything there is no box collider there somewhere
im not exactly sure its a collider that u think it is. b/c that video u shown w/ the stairs gone the issue was still there
I did ctrl + a to view everything there is no collider
Do you think it is a coding issue?
I don't have any code except that I sent you
π€ i dont think soo tbh w/ u
That's my player controller
if it was a code issue it would happen more frequently.. (not just in one area of the house)
I stuck on that bro 2 days I really can't find it out
I am going to other places as well to see if that happens somewhere else
public void MovePlayer()
{
if (RoundManager.instance.currentState == GameState.playing)
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
if (characterController.isGrounded)
{
velocity.y = -1f;
}
else
{
velocity.y -= gravity * -2f * Time.deltaTime;
}
Vector3 moveDirection = transform.TransformDirection(horizontal, 0f, vertical);
Vector3 finalMovement = moveDirection * playerSpeed + velocity;
characterController.Move(finalMovement * Time.deltaTime);
Debug.Log(characterController.isGrounded);
}
}```
you can try adding a debug at teh end like i did here.. and see if ur player is grounded when he's floating like that (my guess is that it is)
jesus...
no need to be scared.. convex colliders wont hurt u
It says true that it is grounded actually
I found out that there are other places that it does that not only one
you still floating ? did you try raycasting to see whats under you ?
its a way to detect colliders
ok how to use that programmatically?
if(Physics.Raycast(transform.position, Vector3.down, out var hit)
Debug.Log(hit.name)
very basic example
So, can I write it inside my move player method for example?
or do i have to create another function
u can put it in update to run it every frame..
then debug the hit like @rich adder mentioned
I mean what I am going to see
well in this example
oh ok
you'll see the object w/ the collider's name
might need to filter out the player collider too
ssets\Scripts\Game\PlayerController.cs(24,27): error CS1061: 'RaycastHit' does not contain a definition for 'name' and no accessible extension method 'name' accepting a first argument of type 'RaycastHit' could be found (are you missing a using directive or an assembly reference?)
I got an error btw
So, check the documentation I sent and see what fields RaycastHit actually has
I just copy paste what the other guy told me XD
u checked digiholics doc page he sent yet?
Yeah
i change the start color of this particle in the particle generator with the script. It does change the color but the particles dont
spawn for some reason, if the color isnt changed it spawns normaly
try it out π all good learning stuff for u to just try stuff
Outside the house
i bet u that was it
it went from the outside through the house to theother side of hte fence
yes
wrapped the entire fence in a box (like plastic wrap) π
yes! thats it
Hello everyone, I'm trying to update my android app target api level from 33 to 34 and I don't understand what's going wrong while building.. do you guys know please?
(Error messages in the console*)
good detective skills mate π
Btw thanks for that method I will be using it from now
haha this is why we try not convex everything..
How do i find the center of an object that has it's pivot off center?
get the center of the bounds
Im trying to do a melee attack system, and for that i use an overlap box, the same shape as sprite
^ bounds /2
Okay, thanks, it worked!
bounds has a center property too no?
idk lol
yeah
lmao
im not a 2D player
ah ok yeah it does
https://docs.unity3d.com/ScriptReference/Bounds-center.html
TIL thanks π
just double checking :p
im guessing center is just bounds/2 in the background
maybe some absolute values too idk
yeah probably too lazy to open up vs rn to go through bounds struct lol
same π im trying to put together an itenerary for the week π¬
u use GUI right?
as in the GUI class ye?
using UnityEngine;
using SPWN;
public class WriteOnScreen : MonoBehaviour
{
public string msg = "THE-KIT - v0.0.1 - 2024";
public Color textColor = Color.cyan;
[HideInInspector]public int textSize = 24;
[HideInInspector]public Vector2 screenSize = new Vector2(1000, 200);
[HideInInspector]public Vector2 offset = new Vector2(40, 40);
private void OnGUI() {
Utils.RealtimeDebug(msg, offset, textSize, textColor, screenSize);
}
}
``` yea i have this code that lets me debug stuff on screen real quick
wait let me find Utils.RealtimeDebug
public static void RealtimeDebug(string text, Vector2 position, int fontSize, Color textColor, Vector2 widthHeight)
{
GUIStyle style = new GUIStyle(GUI.skin.label);
style.fontSize = fontSize;
style.normal.textColor = textColor;
// Draw the text with the adjusted position and calculated size
Rect rect = new Rect(position.x, position.y, widthHeight.x, widthHeight.y);
GUI.Label(rect, text, style);
}```
i was just wondering how i could scale it w/ the viewport
Ohh nice. Is there a benefit to this instead of UGUI ?
I feel like thats where the Canvas shines here
not sure.. ur probably right
I feel like the UGUI is much easier you can even make prefabs thats why
yeah for quick debug i feel like ONGUI is good but anything else I just use canvas esp for designers
as u can see i'd have to get teh viewport size and scale it
ahh okay.. thats probably what i'll do instead
sorry
Unity aquired it back in the day and renamed it to Unity version Control
but we all know the truth
subpar VC solution
there is a reason GIT is so popular π
#Savage
Ah, I'm going to avoid that like hell because Git is the superior option
the only benefit to the unity one is the in editor gui and "locking" a file like a scene for example
...wait so Git for Unity is PlastiSCM?
i cant put my finger on it.. but soething about pulling and pushing form within the project im working in seems a bit sketchy to me
id much rather use an external tool to pull and update before i launch
basically it got aquired yes
its not based on GIT
what.
No
Yeah that's what I thought
Differences can be summarized as: improvements in merge, native support for large files and projects, optional file-locking, can work distributed and centralized. There are differences in the branching structure too: while in Git branches are just pointers, in Plastic branches are containers. Plastic versions directories and files identifying them with "item ids" which is good for move/rename tracking, while Git relies on diffs to rebuild the renames/moves and doesn't version directories.[15]
idk if they changed it since then but this was plastic
Plastic SCM (now called Unity Version Control) is a completely different type of version control.
There are many
Yes
is there a simple way to find objects with tag that also have a specific bool set to true or false?
whats tag got to do with a bool
simlpe enough.. two conditionals
nothing, i just want to search objects by tag, but only add the ones with a specific bool toggle to the array
well yeah if you already have the component with bool
find all w/ tag.. loop thru.. find ones w/ bool
though if you already have the component , using a tag is useless
So I want to use Git and Github, and Git for Unity isn't working, so should I try to do something separate? I saw examples of Git without Git for Unity online
ya wait.. if u have a bool within a component.. just search for components instead
navarone got big brain this morning π§
"Git for unity" is not a thing
Just git init your project folder
just use GIT imo
its a Github Fork..
I think this is to add Git packages from Package Manager
Sorry, my question was phrased badly - should I use this addon, or use Git separately from Unity?
It's MADE by Unity hence my confusion, I assumed this was the default
here this shows you how to setup github with unity using a GUI client https://youtu.be/5IxUElilf2M
It is not either or. You can use it or not, it will not affect your use of git itself
Just set up git first
I have Git setup
its not "made by unity" it was aquired by unity and they have to push it otherwise it was not worth the investment so they shove it down our throats, especially the hub now π
https://fork.dev/ my 2cents as always