#archived-code-general

1 messages · Page 307 of 1

devout silo
#

normal sprite

leaden ice
#

why not:

Vector3 direction = end_t - start_t;
transform.up = direction;```
#

(or possibly transform.right depending on how your sprite is laid out)

devout silo
#

thanks

#

trying

cloud python
#

ok, and I'm supposed to make a new repository?

rigid island
naive swallow
rigid island
#

GUI will probably be easier

proven marsh
#

Yo can anyone help my ass at advanced section, (i dont know if im allowed to ask, sry my bad if not allowed)

rigid island
rigid island
#

great, so check out those steps and setup repo that way

#

be sure to select the gitignore properly

cloud python
spring creek
#

It is clicking a button in the email they sent you

#

(Pretty standard)

cloud python
cloud python
#

check spam?

naive swallow
#

yes

cloud python
#

I did not get that

spring creek
# cloud python 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

cloud python
#

don't have a spam folder

#

also, I have repositiry that is already published but no stuff is in there

spring creek
#

Stop cropping things so much. You have a very bad habit of always doing that

#

Show the whole window

cloud python
spring creek
#

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?

cloud python
spring creek
cloud python
naive swallow
spring creek
cloud python
naive swallow
somber nacelle
#

is there actually anything in that repository?

cloud python
#

ok, now I have published the repositiry,

rigid island
#

@cloud python click on History

spring creek
#

You never answered if this repo is actually linked to your current project though. You said it was something from school in 2023

cloud python
rigid island
#

just gitignores

#

its empty besides that

#

looks like you did the wrong folder

cloud python
#

huh?

#

wrong folder?

spring creek
naive swallow
#

What does your local folder for this repository look like

cloud python
naive swallow
#

The place on your computer this repository exists

naive swallow
# cloud python

Okay, so, I use actual computers so I'm not sure how it looks in mac, but that looks pretty empty to me

rigid island
#

cries in macbook

spring creek
#

Wrong place @cloud python

#

Look INSIDE the project folder

#

Wait wait.. maybe i'm wrong. You have two projects named similarly

rigid island
#

might be easier to just create the repo by doing Add Existing Repo

spring creek
#

Now I'm guessing you created a local repo instead of linking to your exisiting one

rigid island
#

then selecting the project folder

naive swallow
#

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

cloud python
rigid island
spring creek
#

Also empty?

rigid island
#

its literally a nobrainer step by step

#

if you mess that up something is wrong

spring creek
cloud python
rigid island
#

should be no problems

spring creek
#

The folder with all the stuff you are working on

cloud python
rigid island
#

you can literally delete the other blank ones you made

cloud python
rigid island
#

add Local Repo

spring creek
#

Can you guess which of those is closest to it?

cloud python
rigid island
#

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

cloud python
rigid island
cloud python
#

well I can't click on add repository, am i suppose to click on create a repository?

rigid island
#

didnt I literally say that was gonna happen?

cloud python
rigid island
#

so why are you asking something that was explained already

cloud python
#

almost there

rigid island
cloud python
rigid island
#

finally

#

ok. Just publish

cloud python
rigid island
#

you're officially using git on your repo congrats lol

#

periodically make Commits when major changes

cloud python
rigid island
cloud python
#

oh

rigid island
#

this is for you to track your project and its history of changes, and possibly revert any breaking change

lean sail
#

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

rigid island
#

that would be all good if you didn't have to be explaining the whole process again lol

lean sail
#

Yea not it

rigid island
#

@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

jaunty ore
#

Hello! I was wondering how I would go about making a basic planet orbiting system in unity?

rigid island
#

rotate around

#

plus I guess transform.Rotate for self rotation

jaunty ore
#

ok! thank you!

rigid island
# cloud python or like this

yup pretty much thats how you see what you changed , bottom right is where you write the name of change / summary

surreal cloak
#

why does this public List<List<AudioClip>> footstepSoundLists; not show up in the inspector

rigid island
#

use a custom struct/class (make it Serializable)

#

List<CustomStruct>>

#

CustomStruct Has list of AudioClips

leaden ice
cloud python
#

so.... now i have that

rigid island
cloud python
#

like that

rigid island
#

you should know, do you have custom script / gravity ? is movement script enabled? etc.

jaunty ore
#

I'm confused. Why is this errored?

rigid island
leaden ice
#

You need to call it on a specific Transform

rigid island
#

you're trying to use the class. which is just a blueprint

#

also those brackets lol

leaden ice
#

minecraft font lol

rigid island
#

oh my, thought it looked familiar

cloud python
rigid island
jaunty ore
leaden ice
#

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

jaunty ore
#

ok

rigid island
#

on that note.
any "Component" has access to the transform and gameObject properties the component is on

rigid island
#

how do you expect it to fall exactly

cloud python
rigid island
#

alright but now you see why it aint fallin

cloud python
# rigid island

is that if the player dies, the death animation would play but falling through the ground while the circle collider is dissable

cloud python
rigid island
#

thats fine but you just need to reset it

cloud python
#

yeah

rigid island
#

I usually have an Init() method that restores the player to its original values

cloud python
#

you mean Int

rigid island
#

nah Init short for Initialization

cloud python
#

oh

cloud python
rigid island
#

You should know your own code no

cloud python
rigid island
#

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...
cloud python
#

idk, it worked before

rigid island
#

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

cloud python
lean sail
#

dont think ive ever seen so much Find

rigid island
#

also you should not use ? on unity objectsGameObject.FindGameObjectWithTag("Player 2")?.

naive swallow
rigid island
#

its not like they haven't made any references before..

naive swallow
#

It took three hours to explain how to set a variable

#

Like four days ago

lean sail
#

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

rigid island
#

the two player thing is kinda complicating the situation

#

since they are doing same code twice instead of just using a generic player

lean sail
#

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.

naive swallow
lean sail
#

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

cloud python
cloud python
naive swallow
lean sail
naive swallow
#

assuming that was the truth then, this would already be your second project right

cloud python
naive swallow
#

There comes a point where you need to just throw your code into the sun, start at !learn, and make pong

tawny elkBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

lean sail
#

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

elfin tree
#

What would be a clean way to make a TrailRenderer (or any GameObject) go around a UI element's bounds?

rigid island
#

if its only the bounds though, it probably can be easier without splines though

#

since you're not doing curves

cloud python
broken pier
#

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.

cloud python
rigid island
#

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

naive swallow
cloud python
naive swallow
rigid island
rigid island
#

nor should we waste time fixing gpt code

#

its nonsense spam generator

broken pier
#

thats cool

rigid island
broken pier
#

thx. Im hoping there is a section to reference other scripts?

elfin tree
elfin tree
cloud python
rigid island
rigid island
#

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

cloud python
elfin tree
#

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

rigid island
cloud python
rigid island
#

huh? so basically what I said?

#

these GameObject.FindGameObjectWithTag everywhere.. atrocious, really get into a habit of linking things in the inspector

naive swallow
cloud python
rigid island
rigid island
#

if you didn't skip out the basics you would store them inside an Array/List of Player type

cloud python
soft shard
#

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?

rigid island
#

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

surreal cloak
soft shard
rigid island
rigid island
#

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

cloud python
elfin tree
#

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)

steel quartz
#

Maybe you could set it to child of the ui element object?

#

Or make a dampening effect

elfin tree
#

oh that might be all there is to it, lemme see

jaunty ore
elfin tree
jaunty ore
# jaunty ore books way better

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

steel quartz
elfin tree
steel quartz
elfin tree
#

i want to avoid it having that efffect on the trail renderer

cloud python
steel quartz
elfin tree
#

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)

rigid island
spring creek
elfin tree
cloud python
elfin tree
#

he means repeating that to yourself makes it true

rigid island
#

"careful what you wish for" etc..

spring creek
# cloud python what do you mean by that?

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

cloud python
#

you know, maybe I should take a break from the coding for a while and focus on designing a bit for two other stages.

elfin tree
#

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

lean sail
jaunty ore
cloud python
#

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

latent latch
cloud python
cloud python
rigid island
cloud python
lean sail
# jaunty ore irl

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

cloud python
latent latch
#

throw it all in your dev log

minor swan
#

Then just multiply by Time.deltaTime to get rotation per frame

lean sail
#

i was hoping that last part would be obvious in the general channel

jaunty ore
#

oh yeah I should do that. I forgot Time.deltaTime in my script, thats why it was really fast

minor swan
jaunty ore
#

yeah lol

jaunty ore
#

K yeah that works

#

thanks!

elfin tree
#

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?

elfin tree
#

do you know what i mean?

#

basically you're looking at a trail renderer going around a button

latent latch
#

ah, I'd a shader and textures

#

I could think of ways of doing it with the vfx graph though

elfin tree
#

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...

▶ Play video
elfin tree
#

i guess i'll give up on that idea

agile wren
#

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 🥲

latent latch
elfin tree
modern creek
#

Sorry - just catching up on the backlog messages

cloud python
#

well I'll be taking a break from coding and now focus on designing for 2 other stages, and maybe for the boss stage

modern creek
#

Whatcha need, n1co?

mossy snow
#

what's wrong with a masked sprite underneath the button? you guys seem to have gone straight to hard mode

modern creek
#

oh particles in UGUI?

somber nacelle
elfin tree
#

i've kinda did what u did in a way, but since in my case it can move it's weird

modern creek
#

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

elfin tree
#

yeah that's the problem :/

#

i don't think there's an easy fix

modern creek
#

Do you use coffee particles? (I forget the exact library but it's something bland like "particles for UI")

agile wren
#

im asking for help just that

modern creek
elfin tree
modern creek
#

yep, they're 100% in UGUI space

elfin tree
#

ah that might be as simple as that

modern creek
#

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

elfin tree
#

i assume that would work just the same in a world space ui

modern creek
#

(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

elfin tree
#

alright, well thanks for the suggestion, something to experiment with

#

you did that with the ugui particle thing right?

modern creek
#

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

elfin tree
#

for me it kinda needs to go around

modern creek
#

yeah, i did it with the coffee particles on a spline that roughly matched the shape of the button

elfin tree
#

so you werent able to make a trail that wouldn't be messed up by a scroll view?

modern creek
#

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

elfin tree
#

for when i know what that means haha, sounds like an idea

modern creek
#

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

tardy crypt
#

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?

leaden ice
#

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

tardy crypt
#

So this would order them by date then?

leaden ice
#

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

tardy crypt
#

What exactly is a priority queue as opposed to a normal queue?

leaden ice
#

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

tardy crypt
#

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.

leaden ice
#

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

tardy crypt
#

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?

somber nacelle
#

well you won't be able to use a dll that targets a version of .net that unity does not support

leaden ice
#

I don't think it's any harder or easier than any other platform

tardy crypt
#

Ok thanks.

reef garnet
#

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

broken pier
rapid stump
#

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}");
        }
    }
subtle depot
#

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

jaunty ore
#

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?

leaden ice
#

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

jaunty ore
#

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

leaden ice
#

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)

jaunty ore
#

Im still very new to this

leaden ice
#

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...

jaunty ore
leaden ice
#

that article also contains much of the math you'd need to make that a realty

leaden ice
jaunty ore
#

yes

leaden ice
#

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

jaunty ore
#

Is there a way that I can do all of this inside of the script itself?

leaden ice
#

Isn't that what we're talking about?

#

I'm talking about the name of a variable here

jaunty ore
#

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?

leaden ice
#

sure

[Range(0, 90)]
public float inclination;```
#

