#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 483 of 1

rich adder
#

everything that was in Logic script

#

goes in there

deft grail
#

did you add the attribute? [CreateAssetMenu]

queen adder
#

yes

deft grail
deft grail
#

right click

#

at the top there will be a button to create a SO

rich adder
# rich adder

actually one exception , dont store anything that changes in SO

#

always make a copy from the default in SO and modify that

queen adder
#

o dpmt see ot

#

oops-

#

i dont see it

deft grail
#

does a list of buttons popup? maybe your right clicking wrong area

queen adder
#

thats a my class

deft grail
#

makes it easier to see what im looking at

#

because maybe your just in some random place also, which can be confusing

rich adder
# queen adder i dont see it

try creating it with the menu properly labeled
[CreateAssetMenu(fileName ="WeaponSO", menuName ="Weapons/WeaponSO")]

queen adder
#

right click create

#

cant screenshot

deft grail
deft grail
queen adder
#

not there

#

hold on

#

i get the issue

#

my script didnt save the name inside the actual script

#

but did on the outside

rich adder
#

also make sure you dont have compile errors

queen adder
#

yeah did it

deft grail
#

ok so can you see the SO now?

queen adder
#

yeah

deft grail
#

ok create it

#

name it anything, M4A1 or whatever you want

#

change the values of the variables

queen adder
#

uh why

deft grail
queen adder
#

since theyre from the logic script that ive been using theyre perfect as is

deft grail
#

huh

queen adder
#

you mean this?

deft grail
queen adder
#

why would i change them-

deft grail
#

wait

#

no

#

dont change the values on your script, but on the new SO you created (should be blue in the assets folder)

rich adder
queen adder
#

is it like

#

when i change a value

#

i get a new one

#

or do i duplicate them

rich adder
#

on side note - these should probably be in a struct that you can copy btw if you plan on modifying any of the values at runtime
(changing 1 so changes all the SOs of that instance)
if you have pistol that changes then if you get another Pistol it has the same stats

queen adder
#

iiiiiiii have no idea what youre talking about

#

itll be fine

short hazel
#

I suggest you head to !learn first, you seem to lack the knowledge on how all of this works

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

deft grail
queen adder
#

man fuuuuck thaaaaat i hate mindlessly watching tutorials

#

this is how i like to learn

rich adder
#

for example ammo should probably not be in SO only maxAmmo
so you can store ammo inside weapon.cs instance itself
Start()
currentAmmo = weaponSO.maxAmmo

frosty hound
#

@queen adder Make a thread, and do so in the future if you're spending more than 5 minutes on a question.

#

You're excuse that you need someone to explain things to you in order to learn is not going to fly here.

#

But since you're insisting, use a thread so you're not flooding this channel yet again.

queen adder
#

i never said that nor used it as an excuse but yeah i will

#

chicanary

devout onyx
#

Hi guys, I am learning C# for Unity. Do you guys have resources like YT clips about things such as code efficiently, function to be aware of, handle events,..? Thank you very much ๐Ÿ˜†

frosty hound
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

lethal elbow
#

I tried doing this but no luck ๐Ÿ˜ฆ

transform.forward = Vector3.Lerp(transform.forward, Arrow.GetComponent<Rigidbody>().velocity.normalized, Time.deltaTime);
eternal needle
lethal elbow
deft grail
livid ravine
#

maybe little dumb question - i realized i really need to backup my game project, i have account on Github. do i need to do a new project and import things there or i can commit already existing project to new repository ?

lethal elbow
deft grail
#

otherwise your GetComponent will fail

livid ravine
#

that's where my questions comes from basically

wintry quarry
#

Just make sure you add an appropriate .gitignore file first

lethal elbow
#

Before editor start

eternal needle
#

The rotation part* would have to be in update or fixedupdate

lethal elbow
#
Rigidbody Arrow = Instantiate(projectile, transform.position, transform.rotation);
            Arrow.GetComponent<Rigidbody>().AddForce(transform.forward * launchVelocity, ForceMode.Force);
            Arrow.GetComponent<Rigidbody>().AddTorque(transform.forward * torquex * torquey, ForceMode.Force);

It's a rigidbody now

#

I put it in a function that is called by update()

eternal needle
#

If it's a rigidbody now, then you dont need to GetComponent rigidbody still..

lethal elbow
#

That's a good point

#

Okay i've sorted that part :p

eternal needle
#

Also I have no idea where that torquex or torquey came from. Is this from AI or some tutorial, because this is quite questionable.
If you want it to just rotate towards where its moving, take the original code you had with lerp and just change that to MoveTowards as I suggested way above

lethal elbow
#

The torque was something I was experimenting with, it actually makes the arrow roll so I kept it ๐Ÿ™‚

eternal needle
lethal elbow
#

It was also some experimentation but I realized it doesn't do anything more when changing the values

#

The torque does shake the fletching a bit recklessly though

#

I'l do the rotatetowards part now though

lethal elbow
#

Which is weird because in the documentation they did

Vector3 newDirection = Vector3.RotateTowards(transform.forward, targetDirection, singleStep, 0.0f);

and i'm not able to do that

wintry quarry
#

what's stopping you

lethal elbow
#

No idea

wintry quarry
#

Are you sure you didn't do using System.Numerics; or something?

#

Or perhaps made your own Vector3 class

lethal elbow
#

Both Vector3 classes come up with numerics

wintry quarry
rigid pike
#

so confused. I was able to use vector2 throughout the other State scripts but not this one

wintry quarry
#

Delete using System.Numerics; from your code @lethal elbow

wintry quarry
#

When it says "Are you missing a using directive" that's what it's talking about

rigid pike
#

wow what are the chances some1 needs to delete that and someone needs to add that

wintry quarry
#

very high

rigid pike
#

the cleanup code must have deleted that, thanks

wintry quarry
#

because beginners stumble over namespace stuff constantly

rigid pike
#

true

lethal elbow
#

I see the issue now

using Vector3 = System.Numerics.Vector3;
wintry quarry
#

indeed

#

delete that

lethal elbow
#

Deleted ๐Ÿ™‚

weak cedar
#

Does System.Numerics have a Vector2 struct?

weak cedar
#

Ok just read the whole convo

lethal elbow
#
   float singleStep = angularSpeed * Time.deltaTime;
            
            Rigidbody Arrow = Instantiate(projectile, transform.position, transform.rotation);
            transform.forward = Vector3.RotateTowards(Arrow.transform.forward, Arrow.velocity.normalized, singleStep, 0.0f);
            Arrow.AddForce(transform.forward * launchVelocity, ForceMode.Force);
            Arrow.AddTorque(transform.forward * torque, ForceMode.Force);
            

No rotation so far ๐Ÿ˜ฆ

wintry quarry
#

You would need to be doing this in Update or FixedUpdate on the arrow itself

#

it's not something you do when you spawn it

lethal elbow
#

Ah, so a new script

rich adder
lethal elbow
#

Excuse the no formatting but something just like this?

