#archived-code-general

1 messages ยท Page 45 of 1

floral crescent
#

im not certain i will test

plucky inlet
#

why do you use an if statement here? Maybe your input is somehow "jittery" you can still moveposition even with zero vector, its just not moving then.

floral crescent
#

fixed it nvm

plucky inlet
floral crescent
#

use rigidbody.velocity instead of rigidbody.moveposition because velocity allows you to change each axis separately

_playerRigidBody.velocity = new Vector3(_currentJoggingInput.x * _jumpHorizontalSpeed, _playerRigidBody.velocity.y, _currentJoggingInput.y * _jumpHorizontalSpeed);
floral needle
#

Hello guy, I'm making my first (serious) multiplayer shooter (projectile/rigidbody based) using Photon. I have a decent understanding of server connection/creation, client-host relationship... those more basic concepts. Where I think my troubles will start is the bullet syncing part of the game (and probably pretty much everything else that involves syncing tbf). My first thought was to instantiate bullets (with pooling) as RPC's, but I've been reading on it and it doesn't look like the best solution, so I might opt for an authoritarian model with client-prediction implementations. Thing is, I'm not knowledgeable enough on this to filter what are good and bad practices, so I was going to ask if anyone has any recommendations on more in-depth resources that might help me with a project like this and, of course, if you have any inputs/tips that you think are important for projects like this. Thanks in advance!

oblique spoke
floral needle
#

cause that link is just a demo correct?

oblique spoke
#

I believe that includes Fusion, but looks like you can only get it as a standalone through their site

floral needle
#

Again, thank you for your help!

distant owl
#

Hello, does anyone know how you would go about programming an object to follow the movement on the X and Z axis of another object when a collider hits it? I have already sorted out the collision but am struggling making the object follow the player's movement without it teleporting to the player thank you

icy sundial
#

is it possible to regenerate meta files for some objects? im getting some weird errors and i think it comes from there

floral needle
knotty sun
knotty sun
icy sundial
#

im getting a weird error. Somehow when I stop the editor and run it again, a List still contains objects from the previous run. How is that possible?

somber nacelle
#

is it static? and do you have domain reloading turned off?

icy sundial
#

its not static, and it was working well before

floral crescent
#

how can i move my player towards a main camera z rotation?

_playerRigidBody.velocity = new Vector3(_currentJoggingInput.x * _jumpHorizontalSpeed, _playerRigidBody.velocity.y, _currentJoggingInput.y * _jumpHorizontalSpeed);
neat galleon
#

hello, im making a backrooms game with procedural generation

#

so it makes everything in one square, but i need to do chunk generation and cant find information about that anywhere

#

can you tell me how do chunks really work and how do i realise it

somber nacelle
#

if you google unity procedural chunk generation you'll get dozens of results including video tutorials

distant owl
distant owl
somber nacelle
austere orbit
#

Hi, is there a possibility to assign value to readonly field when Instantiate() prefab?
ideal would be something like this:

  GameObject display = Instantiate(ShopItem);
  display.GetComponent<ShopItemManager>().Item = item;
public class ShopItemManager : MonoBehaviour
{
    public readonly IShopItem Item;
}
somber nacelle
#

no, readonly means it can only be assigned via field initializer or constructor

austere orbit
#

Okey, is there any other possibility to assign value to the field when Instantiate() prefab in way that it will be impossible to change after that?

somber nacelle
#
private IShopItem _item;
public IShopItem Item => _item;

public void Init(IShopItem item)
{
    if(_item == null)
      _item = item;
}

This will allow you to access the reference from other objects via the read-only property Item while only being able to assign it once via the Init method. So you just instantiate then call Init and pass the item as the parameter

austere orbit
#

so the only way is to create another class for handling that?

somber nacelle
#

no?

#

the code i just gave you would replace your readonly field in the ShopItemManager class

austere orbit
#

but I don't want to be able to change it even from the inside of the class

somber nacelle
#

then just don't change it in the class. access it only through the Item property even in the class itself.
since you won't have access to call the constructor you won't be able to use a readonly field for this

austere orbit
#

thx for help

jagged laurel
#

how to make a flashlight glow give the script

somber nacelle
#
public Flashlight flashlight;
public void Start()
{
  flashlight.Glow();
}
vagrant blade
mental rover
austere orbit
#

You have to add turn on too

public bool TurnOn;
public Flashlight flashlight;
public void Start()
{
  TurnOn = true;
  flashlight.Glow();
}
jagged laurel
prisma birch
#

Anyone know how to change this setting via script?

somber nacelle
prisma birch
forest storm
#

hello guys

#

how to make the player move in the looking way?

somber nacelle
#

you can use transform.TransformDirection to convert a direction from local space to world space then use the returned Vector3 for your movement

buoyant crane
forest storm
#

my mesh is already rotating with the mouse looking cam but it wont go in the direction of looking

forest storm
somber nacelle
#

!code

tawny elkBOT
#
Posting code

๐Ÿ“ƒ Large Code Blocks
Large code blocks should be posted as 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 get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

forest storm
#

cam script (1), movement script (2)

#

ok

#

sorry mb

somber nacelle
#

also don't multiply mouse input by delta time, mouse input is already frame rate independent and anyone teaching otherwise is wrong. when you remove that make sure to lower your mouse sensitivity variable both in the script and the inspector

forest storm
#
void Update()
    {
        float mouseX = Input.GetAxis("Mouse X") * mouseSens * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * mouseSens * Time.deltaTime;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -80f, 60f);

        yRotation -= mouseX;
        //yRotation = Mathf.Clamp(yRotation, -120f, 120f);

        transform.localRotation = Quaternion.Euler(xRotation, yRotation, 0f);
        //transform.localRotation = Quaternion.Euler(0f, yRotation, 0f);
        playerBody.Rotate(Vector3.up * mouseX);
    }
#
void Update()
    {
        IsGrounded = Physics.CheckSphere(Groundcheck.position, groundDist, groundMask);

        if (IsGrounded && velocity.y < 0) {

            velocity.y = -2;
        }
    
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;
        
        controller.Move(move * speed * Time.deltaTime);

        if (Input.GetButton("Jump") && IsGrounded == true) {

            velocity.y = Mathf.Sqrt(JumpForce * -2f * gravity);

        }

        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);
    }
buoyant crane
# forest storm

retrieve the .right and .forward of the camera and use those in the movement script, or rotate the player as well in the camera script

somber nacelle
#

that shouldn't be necessary if they are actually rotating the player body

somber nacelle
#

i'd bet they have a NRE they aren't paying attention to ๐Ÿ˜‰

forest storm
#

im a beginner in unity

buoyant crane
#

i somehow read that as camera rotation, not the player

forest storm
#

no no

#

player

somber nacelle
forest storm
#

but the character wont move to the direction im looking to

dusk apex
#

Are there errors?

forest storm
dusk apex
#

Runtime errors

forest storm
#

nope

somber nacelle
#

then your setup in the hierarchy is probably wrong

forest storm
#

hm

somber nacelle
#

show how you have it set up

dusk apex
#

Maybe you're not rotating what you think you are? UnityChanThink

forest storm
#

yk its walking to worlds Axis but not the camera looking

forest storm
buoyant crane
somber nacelle
#

if the playerBody is rotating then most likely the movement code is on the wrong object

forest storm
somber nacelle
#

again, show how you've got this set up in the hierarchy so we don't have to make guesses

forest storm
#

here

somber nacelle
#

it's really not helpful that we can't see which object has what components and that two objects have identical names

forest storm
#

yeah mb

#

its just a capsule

#

the above "player" is just an empty

#

the below "player" is a capsule

somber nacelle
#

the "empty" one is the one that should be rotated and moved

somber nacelle
#

are you sure

forest storm
#

yeah wait

#

the collider is at PlayerMesh

somber nacelle
#

and which object does the CamScript reference

pine bronze
#