then you could do like

Vector3 orbitalAxis = Quaternion.Euler(0, 0, inclination) * Vector3.up;``` for example
jaunty ore
#

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

jaunty ore
leaden ice
#

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?

jaunty ore
#

Yeah I did that, it just doesn't do anything

leaden ice
#

wdym by "doesn't do anything"

#

surely it does something

jaunty ore
#

Hold on lemme get a vid

leaden ice
#

Unless you didn't have the basic orbiting code working in the first place

#

in which you may have some other issue.

jaunty ore
#

It does

#

Turns out it does do something

#

ummmm

#

it makes Unity not want to live.

#

it crashed

leaden ice
#

Very little chance of that code crashing Unity. Either an unrelated crash or you have an infinite loop somewhere or something

jaunty ore
#

turns out that was a one off

#

didn't happen again

leaden ice
# jaunty ore

Your code is very clearly useing Vector3.up as the orbital axis still

rapid stump
#

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}");
        }
    }
jaunty ore
leaden ice
#

why are you just ignoring the orbitalAxis we defined

#

that's the whole point of calculating it.

#

You should use it

jaunty ore
#

ok, so I did a thing. Not sure if it's a good thing (prolly not) and now it's editing the rotation

jaunty ore
vapid lynx
#

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

fervent furnace
#

you may claim for too much memory when initialise the 2d array and your os kill your editor, btw read the crash report

leaden ice
jaunty ore
#

huh

#

hold on

leaden ice
#

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

jaunty ore
#

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

jaunty ore
leaden ice
#

The PlanetRotate script may be messing with it

jaunty ore
#

Ill disable and see

#

nope

jaunty ore
leaden ice
#

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

jaunty ore
#

Yeah I think I'm just gonna rewrite this

vapid lynx
#
  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

lapis kernel
#
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)

soft shard
kindred otter
#

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.

lean sail
#

thats the point of the event keywrod

kindred otter
foggy meteor
#

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

rigid island
#

this would only trigger on the collider that has this script

foggy meteor
lyric moon
#

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

rigid island
foggy meteor
lyric moon
rigid island
#

obstacles can have their tag so all you need is tag

foggy meteor
#

i just need to have them have 2 colliders

rigid island
foggy meteor
rigid island
foggy meteor
#

So like this right?

rigid island
#

the list isn't needed, also this script should go on player

foggy meteor
deft timber
#

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

foggy meteor
#

what do u mean obstacle compoment

deft timber
#

do you know what is a component?

foggy meteor
deft timber
#

there is if you create it lol

foggy meteor
#

. . . 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

deft timber
foggy meteor
#

U mean a script?

deft timber
#

yes, a mono behaviour script

#

like Omstakels

foggy meteor
#

That is the obstacle script

#

im dutch

#

Omstakels is dutch for obstacles

deft timber
#

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

foggy meteor
deft timber
#

is the player a obstacle?

foggy meteor
#

No

deft timber
#

so why do you add Obstacle component to it?

foggy meteor
#

Look buddy all i want is to lose points when the player bumps into an obstacle

deft timber
#

i get that

#

but you need to fix your thinking logic first

foggy meteor
#

explain

deft timber
#

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

foggy meteor
#

The player is the bouncy ball and the obstacles are the floor

deft timber
#

okay but the player is not a obstacle

foggy meteor
#

dont i need to use OnTriggerEnter

deft timber
#

so why do you want to add obstacle component to it, asnwer my question

foggy meteor
#

Bc the other person said put it on the player

deft timber
#

who said that

deft timber
#

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

foggy meteor
#

No

#

Im trying to make a minigame

#

fixed it

#

it works now

#

i did what u said

#

this works

deft timber
#

cool

rigid island
# foggy meteor This one

huh i simply was saying you can put the script on the player too detect obstacles instead but you misunderstood

foggy meteor
rigid island
#

fix an axis?

foggy meteor
#

I thought did would do the trick

deft timber
#

you should use google more often

#

before asking such basic questions tbh

rigid island
deft timber
#

trying to help, not being rude

foggy meteor
rigid island
lyric moon
#

ok im still confused.
if i change profileToCopy.ShearModifier (its a float.) will it also change ShearModifier in this class?

leaden ice
#

Floats are a value type

#

Value types are copied by value, not by reference

lyric moon
#

is there an easy way to know whats a value type and whats not

leaden ice
#

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

lyric moon
#

ah alright i get it
ty ty

leaden ice
#

(float is actually called System.Single)

half garden
#

thank you

vestal arch
#

is it possible for a coroutine to define behavior when StopCoroutine/StopAllCoroutines is called?

leaden ice
#

No

vestal arch
#

aight

#

thanks

worn oasis
#

Hey all, I'm attempting to import Unity.InputSystem, which is installed via the package manager but getting this error.

cosmic rain
worn oasis
worn oasis
#

oh, assembly definition, not in the folders I moved stuff around in

trim schooner
#

sounds like you'd be better off asking in #🖱️┃input-system - as that code isn't yours, its the auto generated code

worn oasis
#

Okay, thanks

worn oasis
#

oh that's plastic, nvm...

trim schooner
#

Ignored? Is that Unity's Version Control?

If so, yes, of course. The package's are local and you shouldn't be editing them

reef garnet
#

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&

elfin tree
#

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

deft timber
#

please for god's sake cache that m_springJoint.connectedBody to make it more readable

#
var connectedBody = m_springJoint.connectedBody;
elfin tree
#

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

thin aurora
#

If this is your code then it did not compile and you have an error

untold grotto
#

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.

elfin tree
#

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

thin aurora
covert rock
#

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?

untold grotto
thin aurora
#

Or am I misunderstanding your message about Unity's old standard stuff?

thin aurora
#

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

elfin tree
thin aurora
#

Or make it easier and just make an adjusting ray that checks how far away the floor is

untold grotto
#

I see, thanks

tardy crypt
#

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?

elfin tree
#

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?

placid summit
#

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?!

spring creek
covert rock
# spring creek 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.

crisp folio
#

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.

ocean hollow
crisp folio
#

yea i realised that too

ocean hollow
#

does it work properly when you fix it?

crisp folio
ocean hollow
#
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);
}
leaden ice
#

Couldn't you just do this?

Vector2 diff = mousePos - anchorPoint;
transform.up = -diff;```
ocean hollow
ocean hollow
#