rich adder
# lethal elbow Excuse the no formatting but something just like this?
 public class Arrow : MonoBehaviour
 {
     [SerializeField] Rigidbody rb;
     bool launched = false;
     public void Launch()
     {
         launched = true;
     }
     private void FixedUpdate()
     {
         if (!launched) return;
         float singleStep = angularSpeed * Time.deltaTime;
         transform.forward = Vector3.RotateTowards(rb.transform.forward, rb.velocity.normalized, singleStep, 0.0f);
         rb.AddForce(transform.forward * launchVelocity, ForceMode.Force);
         rb.AddTorque(transform.forward * torque, ForceMode.Force);
     }
 }```
```cs
   void Launch()
   {

       Arrow arrow = Instantiate(projectile, transform.position, transform.rotation);
       arrow.Launch();

   }``` IG
lethal elbow
#

I'l use your one because what I did gave my arrow the funkiest curve to it :p

eternal needle
# lethal elbow Ah, so a new script

Just saying I did mention this above as well, to put the rotation part in update or fixedupdate at least. #๐Ÿ’ปโ”ƒcode-beginner message
But yes some script should be on your arrow controlling its rotation
And you shouldnt be using AddTorque if you wanna just directly set its rotation. Or use AddTorque (look at the docs for the values to use) and dont set the rotation

#

Choose one or the other

rich adder
lethal elbow
rigid pike
lethal elbow
rich adder
#

thats literally a class

#

Launch is probably not needed but just an example to tell your bullet to star doing something after spawning it.. totally uneccessary if its already in fixedupdate tho

#

its good to see examples of how you can call methods like that though

lethal elbow
#

The arrow is doing a weird curve but it's late so il return tomorrow, thanks for the help so far. I'l leave you all with a video of it

lofty sequoia
#

Is there a way to drag into an EditorWindow script a .cs file?

rich adder
#

cs files as just text files no?

short hazel
#

MonoScript should be the type, if I remember correctly

rich adder
#

interesting.. TIL

#

inherits from TextAsset, very nicee

#

ig both work, Mono better if you need specific functions n stuff relating to Mono scripts

short hazel
#

(this is why you see "MonoScript" when you incorrectly try to reference a script instance on a UnityEvent - it's literally the type Unity uses to represent script files)

rich adder
#

oh yeah lol that makes sense i recall you can only rename or something

marble hemlock
#

does anyone have a suggested tutorial for learning to do inventory systems?

#

im not sure how making inventories usually goes

queen adder
#

id assume arrays are a big part of it so learn about those

#

i love giving advice id never use myself

rich adder
#

but yes the most basic inventory would indeed use an array or list..then you can do more complex ones like dictionaries

teal viper
#

That's the universal solution for any mechanic btw.

marble hemlock
#

i feel like i gotta yank a chunk out of my code because i originally designed it where you just picked up one item at a time

#

but now its not being simply picked up and held, but to my memory the object would be getting destroyed and its data stored

#

i guess i can keep most of the functions attached, but just would need to delete any place where its actually used

#

just gotta add that to a new script yipee

teal viper
#

Yanking a chunk of code is normal. Though, maybe keep it as an obsolete code. You might need to reference it later.

marble hemlock
#

soon it will get to be reused ๐Ÿ™

marble hemlock
#

i cant work on this today. i was so excited because i had finished and mostly fixed the pick up and dropping scripts, and how to get items working when you have them equipped, except for a slight problem with clipping objects, and I've just been working on this without a tutorial, and I fixed one of my bugs.

#

but now the mood is just ruined knowing that i worked on something that cant really be put to use for quite some time until i get the inventory situation handled

amber spruce
#

hey so i was reading something about doubles and i was wondering should i be using doubles instead of floats?

timber tide
#

do you have a reason to use doubles

amber spruce
#

not really but the thing i read said the only difference is doubles can hold 2 times the size floats can

timber tide
#

well, unless you're doing stuff like clicker games, there's very little reason for them as you can't even use them with the majority of Unity's API calls

amber spruce
#

ok

timber tide
#

there isn't a Vector3Double class

polar acorn
#

Is there really any noticeable difference between 0.0001999 and 0.0002? Do you have anything so precise that the difference between them is going to matter?

bold iron
#

Which template should I use for 2D games?

deft grail
sullen perch
#

hi, im having problems with this code, can anywone find a solution?

sullen perch
deft grail
#

screenshot the Unity console

sullen perch
#

im following a tutorial for some ai but the tutorial dosent have red lines

deft grail
#

just show the console in Unity or hover of the red line

sullen perch
slender nymph
deft grail
#

perhaps they have different variable type in the tutorial

sullen perch
#

this is a screenshot from the tutorial

slender nymph
#

doesn't look like they are using a configured editor

sullen perch
#

oh

deft grail
#

yeah

slender nymph
#

bad tutorial

sullen perch
#

ok

#

ok

#

thx

deft grail
#

doesnt have capital in class name either, probably not some great tutorial

sullen perch
#

do you have a better tutorial for a horror entity?

#

with nav mesh

deft grail
#

just look up one for basic AI

sullen perch
#

ok

deft grail
#

and then try to adapt it for your needs

sullen perch
#

ok thx

queen adder
#

first time I've seen someone use x to share code catlaugh

vagrant harness
vagrant harness
#

That's... the channel we're in.

near wadi
#

NM

vagrant harness
#

Dw, happens to the best of us lol

wintry quarry
eternal needle
vagrant harness
#

How do I stop the coroutine then?

wintry quarry
#

you don't need to

#

it stops when all the code is done running

#

(like any other function)

#

Are you under the impression this is going to keep repeatedly spawning stuff?

#

if so, then yes you have indeed made a mistake

vagrant harness
#

Oh wait I need a While(true) lol

wintry quarry
vagrant harness
#

Thx!

wintry quarry
#

or you can directly exit out of the whole coroutine with yield break;

vagrant harness
#

I only recently figured out that I can actually learn C# without being annoying lol

#

Like when I tried learning it the first time I was so caught up on learning what IEnumerator meant exactly instead of just using it because I understood how to XD

wintry quarry
#

yeah - that's a common pitfall - trying to understand the meaning of every word you see

#

it's counterproductive

#

You can circle back later on when you have a better understanding

vagrant harness
#

(While I have been managing to learn C# pretty well recently, I'm not confident enough to rely on it lol- i'll keep using visual scripting for main game logic for now)

astral falcon
#

As long as you keep in mind the speed of visualscripting being behind raw c#, you are good to go with visual scripting.

vagrant harness
#

Um... Is this normal??

astral falcon
vagrant harness
#

Why's this suddenly a problem?

vagrant harness
#

There we go :3

astral falcon
languid spire
burnt vapor
#

If you are using it, then this is the correct way to omit the exception.

lunar kelp
#

Guys whats Gizmo in Unity?

languid spire
lunar kelp
languid spire
#

you can do

teal viper
lunar kelp
teal viper
lunar kelp
#

i tried googling

teal viper
lunar kelp
#

but i got something sicentific

teal viper
#

What did you google?

#

And did you check in the manual?

lunar kelp
#

"What is Gizmo in Unity"

languid spire
#

so dificult

teal viper
lunar kelp
#

yes

#

also why are u guys being aggresive i just asked a question

teal viper
#

We don't. We're just trying teach you how to solve issues.

teal viper
# lunar kelp yes

What part did you not understand then? The manual pretty much tells you "Gizmos are blablabla".

#

And even shows some screenshots with examples.

lunar kelp
#

what does it mean when it says setup aids in the scene view?

lunar kelp
teal viper
lunar kelp
lunar kelp
teal viper
teal viper
# lunar kelp

Selected would only show when the object is selected obviously.

lunar kelp
lunar kelp
#

oh great thanks

glossy turtle
#

how to get the i value which i initialized in g() method in interface?.

lunar kelp
#

i have range but its saying i dont, I dont get it

languid spire
rough dust
glossy turtle
languid spire
long jacinth
#

i dont see the blue thing on the ground

cerulean tulip
#

Whats the difference between rigidbody.addForce and .velocity?

#

Cause I've tried both and .velocity seems slower than ```cs
rbd.AddForce(new Vector3(horizontal, 0, vertical) * (Speed * 10) * Time.deltaTime, ForceMode.Impulse);