hey guys so im trying to make doors, im following a tutorial and for some reason my door only opens in one way, and the door should've opened depending on which way the player is facing the door. im using Vector3.dot() with the forward position of the door and the player pos - the door pos.
this code opens the door https://hastebin.com/share/oyevazonub.csharp
and this code closes the door https://hastebin.com/share/ezerucuyup.csharp
the dot variable is always negative

forest storm
somber nacelle
#

not what is it on, what object is it referencing as playerBody

forest storm
#

oh

#

i should bind it with the empty

somber nacelle
#

yes, but it's also not empty, there are several components on that object

forest storm
#

yeah

#

but now i cant rotate cam in y

#

i rotate the mesh but not the cam anymore

somber nacelle
#

the camera is a child of the player, right?

somber nacelle
#

and you rotate the playerBody by mouseX every frame and the camera by -mouseX every frame, right?

forest storm
somber nacelle
# forest storm right

okay so if you rotate playerBody by mouseX then the camera is also rotated by mouseX, so then what do you think happens when you rotate the camera by -mouseX

pine bronze
somber nacelle
#

well the end result is nothing because mouseX + -mouseX == 0

forest storm
#

how to fix?

somber nacelle
#

either don't make the camera a child of the player and have it only follow the player + rotate, or stop rotating it by -mouseX every frame

forest storm
#

hm

forest storm
somber nacelle
#

so make it follow it

forest storm
forest storm
#

wait

#

i got it

#

thanks for the support!

#

find out a solution

dusk apex
dusk apex
empty hollow
#

Hello,
I'm working on a pseudo database (with dictionaries) for my scriptable objects, and I was wondering if it is bad practice to use the scriptable object name as an ID like this :

public string ID()
    {
        return this.name;
    }```

It would make it easier for since I won't have to manually set an ID for each item (I'll have couple hundreds of items).
cedar pivot
#

hello friends, can you recommend youtube tutorial series for advanced coding?

pine bronze
austere orbit
#

Hi, I have general question about currency system. I have that SO that represents my cash amount

[CreateAssetMenu(fileName = "Voult", menuName = "ScriptableObjects/Voult")]
public class Money_SO : ScriptableObject
{
    public int Currency { get; set; }
    public int PremiumCurrency { get; set; }
}

Is it good to store this variables in something like SO or is there a better way?

#

it wouldn't be catastrophe if some players just cheat and add money to their accounts via 3rd party apps

empty hollow
#

And if you really need runtime data in SOs you can always make a copy at runtime

austere orbit
#

I mean I did it in SO cuz thats the only way I know that will store data between game launches (with out obviously *.txt or other files)

#

how is it possible to store data in classes between game sessions?

empty hollow
#

Be careful since data in SOs is saved in unity editor between play sessions, but not in build version (pc, android, etc...)

empty hollow
#

for proper data persistence you should look into a save system that writes to files

austere orbit
#

shiiiiit and I build half of the app on SO XD

empty hollow
#

player prefs are often used to store game settings etc... but in prototyping they can be fine to store your data

#

I can also recommend an asset from the store that is very useful in my projects (Easy Save 3), check it out

strange pine
#

not sure if this is right channel, but i've got Plastic SCM enabled and Unity is refusing to compile any changes until I check in the files, which is then automatically pushing up to my workspace. Is there a way I can disable that, because that is really getting in the way?

trim schooner
#

I've never seen a user on here that knows how to use Plastic. Best place to ask is the Unity forum (Plastic has its own section).. or Plastic suport wherever that is.

strange pine
#

It being the main tool that Unity want people to use for collaboration, and nobody here knows on the official Unity server? Hmmm

vagrant blade
#

Honestly, most people use standard alternatives.

#

Nobody ever has issues with git. Everyone had issues with collaborate, and now plastic comes up often.

maiden breach
trim schooner
strange pine
#

Right weโ€™ll then Iโ€™ll just look for something else, thanks all

sweet egret
#

hey! can anyone call to help me with my errors? I can't seem to figure them out. I'm making a cutscene for my game and my script is messed up. Can anyone help me? Ping me if you can. Thx!

cloud smelt
#

Has anyone else had issues with resources.FindObjectsOfTypeAll() it works but ocasionally it just doesnt find an object nad I have to edit it and save it for it to discover it again.

elfin tree
#

Hi, I have a Tooltip Canvas, inside there is a title, and eventually there will be a Text right below it, that's what I'm unsure about. How can I anchor the text to the title?

viral willow
#

Is there a way to export a gameobject as a .prefab in script?

strange pine
ionic socket
#

is there a way to parent a UI element to a transform in worldspace, and have it auto-translate into 2d/UI screenspace? I have a damage pop-up that I want to follow the unit as it moves around. I could do this in an Update() loop but I'd rather not if possible.

leaden ice
ionic socket
pale marsh
#

So I am making a game where I need to make a timer. The timer needs to count up in minutes seconds and decimals and be in minimal 100 levels... If you reach the end time need to stop. If it stopped it needs to check for the best time and save it so that It can be displayed in another scene. So it actually needs to be a Best Time timer or something. Just like speedrun games. I have the timer working but not the best time and the display in the other scene. Can someone help me with this, because I wasted like 3 hours and motivation.

tepid river
#

hello, i have two trigger-colliders on two separate objects. when they collide, they trigger code that glues them together with a fixed joint.
now i have the two connected objects and want to pull them closer togehter => reduce the offset.
how do i do that?

#

magic rubberduck: you have to set the localposition of the slaved transform and then set the anchorposition (joint.connectedAnchor) afterwards

buoyant crane
pale marsh
buoyant crane
pale marsh
#

mk

buoyant crane
# pale marsh mk

wait actually, are you trying to transfer data or did you want each scene to store its own best time?

pale marsh
#

the last one

buoyant crane
pale marsh
#

I maybe tought of playerpref, but if I use that it will give the 1 best time to every level (its displaying only 1 time for every level in my levelselector)

buoyant crane
#

each scene can access its current build index and use that as the key to the player pref and access the time

pale marsh
#

just like this: Playerpref.SetString("name" + buildindex, amount)

buoyant crane
pale marsh
#

I can try that ig

elder temple
#

Need help.
I'm using leantween to rotate object when a button is pressed. When I press the button it rotates perfectly to 90ยฐ but if I press it again it stays still. I need to rotate object by 90ยฐ everytime with each button press

elder temple
rigid island
#

no

#

!code

tawny elkBOT
#
Posting code

๐Ÿ“ƒ Large Code Blocks
Large code blocks should be posted as 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 get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

elder temple
#

Ah ok๐Ÿ˜…...wait a min

elder temple
sacred frost
# elder temple

try something like ```cs
LeanTween.rotateY(obj, obj.transform.eulerAngles.y + 90, 3);

#

not sure if thats what you meant

elder temple
orchid surge
#

I'm working on my workflow for projectiles and bombs, this time I wanted to make the weapon that fires the projectile, or the bomb that spawns the explosion, gets to define what happens when a projectile detects a potential target. I started by using an OnHit event in the projectile or explosion that the weapon responds to with a funciton, kinda like this pseudocode below.

private void Fire() {
  // projectile spawning and launching code
  projectileFired.OnScoredHit += ValidateHitAndApplyEffects;
}
private void ValidateHitAndApplyEffects(HitData projectileHitData, Projectile projResponsibleForHit){...}

This works great for projectiles, but it didn't work well for bombs, cause bombs explode. The bomb prefab is destroyed when the explosion prefab is spawned, so the callback can't be called. Is there a way to make this sort of setup work?

devout solstice
#

Ive gotten myself into a interesting situation

orchid surge
#

Actually, I think I can just use delegates to avoid my issue. Gonna try that now.

sacred frost
elder temple
devout solstice
#

I've decided to store a slot and a item both in the same dictionary, one as a key, one as the value, and I need the item to follow the slot, so set the item to the slots position, how could I get the key and value using one another?

#

I basically just need to get any of the keys and values but they need to be corresponding to one another

#

I honestly have no idea what I've done but I'm here now so

rigid island
#

you make a script

devout solstice
#