experience or practice or...?

leaden ice
#

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 😆

crisp folio
#

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!

marsh wadi
#

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?

unique delta
#

If i loadSynchrounsly 2 scenes the time freezes and i can t play animations in the loading screen\

#

What can i do?

naive swallow
#

Well, loading synchronously means the game will hang until loading is done. What you want is Async

inland kiln
#

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)

elfin tree
#

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?

ocean hollow
#

just use distanceToPlane in the getpoint func

unique delta
spring creek
unique delta
#

the animation is the idle one so it should always play

#

no?

static matrix
#

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

leaden ice
static matrix
#

thats, worryingly simple

unique delta
#

it has to do something that the loadingscreen is disabled at start?

thick terrace
spring creek
unique delta
#

here

leaden ice
spring creek
unique delta
#

yes i just pasted it from the folder

spring creek
#

Oh sorry
loadinscree

unique delta
unique delta
leaden ice
unique delta
#

no then

leaden ice
#

Is the object it's attached to deactivated when the code runs?

unique delta
#

is disabled from start

leaden ice
#

You can't run a coroutine on a deactivated object

unique delta
#

the script isn t on the loading screen object itself

#

i just activate it in the coroutine

leaden ice
#

Sure but what about the obejct the script is actually on

#

is it active or not

#