glossy turtle
languid spire
glossy turtle
neon ivy
#

isn't this supposed to rename the Element 0 in a list to the stat type? it's not working

glossy turtle
#

probably implementing a method is not supporting in interface.

languid spire
glossy turtle
languid spire
#

pretty sure Unity C# level does not support it

long jacinth
lunar kelp
#

I'm not sure if I can explain this correctly but do you need Null in your coding when you already have Mathf.Infinity ?

languid spire
teal viper
teal viper
neon ivy
# teal viper What does it return?

1 issue I found and that was that it wasn't the first variable, but still I need to set the name myself instead of using the =>. I swear I remember using that before. maybe because it's in a scriptable object?

teal viper
willow scroll
neon ivy
willow scroll
#

This applies to non-static and non-readonly variables

neon ivy
#

I don't get it

teal viper
#

I don't see any lists in their code. I think they mistakenly called enum a list.

neon ivy
#

no I made a list of Stat classes

neon ivy
#

though I swear I've done it like that before and it worked, or I'm hallucinating

willow scroll
# neon ivy I don't get it

When creating a class, you call its constructor. Otherwise, doing this inside of the local method causes a warning on unassigned variable usage.
In Unity, creating a List via the inspector doesn't access any constructor of your class. Instead, the class will be created with all variables set to their Type's defaults, which is null for reference types as string and any other class and Vector2.zero for Vector2, 0f for float etc. That's why, if your class or struct is meant to be used inside of the serialized in the Unity's inspector List, assigning the variables doesn't change anything, unless they are static, readonly or const.
The same applies to arrays. Not sure whether they serialize some other Enumerables

fresh marlin
neon ivy
willow scroll
willow scroll
neon ivy
#

it's a scriptable object

#

I think it has OnValidate?

willow scroll
#

It's not called when the list item is added

#

Neither is PropertyDrawer.OnGUI

neon ivy
#

I mostly just want it to update when I change variables

willow scroll
#

When should it be updated?

neon ivy
#

for instance if I change the stat requirement's stat to Dexterity

willow scroll
#

You can achieve this by creating a custom PropertyDrawer for your ScriptableObject

neon ivy
#

think never worked with those

willow scroll
#

This will be tricky, since you'll have to completely override the List's serialization by getting its IEnumerator and serializing each variable separately, checking whether the suitable one is changed by wrapping it with EditorGUI.BeginChangeCheck

neon ivy
#

I think I'll leave it for another time then xD this is just a small project to prep for my exam

#

I'll add it to the list of things I wanna learn tho UnityChanClever

glossy turtle
willow scroll
neon ivy
silk scroll
#

I'm having an issue with the AgentLinkMover.cs where the agent can only cross the navmesh link once. If it tries to cross the link again, it freezes

#

I'm using the Curve option

#

I'm not sure why since I literally pasted the code straight from the NavMeshComponents repository

#

But the issue is with this script cause they can cross the link multiple times without it

charred spoke
#

Have you tried using breakpoints and the debugger to see what is going on.

silk scroll
#

From what I tried with debugging, it doesn't enter the if statements the second time round for some reason

charred spoke
#

Are your offmeshlinks bidirectional?

silk scroll
#

Yeah
I'm not trying to make the agent cross back and forth, it's a race kinda like Koopa The Quick

#

so if the player loses, they can retry the race

#

but retrying the race gets the agent stuck not crossing the link

wintry quarry
#

Should it go towards data.startPos when crossing back?

silk scroll
#

I don't think so since it's going from the start point to the end point every time.

wintry quarry
#

I see

silk scroll
#

After it runs the course, the agent is deactivated and set back to the beginning of the course

#

Then it's activated again but it can no longer cross links

languid spire
#

you know that code will only run again if you reload the scene

silk scroll
#

really?

languid spire
#

yes, it's in Start, Start only runs once

silk scroll
#

so I've gotta move it elsewhere then,

#

probably into Update
I've just not seen this issue before

languid spire
#

not into Update. Into a Coroutine you start from Start

wintry quarry
#

well

#

it's an infinite loop

#

it should keep running indefinitely

#

but yeah you should be Logging to see if it ever sees isOnOffMeshLink again

fringe plover
#

tf Visual Studio suggesting me to do ๐Ÿ’€

wintry quarry
#

It's very possible that's legit if the User contains a complex hierarchy of objects

#

that being said, it's AI stuff

neon ivy
#

random question if you have a reference to a script on a gameobject that is disabled, can you update it's variables? think I'm guessing not

neon ivy
#

it does?!

deft grail
#

the only thing that doesnt run is Update and stuff like that

#

because its disabled

#

the rest acts the same

neon ivy
neon ivy
#

idk, I just imagined if the gameobject was disabled that u wouldn't be able to do stuff inside of it

wintry quarry
#

You imagined wrong I guess

#

Also the GameObject cannot be disabled

#

Scripts can be disabled. The GameObject can be deactivated

neon ivy
#

ah right, mb

languid spire
neon ivy
#

well yea that's why I asked the question

languid spire
silk scroll
#

Still having the issue after moving it into its own Coroutine,

wintry quarry
#

yeah that wouldn't have made a difference

silk scroll
#

I think deactivating the GameObject is stopping the Coroutine actually i might need to move it

#

to like OnEnable

wintry quarry
silk scroll
#

duhh thats obvious in hindsight

#

alright thats what it is

#

makes so much sense now

#

starting the coroutine in OnEnable should finally fix this

languid spire
silk scroll
#

Alright,

charred spoke
#

I still canโ€™t believe Unity actually shipped this junk code in a real repo ๐Ÿคฃ

silk scroll
#

Well assuming you don't disable the gameobject like I am, it works

charred spoke
#

Working code does not mean it is not junk

silk scroll
#

True

charred spoke
#

The whole concept of doing this in an infinite loop inside a coroutine is just bonkers