Ah

#

Thanks

rigid island
#

idk what ur asking here

#

what is "key"

#

what is "value"

devout solstice
#

its a dictionary

#

a slot and a item

rigid island
#

so say it's a dictionary

devout solstice
#

I literally explained it

rigid island
#

you didn't

devout solstice
#

I did

rigid island
#

it's ambiguous

devout solstice
#

What

rigid island
#

literally provided 0 code in a code channel

#

it's all guessing games at this point

devout solstice
#

A explanation should do just fine

rigid island
#

yeah goodluck with that

sacred frost
devout solstice
#

No, I need to get the key in the dictionary, using the value and vice versa

rigid island
devout solstice
#

the more I explain this, the more idiotic it sounds

rigid island
#

no just a basic question

sacred frost
#

yeah I see, just get an item from dictionary and then you can get a key or value from it

#

that's kinda all

rigid island
#

learn how to work with Dics

leaden ice
sacred frost
#
 foreach(KeyValuePair<string,float> attachStat in attachStats)
 {
     //Now you can access the key and value both separately from t$$anonymous$$s attachStat as:
     Debug.Log(attachStat.Key);
     Debug.Log(attachStat.Value);
 }
#

example i found online idk

devout solstice
#

idk now that I've put it in my script it looks like it should work

#

It very much did not appreciate that

sacred frost
devout solstice
#

I know how dictionaries work

rigid island
#

not synonymous with effective use

devout solstice
#

true

zealous bridge
#

Which approach do you think would be most suitable for a list of strings that can be edited and accessed by other scripts? Would you recommend using scriptable objects, singletons, static lists, or another alternative?

sacred frost
#

depends on the usage

#

what will you use them for exactly?

#

i'd just do a singleton probably

zealous bridge
#

A list of types of items.

sacred frost
#

i'd make it a scriptableobject i guess then

#

and have it stored in a singleton

#

like gamemanager or whatever

rigid island
#

I wouldn't use SO for this type of mutable data

rigid island
#

don't overcomplicate it

sacred frost
#

yeah but it also depends on what you plan to do in future with it

swift falcon
#

the most programmer thing ive ever said

zealous bridge
#

singleton behaviour should be done in the constructor if you want it run correctly in editmode right?

orchid surge
leaden ice
#

Use a lazy-loaded property if you must.

zealous bridge
#

Yeah I'm kinda lost after I wrote the constructor. I feel the need to figure out when unity calls it now aha...

rigid island
#

unless you mean a non-mono class.

leaden ice
#

why do you need your singleton available in edit mode

zealous bridge
#

Figured that is where it starts if it gets instantiated. Although using the property does work for me. Since I need to call get first

#

I'm creating a list of items types.

#

I have a custom inspector that allows for string drop down menu.

leaden ice
young wolf
#

Anyone familiar with Unity EditorXR?

#

How can we make runtime-created objects selectable?

zealous bridge
zealous bridge
#

This is a constructor for a property?

leaden ice
leaden ice
#

no constructors involved

zealous bridge
#

How does it work outside of a function?

leaden ice
#

sorry fixed it

#

it's a property

#

it is a function

#

in disguise

zealous bridge
#

aha yeah alright it's a get now

leaden ice
#

you can think of it as ```cs
public static MyScript GetInstance() {

}```

upbeat dust
#

Heyy, is there i direct way to control transform.rotation, with same values in code and inspector?
Want to make a simple directional light cycle, but can you simply rotate without quaternions?

sacred frost
leaden ice
#

but the numbers won't always be the same due to euler angles not being unique

#

Simpler to use quaternions

upbeat dust
leaden ice
#

what is "a random up and down moutain graph"

sacred frost
#

debug log returns graph now? dayum, unity technology advancing

upbeat dust
#

from what i found

leaden ice
#

yes because euler angles suck

#

this is why I recommend not using them

upbeat dust
zealous bridge
#

Quaternions are complicated but you get tons of functions to use them.

leaden ice
#

quaternions are actually simpler to work with

#

that's why unity uses them

#

they're more complicated to understand the internals of

#

but you don't need to

#

just use them

upbeat dust
#

Alr, thx for info guys)

zealous bridge
craggy sapphire
#

sorry quick dumb question

#

when you want your coroutine to end do you need an extra yield return null at the end

craggy sapphire
#

aight cool

#

thanks

pale marsh
#

so I cant do playerpref.GetFloat()

buoyant crane
potent sleet
pale marsh
#

I can try to do something with that ig

potent sleet
pale marsh
potent sleet
#

just save the current time in the playerprefs and load it inside the score scene

pale marsh
#

so I can check what level it is and check if the required index is the same as the index that I send the best time to.

pale marsh
pale marsh
potent sleet
#

you wanna save time Per-Scene

pale marsh
#

yeahhh

potent sleet
#

cause sure you can use playerprefs but it's not a good system imo. I would highly recommend you make a struct to determine an scene int + time "whatever type it is" in a file json

#

it would be easy to also keep track of everything in a neat list

pale marsh
pale marsh
#

Im still learning C# yk. I know a few things, but not that much

#

O wait a sec...

potent sleet
pale marsh
potent sleet
#

just how json works

#

but in playerprefs

#

then when you can "dissect" the string to extract values

#

eg time + scene number + w/e

#

the important part is you separate info with a certain char you can then use to String Split

pale marsh
#

that sound better then playerprefs tbh...

#

still... it sounds kinda hard

potent sleet
#

this IS with playerprefs

#

lol

pale marsh
#

yeah but a better way to use it

potent sleet
#

JSON would involve knowing how to make a serializable class

pale marsh
#

mkmk

potent sleet
pale marsh
#

yeah ok so I was just stupid... I fixed the time thing. I only need to have the time getting less... its hard to explain

potent sleet
#

huh ?

pale marsh
#

yeah its hard to explain

#

but I fixed it, thats the important part

soft hare
#

he can some one help me i am using ad mob and i am getting this error NullReferenceException: Object reference not set to an instance of an object
AdScript.Update () (at Assets/scripts/AdScript.cs:36)
this is my code >>> if (rewardedAd.IsLoaded())
watchAd.gameObject.SetActive(true);
else
watchAd.gameObject.SetActive(false);

zealous bridge
#

which line is 36 o.o

#

if it is rewardedAd.IsLoaded() It might be rewardedAd that isn't set to a instance of an object,
if it is watchAd it is possible that watchAd is not set to a instance of an object.
It is also possible that you can't access gameObject with watchAd.

soft hare
zealous bridge
#

rewardedAd does it have a right script attached to it in the inspector?

#

If that isn't the issue. It's possible that, the issue lies within the function isLoaded

coral hornet
#

how do i use a navmesh, do i just calculate a path then iterate through the corners? where do i get this supposed "navmesh"? i was looking through unity doccumentation and it said that it was auto generated by geometry, how do i get this automatically created navmesh? where do i create another navmesh? i am very lost

#

can i create my own custom navmesh or no?

sacred frost
# coral hornet how do i use a navmesh, do i just calculate a path then iterate through the corn...

โœ… Get the FULL course here at 80% OFF!! ๐ŸŒ https://unitycodemonkey.com/courseultimateoverview.php
๐Ÿ‘ Learn how to make BETTER games FASTER by using all the Unity Tools and Features at your disposal!
๐Ÿ‘‡
๐ŸŒ Get my Complete Courses! โœ… https://unitycodemonkey.com/courses
๐Ÿ‘ Learn to make awesome games step-by-step from start to finish.
๐ŸŽฎ Get my Steam Gam...

โ–ถ Play video
#

i think this video will answer most of your questions

coral hornet
#

alright

coral hornet
#

theres a 1 minute long segment advertising his own stuff right at the start, god i hate youtube tutorials ๐Ÿ™

#

so wait navmesh is a class?

sacred frost
potent sleet
coral hornet
potent sleet
sacred frost
#

install sponsorblock addon

potent sleet
#

you don't know how to skip a 1 minute chunk of a video ?