it's a simple question

unique delta
#

yes

leaden ice
#

what about the animator?

#

Show some details there.

unique delta
#

here is the code from the collider

unique delta
leaden ice
#

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

unique delta
#

so i just use a coroutine to wait

leaden ice
#

Of course - you should/could just be using the animator state machine here

#

you don't actually need to call animator.Play

spring creek
#

If the animator is separately deactivated, it will remain in that state even if the object is activated

unique delta
#

ok i will try that

leaden ice
#

just have the animator directly transition to the animation as the entrystate

inland kiln
#

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)

woeful spire
sleek bough
#

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

latent latch
#

Treat SOs as parameters to the gameobject you want to instantiate

unique delta
#

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

drifting sun
#

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:

spring creek
#

I am assuming the character types all inherit from character?

west lotus
#

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

spring creek
#

Or at least have some color coding or do dashed lines vs solid lines

drifting sun
#

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

sharp sky
#

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?
leaden ice
#

you'd either be moving it via a Rigidbody (you should do this) or directly moving the Transform (you shouldn't do this)

sharp sky
leaden ice
#

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

languid hound
#

Oh god sorry

rigid island
#

client can only move with RPC or Client Transform

languid hound
#

I'll take my business over there lol

languid hound
#

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

rigid island
elfin tree
#

