#archived-code-general
1 messages · Page 307 of 1
why not:
Vector3 direction = end_t - start_t;
transform.up = direction;```
(or possibly transform.right depending on how your sprite is laid out)
ok, and I'm supposed to make a new repository?
well yeah thats the idea
Unless you already have one you intend to use
GUI will probably be easier
Yo can anyone help my ass at advanced section, (i dont know if im allowed to ask, sry my bad if not allowed)
delete that one tbh, download github desktop
follow simple steps
https://youtu.be/5IxUElilf2M?si=uDQ5_kMhypwBG0Y3
I have github desktop
great, so check out those steps and setup repo that way
be sure to select the gitignore properly
Yes. So authenticate your account
It is clicking a button in the email they sent you
(Pretty standard)
button in the email they sent me? but I got no email from them
Check spam
check spam?
yes
I did not get that
Email services have a spam folder, where they try to filter out things that you may not want. It is not always perfect.
Perhaps it is called something else where you are, but the function is as I described
don't have a spam folder
also, I have repositiry that is already published but no stuff is in there
That just says no changes
Stop cropping things so much. You have a very bad habit of always doing that
Show the whole window
Ok, looks like it was pushed and is all good
Oh wait...
Fetched in 2023?
Interesting. So this is something you've had for a while then?
yeah, when I was at my school
Well is it linked to your current project? And why did you never say that every time I brought up git?
when you said git, I thought you meant something else that is called "git"
Why would "git" mean literally anything else other than the thing named "git"
As opposed to this thing called git?
Alright...
I have signed out and signed back in
Why though
is there actually anything in that repository?
because i did had an error who i clicked on fetch login
ok, now I have published the repositiry,
@cloud python click on History
You never answered if this repo is actually linked to your current project though. You said it was something from school in 2023
ok
idk if it's linked to my current project
Yes
What does your local folder for this repository look like
local folder? as in normal folder in finder?
As in your local checkout of this repository
The place on your computer this repository exists
Okay, so, I use actual computers so I'm not sure how it looks in mac, but that looks pretty empty to me
They are one folder up
cries in macbook
Wrong place @cloud python
Look INSIDE the project folder
Wait wait.. maybe i'm wrong. You have two projects named similarly
might be easier to just create the repo by doing Add Existing Repo
Now I'm guessing you created a local repo instead of linking to your exisiting one
then selecting the project folder
I'm just gonna say, I really really do not want to explain git to someone via successive approximation. I'm out
This is just too complicated for their usual pattern of "Throw shit at the wall that is so astonishingly wrong people have no choice but to correct it"
I'm tapping out now
there, the right one
lol just follow this video
Also empty?
You would be suprised
I am following the video
yeah
alright, follow it exactly
should be no problems
Well... you want to store a folder that is NOT empty obviously
The folder with all the stuff you are working on
while I am following the video, and right at 1:31, I don't have this much stuff since I only have 2 compare to the video
"Add existing repo"....
you skipped to 1:31 without doing the Add Existing repo
you can literally delete the other blank ones you made
I don't have add existing repo
add Local Repo
Can you guess which of those is closest to it?
ok
great now find the project folder
the one that has Assets folder etc.
the root of the project
it will say "No exising repo found", then have a link to create it
Important: select Unity in the gitignore dropdown as shown in the rest of vid steps
ok
yeah
yes
well I can't click on add repository, am i suppose to click on create a repository?
didnt I literally say that was gonna happen?
yes
are u sure you selected it correct, click on History
it seems so
ok, I have published it
you're officially using git on your repo congrats lol
periodically make Commits when major changes
thanks, finally, should i send the url in dms?
why are you sending url no
oh
this is for you to track your project and its history of changes, and possibly revert any breaking change
oh
I recommend making a small test repo so you can see what all the steps do, like committing and pushing.
You can setup a repo with a simple text file then see how it works when edited
that would be all good if you didn't have to be explaining the whole process again lol
Yea not it
@cloud python You can do a quick test on this project, maybe add a //comment inside any of the scripts
You will see under Changes in github desktop that a file was changed with that comment, then just name the commit and push
i think the video linked shows that
Hello! I was wondering how I would go about making a basic planet orbiting system in unity?
ok! thank you!
or like this
yup pretty much thats how you see what you changed , bottom right is where you write the name of change / summary
why does this public List<List<AudioClip>> footstepSoundLists; not show up in the inspector
unity doesn't like that
use a custom struct/class (make it Serializable)
List<CustomStruct>>
CustomStruct Has list of AudioClips
because List is not a Serializable class and UInity can only serialize lists of serializable classes
so.... now i have that
ehh give me a quick TLDR/summary what you're trying to accomplish
well before with other changes in the other scripts, if the player loses all health and dies, it supposed to respawn from the checkpoint and the health is back to full, but right now when the player dies and respawn, the health bar doesn't go back to full and the player is stuck in midair, cannot move
like that
whenever you're spawning the player again something in it is mising or not activating
you should know, do you have custom script / gravity ? is movement script enabled? etc.
I'm confused. Why is this errored?
use the instance of transform
because you're trying to call Rotate on the Transform class instead of a specific Transform you want to rotate.
You need to call it on a specific Transform
minecraft font lol
oh my, thought it looked familiar
well it is like the same one, the script is in it, and it seems like it deactiva "z" and activate to "y" instead in rigidbody2d
you have to show the new player's settings, you're showing the old one up until respawn
also Imo destroying and instantiating a player is highly inefficent.. Easier to just reset it..
I want to be able to put this on any object and have it function. I'm not sure how I would do that now?
Just by doing what I said
Assuming you want to rotate the object the script is attached to, call Rotate on that object's Transform
you can access the Transform of the GameObject your script is attached to just by using the transform property
almost any code example will be using that
ok
on that note.
any "Component" has access to the transform and gameObject properties the component is on
do you see the Position Y is locked?
how do you expect it to fall exactly
yeah, that is for when the player dies
alright but now you see why it aint fallin
is that if the player dies, the death animation would play but falling through the ground while the circle collider is dissable
yeah
thats fine but you just need to reset it
yeah
I usually have an Init() method that restores the player to its original values
you mean Int
nah Init short for Initialization
oh
https://gdl.space/bulividehi.cs this is the checkpoint
https://gdl.space/caqodelama.cs and this is for when the player dies and respawn
no idea how this helps
You should know your own code no
I mean, where should I put the Init method?
certainly not inside a checkpoint script let alone a State Machine state
never said do exactly as I do, just saying scattering your code like this isn't intuitive . You're confusing yourself by scattering all this player code everywhere
so much redundancy too makes it an extra chore to read through
if (other.tag == "Player" || other.tag == "Player 2")
{
checkpointSpriteRenderer.sprite = starpassed;
if (!checkpointReached)
{
if (other.tag == "Player")```
Like what..
` GameObject.FindGameObjectWithTag("Player").transform.position`
then you have these...
idk, it worked before
yeah it worked but now it broke and u have no idea how it works cause its a mess
I'm not saying you need to be a code guru but you have learn how to minimize how much ur repeating rewriting the same thing over and over
https://gdl.space/fukemajoqa.cs well.. there is another script that is a big change to my other script which is... shorten?
dont think ive ever seen so much Find
also you should not use ? on unity objectsGameObject.FindGameObjectWithTag("Player 2")?.
Believe me, I tried
its not like they haven't made any references before..
oh
pretty sure ive tried to tell them before as well. There is a certain point where you should definitely just scrap all of this and try again
the two player thing is kinda complicating the situation
since they are doing same code twice instead of just using a generic player
this will break in the future and it will be absolutely impossible to fix. What happens when you want player 3? you're suddenly editing every single script in your game.
No but you see they just need to fix this one problem and then the project is done forever and won't need to be maintained
if you ever need to check for individual cases like "am i player 1 or 2" or "am i checkpoint 1 2 3 4 or 5" then you could definitely code something better
I know, I mena like if it's just one player there, only player one respawns, but if 2 players are there, and if one of the players dies, they both respawn
yeah, my second project sure is going to be big
Okay so what happened to the first project that you just needed to know how to set a variable in last week before you finished it
it shouldnt be, you DEFINITELY need to scale down and make something simple like cookie clicker or flappy bird.
assuming that was the truth then, this would already be your second project right
my first project is out in gamejolt, it is a singleplayer
There comes a point where you need to just throw your code into the sun, start at !learn, and make pong
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Think about it like this, you are learning. Any code you write now will be pretty ass in comparison to something you write lets say 6 months in the future. In 6 months, you'll have to rewrite all the shitty code
What would be a clean way to make a TrailRenderer (or any GameObject) go around a UI element's bounds?
I helped someone with this a while back, ended up using Splines package
if its only the bounds though, it probably can be easier without splines though
since you're not doing curves
how much should i rewrite the checkpoint script?
can i ask a question about a code i made. I am a beginner but i dont think the code i made belongs in code-beginner cause it was partly made by gpt, I do understand it but a component isnt working.
should I change the checkpint script a lot?
seperations of concenrs, the checkpoint is doing wayyyy to much
it should only run a function on the player, player should handle its own stuff
Have you ever seen the movie "Old Yeller"
no
Ah, well then nevermind. My answer would have been spoilers
gpt code doesn't belong in any channel, you should probably actually learn coding properly
ik ik
thats cool
highly recommend
https://learn.unity.com/project/beginner-gameplay-scripting
thx. Im hoping there is a section to reference other scripts?
so just putting a spline 'on top' of the ui element and having my trailrenderer 'ride' it?
yeah, what i thought of is getting the corners and just moving it from corner to corner over time, just not sure if there's to not have to handle each direction seperately if that makes sense
yet how would like the game tell that the player have 0 lives and one of them dies again and it becomes a gameover?
the direction would be from one corner point to another
for example you'd check the amount of lives remaining on the player itself
each player has their own stats, they check their own variable for lives remaining
if you need the whole game to know about it then you need a manager script that just listens to those changes and reads the value
it do have the manager
https://gdl.space/dijoruxuje.cs I tried (I am not saving it, I was just checking)
i already have a pathcreator that allows to make some sort of splines in my project, and i know how to use it with a trailrenderer, it's kinda janky but i think it might get me there
otherwise i'll do the get corners thing
https://gdl.space/lovixumexa.cs this is the manager script
so both players share the same lives?
like, like you start at 3 lives, if player 1 dies and respawn, 1 life lost to 2 lifes, if the player 2 also dies and respawn, another life lost and there is 1 life left
huh? so basically what I said?
these GameObject.FindGameObjectWithTag everywhere.. atrocious, really get into a habit of linking things in the inspector
At least caching them in variables. Pretty sure we finally managed to explain how to do that last time
I was laso like trying to make 2 separate scripts for 2 separate players for respawning
you would think after they somewhat learned to use, they would start replacing and cleaning stuff up but alas here we are..
why would you need 2 seperate scripts
if you didn't skip out the basics you would store them inside an Array/List of Player type
I thouhgt you meant that
Half a second could be a lot of frames between that time, and the Inspector updates at a fixed rate, so some updates between frames might not be shown by the inspector before that data changes - aside from visually/through the inspector, have you also confirmed this with logs per frame?
doesnt mean each player needs separate script if they are functionally the same.
I meant more like the Player needs to teleport, change that inside the player and run the function instead of manually changing position from checkpoint script
i fixed it for some reason the sounds sounded good as an mp3. byt got broken in unity.
Odd that Unity would break the audio file itself, but good to hear you got it fixed
inside the player script?
wel yeah..
I don't need to like see every script..
like already suggested, start with a smaller scoped game to learn / practice more
cause you got a lot going on here and its only gonna get more complex from here
also just because I mention a Player script doen't mean it has to be all crammed in the Player movement script, player can have different scripts that do different things for player
oh.. then.. should I make a respawn script?
How could I fix my trail renderer not 'sticking to the ui' but moving in world space too
expected rsult:
actual result:
(when moving the camera around, the ui has a billboard effect)
Maybe you could set it to child of the ui element object?
Or make a dampening effect
oh that might be all there is to it, lemme see
books way better
nvm it's already child of the ui element
but off topic so. I need to make earths rotation be equal to a day, but I can't find the actual number? any help would be awesome
Maybe child of the wrong ui element? Not the one you are moving?
it's child of the actual button inside the whole ui
You're moving the button then?
when the camera moves, since there's a billboard effect, the menu kinda moves
i want to avoid it having that efffect on the trail renderer
I will never able to learn because I am way to forgetful and low iq... no matter how much i try. I literally even forget how blender 3d works
probably some setting in the shader graph or particle system, idk about those
i've looked online a bit and some people recoded trail renderer to fix this
not sure if i'll just take that maybe
(to have a trail renderer in local space instead of world space)
You forget because you're jumping to far ahead too soon, keep things simple in the beginning and repetition is key to remembering.
I have horrid memory believe me...I remember by muscle memory almost by doing it over and over
Stop saying that
Self-fulfilling prophecy
it's just a matter of putting time into it usually
what do you mean by that?
he means repeating that to yourself makes it true
the old saying " speaking things into existance"
"careful what you wish for" etc..
First of all, this is one of your biggest problems.
I said something.
You didn't know what it means.
Instead of googling it first, you ask.
In this instance, it is ok, but so much of the time working with code, you googling something would give you the answer quicker
If you had googled "self-fulfilling prophecy" you would have gotten many pages of descriptions of what it is
Learning how to learn is super important
you know, maybe I should take a break from the coding for a while and focus on designing a bit for two other stages.
another tip is whatever you're working on make sure you enjoy the process
u'll improve much more if you're not constantly beating yourself over not getting to desired end result
a day in real life? or a day in your game
irl
thanks, maybe I am not good with this coding and can be emotional about things that didn't work out, but I am good with pixel designing
majority of coders here can't art for shite so you got something they don't
oh, really? because I do draw a lot, I made like 1000s I think.
like designing a music theme stage and a toybox town stage
I could not draw to save my life
well I do have tons of drawings for my game series and characters
im gonna assume we arent talking about the earths tilt and all that stuff, because i suck at physics. But this should be an easy calculation for just spinning around once per day.
U want to spin 360 degrees on the y axis over 1 day or 86400 seconds. So you want to spin at a rate of 360/86400 per second
can I show you in dms, what type of drawings I did make?
throw it all in your dev log
yes.
k got it. I hope
Then just multiply by Time.deltaTime to get rotation per frame
i was hoping that last part would be obvious in the general channel
oh yeah I should do that. I forgot Time.deltaTime in my script, thats why it was really fast
Yeah just making sure, you never know
Good timing lol
yeah lol
I still have this issue i'm not quite sure how to fix..
I think it'll be there no matter if i use particles or trail renderer because my it's a world space canvas with a billboard effect
any idea how i could achieve a similar effect using neither a trail renderer or a particle system, i guess some ui component instead?
#1225882878831759430 message speaking of
what am I looking at
i'm trying to make an 'auto-cast' type of effect around a button
do you know what i mean?
basically you're looking at a trail renderer going around a button
ah, I'd a shader and textures
I could think of ways of doing it with the vfx graph though
example: if u look at the bottom of the screen on the 'W' key at 14s something like that
https://www.youtube.com/watch?v=tBaI4Jv16r0&t=12s
MAKE YOUR GAME MORE EASIER, HOW TO TURN ON/TOGGLE MEEPO AUTOCAST WITHOUT CLICKING THE POOF ICON!
Learn from mistake, especially when u died is the best way to improve your gameplay.
One die = One lesson.
Meepo is Back !!!
#Meepo #tips #autocast #7.33e #dota2
#дота
Please Subscribe, Like, and Comment !!!
Thanks~
- Dota Dawn
Meepo
Meepo i...
oof i'm using built-in
i guess i'll give up on that idea
hello i need help
Hello, I need help, I need some .net reactor 6.9.8 key for my project. I am from Cuba and I can not pay for the license, it is very expensive. Please help 🥲
@modern creek was working on something similar if I recall. Perhaps you can ask for their solution
someone refered me to it, in his case the canvas doesn't move
Sorry - just catching up on the backlog messages
well I'll be taking a break from coding and now focus on designing for 2 other stages, and maybe for the boss stage
Whatcha need, n1co?
what's wrong with a masked sprite underneath the button? you guys seem to have gone straight to hard mode
oh particles in UGUI?
don't crosspost. and idk what you are expecting to get help with, if the software requires a license to use then you'll need to purchase a license.
i'm trying to implement something similar u did, but i don't think my issue is quite the same
#archived-code-general message
i've kinda did what u did in a way, but since in my case it can move it's weird
You'll need to either use a library (I have two that I can recommend) or make your UI space transparent and render particles in worldspace.. but I wouldn't recommend mixing UGUI and world space particles
Do you use coffee particles? (I forget the exact library but it's something bland like "particles for UI")
im asking for help just that
hmmm, are they in 2d space and only move inside the canvas for trail for example?
yep, they're 100% in UGUI space
ah that might be as simple as that
basically he takes the particles, bakes them into a mesh and flattens it so you can display it in your UI layer
then you move it around however you want so you can do things like gravity or .. particles in certain locations.. i use it extensively
example - particles in UI space wherever i have buttons or in-game stuff
i assume that would work just the same in a world space ui
(note how the particles are above/below some UI elements but I don't have to make them transparent and try to get them in world space in the right place)
yeah, it can, but .. it's in the UI layer, not so much in "world space" per se
try it out, it's a pretty straightforward library.. you just add the component to an object and then configure the particle systems on it, and it'll render them in UI space (even if the object is in world space).. if that makes sense
I used it for some particle effects that "traveled around" an object using splines but it didn't end up working as well as just putting the particle effects directly on the buttons and emitting them from the entire circle
it just looked kinda lame
alright, well thanks for the suggestion, something to experiment with
you did that with the ugui particle thing right?
also - this was in a scroll view so if you moved the scroll view up and down you'd either have particles "trailing behind", which was weird, or the entire system would move with the scrollview which.. seems like what you'd want, but it looked broken
for me it kinda needs to go around
oh ye i want to avoid that
yeah, i did it with the coffee particles on a spline that roughly matched the shape of the button
so you werent able to make a trail that wouldn't be messed up by a scroll view?
it was more trouble than it was worth though - i think you're better off doing a square or a circle emitter that emits in a small arc and you change the arc in a coroutine or update
hmm i'll write that down
for when i know what that means haha, sounds like an idea
i was but it just didn't feel good.. i opted for a different strategy to indicate "clicked-ness"
"Arc: 360" = emit from all 360 degrees
change that to something small like 5 degrees, then just rotate the whole thing around (shape.rotation.z)
as far as the details of how to do that, you can ask this channel if you don't know 🙂 but that should get you 95% of what you're looking for at 5% of the effort
this should explain it
Let’s say I have a sim that has a calendar with timed events. The sim can move time forward to a future date. Some events require player input. What is a good way to implement this where I stop the game for the earliest such event?
put the events in a PriorityQueue / Heap so you can Peek() and always see the next upcoming event
then Pop/Dequeue the event when you consume it
So this would order them by date then?
ps I don't think C# has a built in prioerity queue so you'll need to find one somewhere, write your own, or use SortedList as an alternative
SortedList would fully order them
a true priority queue wouldn't need to
but maybe you'll want SortedList anyway
you'll probably want to display them on a timeline for example, so that would be helpful
What exactly is a priority queue as opposed to a normal queue?
objects in a normal queue go in and out in FIFO order
priority queue orders them by some priority value
such as the "time" on the timed event
I see
Ok that makes sense.
Any tips for doing recurring events?
You could for example put a bunch in the queue or put a new one when the old one ends. Or handle them fundamentally differently such as maybe in their own queue.
I would have some preset time threshold for putting events in the queue, and periodically check my list of timed events to see if I need to add the next timed copy to the queue
but yeah a separate structure might make sense too
especially if you want to do things like remove all copies of it when the primary event is removed from the queue. It could be tricky
it does, but it's .net 6 
Ok thanks guys.
Ok another question. Let’s say I want to write some part of my game in a dll or other library not necessarily written in the version of c# supported by Unity (or even c# at all). How hard is it to package that with a webgl build?
well you won't be able to use a dll that targets a version of .net that unity does not support
Ok thanks.
Hi I'm working on a Gravity rush style game where you set the characters down direction in the camera look direction, I've been playing around with different ideas but getting stuck, I need to essentially have the character upright in the direction of gravity but then be able to make adjustments mid air with WASD.
Using the character transform for this is just not working as the right and forward aren't always where I want them to be and using the camera seems to not be a reliable option as I essentially want the movement to be perpendicular to the gravity direction so I can get that perpendicular plane of movement, it's just the translation of input where things are going wrong.
The video below displays what my problem is, the blue line gizmo is the W and S axis where the red line is A and D.
Any advice technically or design wise is welcome
tysm, it finally worked. AI code was way of the mark. Ill keep it original from now on👌
Sorry I got busy. lol
I tried miniMapCamera.transform.TransformVector(localPoint) and miniMapCamera.transform.TransformPoint(localPoint)
TransformVector seems to not effect the position at all. While TransformPoint makes the positioning even more inaccurate.
private void OnDoubleClick(PointerEventData eventData)
{
RectTransform mapPanelRect = mapPanel.GetComponent<RectTransform>();
Vector2 localPoint;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(mapPanelRect, eventData.position, miniMapCamera, out localPoint))
{
MapController.instance.SetDestinationMarker(miniMapCamera.transform.TransformPoint(localPoint));
Debug.Log($"MiniMapController: OnDoubleClick: evenData.position {eventData.position}" +
$"\nlocalPoint {localPoint}");
}
}
im getting an error which state that it can't find the script(if im understanding this right)
in the second image i got a debug log which gets called successfully as shown in pic 3
hovering over pick 4 leads to the script which is meant to run
this is meant to change the npcs from patrol to attack
What is baseState ?
Is there a way I rotate around multiple axis? like if I want inclination how would I go about doing it? cause Vector3 needs to have something like .up?
You can pass any vector you want to serve as the rotation axis
you can only rotate around one axis though
if you want inclination, pass in an inclined axis
you can make any vector you want with new Vector3(x, y, z)
you are not limited to Vector3.up left right etc
or you can use something like OrbitalObject.transform.up perhaps
ok..... I don't know how I would do an Inclination though?
I want this to be a general script that can apply to all planets
the simplest way is just to use an empy GameObject to define the axis
and use its transform.up
but otherwise.. .literally any vector you want friend
new Vector3(1, 1, 0) is "inclined" 45 degrees for example
you could even define it in the inspector
(but again I recommend using a GameObject to define it)
Im still very new to this
you could also define it as like a float in the inspector - call it inclination. You could use real orbital parameters like Keplerian elements in the inspector to define the orbit if you wish https://en.wikipedia.org/wiki/Orbital_elements
Orbital elements are the parameters required to uniquely identify a specific orbit. In celestial mechanics these elements are considered in two-body systems using a Kepler orbit. There are many different ways to mathematically describe the same orbit, but certain schemes, each consisting of a set of six parameters, are commonly used in astronom...
How would I do this? Wouldn't I need 6 Empty GameObjects for 6 planets?
that article also contains much of the math you'd need to make that a realty
do they each orbit at a different inclination?
yes
then yes you could use one empty object to help define each orbit
put them in an array
or just make them individually if they won't change
if this is like Kerbal Space Program or The Outer Wilds where there's a fixed set of well known planets you could probably get away with individual variables for each. Like JoolOrbitHolder
Is there a way that I can do all of this inside of the script itself?
I mean in the PlanetOrbit script itself. I haven't made all the planets yet either so is there a way of making an inclination slider?
sure
[Range(0, 90)]
public float inclination;```
then you could do like
Vector3 orbitalAxis = Quaternion.Euler(0, 0, inclination) * Vector3.up;``` for example
Okay, anything else I gotta do? Cause I'm not sure how most of this stuff works
I understand some of it
just not how it all fits together
Im not sure what to do to this to make this work?
there's not much more to it
use that as your axis in your RotateAround code
remember you were asking about making an axis vector originally?
Yeah I did that, it just doesn't do anything
Hold on lemme get a vid
Unless you didn't have the basic orbiting code working in the first place
in which you may have some other issue.
It does
Turns out it does do something
ummmm
it makes Unity not want to live.
it crashed
Very little chance of that code crashing Unity. Either an unrelated crash or you have an infinite loop somewhere or something
Your code is very clearly useing Vector3.up as the orbital axis still
Sorry to bother you again...
I tried miniMapCamera.transform.TransformVector(localPoint) and miniMapCamera.transform.TransformPoint(localPoint)
TransformVector seems to not effect the position at all. While TransformPoint makes the positioning even more inaccurate.
I also started testing random combinations, like using TransformPoint with the evenData.Position and plugging that into the RectTransformUtility statement, but nothing works XD
private void OnDoubleClick(PointerEventData eventData)
{
RectTransform mapPanelRect = mapPanel.GetComponent<RectTransform>();
Vector2 localPoint;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(mapPanelRect, eventData.position, miniMapCamera, out localPoint))
{
MapController.instance.SetDestinationMarker(miniMapCamera.transform.TransformPoint(localPoint));
Debug.Log($"MiniMapController: OnDoubleClick: evenData.position {eventData.position}" +
$"\nlocalPoint {localPoint}");
}
}
ohhhhhhhhhhhhhh. I forgot about that, sorry
that's new
now you're using Vector3.right
why are you just ignoring the orbitalAxis we defined
that's the whole point of calculating it.
You should use it
ok, so I did a thing. Not sure if it's a good thing (prolly not) and now it's editing the rotation
@leaden ice I don't know what to do, I'm a pretty massive noob at this stage, I only know some basic C# stuff.
I have a question about spawining trees procedurally.
{
float[,] noiseMapTrees = new float[mapW, mapH];
(float xOffset, float yOffset) = (Random.Range(-10000f, 10000f), Random.Range(-10000f, 10000f));
for(int y = 0; y < mapH; y++)
{
for(int x = 0; x < mapW; x++)
{
float noiseValue = Mathf.PerlinNoise(x * treeNoiseScale + xOffset, y * treeNoiseScale + yOffset);
noiseMapTrees[x, y] = noiseValue;
}
}
return noiseMapTrees;
}```
``` float[,] treeNoise = Noise.GenerateTrees(size, size, 0.05f);
for(int y = 0; y < size; y++)
{
for (int x = 0; x < size; x++)
{
float rng = UnityEngine.Random.Range(0f, 0.5f);
if (treeNoise[x, y] < rng)
{
GameObject tree = Instantiate(treePrefab, treePrefab.transform);
tree.transform.position = new Vector3(x, 0, y);
}
}
}```
where treePrefab is also a gameObject
when i run my game with this code, unity just crashes completly
and i cant really figure out why
Sounds like it's working no?
you may claim for too much memory when initialise the 2d array and your os kill your editor, btw read the crash report
no.
you have two different inclination fields for some reason
and you seem to be changing the one that your code isn't using at all
These are silly mistakes
Pay closer attention to what you're doing
yeah this is still very new to me.
but still that's not working either
Ok unity Crashed when I set the Inclination slider to 90, Im checking the log
huh
Ok. I dropped the other Inclination. it's doing something. But it seems to not go in a circle around the sun like it used to
The PlanetRotate script may be messing with it
here's the code for both.
eh it's just the axis then
you probably want an axis that's orthogonal to where your planet is starting
the code currently assumes the planet and the sun are starting in certain spots that they're not
you could put the inclination on the x axis instead of the z and that might help
really RotateAround is kinda sketchy for this though
Yeah I think I'm just gonna rewrite this
int treeCount = 0;
for (int y = 0; y < size; y++)
{
for (int x = 0; x < size; x++)
{
float rng = UnityEngine.Random.Range(0f, range);
if (treeNoise[x, y] < rng)
{
tree.Add(Instantiate(treePrefab));
tree[treeCount].transform.position = new Vector3(x, 0, y);
tree[treeCount].transform.parent = parent;
treeCount++;
}
}
}```
{
float[,] noiseMapTrees = new float[mapW, mapH];
(float xOffset, float yOffset) = (Random.Range(-10000f, 10000f), Random.Range(-10000f, 10000f));
for(int y = 0; y < mapH; y++)
{
for(int x = 0; x < mapW; x++)
{
float noiseValue = Mathf.PerlinNoise(x * treeNoiseScale + xOffset, y * treeNoiseScale + yOffset);
noiseMapTrees[x, y] = noiseValue;
}
}
return noiseMapTrees;
}```
why are the trees spawning so close to eachother?
I cant seem to figure it out
treePrefab is a gameobjct
nvm
figured it out
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Oculus.Platform;
using Oculus.Platform.Models;
using PlayFab;
using PlayFab.ClientModels;
public class IAPChimp : MonoBehaviour
{
[SerializeField]
private Playfablogin playfablogin;
public string SKU;
public int Amount;
public Material normal;
public Material pressed;
public AudioSource sfx;
private Renderer render;
private void Awake()
{
render = GetComponent<Renderer>();
render.material = normal;
Oculus.Platform.Core.AsyncInitialize("OCULUS_DEV_KEY").OnComplete(OnPlatformInitialized);
}
private void OnPlatformInitialized(Message<Oculus.Platform.Models.PlatformInitialize> msg)
{
if (msg.IsError)
{
Debug.LogError("Oculus Platform initialization failed: " + msg.GetError().Message);
}
else
{
Debug.Log("Oculus Platform initialized successfully!");
}
}
private void GetPurchases()
{
IAP.GetViewerPurchases().OnComplete(GetPurchasesCallback);
}
private void GetPurchasesCallback(Message<PurchaseList> msg)
{
if (msg.IsError)
return;
foreach (var purchase in msg.GetPurchaseList())
{
if (purchase.Sku == SKU)
{
CurrencyAdd();
IAP.ConsumePurchase(SKU);
}
}
}
public void BuyIAP()
{
IAP.LaunchCheckoutFlow(SKU).OnComplete(BuyProductCallback);
}
private void BuyProductCallback(Message<Purchase> msg)
{
if (msg.IsError)
return;
GetPurchases();
}
public void CurrencyAdd()
{
var request = new AddUserVirtualCurrencyRequest
{
VirtualCurrency = "OR",
Amount = Amount
};
PlayFabClientAPI.AddUserVirtualCurrency(request, OnAddCoinsSuccess, OnError);
playfablogin.GetVirtualCurrencies();
}
void OnAddCoinsSuccess(ModifyUserVirtualCurrencyResult result)
{
playfablogin.GetVirtualCurrencies();
}
void OnError(PlayFabError error)
{
Debug.Log("Error: " + error.ErrorMessage);
}
private void OnTriggerEnter(Collider other)
{
if(other.tag == "HandTag")
{
Debug.Log("Clicked Button...");
sfx.Play();
StartCoroutine(resetColor());
if (playfablogin.loggedIn)
{
Debug.Log("Buying ITEM...");
BuyIAP();
}
}
}
IEnumerator resetColor()
{
render.material = pressed;
yield return new WaitForSeconds(0.1f);
render.material = normal;
}
}
I have a script that handles IAP purchases
The button works when I press it, the SKU is set to "menu" and so is an item in meta named "menu".
there is also an item named "menu" in playfab and in unity and in the "special items" section.
After the purchase is complete, the user does not receive the item, after hours of waiting aswell.
(CODE IS ABOVE)
I would try adding more logs, it looks like you are returning on error, so its possible it could be failing and you dont get any feedback about that happening, you could try logging the error before returning, you could also add a log to your other functions like GetPurchases to make sure its actually being called when expected (or at all)
Is there any way to get the invokation list on an event similar to usual delegates, without using reflection?
With a casual delegate i could do something like
var listeners = (MulticastDelegate)myEvent.GetInvocationList();
but as soon as the event keyword comes into play, this isn't possible anymore.
it should be accessible from within the same script that has the event
thats the point of the event keywrod
Oh right, thank you. I was aware that you could not invoke them from outside, and only (un)subscribe them. Didn't consider that as the issue here 🙂
okay so idk how to write this bc im stupid,
If the player collides with any object that is in the list remove points
This is the code
thats not how lists work
this would only trigger on the collider that has this script
but what do i need to do to get get the same result but have it slected to multiple gameobjects without putting it on all the gameojects
if i change a value (like SubEntityData) inside originalProfile, will it also change the one inside blackboard.AttackProfile
like, is originalProfile an exact copy, or does changing it also change the place i got it from
what are you trying to accomplish? also how come you don't want to put script on multiple objects
basically im working on a minigame where u have to avoid obstacles and try to get 10 coins to beat the minigame and i want the obstacles in a list so it is easier for me to do
nvm it would change it, thanks chatgpt
so just put the script on the player instead
obstacles can have their tag so all you need is tag
that is a good idea
i just need to have them have 2 colliders
what for?
1 is so u can bump into them the other one is for the trigger?
if you want to bump into them could use OnCollision instead of trigger
So like this right?
use this method instead of ==
https://docs.unity3d.com/ScriptReference/Component.CompareTag.html
the list isn't needed, also this script should go on player
But u just said but i want the player to bump into the obstacles
this
that's not related at all
do you have Obstacle component?
generally it's better to check for components instead of tags
if(other.gameObject.TryGetComponent(out Obstacle obstacle))
and you have reference to that obstacle instance aswell at the same time
what do u mean obstacle compoment
do you know what is a component?
yes i just didnt know there was a Obstacle compoment
there is if you create it lol
. . . ur just making me do extra steps for something that doesnt need it
Let me say it again
IF the player bumps into a obstacle remove points
i alrady have the remove points part
no, you just dont understand what am I saying
Maybe i dont
U mean a script?
so why do you check in obstacle script if you collided with obstacle
and why do you have a list of obstacles inside a obstacle script
bc i put the script onto the player?
is the player a obstacle?
No
so why do you add Obstacle component to it?
Look buddy all i want is to lose points when the player bumps into an obstacle
explain
i just did, read again all what i said
if you want to detect if your Player collided with Obstacle, why do you add Obstacle component to the player
U know how bouncy balls hit the floor and go back up?
The player is the bouncy ball and the obstacles are the floor
okay but the player is not a obstacle
dont i need to use OnTriggerEnter
so why do you want to add obstacle component to it, asnwer my question
Bc the other person said put it on the player
who said that
This one
they probably meant to put the detection if you collided with obstacle on the player, not the other way around
because your code is confusing
inside the Obstacle script you are checking if you collided with Obstacle, which makes no sense in your case
No
Im trying to make a minigame
fixed it
it works now
i did what u said
This
this works
cool
huh i simply was saying you can put the script on the player too detect obstacles instead but you misunderstood
Now to the next problem, how do i fix an axis by a button press?
fix an axis?
yes i want that if u press the R button u reset the Z axis
I thought did would do the trick
where is 90 coming from anyway?
trying to help, not being rude
the y axis is 90
yes I can read, but 90 is magic number with no meaning..
ok im still confused.
if i change profileToCopy.ShearModifier (its a float.) will it also change ShearModifier in this class?
No
Floats are a value type
Value types are copied by value, not by reference
is there an easy way to know whats a value type and whats not
Yes
Structs are value types
Classes are reference types
Float is a struct
You can see that if you look at the documentation or just the definition
ah alright i get it
ty ty
thank you
is it possible for a coroutine to define behavior when StopCoroutine/StopAllCoroutines is called?
No
Hey all, I'm attempting to import Unity.InputSystem, which is installed via the package manager but getting this error.
Did you enable it in the project settings?
yes, the problem arised when I started moving scripts we wrote out of their folders
using asmdef's?
never heard of that
oh, assembly definition, not in the folders I moved stuff around in
sounds like you'd be better off asking in #🖱️┃input-system - as that code isn't yours, its the auto generated code
Okay, thanks
Is it normal for my packages to be ignored like this?
oh that's plastic, nvm...
Ignored? Is that Unity's Version Control?
If so, yes, of course. The package's are local and you shouldn't be editing them
Hi I'm working on a Gravity rush style game where you set the characters down direction in the camera look direction, I've been playing around with different ideas but getting stuck, I need to essentially have the character upright in the direction of gravity but then be able to make adjustments mid air with WASD.
Using the character transform for this is just not working as the right and forward aren't always where I want them to be and using the camera seems to not be a reliable option as I essentially want the movement to be perpendicular to the gravity direction so I can get that perpendicular plane of movement, it's just the translation of input where things are going wrong.
The video below displays what my problem is, the blue line gizmo is the W and S axis where the red line is A and D.
Any advice technically or design wise is welcome
https://cdn.discordapp.com/attachments/763497743976497222/1229556537538773043/2024-04-16_00-08-22.mp4?ex=66301cc2&is=661da7c2&hm=8b0693cbf908a15b020cc3ba2a7bfc740aef27695bae6c9f2e5ec330b61b41b2&
Does anyone know how I could modify this code so that the object is dragged only on a given Transform/Plane (probably serialized) or just an axis? Screenshot is there for types in case
private IEnumerator DragObject(float distance) {
var oldDrag = m_SpringJoint.connectedBody.drag;
var oldAngularDrag = m_SpringJoint.connectedBody.angularDrag;
m_SpringJoint.connectedBody.drag = k_Drag;
m_SpringJoint.connectedBody.angularDrag = k_AngularDrag;
var mainCamera = FindCamera();
while (Input.GetMouseButton(0)) {
var ray = mainCamera.ScreenPointToRay(Input.mousePosition);
m_SpringJoint.transform.position = ray.GetPoint(distance);
yield return null;
}
if (m_SpringJoint.connectedBody) {
m_SpringJoint.connectedBody.drag = oldDrag;
m_SpringJoint.connectedBody.angularDrag = oldAngularDrag;
m_SpringJoint.connectedBody = null;
}
}
It's definitely some operation in the mainCamera.ScreenPointToRay part, gotta project it onto a plane or something
please for god's sake cache that m_springJoint.connectedBody to make it more readable
var connectedBody = m_springJoint.connectedBody;
It's taken from unity's old standard stuff lol
Something like that maybe (doesn't work)
it barely moves, i'm a bit confused
If this is your code then it did not compile and you have an error
Hey guys, I am using 0.1f length to detect ground. But when I wake down on a slope, It seems to be going into fall animation, because 0.1 isn't sufficient I guess.
i just took the screenshot quickly
i added the ;
i think my issue is i need to do something with 'distance' that's just not used anymore
Then you probably want to add more checks and detect slopes
I've got a weird one today. Has anybody ever run into an issue when trying to read a folder in your android install directory, but only when the folder contains a "+" in its name? I am loading some custom content that way and ran into an issue where a player had a folder with a "+" in it and it threw an unauthorized access exception for the files inside the folder. I was able to reproduce it and it seems like just renaming the folder with like Directory.Move() unfortunately doesnt fix the issue. It can only be fixed by renaming the folder outside of my game with a file browser. weird right?
I see, so like a forward/backwards check too?
So you copy pasted this code and now you're unsure how to continue?
Or am I misunderstanding your message about Unity's old standard stuff?
No, multiple checks around the player's bottom part of the collission, and then you can check how many rays touch the ground for example
To differentiate between slopes and ledges you could have additional rays that are longer/shorter. If only one of the two are hit then it's likely a slope
I've modified it unsuccessfuly and unsure how to continue, my initial question was how to project it onto a plane
that's an attempt
all the plane stuff was not in the code initially
Or make it easier and just make an adjusting ray that checks how far away the floor is
I see, thanks
I'm using curly braces to give variables declared in switch cases local scope so I can reuse variable names declared in different cases. However, VS is giving very weird auto-indent behavior when I do this. Can somebody give any advice as to what I should do to fix this?
I'm trying to modify something that drags a rigidbody in the world to move along a space
I ended up with this that works but does not use 'distanceToPlane'
while (Input.GetMouseButton(0)) {
var ray = mainCamera.ScreenPointToRay(Input.mousePosition);
var planeTransform = SkirmishServices.GameAssetManager.dragPlane;
Plane plane = new Plane(planeTransform.up, planeTransform.position);
float distanceToPlane;
if (plane.Raycast(ray, out distanceToPlane)) {
Vector3 intersectionPoint = ray.GetPoint(distance);
m_SpringJoint.transform.position = intersectionPoint;
}
yield return null;
}
How can I combine distanceToPlane with distance, or am I totally in the wrong direction to have it move along a plane rather than fully in 3d?
Hi I am trying to draw a continuous line with correct thickness at corners. I can use dot products etc to get it right up to 90 degrees but then the thickness fails to come out correctly and I get narrow corners. Anyone got the correct algorithm?!
You should never have special chatacters in a file path
I mean, there are specific characters that are obviously not allowed but some special characters is generally fine in my experience but when creating files or folders in my game, I do remove the special characters, but I allow players to add custom content so I cant 100% control what they name things, just try to account for it.
im trying to make a custom "hand" cursot where the sleve is always pointing to the right bottom corner. but i cant understand what i am doing wrong neither how atan2 works. my dad gave me a brief "introduction" to it but it still isnt working. i dont know what is wrong in my code: https://gdl.space/uximamuyon.cs. ill show you a vid on what its doing too.
float rot = Mathf.Atan2(anchorPoint.y + mousePos.y, anchorPoint.x + mousePos.x) * Mathf.Rad2Deg; this looks like youre understanding Atan2 completely wrong
yea i realised that too
does it work properly when you fix it?
what do you mean with fix it? im asking here cause i dont know how to fix it
you said "i dont know what is wrong in my code" so i assumed you didnt see this originally, but i think something like this should work
void Update()
{
Vector3 mousePos = mainCam.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = 0;
float xDiff = mousePos.x - anchorPoint.x;
float yDiff = mousePos.y - anchorPoint.y;
float rot = Mathf.Atan2(yDiff, xDiff) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0, 0, rot);
transform.position = mousePos;
Debug.DrawLine(anchorPoint, mousePos, Color.blue);
}
Couldn't you just do this?
Vector2 diff = mousePos - anchorPoint;
transform.up = -diff;```
yeah that would simplify it a lot, thanks for the insight 👍
how did you see this so fast, if i may ask?
experience or practice or...?
I've seen similar problems hundreds of times yes
There's a lot of usage of Atan2 that is unecessary
mostly due to copying of copying of copying of tutorials
there's always many way sto skin a cat but people usually skin the cat the same way they originally learned.
I hate that metaphor 😆
thanks allot guys! you are right i "copied" of a tutorial. it was not origianaly meant for this usage tho so it might have been because of that!
I'm trying to profile using superluminal (attaching to the editor), but I can't get it to recognize any managed callstacks. I've tried adding the Library\ScriptAssemblies folder as symbol file locations but it didn't help. I didn't find anything specific about this in the docs. Did I miss something?
If i loadSynchrounsly 2 scenes the time freezes and i can t play animations in the loading screen\
What can i do?
Well, loading synchronously means the game will hang until loading is done. What you want is Async
If I was creating a inventory system with items being a scriptable object and the inventory script being a component on the player which contains all the operations to add and remove inventory items would this be a good approach or should I have the inventory be a scriptable object itself. (inventory will be on npc’s and chests)
I'm trying to modify something that drags a rigidbody in the world to move along a space
I ended up with this that works but does not use 'distanceToPlane'
while (Input.GetMouseButton(0)) {
var ray = mainCamera.ScreenPointToRay(Input.mousePosition);
var planeTransform = SkirmishServices.GameAssetManager.dragPlane;
Plane plane = new Plane(planeTransform.up, planeTransform.position);
float distanceToPlane;
if (plane.Raycast(ray, out distanceToPlane)) {
Vector3 intersectionPoint = ray.GetPoint(distance);
m_SpringJoint.transform.position = intersectionPoint;
}
yield return null;
}
How can I combine distanceToPlane with distance, or am I totally in the wrong direction to have it move along a plane rather than fully in 3d?
why are you doing ray.GetPoint(distance); instead of ray.GetPoint(distanceToPlane);?
just use distanceToPlane in the getpoint func
even if use LoadSceneAsync the animation still dosen t play
It could if done right. We'd need to actually see some code
how can I get the angle between two raycasts? (2d)
effectively determine if the angle from a direct forward raycast and one pointing at an object is within a certain range
You can calculate the angle between two direction vectors with Vector3.Angle or Vector2.Angle
thats, worryingly simple
it has to do something that the loadingscreen is disabled at start?
scene activation takes place on the main thread so if it takes a short time to load and a long time to activate you won't see much animation, maybe that's it? can you log the progress each update to see when it freezes?
I mean, no. Idle is not a unity thing. And if the animation is specifically the issue (and not the scene loading), then ask in #🏃┃animation
Otherwise show the code
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
here
is this script attached to the LoadingScreen object itself?
Is it called loadingscree exactly?
yes i just pasted it from the folder
Oh sorry
loadinscree
i just type bad
is attached to a collider that when i press E just calls the Loadlevel() function
that doesn't actually answer my question lol
no then
Is the object it's attached to deactivated when the code runs?
is disabled from start
You can't run a coroutine on a deactivated object
the script isn t on the loading screen object itself
i just activate it in the coroutine
Sure but what about the obejct the script is actually on
is it active or not
it's a simple question
yes
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
here is the code from the collider
it isn t but when the game object is activated it should activate the animator too no?
You probably want to play the animation AFTER activating the object
I don't think the animator will be happy trying to play an animation when it's deactivated
No, not necessarily
so i just use a coroutine to wait
Of course - you should/could just be using the animator state machine here
you don't actually need to call animator.Play
If the animator is separately deactivated, it will remain in that state even if the object is activated
ok i will try that
just have the animator directly transition to the animation as the entrystate
If I was creating a inventory system with items being a scriptable object and the inventory script being a component on the player which contains all the operations to add and remove inventory items would this be a good approach or should I have the inventory be a scriptable object itself. (inventory will be on npc’s and chests)
pros and cons to both ways. Look at how other people have done it and go from there.
Scriptable Object should be used when you want setup something as an asset to instantiate and pass later (like items presets or configuration), or to keep settings on an asset.
Once it's instanced at runtime it is used like any regular data class
Treat SOs as parameters to the gameobject you want to instantiate
i don t know i m doing wrong but still not working i just used an IEnumerator to wait 0.1f seconds and play the anim after. Still don t work
Guess i'll try here to get some feedback. Don't know if this is going in the right directions in creating a class map or if i'm making some major mistakes:
Bit hard to know what is going on.
Looks like a mix of inheritance and composition?
I am assuming the character types all inherit from character?
Seems like a decent UML diagram to me but maybe clarify what the arrows are. Some seem like inheritance, some look like interactions and some look like dependencies
Usually you would split the interaction and inheritance diagrams
Or at least have some color coding or do dashed lines vs solid lines
It's been a while since I had a class on UML and still don't know how I passed it. Will work on clarity and making sure to show what is inheritance and what is interaction
I have two objects moving. The main one is a rigidbody and the other is using Vector2.MoveTowards. for movement. I have
{
...
}```
to detect collision on the top and bottom of the object and I destroy it when it does.(Both use box colliders)
However, sometimes when the rigidbody object hits the top/bottom corner of the other object, it does not detect that it was the top/bottom of the object. How can I make the detection more precise?
Vector2.MoveTowards is not a method of moving an object
you'd either be moving it via a Rigidbody (you should do this) or directly moving the Transform (you shouldn't do this)
Hmm, ok.
Mind explaining when it would be good for me to use MoveTowards then? For future reference.
You can use MoveTowards with whatever you want, including these movement methods
I'm just saying MoveTowards is simply a math function
ultimately you're either moving the object via a Rigidbody or the Transform
As for your actual question don't directly compare those vectors for exact equality
you'd be better off doing something like this:
Vector2 normal = collision.GetContact(0).normal;
if (normal.y > 0) {
// generally the top of the object
}
else if (normal.y < 0) {
// generally the bottom of the object
}
else { // == 0
// Directly on one of the sides of the object
}```
likewise for the horizontal part with .x
Oh god sorry
I was looking for #archived-networking but I'm blind and didn't see it
client can only move with RPC or Client Transform
I'll take my business over there lol
Oh I see
Still new to more manual networking stuff. I've been using the super high level stuff like pun and fusion for a while
I appreciate it
more or less the workflows are very smiliar
but yeah #archived-networking is better channel
That's part of the confusion, the previous method was using distance, using only the plane one generates almost no movement so I'm not quite sure how to resolve this
wait it just works...
I guess it was alright all along and i was doing something else wrong
Is this better in terms of readibility and understandability? And most important, is this a better class system or should I, for example, not have a spawn controller responsible for spawning in all the different characters
PlayerMovementController implements PlayerCharacter?
i think you aren't separating your concerns properly. you should avoid inheritance for concepts that can be represented by an enum (friend/foe) and not put them on the same level of abstraction as totally unrelated things player character that may need totally different things to happen inside.
whatever makes an entity what it is should be inferred from the components that compose it and how those components respond to the world based ont their config.
also your classes/components & relationships will get way messier so this "plan" may actually get in the way rather than help.
Hey, I'm following CodeMonkey's tutorial and he uses this code for detecting collisions. Is this better than just attaching a Collider component in a game object?
I wouldn't say better.
Perhaps more flexible
hello I need help I start programming and I encountered a problem, I want each set of 16*16 is a clickable button that allows access to an interface however how to do, I create a canvas and a button and a good code but I can not see this button, come in private message to make it easier thank you in advance
No private messages, it's the server rules.
Make sure your buttons are inside the bounds of a Canvas. Further questions should be asked in #📲┃ui-ux
You should not inherit to create different type of Character. Usually, I use what I call "Faction" (ScriptableObject) to define Foe, Enemy, Neutral, Player, etc.
HealthModule, StaminaModule, ManaModule and MovementModule seem to be overkill. Start by using simple function than whenever the script start to be bigger divide it in smaller part.
Sup guys, im trying to experiment with the netcode for gameobjects package, but i cannot install the 2.0.0-exp 2 version, and i cant find it to install, any tips on how to find install this version?
I guess a grid layout group could help u
Cool, I appreciate it!
Where have I gone wrong?
...
if (IsOwner)
{
SetSpawnLocationRpc(spawnLocation.position);
}
}
[Rpc(SendTo.Server)]
public void SetSpawnLocationRpc(Vector3 position)
{
networkTransform.Teleport(position, new Quaternion(0,0,0,0), new Vector3(1,1,1));
}
}```
Rpc is marked abstract. Use one of its subclasses that are not abstract
Thanks
I have a script that cycles between color hues to give my text a rainbow effect.
sat = 1, bri = 1.
void Update()
{
Color.RGBToHSV(fillTexts[7].material.color, out hue, out sat, out bri);
hue += rainbowSpeed * Time.deltaTime / 10000;
if (hue >= 1)
{
hue = 0f;
}
fillTexts[7].material.color = Color.HSVToRGB(hue, sat, bri);
}
The hue of the text changes every frame. However, the cycle consistently pauses for a moment. I'm not sure what I'm doing wrong.
When the hue gets over 1, try with hue -= 1; instead, so the line isn't "broken" when it goes over that value.
0.8 -> 0.95 -> 0.1 (= 1.1 - 1)
I tried as you suggested, but it's still pausing in between cycles.
Color.RGBToHSV(fillTexts[7].material.color, out hue, out sat, out bri);
hue += rainbowSpeed * Time.deltaTime / 10000;
if (hue >= 1)
{
hue -= 1f;
}
fillTexts[7].material.color = Color.HSVToRGB(hue, sat, bri);
you sure it's actually a pause and not just a perceptual inability to distinguish between different greens for example?
Debug.Log(hue);
Funny you say that, because around the green is when the cycle does that.
yeah
the band of greens is I'm pretty sure more difficult for humans to disambiguate
I could be making that up
but it feels right 😆
Sounds believable, I'm trying the logs.
It could also be a problem with:
- your eyes (a type of colorblindness)?
- your monitor (they all have different color ranges etc)
Okay, something funky is going on.
The hue is consistently going up, until it hits .28. Then it jumps to .35.
every time the same thing?
The line with deltaTime looks a bit funky
It took 4 frames to go from .27 to .28. Then 1 frame to get to .35.
Maybe there's float imprecision that's amplified by that division at the end?
maybe you have a framerate hiccup
that's also possible yeah
what's up with that that crazy Time.deltaTime / 10000 thing?
that's going to play hell with your precision
that implies to me that your rainbowSpeed must be a massive number
This is a modified version of a tutorial I found. I modified it by adding in deltaTime, which wasn't there before. However, I was experiencing the color pause issue with both my version and his version.
Correct. 10000.
would you mind sharing the rest of the code? (though I fear it's ugly given the hardcoded 7 in there 😭 )
why not just make that 1 and delete the 10000 thing
Sure, I wanted to get this to work before changing things up though.
well it might help
📃 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 tried with 1f instead of 10000f and removed the division after the delta time.
Same "pause."
Well it's weird you're saying it's pausing when the hue is actually jumping very quickly
My guess at this point is you are having a framerate stutter
The game is running smoothly.
my next suggested course of action would be to use the profiler and see if there's a frame spike.
It might have to do with the consecutive RGBToHSV (reads) and HSVToRGB (writes) on the material. Maybe these have some rounding or precision errors themselves. Why not store HSV in the script directly as fields instead of reading them from the material every time?
I wonder if it'll look normal if I run it built.
by the way I[m very confused by this:
texts[2].GetComponent<Text>().text```
Why are you doing `GetComponent<Text>()` when `texts` is already a `List<Text>` 🤔
pretty sure you can get rid of every GetComponent<Text>() in this whole script
yes - confirmed, you should be able to
This is something that I discovered recently, and I will be going through and cleaning it up.
You're right.
Okay, I am making this revision.
https://gdl.space/qegecofida.cs
I'm doing something wrong. My hue value is .002, so it's staying red. I modified the code to use the rgbToHsv field instead.
I modified line 65, 97 and 98.
tfw your colliders don't collide and you fix that and now your colliders are colliding the wrong layers