coral hornet
#

ive never personally heard it called a timeline seekscroller

potent sleet
#

seek scroll ?

#

you never developed a media player then

coral hornet
#

should i have developed a media player before watching youtube?

potent sleet
coral hornet
#

or any other platform with a media player integrated into it?

coral hornet
#

idk i just dont really see it as a "bar" or as "seeking", even if that is the official term

potent sleet
#

so you know it has the words in it why are you still goin

coral hornet
#

i see it as "moving to a different time in the video", i just dont personally identify it as a timeline seekscroller

potent sleet
#

technical term is seek bar

coral hornet
coral hornet
#

on a different note where is the navigation tab

#

nvm

#

ok built the navmesh thanks guys ๐Ÿ‘

coral hornet
#

so assuming the path's corners are points in world space that i can iterate through, how do i tell when an agent has reached the waypoint?

sacred frost
#

check the remaining distance

coral hornet
sacred frost
#

navMeshAgent.remainingDistance

coral hornet
#

oh thats a property?

potent sleet
#

there is more info than that too

sacred frost
#

yeah it has a lot of properties

coral hornet
#

oh, i figured itd just give me the waypoints and leave me to do the rest, thanks

#

wait whats this?

#

also how does auto repath work?

#

assuming that the path i create manually can be stored in the path property

#

will auto repath automatically overwrite the path property if the path ive made becomes invalid?

sacred frost
#

are you creating the path for the navmeshagent manually?

coral hornet
#

considering auto repath

#

should i just create one to kick off the pathing or what?

#

what counts as an invalid path, and what about the destination?

sacred frost
#

if you want him to patrol an area non-dynamically, then create a path manually

coral hornet
#

if i set this mid-pathing and it doesnt line up with the previous paths destination will it auto-repath to try to approach the new destination? when exactly is auto-repath active?

sacred frost
#

if you want to make him code to just walk around in random ways dynamically then yeah dont create a path manually

#

autorepath is for when it sees an obstacle i think, but im no navmeshagent expert

#

im just guessing

coral hornet
#

alright

sacred frost
coral hornet
#

well im looking to make this creature constantly try to reach a player

#

and im sorta puzzled

#

cuz like

#

wait so if i make a path manually

#

but the paths endpoint is no longer the player (player moved) then do i make another one immediately after?

sacred frost
#

then just set the destination to player's position

coral hornet
#

alright

#

thanks

coral hornet
#

ok yeah that clears up alot, thanks

wide burrow
#

No matter what I try I can't seem to change the Icon for my scriptable objects

coral hornet
zealous bridge
#

#if UNITY_EDITOR directive allows you to run things in edit mode?

#

Or am I understanding this wrong?

lyric wadi
#

play mode in the editor

#

is it not working? it should but it needs to be before any other platforms

#

so if your target platform is android, and you have #elif UNITY_EDITOR after UNITY_ANDROID the android one will superceed it

zealous bridge
#

but I'm not sure I'm using it right.

#

It feels like a unintended way of doing it.

lyric wadi
#

just lets different blocks run on different platforms, so if you have different input for different platforms or something you can define each and it just triggers the right one

zealous bridge
#

Uhh that means I don't actually need it and my understanding of update is wrong?

#

I thought unity doesn't run update in edit mode

#

Only during play, and outside of play it(edit mode) it doesn't run.

lyric wadi
#

if you have [ExecuteInEditMode] it runs the code

zealous bridge
#

I don't have it.

lyric wadi
#

weird

zealous bridge
#

yeah

zealous bridge
#

Uhg yeah I was testing it and you need execute in edit mode for it to run the code in update. something buggy is happening on my side

lunar mauve
#

Im using animation rigging and I made a small script to make it so when you turn the camera facing it, it will put the weight to zero. but when you turn 180 degrees it does the opposite can someone help me?

        Vector3 Direction = targetConstraint.position - sourceObject.position;
        if(Direction.z <= 0)
        {
            targetWeight = 0f;
        }
        else
        {
            targetWeight = orginWeight;
        }```
digital whale
hexed pecan
digital whale
#

I don't know how I missed that lol.

tall lagoon
#

Hey guys so I'm making a 3d enemy and i want the transform.foward or the current direction looking at the player bc ima need it for something else later bc right now i have it looking at the player but how can i get the forward or current direction to look at the player instead? This is my code

Vector3 LookDir = transform.position - Target.transform.position;
        transform.localRotation = Quaternion.Euler(0, LookDir.y, 0);
        transform.forward = new Vector3 (LookDir.y, 0, 0);
```cs
supple hinge
#

!code

tawny elkBOT
#
Posting code

๐Ÿ“ƒ Large Code Blocks
Large code blocks should be posted as 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 get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

tall lagoon
supple hinge
tall lagoon
#

i thought you were talking to me

#

hey joseluis now that your hear if you got a sec you think you could help me out with my problem real fast?

supple hinge
tall lagoon
#

wdym?

supple hinge
#

but that won't change anything bc it's the same problem

tall lagoon
#

ye i just need the current or blue arrow of the enemy to face the player

#

thats the tricky part

supple hinge
#

position.X? i don't know man, sorry i won't give you any advice if i don't know what im talking about

#

good luck

tall lagoon
#

WAIt

#

Josusl i can explain

tall lagoon
supple hinge
supple hinge
#

he's a great guy

lyric wadi
bronze egret
#
Vector2 inputDir = new Vector2 (Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));```
Im trying to get a player input for my player object, what do you guys think, i've seen other people do it like this:
>  float X or Y input = input.getaxisraw("X Or Y");
i assume this way its more optimised since its a single line
somber nacelle
#

being a single line doesn't make it any more optimized. use whichever you prefer, the performance difference between the two is likely negligible at best

tall lagoon
#

For the suggestion

timid meteor
#

is there away to add a 3d collider to a tilemap?

potent sleet
#

you can use a gameobject brush with 3D colliders on them

potent sleet
timid meteor
#

is there away to do it via code?

#

I am using it to generator terrain

potent sleet
#

put a tilemap collider

timid meteor
#

I have set it up so it generates meshs

#

I did but it wasn't workign

#

the player walked straight through them

potent sleet
#

or 2D

timid meteor
#

yes

#

3d

#

I am using it for vr

#

since I found out it runs better on vr urp

#

I can load massive worlds with no performance issues

potent sleet
timid meteor
#

how do you add a mesh collider in c#

timid meteor
#

MeshCollider meshCollider = edgeObj.AddComponent<MeshCollider>();
meshFilter.collider = mesh;

potent sleet
#

pretty much

potent sleet
hexed pecan
wet condor
#

How can i make my arrow in Minimap adjust with my minimap texture.

i mean my arrow (PNG) is place inside my Car and another camera render that Arrow (layer) and place it in my UI..

since my Arrow is flowing all my places should i have to scale my map texture in scale and place it exect sclae as my acutal scene map while that layer is render with another camera ?

#

this white is my road texture i mean like this
it's place accordingly with my acutaly road rander with another camera

wild nebula
#
  • Car
    -- Arrow (Just resize this based on object to camera distance)
#

I imagine it something like this.

float size = (Camera.transform.position - Arrow.transform.position).sqrMagnitude * resizeFactor;
//Then clamp it:
size = Mathf.Clamp(size, 0, maxSize);
//Then apply it:
Arrow.transform.scale = Vector3.one * size;```
#

Just a pseudo code, but you get the idea.

#

On the other hand ------

#

Anyone know if I can peek into the implementation of this? Internal_ToEulerRad(Quaternion q)

#

Its from Quaternion.eulerAngles C# reference

somber nacelle
#

if it isn't available in the csreference then it isn't available for you to look at

#

unless you buy whatever license unity offers that allows access to the internal code

wild nebula
somber nacelle
#

i dunno what to tell you mate, the engine is closed source except for what is available through github. if it isn't on github then the source is not available to view

wild nebula
#

๐Ÿ˜ญ

leaden ice
#

It's marked extern which means it's implemented in C++ and closed source