heavy knoll
#

Anyone know how i can implement the spring damper code here to be used for anything, like camera shake or gun recoil or a camera fov zoom? https://x.com/wilnyl/status/1201516498445058048

@haanssksum Thank you!
I dont think so.
The code is basically:

Velocity += (targetPos - currentPos) * spring;
Velocity -= drag * velocity;
CurrentPos += Velocity

eternal falconBOT
heavy knoll
# deft grail !code

ooh, im not really sure how to format it the right way just found this on X about an example with springs, and have no idea how to actually implement that

deft grail
#

i and probably others dont want to go on X to look up code you want to implement...

heavy knoll
deft grail
exotic prism
#

I use box collider with animation keys(enable colliders for exact times) for sword attack in 3d game. Unity sword attack collider not working with increased animation speed. What is the best way to do sword attack detection for high speed animations. Any help would be nice.

heavy knoll
deft grail
heavy knoll
deft grail
glossy turtle
short hazel
eternal needle
astral falcon
#

Also consider to increase the timestep value if you need faster collision detection

exotic prism
astral falcon
exotic prism
exotic prism
#

and this is the enemy

languid spire
astral falcon
#

And how do you check the collision again?

astral falcon
eternal needle
exotic prism
#

when attack animation is started collider will enable

exotic prism
astral falcon
exotic prism
#

thats why i avoid that method but i think have to do it that way

astral falcon
#

And also one of both needs a rigidbody attached to actually get the collision events to be fired

exotic prism
#

i am making this game for mobile

astral falcon
# exotic prism continues detection is expensive i suppose

You can always switch the mode when you attack for the time of animating. But if you want super fast detection, you need to use that. If you can work around it with your own predictive box or sphere overlap checks, because you dont need like arcade fighter game like collision checks, try to work that way

exotic prism
astral falcon
exotic prism
#

"The easiest way, start timer after executing hit and then check if target is in range. You donโ€™t need really fast collision detection. You could also use raycast, when executing hit." i saw that on forums. What do you think about that

astral falcon
#

You could also twist it around and let only the player (if thats the case) check for enemys around him, if yes, they get "enabled" and can attack with that timer or whatever you wanna use to have the attack rate going. Really depends on the style of your game as well as the feeling of it

eternal needle
#

A lot of this also depends what you want a hit to actually be. In some games, your sword goes straight from right to left in 2 frames. In some games (example: souls like games) its much slower

#

In the fast cases you could just detect the whole area infront of the player

exotic prism
eternal needle
#

No but that raycast was likely a suggestion to make sure the target is visible. I hope at least
Not to actually get the target

#

Because a raycast will get 1 target in a straight line. You want something probably to get all enemies in front of you

astral falcon
#

Maybe you need a multiple step check. First check the distance with a static vector for the player position against enemy. then, if in range, do a raycast to check if visible, if yes, do your box collision check or whatever to actually hit the player. But best would be you writing down yoru mechanics and then what systems could help you achieve those states you got in your mechanics. Find common routes and try to sum it up to reduce calls for physics and what not.

#

Maybe you can share a little bit more information about what the enemies are doing, can do. Who will they attack, only the player? and so on. Thats important to get a proper solution

exotic prism
#

i can share quick gameplay in dm

#

is that okey for u

#

@eternal needle https://youtu.be/j2OCes42qvg?t=1476
You suggested me to do a method similar to the one here, right?

BUGFIX
https://youtu.be/AgmBIHlD12k

In this video we create a new weapon component. This component is responsible for defining a HitBox for the weapon and detecting entities within that hitbox.

All Assets:
https://drive.google.com/drive/folders/17JbMy70gbXLcPYrIIpwYt7xJmKngu0oB?usp=sharing

Discord Server:
https://discord.gg/uHQrf7K

If yo...

โ–ถ Play video
eternal needle
exotic prism
#

@eternal needle okey thank you for answering me while u are busy

#

its help a lot

lethal elbow
weary finch
#

What's the best way to create documentation from code?

#

I would like a way to add descriptions in the code itself and later generate some docs from it

wintry quarry
rocky canyon
#

XML is indeed my favorite as well

steep rose
#

very useful

cobalt dagger
#

The code GeometryUtility.CalculateFrustumPlanes(cam) gives me an error of Object reference not set to an instance of an object any help would be appriciated

wintry quarry
steep rose
wintry quarry
#

but it's likely that cam is null

steep rose
#

and is not referenced