You technically don't need to convert to HSV on line 58 nor having a RGB representation, just have one hue variable in the class and do Color.HSVToRGB(hue, 1, 1); when assigning to the material on line 65.
And increment that hue variable only
the "include layers" thing is for overriding which layers touch, rather than specifying only what layers it touches, isn't it
I know this isn't really code, but I don't know where else to go.
GPU: Intel UHD Graphics 630
The code works the same with or without line 58, I've taken that out.
I'm trying to understand what said you here, "just have one hue variable in the class and do Color.HSVToRGB(hue, 1, 1); when assigning to the material on line 65."
on line 65, hsvToRgb = Color.HSVToRGB(hue, sat, bri) and sat = 1, bri =1, so I thought that was the same as you just suggested here.
Looks the same built or not.
Correct, mine was just a simplification since SV are both always 1.
Line 65 currently does not recompute a RGB Color based on the new hue (it uses hsvToRgb), so the material will stay at the same color
Okay, so I should leave line 65 the way it was originally:
fillTexts[7].material.color = Color.HSVToRGB(hue, sat, bri);
Yup, remove line 58 if you haven't done so yet, and that should be it
Then I guess it no longer matters if Color.HSVToRGB is a field anymore since it's only used once per frame?
Yes that hsvToRgb field can be removed as it's not used anymore. Make sure to apply roughly the same edits in your void LevelComplete() method to not get any compiler errors
https://gdl.space/vulalibome.cs
The result is the same. Once again, suspiciously, around green is when the pause happens. I'll record it.
@simple egret
I'll download that, slow it down a lot and see if I can see the issue using a color picker
PraetorBlue might be on to something. It seems like there's a lack of color diversification when green is reached.
It kind of happens around red as well, but not as badly.
Also the color is permanently modified to whatever color I leave on when I stop the gameplay, meaning it starts at a different hue. The "pause" still occurrs when the green shade is hit.
There's no clear pause on the RGB values on that video, slowed down 50 times. So it's probably just the eye not able to distinguish shades of green as precisely as other colors
I mean just look at this. Doesn't "green" just look bigger than any of the other colors? Or is it just me.
Yes, it does.
Like we consider more of the turqoise and yellow zones still to be "green" than we do for the red/orange zone for example
This is so interesting.
I might just have it skip a section of the hue and see if it looks smoother.
or go faster through the green zone 😆
BTW human vision and perception is absolutely fascinating
that's a wikipedia rabbit hole that can last you for weeks
Well, I'm officially knee deep in this stuff right now so I might check it out.
Yeah, I think having it speed up in the green zone makes the most sense.
if (rainbowText)
{
if (hue >= 0.2f && hue <= 0.4f)
{
rainbowSpeed = 3f;
}
else
{
rainbowSpeed = 1f;
}
hue += rainbowSpeed * Time.deltaTime;
Debug.Log("hue = " + hue);
if (hue >= 1)
{
hue -= 1f;
}
fillTexts[7].material.color = Color.HSVToRGB(hue, sat, bri);
}
So simple. It looks smooth now.
Thank you SPR2 and PraetorBlue 
Wild. Now you just have to do a massive neurological study on your users to see exactly what their internal color wheel bias is and apply that statistical model to the code then it will be perfect 👌
Haha, that's all huh? Guess I'll just have a menu at the beginning and they do the work and fill in the value themselves.
Wikipedia says we have 1/3 of cones that detects green, so setting the speed to 3 counteracts that effect perfectly (?)
Lucky guess.
So, this is actually true. Humans have a much greater chance at detecting green due to how common it is on plants. Herbivores and Omnivores are much better at discerning green from other colors so we can more easily notice fruits and berries in foliage.
Color vision is pretty buck wild, tbh
it’s almost like you have twice as many green cones as red/blue cones
@swift falcon !collab
We do not accept job or collab posts on discord.
Please use the forums:
• Commercial Job Seeking
• Commercial Job Offering
• Non Commercial Collaboration
I'm playing this game, with basic unity text, the code below is what the image is.
Is there a way to Outline the text with a color?
<i><size=95px><b>R<size=590%>obinson <i><size=95px><b>G<size=590%>ap <size=95px>C<size=590%>oal
yes you can apply a different material to a specific word / letter
How does one do that?
http://digitalnativestudios.com/textmeshpro/docs/rich-text/ doesn't link directly but its part of font #6
Rich text documentation for TextMesh Pro.
So what would the code be?
or prefix
material =
material = outline?
does it not work ? its been a while since i used the rich text
material="NotoSans Outline" <i><size=95px><b>R<size=590%>obinson <i><size=95px><b>G<size=590%>ap
This is what's its doing
Treating it as regular text
it needs to be in the <font> tag
but I think that might not work with TMP material but font material?
<font material="NotoSans Outline"> <i><size=95px><b>R<size=590%>obinson <i><size=95px><b>G<size=590%>ap
This doesn't work either
idk
it says it needs to be in specific folder
Whatcha mean?
This is using the ingame text box
did you read a word of the page I sent ?
I'd like to think so 🤣
I tried the <font> tag, with and without the material and it didn't register
I tried all of the tags on the site, didn't register within the game.
private void OnDoubleClick(PointerEventData eventData)
{
RectTransform mapPanelRect = mapPanel.GetComponent<RectTransform>();
Vector2 localPoint;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(mapPanelRect, eventData.position, miniMapCamera, out localPoint))
{
MapController.instance.SetDestinationMarker(mapPanel.transform.TransformVector(localPoint));
Debug.Log($"MiniMapController: OnDoubleClick: evenData.position {eventData.position}" +
$"\nlocalPoint {localPoint}");
}
}
I'm so stuck XD
Anyone else got any ideas?
I'm working with delegates and I'm want to use a func<bool> to return a boolean value. However, Unity throws this error message "Cannot convert expression type 'System.Nullable<bool>' to return type 'bool'".
None of of the other types have required extra steps so I'm confused.
Here's my code:
public static Func<bool> PlayerAliveStatus;
public static bool CheckPlayerAlive() => PlayerAliveStatus?.Invoke();
if I convert the static bool to a "bool?" , it throws the same error anytime i try to call the func.
because your Func<bool> might not actually have a function assigned to it yet
in which case it wouldn't return true or false, it would return null
you should instead do CheckPlayerAlive() => PlayerAliveStatus?.Invoke() ?? false; to return false if the expression is null
Seems to be working. learnt something new today. Cheers
Im trying to get the height of my terrain mesh using a raycast and it never prints anything
and im confused why there aren't any collisions
Try visualizing the ray
Your origin is 1000 y
And distance is 1
So it goes from x, 1000, z to x, 999, z
How do you know that?
wait
wydm
Oh
how do i fix that ☠️
The first parameter is origin point
How do you know that this specific code executes?
the trees spawn
mhm
Multiply Vector3.down by a number to increase range
And consider lowering the origin
Unless you NEED it that high
oh
alr
uhh i dont think i see the ray
wait
i think i saw them for a second
oh i see htme
i js needed to change the duration
i can created a script where it will generate random numbers from 1-5, depending on the output, it will generate an enemy on the number generated. For example if the number generated is 3 then it will spawn an enemy on spawner 3.
It worked completely fine although when i instantiate the enemy model, i have an error in navmesh.
Error : ```"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination (UnityEngine.Vector3)
enemyMain:gotoPlayer () (at Assets/Enemies/enemyMain.cs:46)
enemyMain:Update () (at Assets/Enemies/enemyMain.cs:32)
seems the agent isn'tactive when you call SetDestination
ik but idk how to fix that
i am messing with navmesh for the first time so idk many things about it
Getting a bunch of errors in the Library/ScriptAssemblies folder every time i re-compile code. If i close unity, delete the script assemblies folder and re-open it goes away temporarily; but every now and then when i re-compile scripts the error comes back then i'm forced to close unity again. Getting the problem in Unity 2022 LTS, 2023 Alpha and 6 Beta. It mentions a bunch of bultin unity DLL's as you can see in the screenshot so it's not like i can just removed one package and fix the issue. Anyone run into this issue before or have an idea what i could try?
Close Uniity, delete the complete Library folder and the Temp folder if it exists
I'll do that, i was kind of hoping i wouldn't have to though and figure out what the root cause is because recompiling the whole project will take a while and who knows if that solves the problem permanently or just for a few days. But alright thanks @knotty sun i'll do that for now
tbh you should never touch anything inside the Library folder unless you really, really know what you are doing. Getting the whole folder rebuilt should straighten things out
Hi, I have the same question as this guy from the forums and I want to know if I should use Physics.Capsulecast or Capsule collider for my player
The main reason for using Casts rather than colliders is if you have very fast moving objects or very thin objects. Colliders can be inaccurate in this case
Yeah so deleting the library folder helped for about 20 minutes and now i am getting the issue again
Deleting the library doesn't help if i don't know the root cause because i won't know what it is that is making the issue re-appear
Are you using something like OneDrive?
any chance it's an antivirus thing? are you able to exclude your project folder from scanning? i've had issues with that in unity before
Yes i was using OneDrive actually. Turned it off now and deleting the library folder and re-opening the project and will see if it happens again
Thank you simonp i'll check that as well
Yeah, unity projects should never be in a OneDrive controlled folder
Oh the folder that has my projects itself i don't think was synced to OneDrive so it might be the antivirus, but i'll check both and let you know,. Thanks guys
Yeah seems to be fine now, looks liek it was the antivirus settings. Exluded my projects folder as well as the Unity folder in program files that has all the version installs. Will give it like 30 minutes of updating and saving scripts but for now it seems to be working
Thanks guys
Interesting, which Antivirus are you using?
Just the builtin windows protection
Never had a problem with Windows Defender
it can't hurt for performance at least, but yeah my bad antivirus experience is with stricter corporate stuff
good catch though
let's see if it stays fixed haha
indeed
Hopefully 😅 😂
Noooo, it's happening again. OneDrive is completely disabled and got all unity related folder exluded by the builtin windows defender
Does it not have to do more with Visual Studio maybe? The reasoning i'm thinking that is because why would i suddenly be having this issue in multiple unity versions. The only common link is that i'm using the same Visual Studio 2022 in all the projects
Just being in the directory associated with one drive could be the cause. Also, changing this kind of settings it's advised to restart your PC.
Yeah so i closed unity, excluded the folders in the antivirus, disabled one drive, deleted by library folder and restarted the PC, so when i opened the project and re-compiled scripts the unity project was the only thing open
If nothing helps, I'd try checking what process accesses the files.
Why can't I add modules. Because currently for coding the programm opens up my Visual Studio Code. However writing in this programm does not help me to write code. Usually as one types the first characters of a command it is recommended so one can simply hit Tab and the word is fullfilled. Yet Visual Studio Code does not do that for me. Is there a way to add Visual Studio Code as a module to Unity or is there any other way for my external Visual Studio Code to be able to see the code and so recommend it to me as I'm typing?
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
Usually the attribute .name would now be recommended for my by Visual Studio Code, but it isn't
Please check the steps for configuring your !ide and maybe consider switching to either Visual Studio or Jetbrains if possible.
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
Will do
@thin aurora @cosmic rain I done set it up, yet the recommendations still doesn't work 😦
Sorry, not too familiar with VSCode
Damn
This is the features name
Intellisense is the same everywhere. If it doesn't work for you, then you don't have it configured correctly. Follow the guide again.
Just in case you don't know, setting it in external tools is not the only step.
I've also checked the package mananger
What about the extension in vs code?
Installed it
Try opening the console and checking the intellisense category
Oh I just noticed smth
Could it be that the intellisense is not working because of this error:
Download a .NET SDK:
https://aka.ms/dotnet-download
Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
2024-04-17 12:20:37.147 [info] Additional information of .NET SDKs for diagnostic
global.json file:
Not found
Host:
Version: 6.0.21
Architecture: x64
Commit: e40b3abf1b
.NET SDKs installed:
No SDKs were found.
.NET runtimes installed:
Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Download .NET:
https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs:
https://aka.ms/dotnet/runtimes-sdk-info
2024-04-17 12:20:37.162 [info] Project system initialization finished. 0 project(s) are loaded, and 1 failed to load.
Most likely, yes.
Is ".NET SDK" required for VS code or unity or?
Installing the Unity extension installs all its dependencies required to write C# with Visual Studio Code, including the C# Dev Kit.
The dot net is usually installed by one of these extensions, but sometimes you have to install it manually
Vs code.
@cosmic rain Thank you so much! Works perfectly fien