wild nebula
#

Thanks, I will keep trying all the implementations I can find ig.

coral kettle
#

I can't find any info on how to clamp a long

#

System.Math.Clamp gives an error about Math not containing the definition of Clamp

prime sinew
#

do you specifically need a long?

coral kettle
#

at the moment yes

prime sinew
#

i'm not sure.. but what version of .Net is your Unity using?

wet condor
#

Or there's another way to do it

coral kettle
wild nebula
#

I thought you want to scale your arrows when the mini map camera is very far.

#

Because you want a huge part of the map to be seen.

wet condor
#

No no not that ':) ๐Ÿฑ

#

I just fell like i dont have to scale my map texture (the road lines) in the game and scale it 200x soo it be same as my environment

#

This while is my texture and i have scale it 200x so it can be same as my road ๐Ÿ›ฃ๏ธ

earnest epoch
wet condor
hexed pecan
#

What kind of object is the white road?

#

And what is the arrow, I don't see any

#

Is your map one Terrain component?

#

You could get its scale and adjust the white road mesh to that

wet condor
#

Just a png

#

Arrow is just a png also inside my car

hexed pecan
#

But it's on some renderer component, is it a MeshRenderer with a plane/quad mesh?

#

Or world space UI?

earnest epoch
wet condor
#

This. I mean this white is my map and i to place it my environment I've scale it 200x so it can big enough to place my environment..

#

Everything work fine but somehow i think that's not the correct way since I've sclae too much also what if there a much bigger project ๐Ÿ˜…

#

This small is what I've scaled. And make this big one.

hexed pecan
#

If it works, it works. Another option would be to render it to the minimap camera on a canvas

wet condor
#

Yes im rendering to rander texture and using UI to place it

earnest epoch
#

So two things: @wet condor

  1. If you want to eliminate this difference in relative scale, you need to make one thing a different scale than the other intrinsically. Import a bigger thing into your project if you don't want to scale it up. The same for going smaller.
  2. This is the wrong channel to discuss non-programming related topics. Try #๐Ÿ’ปโ”ƒunity-talk, or share your code which attempts to solve the scaling issue programatically.
wet condor
unique cloak
#
            {
                Debug.Log(r.ToString());
                for (int i = 0; i < x; i++)
                {
                    Debug.Log("= " + r.ToString());
                }
            }

The debug log says