wait it just works...

#

I guess it was alright all along and i was doing something else wrong

drifting sun
#

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

hexed oak
#

PlayerMovementController implements PlayerCharacter?

cold parrot
# drifting sun

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.

analog aspen
#

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?

spring creek
buoyant geyser
#

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

simple egret
steady moat
# drifting sun

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.

molten willow
#

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?

molten willow
swift falcon
#

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));
    }
}```
simple egret
waxen blade
#

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.

simple egret
#

0.8 -> 0.95 -> 0.1 (= 1.1 - 1)

waxen blade
leaden ice
#

Debug.Log(hue);

waxen blade
leaden ice
#

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 😆

waxen blade
#

Sounds believable, I'm trying the logs.

leaden ice
#

It could also be a problem with:

  • your eyes (a type of colorblindness)?
  • your monitor (they all have different color ranges etc)
waxen blade
#

Okay, something funky is going on.

#

The hue is consistently going up, until it hits .28. Then it jumps to .35.

leaden ice
#

every time the same thing?

simple egret
#

The line with deltaTime looks a bit funky

waxen blade
#

It took 4 frames to go from .27 to .28. Then 1 frame to get to .35.

simple egret
#

Maybe there's float imprecision that's amplified by that division at the end?

leaden ice
#

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

waxen blade
#

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.

leaden ice
#

would you mind sharing the rest of the code? (though I fear it's ugly given the hardcoded 7 in there 😭 )

leaden ice
waxen blade
leaden ice
#

well it might help

waxen blade
#

I'll delete the 10,000

#

And I'll post the whole code.

#

!code

tawny elkBOT
waxen blade
#

I tried with 1f instead of 10000f and removed the division after the delta time.

#

Same "pause."

leaden ice
#

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

waxen blade
#

The game is running smoothly.

leaden ice
#

my next suggested course of action would be to use the profiler and see if there's a frame spike.

simple egret
#

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?

waxen blade
#

I wonder if it'll look normal if I run it built.

leaden ice
#

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

waxen blade
#

You're right.

waxen blade
waxen blade
#

I modified line 65, 97 and 98.

vestal arch
#

tfw your colliders don't collide and you fix that and now your colliders are colliding the wrong layers

simple egret
# waxen blade I modified line 65, 97 and 98.

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

vestal arch
#

the "include layers" thing is for overriding which layers touch, rather than specifying only what layers it touches, isn't it

lapis kernel
#

I know this isn't really code, but I don't know where else to go.

#

GPU: Intel UHD Graphics 630

waxen blade
waxen blade
waxen blade
simple egret
#

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

waxen blade
#

Okay, so I should leave line 65 the way it was originally:

fillTexts[7].material.color = Color.HSVToRGB(hue, sat, bri);
simple egret
#

Yup, remove line 58 if you haven't done so yet, and that should be it

waxen blade
simple egret
#

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

waxen blade
simple egret
#

I'll download that, slow it down a lot and see if I can see the issue using a color picker

waxen blade
#

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.

simple egret
#

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

leaden ice
#

I mean just look at this. Doesn't "green" just look bigger than any of the other colors? Or is it just me.

waxen blade
#

Yes, it does.

leaden ice
#

Like we consider more of the turqoise and yellow zones still to be "green" than we do for the red/orange zone for example

waxen blade
#

This is so interesting.

#

I might just have it skip a section of the hue and see if it looks smoother.

leaden ice
#

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

waxen blade
#

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 UnityChanCelebrate

leaden ice
#

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 👌

waxen blade
#

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.

simple egret
#

Wikipedia says we have 1/3 of cones that detects green, so setting the speed to 3 counteracts that effect perfectly (?)

waxen blade
#

Lucky guess.

naive swallow
#

Color vision is pretty buck wild, tbh

hard viper
vagrant blade
#

@swift falcon !collab

tawny elkBOT
hallow zenith
#

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

rigid island
hallow zenith
rigid island
hallow zenith
#

or prefix

rigid island
hallow zenith
rigid island
hallow zenith
#

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

rigid island
#

it needs to be in the <font> tag

#

but I think that might not work with TMP material but font material?

hallow zenith
#

<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

rigid island
#

idk

#

it says it needs to be in specific folder

hallow zenith
#

This is using the ingame text box

rigid island
#

did you read a word of the page I sent ?

hallow zenith
#

I tried the <font> tag, with and without the material and it didn't register

hallow zenith
rapid stump
#
    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

gaunt wren
#

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.

crude mortar
#

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

gaunt wren
#

Seems to be working. learnt something new today. Cheers

vapid lynx
#

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

vapid lynx
#

i did

#

it like

#

it doesnt show up

#

and i turned on gizmos too

cosmic rain
#

Does the code run?

#

Share the updated code with the debug ray

vapid lynx
spring creek
#

And distance is 1
So it goes from x, 1000, z to x, 999, z

cosmic rain
vapid lynx
#

and it runs

#

idk

vapid lynx
#

wydm

#

Oh

#

how do i fix that ☠️

spring creek
cosmic rain
vapid lynx
vapid lynx
spring creek
#

Multiply Vector3.down by a number to increase range

#

And consider lowering the origin

#

Unless you NEED it that high

vapid lynx
#

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

steady oasis
#

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)

rigid island
steady oasis
#

ik but idk how to fix that

#

i am messing with navmesh for the first time so idk many things about it

rigid island
#

also don't crosspost

dim crypt
#

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?

knotty sun
dim crypt
#

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

knotty sun
analog aspen
#

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

knotty sun
dim crypt
#

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

knotty sun
thick terrace
dim crypt
dim crypt
knotty sun
dim crypt
#

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

dim crypt
#

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

knotty sun
dim crypt
#

Just the builtin windows protection

knotty sun
#

Never had a problem with Windows Defender

thick terrace
#

it can't hurt for performance at least, but yeah my bad antivirus experience is with stricter corporate stuff

thick terrace
#

let's see if it stays fixed haha

knotty sun
#

indeed

dim crypt
dim crypt
#

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

cosmic rain
dim crypt
#

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

cosmic rain
#

If nothing helps, I'd try checking what process accesses the files.

floral pulsar
#

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?

tawny elkBOT
floral pulsar
#

Usually the attribute .name would now be recommended for my by Visual Studio Code, but it isn't

thin aurora
tawny elkBOT
floral pulsar
#

Will do

#

@thin aurora @cosmic rain I done set it up, yet the recommendations still doesn't work 😦

thin aurora
floral pulsar
#

Damn

#

This is the features name

cosmic rain
#

Just in case you don't know, setting it in external tools is not the only step.

floral pulsar
cosmic rain
#

What about the extension in vs code?

floral pulsar
cosmic rain
floral pulsar
#

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.
floral pulsar
cosmic rain
#
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

cosmic rain
floral pulsar
#

@cosmic rain Thank you so much! Works perfectly fien