cobalt dagger
#
UnityEngine.GeometryUtility.CalculateFrustumPlanes (UnityEngine.Camera camera, UnityEngine.Plane[] planes) (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
UnityEngine.GeometryUtility.CalculateFrustumPlanes (UnityEngine.Camera camera) (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
CameraDetector.Start () (at Assets/Scripts/Player/CameraDetector.cs:15)
wintry quarry
#

make sure you assign the variable before trying to use it

cobalt dagger
#

oh wait yeah

#

i forgot to assign the MainCamera tag

#

ty for the help

vagrant harness
#

Why does it need to be so hard to multiply two Vector3s ):

wintry quarry
short hazel
wintry quarry
#

it's easy to do so

#

you just have to pick which kind of multiplication you want

vagrant harness
#

I don't get why you can't just (Vec3Var * Vec3Var2)- they really couldn't code that in?

eternal needle
#

Because it doesnt make sense. That's not a thing in the math world

#

And as they said above, it could mean multiple things

#

Some may even consider that the cross product in the math world

polar acorn
wintry quarry
vagrant harness
wintry quarry
vagrant harness
#

I use it all the time /:

polar acorn
# vagrant harness It makes sense to me- you just multiply each number with its counterpart, like h...

In mathematics, vector multiplication may refer to one of several operations between two (or more) vectors. It may concern any of the following articles:

Dot product โ€“ also known as the "scalar product", a binary operation that takes two vectors and returns a scalar quantity. The dot product of two vectors can be defined as the product of the m...

wintry quarry
#

Dot product and cross product are insanely common

#

much more so than the hadamard product

frosty hound
#

Can always make an Extension method so you don't have to do it manually

wintry quarry
#

(As navarone pointed out above)

brave compass
#

HLSL implements the * operator as per-component multiplication. It makes sense to me in that context, but I suppose it's more common in shaders than in scripts.

wintry quarry
#

Look none of us work for Unity, they could certainly have chosen to do it. They didn't. We're just provided post-hoc guesses and reasonings about why

vagrant harness
#

Unrelated to the above conversation- does a C# counterpart to this exist?
(val1 if bool else val2)

polar acorn
wintry quarry
#

you're clearly a Python person

vagrant harness
#

Yeah lol

brave compass
wintry quarry
#

so you'd write mul(vec1, vec2)

#

which is equivalent to Vector3.Scale(vec1, vec2)

vagrant harness
# vagrant harness Yeah lol

Learning Python in computer class surprisingly enough has really helped with learning C#- I didn't know how to properly learn a coding language before then lol

wintry quarry
#

Learning ANY programming language makes learning others 100X easier

vagrant harness
wintry quarry
#

the concepts are the same

#

just a different presentation

#

the whole idea of data flowing from one place to another and being manipulated, it's always the same.

vagrant harness
#

Plus the way I learned Visual Scripting was by looking through the menus and you can't just do that with other programming languages lol

#

Anyway enough talk about VS let's change the topic before anyone gets mad

vagrant harness
eternal needle
#

Ternary expressions often arent fun to read in expressions like that

languid spire
wintry quarry
#

It looks syntactically correct.

vagrant harness
wintry quarry
wintry quarry
#
Vector3 destination = IsTransform ? destination.position : destinationv3;
while (Vector3.Distance(transform.position, destination) > 0.1f) {
  ...
}```
#

This would be better

#

and easier to read

vagrant harness
#

This is how you know I've been up for 16 hours lol

#

How didn't I think of that ๐Ÿ˜…

languid spire
#

wdym, I've been up for 16 hours

vagrant harness
#

I still have a lot to learn, but I am actually learning! Thanks for the guidance, everyone!

#

(No, my way of learning isn't by asking other people lol I just couldn't find any documentation about these)

eternal needle
vagrant harness
#

So I know GetComponent<>() is horrible for optimization, but how would I avoid using that is a situation where I would need to get a specific component without an explicit reference?

frosty hound
#

You can use it whenever you need it, such as getting a component off an object at runtime.

#

But if you find yourself constantly getting the same component off the same object (such as in a loop/update), then you cache it

languid spire
silk crag
#

Can someone help with this script? Not sure whats wrong with it.

vagrant harness
wintry quarry
silk crag
#

Realistic FPS Prefab

#

its a fps prefab

#

but for some reason its not working

wintry quarry
#

Yeah I just explained what you need to do

#

Replace MinAttribute with UnityEngine.MinAttribute or UnityEngine.Postprocessing.MinAttribute

#

depending on which one you want.

#

You can also do using MinAttribute = UnityEngine.MinAttribute; or whichever one you want

languid spire
silk crag
vagrant harness
frosty hound
languid spire
lunar kelp
#

does this mean i cant use enemy code again? im so confused

wintry quarry
#
int x = 5;
int y = 6;
int x = 4;``` is not allowed
#

nor is

int x = 5;
List<int> someListOfInts = whatever;
foreach (int x in someListOfInts) {

}```
sage mirage
#

I mean that one Praetor said isn't something advanced in programming. You have to learn fundamentals first.

lunar kelp
#

ok but i said enemy in enemIES not enemy again

worthy knot
#

Hi, I'm trying to create a 2D game using visual scripting and tilemap, except I have a problem, when I move my character from left to right with the keyboard sometimes it gets stuck in place in one direction as I press my key, can anyone help me?

sage mirage
lunar kelp
sage mirage
#

I mean where you have this code?

lunar kelp
#

in Turret Script

short hazel
worthy knot
#

ah okay I hadn't seen it sorry

short hazel
#

No worries

short hazel
lunar kelp
#

OH

short hazel
#

You cannot have multiple local variables with the same name

silk crag
wintry quarry
#

every time you get that error

silk crag
#

okay thanks

wintry quarry
silk crag
#

Yes i got it to work

vagrant harness
#

i am so unimaginably slightly annoyed by this
CS1503 Argument 1: cannot convert from 'bool' to 'System.Func<bool>'

#
    IEnumerator WaitForEnd()
    {
        float Percentage = Variables.ActiveScene.Get<float>("Percentage");
        yield return new WaitUntil(Percentage == 100f);
    }
silk crag
#

my character wont move because of this

vagrant harness
slender nymph
#

did you make sure that the input button you are attempting to use is actually set up in the input settings?

languid spire
silk crag
slender nymph
#

and? the input button is not set up in your project settings therefore it does not work

silk crag
slender nymph
#

neither of those are called Left

silk crag
#

so i just call it left

vagrant harness
languid spire
vagrant harness
#

Oh.

#

Is this correct?

languid spire
#

does it compile?

vagrant harness
#

Yeh

languid spire
#

then it is correct

vagrant harness
#

Overly complicated :D because :D isn't allowed for some reason!

livid grail
#

Hey! is it possible to use inventory.Contain to see if itemName is equal to "string"?

cs
 public List<Inventory> inventory = new();
    [System.Serializable]
    public class Inventory
    {
        public string itemName;
        public Item itemData;     
    }
languid spire
short hazel
# vagrant harness Is this correct?

I'd use >= 100f, as floats cannot be represented exactly by computers, there might be cases where it'll never be exactly equal to 100, it'll be more like 100.0000000003

vagrant harness
#

In the Visual Scripting code that sets Percentage, it sets it to 100 as an integer when done, dw.

languid spire
vagrant harness
#

The percentage can contain decimals

short hazel
#

Then definitely use >=

languid spire
#

but what SPR2 still stands. 100 cannot be represented exactly as a float

vagrant harness
#

So this?

short hazel
#

Even if you "round" it, most floats won't be accurately stored

#

100, not 99, but that's the gist of it

wintry quarry
languid spire
#

99.8

wintry quarry
#

because your local variable is not going to keep updating.

vagrant harness
wintry quarry
#

you would do cs yield return new WaitUntil(() => Variables.ActiveScene.Get<float>("Percentage") >= 99f);

short hazel
#

And if you don't plan on putting any code after the yield, or that this coroutine isn't awaited from another coroutine, it's esentially useless. It won't block the function that executed StartCoroutine() from running. In fact it will proceed with the rest of the code immediately after hitting the first yield

vagrant harness
#

Oh. So how would I properly do that?

polar acorn
#

The coroutine only delays itself

vagrant harness
#

What if I made the source method a coroutine?

#
...
Ending()

void Ending()
{
  // code
}

to

...
StartCoroutine(Ending())

IEnumerator Ending()
{
  yield return null;
  // code
}
polar acorn
#

But as long as you call it with StartCoroutine it doesn't matter what you name it

#

it'll run until it hits a yield, wait for whatever condition you've specified, then continue from there

vagrant harness
#

...
how do i direct it directly to the main unity thread without chaining yields- all i want to do is just run one thing that takes some time, and then run another thing without overlap

wintry quarry
#

Coroutines aren't multi threaded

livid grail
slender nymph
#

is the example in the documentation that i linked not sufficient?

vagrant harness
#

Is there any way to do this?

Thing 1- Takes time to execute, pauses this thread without freezing Unity
Other stuff
wintry quarry
#

Well again they're not threads

#

but yeah just write it in your coroutine

IEnumerator Example() {
  // some stuff that takes time

  // some other stuff that happens after the first stuff
}```
vagrant harness
#

Wait, so I can actually nest coroutines and waiting will work as expected?

wintry quarry
#

depends what you mean by nesting coroutines

#

if you want to start a coroutine from another coroutine you either
yield return OtherCoroutine(); // waits for it to finish
or yield return StartCoroutine(OtherCoroutine()); // waits for it to finish
or StartCoroutine(OtherCoroutine()); // doesn't wait for it to finish

vagrant harness
#

Like this:

Coroutine1
StartCoroutine(Coroutine2) // Waits for Coroutine2 to stop waiting
//Other Code

Coroutine2
// Code that waits
wintry quarry
#

See my above message

#

it will wait only if you yield return it

vagrant harness
#

Ah

#

C# is daunting... I'm a little tempted to go back to Visual Scripting but I won't lol

wintry quarry
#

Coroutines are a Unity thing only

#

They're not part of regular C#, though the feature they are built upon IS part of C#

vagrant harness
#

Unity oriented C# is daunting... I'm a little tempted to go back to Visual Scripting but I won't lol*

wintry quarry
#

the whole IEnumerator and yield thing - those are for iterator methods which is C#.

vagrant harness
#

Oops- forgot that I reverted my change of making Ending() a coroutine lol

steep rose
#

im trying to make a raycast go in the direction of movement so like any sane person I used the RB's velocity + the forward direction of my playerleghitpos object. but instead of it not hitting something, its hitting something when it should not be, if i move far away from any stairs it seems to not hit anything. so i havent a clue what is happening ๐Ÿ˜…

        Debug.DrawRay(playerlegpos.position, rbvelocityXY.normalized * staircheck); 
        rbvelocityXY = new Vector3(rb.velocity.x, 0, rb.velocity.z);

        if(Physics.Raycast(playerlegpos.position, rbvelocityXY.normalized * staircheck, out hit3, stairmask))
        {
            Debug.Log("hitting stairs!");
        }
wintry quarry
steep rose
#

i dont want it to measure Y movement

wintry quarry
#

rbvelocityXY.normalized * staircheck < stairCheck will be ignored here

#

it doesn't care about the length of this vector

#

only the direction

#

You want probably:

if(Physics.Raycast(playerlegpos.position, rbvelocityXY.normalized, out hit3, staircheck, stairmask))```
steep rose
#

that will do it, thanks for correcting my mistake, went right over my head ๐Ÿ˜…

wintry quarry
#

It's unfortunate that DrawRay and Raycast use different conventions

#

it leads to much confustion

steep rose
#

yeah i havent a clue why they are like that

rocky canyon
#

i wrote my own Draw.Ray() that works by passing in the ray itself

slender nymph
#

eh, it's not really even all that necessary in recent unity versions to draw the ray manually (unless you're using 2d) because of the physics debugging window that will draw your queries

#

this is a code channel

unkempt hornet
#

ops

#

โค๏ธ

#

srry

rough dust
fresh marlin
rough dust
#

Thanks

fresh marlin
#

yea ik, i got the same problem a long time ago

#

np and gl with ur game :DD

lunar kelp
#

why is it saying im not using Update or Gizmos while im clearly using them and have codes in them

slender nymph
#

you have those methods nested inside of another method. therefore they are not actually in use

lunar kelp
#

so the {} is placed wrong?

fresh marlin
#

show the whole code

lunar kelp
fresh marlin
#

those warnings are in the vs not in unity

wintry quarry
#

if you use proper indentation/formatting it will be much easier to see

slender nymph
#

and using explicit access modifiers on your methods will really make it obvious when one is nested inside of another

lunar kelp
#

fixed thanks guys

vocal wharf
cosmic dagger
lunar kelp
#

can someone help me out with this i tried debugging but it didnt work

deft grail
lunar kelp
#

mostly supports the turret to move its head

deft grail
lunar kelp
#

this?

deft grail
#

yeah

deft grail
#

but it takes 2 quaternions

#

and a float

lunar kelp
#

so i should only have 2?

deft grail
#

and it requires 2

lunar kelp
#

i typed like 4 quaterions in the code tho

deft grail
lunar kelp
#

i did it like this

deft grail
#

huh

lunar kelp
#

you said make 2 so i did

deft grail
#

no

#

thats not what i said

#

lerp takes 2 quaternions

#

you gave it 1 lookRotation

lunar kelp
#

it gave 1 in the video but it completley works for him

deft grail
#

and he gave 2 quaternions

lunar kelp
#

I already hate quaternions

deft grail
#

nothing here your doing is complicated

#

its just your lack of copy pasting / basic C# knowledge

lunar kelp
#

even in the manual its too complex

#

or its just me yeah

#

now its giving me Lerp error

#

i checked everything it seemed like everything was in order with the video

short hazel
#

You probably need to involve your lookRotation variable (created on the line above) in the calculation.

deft grail
inner quartz
#

What do I made wrong?

teal viper
inner quartz
teal viper
#

The you're not accessing these keys.

#

But some other key that doesn't exist

inner quartz
teal viper
inner quartz
teal viper
#

Because I don't see you accessing them anywhere.

#

Do you even understand what line throws the error?

teal viper
inner quartz
#

or simply, Values.IntsContainer[i.name]

inner quartz
teal viper
inner quartz
#

key is = my text name

teal viper
#

Yep. So the keys that you use here must be missing in the dictionary

teal viper
#

Try debugging the keys before using them.

inner quartz
inner quartz
inner quartz
teal viper
inner quartz
heavy knoll
#

Anyone know how i can make a spring feature like the one shown in this video at 1:30 to affect the scale rotation or position of an object and also be able to bump an object. I tried following along with it but it just seems way to complex and i dont really seem to understand how to implement it. https://www.youtube.com/watch?v=6mR7NSsi91Y

Something a lot of young indies skip over is the "juice factor" of their game. Simple, bland transitions and movement leaves the game feeling boring. This week you can not only learn about Springs and how to use them, but also get a framework to use them in your game today!

Springs allow us to move, rotate, and scale objects in a, well, spring...

โ–ถ Play video
slender nymph
#

look up how to tween objects, because that's pretty much all it is, is tweening using different easing functions

inner quartz
slender nymph
#

there are several good options, lean tween is one of them. I haven't personally used it though. I've used DOTween and PrimeTween and thought they were both pretty good

heavy knoll
heavy knoll
slender nymph
#

you know that tweet that is a few replies in that provides a few lines of code? that's pretty much the easing function they are using

heavy knoll
steep rose
solar prairie
#

hey anyone know a good tutorial that shows you how to make a 3d object move cant find one or it dose not work and I'm trying learn how to do it not ctrl c it

slender nymph
steep rose
deft grail
solar prairie
deft grail
slender nymph
solar prairie
heavy knoll
slender nymph
#

well you obviously need to call it over time because calling it just once will only move it one frame's worth of that movement. so clearly it should go in Update or a coroutine, or something that is called repeatedly. And you obviously need variables for the different variables in the function.
You should probably go through some beginner courses like the pathways on the unity !learn site if you don't know how to do any of that

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

heavy knoll
steep rose
#

the velocity is just the RB's velocity

slender nymph
steep rose
#

you must learn the basics before you dive into things like this

heavy knoll
heavy knoll
deft grail
steep rose
#

or follow a tutorial on youtube

heavy knoll
steep rose
slender nymph
#

there is no rigidbody involved here

steep rose
#

then the Velocity(s) are a vector3 or a transform's position

#

i just looked at the tweet, my bad

heavy knoll
#

cause they both need to be getting constantly set right?

slender nymph
#

if you would bother going through the pathways on the unity learn site, you might have some idea what you may need for the CurrentPos variable

vagrant harness
#

Whenever I try to use Random.Range(); with even explicitly floating point numbers, it still complains about them not being integers despite supporting floats?

slender nymph
#

are you still trying to assign the result to an int variable?

vagrant harness
#

Oh

heavy knoll
slender nymph
#

well you've missed the crucial step of actually using the currentPos variable

heavy knoll
slender nymph
#

you only use it in the one calculation. you never assign to the position with it

heavy knoll
#

also all the Velocity and currentPos can be made the same capitalization right? cause originally the it has currentPos and CurrentPos and Velocity and velocity

heavy knoll
slender nymph
#

!learn

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

heavy knoll
steep rose
heavy knoll
steep rose
heavy knoll
deft grail
heavy knoll
steep rose
#

remove the start variable

#

you dont need it

heavy knoll
deft grail
#

thats not what i mean

deft grail
heavy knoll
deft grail
deft grail
# heavy knoll ohh like this?

and i assume you need to lerp Velocity or currentPos back to 0 or whatever the default position is
(but you can figure this out later if you need)

heavy knoll
deft grail
#

might need to clamp the numbers or something

#

hold on ๐Ÿค”

#

why is this on a Cube? when its camera shake

heavy knoll
heavy knoll
deft grail
deft grail
#

see if that helps anything

heavy knoll
deft grail
heavy knoll
deft grail
#

do the same but currentPos.x instead of Velocity.x and put it underneath instead of above

wintry quarry
#

you're ignoring the result

#

anyway you're getting a NaN in there somewhere - and it's not coming from this code.

cosmic dagger
#

you're not saving the value returned from Mathf.Clamp . . .

heavy knoll
#

same error still on line 23

steep rose
#

they suggested to clamp the value

#

but you are ignoring the result of the clamp

cosmic dagger
#

to infinity, and BEYOND! ๐Ÿš€

wind dust
#

Hi, everyone, Nice to meet you.

heavy knoll
deft grail
cosmic dagger
steep rose
wind dust
#

sorry to interrupt you.

heavy knoll
deft grail
#

because your using the Y position not X

heavy knoll
deft grail
steep rose
eternal falconBOT
#

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #๐Ÿ”Žโ”ƒfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696

steep rose
#

speak up

heavy knoll
deft grail
#

try making the clamp -50, 50

#

instead of 0, 10

heavy knoll
deft grail
#

but if the value is always smaller then you will never see a "shake"

#

this code is pointless

heavy knoll
# deft grail yeah i mean because its a high number, the most you would wanna move it is like ...

yea idk lol, i found a longer video (https://www.youtube.com/watch?v=eaymdtBHpxM) of the code block that i had linked earlier being used, which is basically how i want it to be able to be used, to move objects to spot or be able to change scale or rotate, and also for a camera shake (so its like pretty modular and can be used for a bunch of different uses in my game in the future like recoil or something on a gun) . I thought the camera shake would be easier so that's why i was starting with that. This is where (https://x.com/wilnyl/status/1201516498445058048) he said the what the code for this example basically just is, and someone in the replies said they were able to use that for a camera shaker.

@haanssksum Thank you!
I dont think so.
The code is basically:

Velocity += (targetPos - currentPos) * spring;
Velocity -= drag * velocity;
CurrentPos += Velocity

steep rose
deft grail
#

since its "physics"

#

and you have literally zero physics lmao

heavy knoll
# deft grail since its "physics"

yea im not sure if its actually physics based or he's just saying that cause it looks like it, but he said in the replies on another tweet about working on the slide is that the motion is all spring damper based, not exactly sure what that means.

deft grail
heavy knoll
slender nymph
#

here is the code actually working after making the necessary changes to work. the issue isn't that they are missing a component or anything, they just don't understand what they are doing so they don't know what changes to make to get it to work

#

that is also using 10 and 2 which were the spring and drag values they attempted to use

cosmic dagger
slender nymph
#

yes, it's literally just an easing function that replicates a spring

cosmic dagger
#

so just use an easing function, or an animation curve where you replicate the (spring) curve you want . . .

heavy knoll
#

i still have no idea what changes to make to get it to work though, and cant seem to figure it out at all no matter what i try and look at lol

slender nymph
#

try going through the pathways on the unity !learn site to learn how to use the engine and you might have some clue as to what needs to change

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

worn plover
#

I have a misunderstanding regarding to setting a gameobject position. If i call this line the first time, the position goes the 1,1,1 position.
But if i call the same line again, it translates the object to 2,2,2 but i just want to set this gameObject exact position to 1,1,1 again. How can i achieve this?

gameObject.transform.position = new Vector3(1,1,1);
languid spire
noble forum
#

Hi! I have a problem with movement

#

in 3d

#

it works fine, but every time i stuble upon an obstacle that makes my player go up a bit, he keeps moving up and flying

#
  private void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.freezeRotation = true;

        
    }

    private void Update()
    {
        // ground check
        grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, whatIsGround);

        MyInput();
        SpeedControl();

        // handle drag
        if (grounded)
        {
            rb.drag = groundDrag;
            Debug.Log("Grounded");
        }
        else
            rb.drag = 0;
    }

    private void FixedUpdate()
    {
        MovePlayer();
    }

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


    }

private void MovePlayer()
{
    // Calculate movement direction
    moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;

    Vector3 targetVelocity = moveDirection.normalized * moveSpeed;

    if (grounded)
    {
        rb.velocity = new Vector3(targetVelocity.x, rb.velocity.y, targetVelocity.z);
    }
    else
    {
        rb.velocity = new Vector3(targetVelocity.x * airMultiplier, rb.velocity.y, targetVelocity.z * airMultiplier);
    }
}

    private void SpeedControl()
    {
        Vector3 flatVel = new Vector3(rb.velocity.x, 0f, rb.velocity.z);

        // limit velocity if needed
        if(flatVel.magnitude > moveSpeed)
        {
            Vector3 limitedVel = flatVel.normalized * moveSpeed;
            rb.velocity = new Vector3(limitedVel.x, rb.velocity.y, limitedVel.z);
        }
    }
}``` That's most of he code, movement isnt stored anywhere else
eternal falconBOT
noble forum
#

when the white object (player) goes through this black doorstep, it begins flying up

#

Any ideas?

stone pilot
#

is it possible to instantiate a particle system and it change it emission amount based on the speed of the charcter?

stone pilot
#

Can you show me ?

deft grail
stone pilot
#

Alright, I will try to do it

languid spire
noble forum
languid spire
# noble forum

that looks fine. You need to debug your code. especially this line

rb.velocity = new Vector3(targetVelocity.x * airMultiplier, rb.velocity.y, targetVelocity.z * airMultiplier);
noble forum
#

So it never counts player as grounded

worn plover
# languid spire no, that line will not set the position to 2,2,2

Sorry this was a stripped down example, it is actually working. My problem is that i use this line of code:

var leftViewportMiddle = Camera.main.ViewportToWorldPoint(new Vector3(0, 0.5f, 0));

This gets the right position at startup, but when i call later in runtine it gets totally wrong position. The position of the camera was remained the same.
I use the camera with Cinamachine if that could be any helpful information. What could cause the problem?

glossy turtle
vale geyser
#

hey, I do not know if this is the correct channel to use for this problem. But I just started using unity but it seems I already got errors and I don't know how to fix them. I have been trying to fix them myself without success, I am using 2022.3.45f1 editor. the errors are : Library\PackageCache\com.unity.render-pipelines.core@14.0.11\Runtime\Lighting\ProbeVolume\ProbeReferenceVolume.cs(651,13): error CS0103: The name 'AdditionalGIBakeRequestsManager' does not exist in the current context and Library\PackageCache\com.unity.render-pipelines.core@14.0.11\Runtime\Lighting\ProbeVolume\ProbeReferenceVolume.cs(689,13): error CS0103: The name 'AdditionalGIBakeRequestsManager' does not exist in the current context

teal viper
vale geyser
#

no I did not. After I installed the editor I created the project

teal viper
vale geyser
vale geyser
#

it complained about storage space (22gb left), but it successfully downloaded when i reopened my computer

teal viper
#

There's a chance that it didn't install correctly

vale geyser
teal viper
#

The same version is fine. Just make sure it installs without issues.

vale geyser
teal viper
#

But no, that should ruin it. Though, the error might persist until you reset the project cache.

vale geyser
vale geyser
wise loom
#

hey can someone help with some code its not working

languid spire
eternal falconBOT
#

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #๐Ÿ”Žโ”ƒfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696

wraith grotto
#

are there any good fov tutorials for enemy ai im making a top down 2d game using navmeshplus for pathfinding

sullen rock
#

Hi! I dont have a quesiton about a particular piece of code, Im more looking for a tool I could use. My armor data is structured like this https://gdl.space/ozodihobop.cs

I would prefer to not do any changes to it and Im looking for a way to nicely look up a specific ItemExtras based on the name (for now Im literally going by indexes like
armorExtras.categories[x].itemExtras[y].animClip'
for example, its fine, but it gets very long in some cases

teal viper
sullen rock
#

thats solid, thx

worthy veldt
#

how does OnPointerEnter behaves ? i have one that doesn't work even when it's using the same UI prefab with one that works. i'd rather not writing my own raycast if possible but i have no idea what their condition to be detected and executed.

#

i was hoping that it is "the first to be hit/ closer to camera" but apparently it's not that simple.

jolly musk
#

I hope I'm in the right channel here but I have a question

I'm very new to this unity stuff but I've been looking into how to decompile a certain game made in Unity, a little game called Bo: Path Of The Teal Lotus
The reason I wanted to decompile it is cause I wanted to start making mods for it, just a fun little personal project

So the thing is, I managed to decompile the game, and the textures I want to alter for the mod I want to make were found in level0.file, but how do you recompile a file like that into a new level0.file except with the altered textures?

wintry quarry
languid spire
lunar cove
#

I have been trying to make make camera movement, and followed some code online, it only works when turning on the x axis, but not for the y axis, is there something I should be checking?

worthy veldt
weak talon
#

im making game and suddenly i cant do any like unity shortcuts
like gameobject, transform, and the for loop is weird and different
noit sure what happend

teal viper
worthy veldt
#

it is, thats my problem as my game grows. how do i use event system to detect which UI my pointer is on ?

wintry quarry
wintry quarry
weak talon
eternal falconBOT
teal viper
weak talon
worthy veldt
teal viper
worthy veldt
#

this ?

teal viper
#

Ah, you're using the new input system. It might not be showing then.๐Ÿ˜…

#

Plan b. Pause your game when the issue is easy to reproduce, switch to scene view, focus on the canvas and start clicking in the area where you'd click in the game and see what objects get selected. If among them any undesired objects, uncheck their raycast target, untill only the desired object is being selected.

worthy veldt
#

all my stuffs were anchored to the whole screen so it will choose one of them each click, ill just brute force through everything untill i decide it's not worth it and do it manually.

heavy knoll
faint osprey
#

im getting floating point errors where its adding 0.009 randomly instead of the required number how do i fix this

wintry quarry
languid spire
faint osprey
#

        massCount.text = dustCount.ToString() + " Solar Masses";```
wintry quarry
faint osprey
#

ah right so how would i go about changing it

#

a double?

wintry quarry
#

no

#

it cannot be represented in binary at all

#

It's like 1/3 in base 10

#

it becomes 0.333333.....

#

similarly 1/1000 and 1/10 cannot be represented in binary

faint osprey
#

so what do i do

wintry quarry
#

What are you trying to do

polar acorn
wintry quarry
polar acorn
#

There are other ways to represent numbers, depending on your specific use case. If you're doing it for the purposes of precise math, for example

wintry quarry
#

e.g.

long OneThousandthsOfASolarMass;```
#

Then you just do formatting tricks when you print it

#

And when you do math, you multiply it by 1000 and use double to do the math itself

faint osprey
#

oh so if i keep it as an int but then do math as a double then display that it will work

wintry quarry
#

if the math is just adding one 1/1000th, you don't do the math as a double, no

#

you just add 1

#

because 1 means a 1/1000th in this scheme

faint osprey
#

so then how do i display that

wintry quarry
#

Think of it like having a variable for pennies when talking about money in dollars

wintry quarry
#

for example

#

When you want to do other math with it, you would do like:

double asDouble = OneThousandthsOfASolarMass / 1000.0;
double totalMass = asDouble * numberOfStars;
long backToIntRepresentation = System.Math.Floor(totalMass * 1000.0);```
faint osprey
#
        massCount.text = ((double)dustCount / 1000).ToString() + " Solar Masses";``` this seems to work for me so im going with this
#

thanks for help guys

shy tiger
#

Can anyone help me bit please, I didn't found script for speed and jump.
These my C# Code

languid spire
wintry quarry
shy tiger
#

Hmm, so if (Input.GetButtonDown"Jump"))

Were error or something? Im beginner anyway tho

ashen birch
#

!cs

eternal falconBOT
ashen birch
#

!vscode

eternal falconBOT
#
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

languid spire
wintry quarry
shy tiger
#

What does that green mean?

wintry quarry
shy tiger
#

Also, noice

#

Ah thanks

wintry quarry
#

yellow means unsaved changes

shy tiger
#

Ok uhh, how to Attached that to my object indonesia
(As I start it's still floating)

shy tiger
polar acorn
shy tiger
polar acorn
#

You click add component

#

and then pick it

shy tiger
#

Aight, I finally found it, thanks.

It may drop but that just because I haven't coded the ground yet, but still thanks.

iron mango
#

hey i want to check if the mouse is hovering over any ui object before i call a raycast to select an object (or in general preventing the raycast to go through ui lol)

wintry quarry