"1"
"2"
"= 2"```
How on earth is this possible?
#

Why is it not running the debug.log inside the for loop for r = 0 and r = 1

prime sinew
#

or do you mean you dont see = 0 and = 1

#

it'll be helpful if you shared what s and x are

leaden ice
#

Do you have Collapse enabled?

wild nebula
#

Anyone know how to clean up unused assembly references?

#

I don't want to do the stone-man approach

#

Using Visual Studio 2022

leaden ice
unique cloak
leaden ice
# unique cloak

none of this seems to relate to the code you posted above, since nothing in the code above prints "rows = someting"

unique cloak
#

oh I just found the problem

#

cheers tho

restive dirge
#

How can we get right and left mobile tilt movement(when mobile screen vertically facing us) values?

prime sinew
#

How come Input.acceleration detects the tilt, when it's a "linear acceleration"? Or am i misunderstanding what linear acceleration is.

swift falcon
#

I load an asset bundle and it gives me this error "Desired shader compiler platform 14 is not available in shader blob". Any idea on how to fix it?

leaden ice
#

Or rather, by reading the direction of gravity, it can surmise the orientation of the phone to some degree

prime sinew
#

oh.. wow. so I can just assume it'll detect movement and tilt. thanks!

ionic socket
#

Invoke vs. Coroutine vs. using a DoTween to delay triggering an event. What's the cleanest, most professional way?

potent sleet
#

Coroutine

#

the true answer is async

ionic socket
potent sleet
#

I don't even think it works in unity so that's that

ionic socket
#

Task.Delay seems both clean and semantic

potent sleet
#

there is also Wait

thin aurora
#

So let's all forget Thread.Sleep exists ๐Ÿ˜„

potent sleet
#

agree lol

thin aurora
#

Weird

potent sleet
#

screen was shaking

thin aurora
#

Weird..........

cloud smelt
#

Not sure if this is a bug, and im struggling to google for the issue but I'm using Resources.FindObjectsOfTypeAll() to pull a load of scriptable objects into a dictionary. My issue is occasionally it just doesn't pull anything in, and will continue to do so until I change something on one of the objects and re save it. Anyone ever had this issue? Any other alternatives?

thick heron
#

im doing animation stuff and the last keyframe plays for a millisecond is there a way to add idle time to the last frame

#

I want to move that bar without moving the rhoumbus

sacred frost
quartz folio
#

You generally shouldn't be using that API, it only returns loaded objects

sacred frost
#

yep, you can't trust it, i'd just do an array and you can drag your stuff there

cloud smelt
sacred frost
#

well yeah you cant really trust that function for that then

quartz folio
#

Despite the name, FindObjectsOfTypeAll isn't really anything to do with the Resources folder

#

if you want to load an array of data from the resources folder, use LoadAll

cloud smelt
#

oh...

#

Gotcha

#

haha ok my bad

#

Thanks guys โค๏ธ

swift falcon
#

im using first person core and every time i open the camera prefab the scene goes grey even tho i didnt touch anything but it works just fine in play mode

sacred frost
#

I think that's a unity bug lol

#

I had it a lot in older versions

#

if you restart it will probably show up normally but if you move is it gray again?

#

if so then yeah - from my knowledge just a unity bug ;/

swift falcon
#

do you know the bug name so i can search in google

sacred frost
#

nope, you can try disabling the lighting though see if that fixes anything

prime sinew
frozen peak
#

Hello! I am using Netcode for gameobjects and I am trying to display the ping of each player.

public TextMeshProUGUI pingText;

    private float pollingTime = 1f;
    private float time;
    private float frameCount = 0f;


    private NetworkTransport networkTransport;
    private ulong clientId;
    private bool networkSpawned = false;
    public override void OnNetworkSpawn()
    {
        networkTransport = GameObject.Find("NetworkManager").GetComponent<NetworkTransport>();
        clientId = NetworkManager.Singleton.LocalClientId;
        networkSpawned = true;
    }

    // Update is called once per frame
    void Update()
    {
        if (!networkSpawned) return;

        time += Time.unscaledDeltaTime;
        frameCount++;

        if (time >= pollingTime)
        {
            ulong ping = networkTransport.GetCurrentRtt(clientId);
            pingText.text = $"{ping} ms";

            time -= pollingTime;
            frameCount = 0;
        }
    }

This is how i am doing it. The player that hosts the game has 0 ms latency, but when a client connects, it outputs this error:

KeyNotFoundException: The given key '1' was not present in the dictionary.

It references this line ulong ping = networkTransport.GetCurrentRtt(clientId);

upbeat dust
#

heyy, so i have this simple IF statement checking the quternion rotation (float)

if ((Mathf.Round(transform.rotation.x * 1000) / 1000) == 0.707)
{
      Debug.Log("DAY OR NIGHT");
}

At first i put 0.707**f **like its supposed to be, but the if statement did not pass, but when i removed f, it stated working

Do quaternions return some kind of other data type?

wild smelt
#

I want to make the user select a json file and then the game should read it, but not modify it

#

how

dusky lake
upbeat dust
dusky lake
#

Oh nvm to the first part, didnt see the / 1000 behind the round

#

Put an f behind the 1000 you are dividing by

#

You are currently working with doubled

#

Doubles*

upbeat dust
#

oooohh

#

yeah i forgot they exist

#

tysm mate

tacit kestrel
#

@upbeat dust - you should try something like:

float value = Mathf.Round(transform.rotation.x * 1000) / 1000;
if (Mathf.Abs(value - target) <= float.epsilon) {
  // equality functionality
}
upbeat dust
#

ill research on epsilon tho, thx

somber nacelle
tacit kestrel
#

that is a good choice too

austere orbit
#

Hi, is it possible to force devs to assign values to fields in scripts?

[RequireComponent(typeof(Rigidbody))]

Something like this but with fields in script

[RequireValue]
[SerializeField]
private int JumpForce;
#

so if you try to test the game it will not start until you fill the required values

earnest gazelle
#

Odin inspector has an attribute for it called Required.
If it is null, you will see an error below the field in the inspector.
Then you can run Odin validation tool, it shows all validation errors

swift falcon
#

Do asset bundles for WIndows work for Ios or Mac or do I need to build asset bundles for each platform?

late lion
sacred frost
austere orbit
placid summit
#

Hi has anyone used alternatives for http communication like System.Net.Http?

hybrid relic
#

Does anyone know if Facepunch fixed their p2p ip leak thing in Facepunch.Steamworks ?
I last remember Dani having problems in Crab Game with DDOS attacks cuz of it

somber nacelle
copper plaza
#

hey ,I need a help;
Im try to build my game,it was built perfect,but after integrate sdk it not,it failed build,
This is my error console:

hybrid relic
gentle hinge
#

How can I check if a spotlight is shining onto an object?

somber nacelle
hybrid relic
#

im also confused that i asked here and noone has an answer for me, i thought it might be used more often then Steamworks.NET since its more easy

somber nacelle
#

i'm aware they have a github. they link to their forum thread on the github ๐Ÿ˜‰

somber nacelle
hybrid relic
#

im a steamworks developer so i should have access to that group

somber nacelle
#

works for me

hybrid relic
#

lemme try something

copper plaza
#

@hybrid relic & @somber nacelle this is code general room not chat room;please go there

somber nacelle
#

Notice how i was already redirecting the person to the proper place to ask their question? this wasn't just a casual chat mate

hybrid relic
hybrid relic
#

If i click on "here" nothing happends

#

im a steamworks dev and i have a game

#

Its just too dumb to redirect me correctly

somber nacelle
#

have you even bothered looking at their docs pages? that would answer your question

hybrid relic
#

now i get this, after i joined the group

somber nacelle
hybrid relic
#

Pff yeah ok then i wont use Facepunch

somber nacelle
#

they stopped doing the thing that revealed IP addresses. isn't that what you wanted?

hybrid relic
#

They stopped using peer to peer for vc

#

cuz their peer 2 peer stuff is leaking ips

#

they did not fix the ip leak issue, just ignored it and used something else

leaden ice
#

not really a "leak"

somber nacelle
hybrid relic
#

since you use steam as a kind of proxy, steam also routes the whole traffic so no port stuff has to be done

leaden ice
#

Not sure how that could work without using some kind of intermediate host, which makes it not really P2P right?

hybrid relic
#

well steam is kinda handling the peer to peer traffic and afaik a intermediate host with steamworks p2p

#

kinda works like a proxy

lethal plank
#

anyone know what was that called?

#

i dont even know the keywords to google it

leaden ice
lethal plank
#

yes

#

that line follow object

leaden ice
#

it's just a LineRenderer, no?

lethal plank
#

for real?

#

alright

#

thanks

copper plaza
#

you can use several stuff for that,like UI or line renderer or even creat your own line via script (this will help you to defined the start and end position and control the size ...)

icy schooner
#

Hey!
I'm having some issues with my code where if (!isLocalPlayer) is returning the error (The name "isLocalPlayer" does not exist in the current context. I changed to capital I so IsLocalPlayer where the error disappeared but its not correct according to the documentation
Thank you in advance

somber nacelle
icy schooner
somber nacelle
neon plank
#

What does mean when NavMeshAgent.isOnOffMeshLink is true but NavMeshAgent.nextOffMeshLinkData.valid is false?

rain minnow
#

That sounds an entire system with a bunch of mechanics working together. You'll need a research a few topics . . .

wary wraith
#

anyone know what to do here?

leaden ice
wary wraith
#

it wants me to select a root sdk folder

#

and no wonder what folder I select it just goes back to that screen

wary wraith
jagged laurel
#

!docs player walking

tawny elkBOT
cedar pivot
#

!docs player dribbling

tawny elkBOT
hexed sorrel
#

I want to check for collisions on very large scales where floating point inaccuracy would usually make it break down; I'm thinking I could do some rudimentary check using my double precision coordinates and then use a raycast at a collider placed at the origin; if I don't want to create lots of such colliders, is there some way to raycast at a collider without actually creating one in the scene? (Or is there a much better way to go about things?)
Thanks

wary wraith
hexed pecan
#

It says See the Console for more details

whole night
#

I want to put a number on default cube, I have made text mesh pro the child of the object but still the number is not showing up

hexed pecan
#

And look at its local position

#

Not a code question though

whole night
#

what is the size of a default cube in unity?

rigid island
#

*1 unity unit = 1m

whole night
#

so in text mesh pro the width and height should be 1>

#

?

rigid island
#

if its world canvas prob

hexed pecan
thick socket
#

it uses meshes rn

wary wraith
#

like that is the console

hexed pecan
wary wraith
#

even downloaded other sdks

#

but I just get this no matter what

lunar mauve
#

Does anyone know if its possible to fetch all scriptable objects of a type and pick a random one or more?

lunar mauve
rigid island
lunar mauve
#

oh alright

rigid island
lunar mauve
#

alright

thick socket
#

whats the best way performance-wise to convert from screen space to world space

#
Vector3 worldPosition = mainCamera.ScreenToWorldPoint(screenPosition);

for some reason I feel I was told bad performance

ionic socket
#

long running question I've had about damaging a player with an attack. Should I simply raise an event on the player with the attack info in it, and let the player respond, or should I call a Damage method on the player, and have /that/ raise some events? On one hand, the later method allows me to control the ordering of certain things (ie, I can subtract the damage after invoking any events that may change the damage?), but it then requires me to add methods to the player and starts nibbling into "Single Responsibility". How would you do it?

thick socket
wheat cargo
#

Does Quaternion.AngleAxis not work when supplying an axis that isn't Vector3.up, Vector3.right, Vector3.forward?

wheat cargo
# hexed pecan It does

Why then, when I supply transform.forward as the axis, it reorients the object to default orientation?

hexed pecan
#

Hard to say

#

How are you doing it?

wheat cargo
hexed pecan
#

Either use transform.rotation or change transform.forward to Vector3.forward

wheat cargo
hexed pecan
#

Hmm what exactly do you expect to happen?

#

Usually I use AngleAxis to multiply it with another rotation

hexed pecan
wheat cargo
#

I just want to rotate an object to a specific angle around one of it's transform's axes, I don't want to continuously rotate it

#

I want to rotate it to a specific angle around the forward axis, so essentially this would 0 degrees

#

And 90 degrees would be rotated right around the forward axis

hexed pecan
#

Then you would multiply it with the current rotation

#
transform.rotation = transform.rotation * Quaternion.AngleAxis(newAngle, transform.forward);```Or I believe this works the same:
```cs
transform.rotation *= Quaternion.AngleAxis(newAngle, transform.forward);```
#

Might need to flip the multiplication sides around. Might not matter. I never remember

wheat cargo
#

This is in an update loop though, so that rotates it continuously, I want to be able to change the angle value and it always stays in the same rotation of what that value is set to

hexed pecan
wheat cargo
#

Yeah I don't

hexed pecan
#

Store the original rotation in a variable then, and apply the rotation on top of that

thick socket
#

@hexed pecan big ask from ya...wouls you be able to help me convert a code made for 3d->2d?

hexed pecan
#

Not sure how you would 2D that

#

Also yeah asking someone specifically to fix your code is a bit weird.

thick socket
#

Not my code...its some elses lol

hexed pecan
#

Even worse

thick socket
#

Its a 3d version that converts ui toolkit to worldspace

hexed pecan
#

Never used UI toolkit

thick socket
#

Really good for formatting...doesnt work in worldspace

#

Thus why this code is so great

#

Guess converting it isnt as easy as I hoped...maybe Ill have to try and learn 3d mesh collider stuff to try and make it work for 2d ๐Ÿ˜ฆ

hybrid sleet
#

Hi all, in C#, is there anything that's like a combination Enum and Dictionary? I would like to create a dictionary but where all the keys are sort of like the immutable data of an Enum entry. I'm mostly going to have a big long list of setting names, and I'd like to pair each one with a type, and I don't want to declare the enum first, and then write all the enum entries again as keys in a dictionary.

#

At first I thought of creating a new class for each thing that I would use as an Enum entry, but it was starting to get cluttered.

#

This feels like there might just be some kind of existing type that handles this kind of thing, no?

#

I also thought of using ScriptableObjects as an entry, but I don't think it's much more practical.

somber nacelle
#

well one (not super great) option is to just have a bunch of constants all in one class

#

of course that would only work if the values would be constant

soft shard
# hybrid sleet Hi all, in C#, is there anything that's like a combination Enum and Dictionary? ...

System.Enum does have functions to get an array of the enums (as values or strings, then you can cast by the index or type), you could technically loop through that and auto-populate the keys of your dictionary, assuming all you need to do is something like someDict.Add(enumValue[i], new List<string>); or whatever initialization you need for the value - or would this still not be ideal for you?
https://learn.microsoft.com/en-us/dotnet/api/system.enum.getvalues?view=net-7.0

hybrid sleet
#

right now it's like Dictionary <MyEnum, MyClass>, where MyEnum is a long list I've started writing out, and MyClass is two or three subclasses that all behave a little differently

#

Matching Enums with Subclasses is what I'm trying to accomplish, and just not have to write everything twice, because the list is very long, like maybe 50+ entries

#

I don't care so much about typing it out, I'm more worried about making changes later.

soft shard
ionic path
#

question for navMeshAgent - is there a way to keep the agent from overlapping the destination?

I have an enemy chasing my player, and it keeps overlapping the player - I set the stopping distance to be further away but either it's just way too far, or doesn't affect anything and the enemy still overlaps the player

lyric wadi
#

tried changing the agent radius?

swift falcon
#

i need help how do i change the apk install location to auto for my game

lucid valley
swift falcon
#

sorry

lucid valley
#

delete your messages in the other channels

lyric wadi
#

what does "install location to auto" mean

ionic path
cloud smelt
#

Is anyone able to give me some advice on the best place to store sprites and grow stages of a tile? I have a 2D array that holds my tile data but if I have the grow stages stored there then I would need a tile for each stage of every crop... which ads up fast...

sleek bough
#

@random raft Your post got caught by a wrong automod filter. It is turned off now.

noble leaf
#

Good aftgernoon

#

I have a issue in Mirror with Unity

random raft
noble leaf
noble leaf
sleek bough
stiff tide
#

Thank you!

#

I'm super lost on what feels like it should be really simple. I want to make a menu button appear (that I can click on) when I hover over a zone.

But, unity thinks the mouse has left the zone when the button appears, causing a flickering effect. If I could just test for what object the mouse is on, I could tell it to not disable things, it'd be easy. Or if I could just tell it to ignore it's children when exiting. Or anything like that. But I've spent my last two days trying to research and figure out how to do this without messing with ray casting. Because 'IsPointerOverGameObject' and 'EventSystem.current.currentSelectedGameObject' sounds like the correct things? But they can't return objects, they're just lways true.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class HoverMenuButton : MonoBehaviour
{
    [SerializeField] GameObject MenuButton;
    [SerializeField] GameObject ViewButton;

    public void Start()
    {
        //transform.Find().gameObject only searches through it's children for the object.
        MenuButton = transform.Find("Mini Menu Button").gameObject;
        ViewButton = transform.Find("View Button").gameObject;
        
        // I'll probably want to check for the parent here. Then I can easily know if this is yours or opponent's.
        OnMouseHoverExit();
    }

    public void OnMouseHoverEnter()
    {
        MenuButton.SetActive(true);
        ViewButton.SetActive(true);
    }

    public void OnMouseHoverExit()
    {
        if (IsMouseOverChild())
        {
            //stuff
        }
        MenuButton.SetActive(false);
        ViewButton.SetActive(false);
    }

   private bool IsMouseOverChild()
    {
        return EventSystem.current.IsPointerOverGameObject();
    }
}```
hybrid sleet
#

Basically just checking a bunch of values and lerping or flipping them, in a state machine kind of thing

#

Like State A, has a big collection of settings, and State B has an identical collection, but the values are a bit different. We then transition from StateA to StateB by checking the dictionaries and lerping the differences

lucid valley
stiff tide
#

Ah yeah that will probably work

#

Now I feel kind of dumb, cuz the solution is as simple as I thought it'd be

#

Although, I just realized that wouldn't work. Not without something else too.

When you hover over the zone, then the mouse leaves, the button won't disappear if you don't hover over the button first.

noble leaf
# noble leaf Somebody help me?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using UnityEngine.UI;

public class MenuScripts : NetworkBehaviour
{
    private bool menuState = false;
    public Canvas canvasMenu;

    void Start()
    {
        menuState = false;
    }

    void Update()
    {
        if(isLocalPlayer)
        {
            MenuActivation();
        }
    }

    void MenuActivation()
    {
        if(Input.GetKeyDown(KeyCode.Escape) && isLocalPlayer)
        {
            menuState = !menuState;
        }

        if(menuState && isLocalPlayer)
        {
            canvasMenu.enabled = true;
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible = true;
        }
        else
        {
            canvasMenu.enabled = false;
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = true;
        }
    }
}
stiff tide
#

Vagetti-Dev, I won't be able to help you, since I'm not experienced.

But I will say you haven't shared what it's doing, or what it's meant to do.

noble leaf
#

Ok

#

I understand this server

sleek bough
#

@noble leaf #854851968446365696 on how to ask questions. Specifically indicate what's wrong and how you've attempted to debug it

vestal summit
#

yo! What I'm trying to do is make the character rotate when I press wasd by the camera's orientation (cam.forward) thingy. Everything works but it rotates in z and x axis. I want to restrict it to the y axis. I tried to use this: https://answers.unity.com/questions/127765/how-to-restrict-quaternionslerp-to-the-y-axis.html but it was using quaternion.slerp and I'm using vector3.slerp cause the forward is vector not quaternion. Is there a way to do it with vector3? Here's the code and a clip of the problem to explain the issue a little better:

leaden ice
#

Vector3.ProjectOnPlane

vestal summit
#

I'll c what I can do

#

yeah idk what I'm doing

#

if I understand correctly I have to do something like this but on the last one idk

#

right directions on the x/z plane??

rustic furnace
#

Hello, I am a bit confused if I did this correctly or not.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerInteract : MonoBehaviour
{
    // Start is called before the first frame update
    public npcDialogue npc;
   

    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("NPC"))
        {
            
            npc = other.GetComponent<npcDialogue>();
            npc.dialogueText.gameObject.SetActive(true);
            if (npc.currentIndex < npc.lines.Length && Input.GetKeyDown("e")  )
            {
                Debug.Log("click click");
               this.GetComponentInParent<mouseMovement>().inDialogue = true;
                npc.dialogueText.text = npc.lines[npc.currentIndex];
                npc.currentIndex++;
            }
            else if (Input.GetKeyDown("e") && npc.currentIndex >= npc.lines.Length)
            {
                npc.dialogueText.gameObject.SetActive(false);
            }

        }
    }
}

Basically, if the player is in trigger and clicks e, dialogue should play one line at a time. But when I go into play mode, I make sure that the player is in the trigger, then it takes multiple 'e' key clicks for it to register the click and I'm not sure why it does that. Also, it does halt the movement correctly. my problem is just with the input not registering with the clicks of e
My other script is

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class npcDialogue : MonoBehaviour
{
    // array
    public string[] lines = new string[] { "Hello there friend!", "Eat up all the food!", "Have fun!" };
    public TMP_Text dialogueText;
    //text object

    public int currentIndex = 0;
    // Update is called once per frame
    private void Start()
    {
       dialogueText.gameObject.SetActive(false);
    }
    
}

Please do not hesitate to @ me. Thanks!

vestal summit
#

I either don't understand something or idk

#

or it's something like this

#

how am I supposed to put x and z axis in there

#

I'm so confusedc

potent sleet
vestal summit
#

yeah I understand that

hexed pecan
#

If you want a horizontal plane, use Vector3.up as planeNormal

vestal summit
#

yeah I did that before you said that

#

but I'll try that

leaden ice
leaden ice
#

in fact why are you changing the camera orientation at all

vestal summit
leaden ice
#

W're just producing a vector to use later in your calculations

#

you shouldn't be assigning anything to cam.forward

vestal summit
#

oh

#

oh shi

#

I didn't see that

leaden ice
#
Vector3 flatForward = Vector3.ProjectOnPlane(cam.forward, Vector3.up);```
potent sleet
#

it won't be as responsive

#

even on TriggerStay

vestal summit
rustic furnace
#

Okay...hmmm, then How could I remake this but without physics triggerStay? I need my player to be in the trigger and then update lines of dialogue...maybe I could use a bool for it instead

#

That might work

potent sleet
vestal summit
#

ok so I got that now where should I replace it with

potent sleet
#

then u set bool InTrigger to false on TriggerExit

#

either way works

rustic furnace
#

I'll update the code and come back if it doesn't work

leaden ice
potent sleet
leaden ice
#

should probably normalize it too

rustic furnace
vestal summit
#

kk

#

wait nvm it's already normalized

potent sleet
vestal summit
#

I'll see

potent sleet
#

so it's a boolean

#

return type is bool

#

in yellow

rustic furnace
potent sleet
potent sleet
vestal summit
#

wait bro you can't

hexed pecan
#

It works with the =>

vestal summit
#

I don

hexed pecan
#

It makes it into a property

#

Instead of field

vestal summit
#

I don't get it at all. The hell is flat? I got flatforward. I can't place it in the inputDirections cause it's using it to call the if statement thing

#

am I dumb?

#

or I just don't get something

#

oh wait

#

nope I don't get it at all

rustic furnace
hexed pecan
#

That example doesnt work

rustic furnace
#

then...what would

slim light
#

PLease can someone help me with a problem connecting vs code to unity

#

i code with c#

tawny elkBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

hexed pecan
potent sleet
#

it works just put arrow

potent sleet
hexed pecan
#

If thats called from FixedUpdate it can still be missed

rustic furnace
#

so I need to put that bool into update()?

potent sleet
#
    bool IsInteract => Input.GetKeyDown(KeyCode.E);

    private void OnTriggerStay(Collider other)
    {
        if (IsInteract)
        {
            Debug.Log("HI");
        }
    }```
hexed pecan
#

Except FixedUpdate or OnCollisionStay/Enter etc

#

No Null

potent sleet
#

no?

hexed pecan
#

OnTriggerStay is called as frequently as FixedUpdate

potent sleet
#

I don't use Triggers that often but iirc they did work

hexed pecan
#

So GetKeyDown can get missed

potent sleet
#

oh you right.. the getter is in the fixedupdate

hexed pecan
#

Single key presses should be detected in Update (or anything that runs with the render loop, not physics loop)

rustic furnace
#

I am slightly confused...

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerInteract : MonoBehaviour
{

    public npcDialogue npc;

    private bool interactPressed => Input.GetKeyDown(KeyCode.E);

    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("NPC"))
        {

            npc = other.GetComponent<npcDialogue>();
            npc.dialogueText.gameObject.SetActive(true);

        }
    }
    private void Update()
    {

        if (npc.currentIndex < npc.lines.Length && interactPressed)
        {
            Debug.Log("click click");
            this.GetComponentInParent<mouseMovement>().inDialogue = true;
            npc.dialogueText.text = npc.lines[npc.currentIndex];
            npc.currentIndex++;
        }
        else if (interactPressed && npc.currentIndex >= npc.lines.Length)
        {
            npc.dialogueText.gameObject.SetActive(false);
        }

    }
}
``` like this?
potent sleet
#

then do the logic in Update or Coroutine

leaden ice
hexed pecan
potent sleet
#

@rustic furnace

potent sleet
vestal summit
#

so I was stupid

rustic furnace
potent sleet
#

or just a bug rn ?

rustic furnace
vestal summit
#

thanks I got it done

potent sleet
rustic furnace
#

the player will never get out of the trigger

#

so onTriggerExit doesnt work

potent sleet
potent sleet
#

you can set it to be able to move after it has done with dialogue @rustic furnace

#

not on trigger exit

#

ontrigger exit should only know how close or if it's within the radius of interaction no ?

vestal summit
#

you helped me understand ProjectOnPlane a little more :)

#

Got another problem that seems a lot easier than the last one but I don't get it at all since the slerp with delta time makes the turn smooth but it don't for some reason. Here's the code and a clip of the problem. Tried to fix it with some tries but it gave me the same result.

#

forgot to include one line

#

worked on this issue for a day :P

#

still no progress

rustic furnace
#

@potent sleet Thanks! It works! Have a nice day

leaden ice
#

GetKeyDown will only be true for one frame

vestal summit
leaden ice
#

Slerp is something you need to be calling every frame as long as the transition is happening

vestal summit
#

that's what I was thinking

leaden ice
#

you would just set a target orientation in the if statement

#

and in Update is where you would do the rotation

vestal summit
vestal summit
#

I'll see

#

ok so I did this. But it's a little messed up

#

it does the nice slerp thing after I come out for some reason

#

it should do just when I press the button

vestal summit
leaden ice
leaden ice
# vestal summit

lookView seems backwards here. I think you reversed your subtraction.

vestal summit
#

can't think anymore tho cause it's 1 am and I'm trying to fix this problem :P

leaden ice
#

actually maybe not

#

idk

vestal summit
#

no

#

it's fine

#

I used the lookView for camera and body rotation orientation

#

it was fine

#

the script that gets called is inside a different method that gets called when it gets to thirdperson

#

when I press the zoom key it goes to first person

#

and uses a different code

#

and stops using the code that is in that third method

#

though I already tried to put it in an update it was the same result

#

yeah got no idea

#

whenever I place the Slerp in a different if statement without the keys it doesn't even run anymore

warm plaza
#

Hey ๐Ÿ˜
Currently trying to visualise different data.. I want it to be a 3d volume, but I did not find something fitting online. Instead I generated cubes for the data, each with respective colors and transparency. Due to the amount this is however not really efficient (10.000+ cubes) ... I basically need every point to have a corresponding color but interpolated as a volume. Are there any approaches to that instead of my self written interpolating cubes? If not, is there any way to make it more efficient (f.e. culling, change cubes to a prefab of planes, if these would work at all)?

quartz folio
#

I have done it before and it came out like this

bronze egret
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class player_movement : MonoBehaviour
{
    [Header("Movement")]
    public float moveSpeed = 0f;
    public float gravity = 9.81f;

    public Transform orientation;

    float horizontalInput;
    float verticalInput;
    
    Vector3 movementDirection;
    Vector3 velocity;
    CharacterController characterController;

    void Start()
    {
        characterController = GetComponent<CharacterController>();
    }

    void FixedUpdate()
    {
        MovePlayer();
    }

    private void MovePlayer()
    {
        horizontalInput = Input.GetAxisRaw("Horizontal");
        verticalInput = Input.GetAxisRaw("Vertical");

        movementDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;

        velocity.y += Physics.gravity.y * Time.deltaTime;
        Vector3 combinedMovement = movementDirection.normalized * moveSpeed * Time.deltaTime + velocity * Time.deltaTime;
        
        characterController.Move(combinedMovement + velocity * Time.fixedDeltaTime);
        
        if (characterController.isGrounded && velocity.y < 0f)
        {
            velocity.y = 0f;
        }
        
    }
}```
wrote this basic First Person Script with Char. Controller in mind
what do you guys think? anything i should improve or fix?
warm plaza