#💻┃code-beginner

1 messages · Page 492 of 1

steep rose
#

those are not debugs, those are warnings

#

actually Debug

ashen frigate
#

can u give exemple ?

ashen frigate
#

u mean the dug.log?

steep rose
#

thats what debugging is

#

well not specific to Debug.log but it is a big area

#

debugging also expands to errors and warnings and knowing what they are telling you

#

and common sense

ashen frigate
steep rose
#

click on collapse in the console please

ashen frigate
#

when i press jump the on jump turn pressjump to true

#

doesnt reach Debug.Log("double jump");

steep rose
#

so, where is doubleJump being called?

#

im not seeing anything activating that boolean

ashen frigate
#

i dont think it the problem ive change the handlejump function multibles time but be cuz it called from update something is happening so fast that it dont let me count double jump or it does cout double jump but wont preform it cuz its happening so fast

`private void OnCollisionEnter(Collision collision)
{
grounded = true;
doubleJump = false; // Reset the ability to double jump
Debug.Log("grounded true");
}

private void OnCollisionExit(Collision collision)
{
grounded = false;
Debug.Log("grounded false");
}

void handleJump()
{
Debug.Log("entered handleJUMP");
if (isJumpPressed)
{
if (grounded)
{
Debug.Log("grounded jump");
rb.AddRelativeForce(Vector3.up * 10);
doubleJump = true; // Allow double jump after leaving the ground
}
else if (doubleJump) // This will only trigger if grounded is false and doubleJump is true
{
Debug.Log("double jump");
rb.AddRelativeForce(Vector3.up * 10);
doubleJump = false; // Disable further double jumps until grounded
}
}
}`

#

void Update() { //AnimatorStateInfo animStateInfo = animator.GetCurrentAnimatorStateInfo(0); //moveDirection = currentMovementInput; handleRotation(); handleJump(); } void onJump(InputAction.CallbackContext context) { isJumpPressed = context.ReadValueAsButton(); //if jump press true Debug.Log("Onjump"); }

steep rose
#

okay first off, please format your !code correctly

eternal falconBOT
ashen frigate
steep rose
#

is your debug for DoubleJump being called?

#

from what im seeing, it looks like fine code other than you applying addforce in update()

ashen frigate
#

"double jump" yea

steep rose
#

you are suppose to apply any physics things in FixedUpdate() due to the fact FixedUpdate() is in the physics update of unity and its framrate independant

#

while Update() is framerate dependant, so the lower the framrate the slower you go, vice versa for the faster your framerate is

#

show us whats happening when you double jump, it should be adding a force to your rigidbody

quick cobalt
#

Hm, im writting my own "Makeshift" Inventory, when i want to destory an object of a child component, it said im not permitted to destroy it because of data-loss what should i do instead? Replace it with a placeholder?

ashen frigate
quick cobalt
ashen frigate
quick cobalt
#

maybe i should use scriptable objects instead (technically still gameobjects)

ashen frigate
deft grail
steep rose
#

so we can see what it actually does

deft grail
quick cobalt
#

Ah this makes more sense

ashen frigate
deft grail
# quick cobalt Ah this makes more sense

yeah, if your destroying the prefab itself thats why there would be "data loss" because you would be getting rid of the prefab completely.
but if you destryo an instance of it that would work fine

quick cobalt
deft grail
#

an inventory realistically is just a list of items

quick cobalt
#

Yeah im just trying my functions and working on drag & drop

#

so i put something into my array

#

and want to drag it out, but i did put the prefab in it with the editor which is not an instance

ashen frigate
steep rose
#

you can either use a coroutine or invoke it to make it stagger or preferably see if you pressed jump in a short amount of time then execute it

outer coral
#

How can I debug through my TestRunner code? It won't find my breakpoints in my tester file:

#

actually seems to be most the files

#

whats wrong with my breakpoints 😭

solemn salmon
#

why is it that if i set the body velocity outside the wallJumpCooldown block, the jump animation that pushes the sprite along the x axis no longer works (body.velocity = new Vector2(-Mathf.Sign(transform.localScale.x) * 10, 2);)

it only works if the i set the body velocity within the wallJumpCooldown block:

https://paste.ofcode.org/euxnD4BgHv8MMrgwHbFbTW

ruby python
#

!code

eternal falconBOT
ruby python
#

Bit about large code blocks. 😕

solemn salmon
#

ok i think i've got it, it's because of the delay introduce by the cooldown block. for anyone else with the same issue at this moment in time, if you don't have a delay between frames, your velocity movement will be interrupted and replaced by the next velocity line as soon as the next frame loads.

by putting it inside the cooldown block, i gave myself about 12 frames for the jump movement to finish before taking back control.

vagrant heart
#

Is it usual practice to put camera as player's child or to put it as independent object and then provide it to the player using SerializeddField? I've tried to have it as a child to my player object but I had a lot of problems with it's rotation and tried to move it out of player's hierarchy, which made it suddenly work, but I don't understand why my approach wasn't able to produce correct result. Relative rotation was a big problem for me. I wanted my camera to face the player while player is rotating (he is rotating as he is moving - he is facing direction in which he is moving). During that time, camera is keeping same offset from player (which is it's parent) and is looking at the player the whole time. Since camera was child of player, in order for it to keep looking at the same position, I had to apply invers of rotation that player was getting rotated for. I also wanted to be able to manually rotate my camera. Once camera is rotated, I wanted my player to move in the direction that camera is pointing to. Now what I had to do, is to apply rotation to the player which is equal to accumulated_offset_rotation (which represents all the inverse rotations that had to be applied to camera in order for it to look at the same point) * current rotation of the camera. I still don't get why is this approach wrong. If somebody got any suggestion on how to make camera work while still being child of a player, I would appreciate insight and ideas

shell sorrel
#

depends on the type of camera wanted

#

if its child object it will move and rotate with the player, that is often not wanted if its third person camera. where you often want some sort of easing and damping on its movement

vagrant heart
#

Yeah that makes sense. So it would make more sense to have it as a child in case of making 1st person camera right?

shell sorrel
#

yeah for a first person i would make it a child object

#

since you really want that directly tied to player faceing which is directlyed tied to mouse input

vagrant heart
#

I am making 3rd person camera, and as you have said, moving and rotating of camera with the player isn't wanted because it can result in lot of these edge cases and can cause a lot of tweaking to get the result. I am just bumped out because I wasn't able to find out what was I doing wrong even though relative rotation as a concept seems pretty straight forward

shell sorrel
#

yeah for a 3rd person i would just make it its own object and give it reference ot the player so it knows how it track

#

would use something like cinemachine, or do some basic vector math and compute a position and rotation relative to the player

#

also other reason to have it its own object is most games let you have some camera control indedepent of player movement with right stick or mouse

vagrant heart
#

I considered using cinemachine but I haven't looked too deeply into it. I needed pretty basic functionality that might be upgraded and expanded further down the line, so I wrote my own camera class because I wasn't sure how flexible is cinemachine

shell sorrel
#

its fairly flexialbe, but wrting your own is also good experience

vagrant heart
rocky canyon
#

cinemachine is a good solution even for a 1st peson camera..

#

vcam being the child

vagrant heart
rocky canyon
#

and the main camera is just loose in the hierarchy

shell sorrel
#

for simple cases computing the position should be easy

#

just cameras take a lot of fine tuning

vagrant heart
# rocky canyon

I'll definitely have to look into it as soon as possible because I've seen that everybody is using it. It must be really good

rocky canyon
shell sorrel
#

yeah i have done all of hte above, pure scripted camera, cinemachine, or having the cinemaching camera follow a camera target i compute

vagrant heart
rocky canyon
#

that way its easy to transition to cutscenes or Points of Interest etc..

vagrant heart
rocky canyon
#

i just enable another cinemachine camera with a higher priority

#

and then it takes care of the transition for me

#

done and done 🙂

shell sorrel
#

but yeah spawn camps point about cutscenes is useful

vagrant heart
rocky canyon
#

ya. just throwing it out there 👍

shell sorrel
#

cinemachine pairs very well with timeline if you want to have little in game directed bits where camera gets taken control of

rocky canyon
#

always good to think a bit ahead

shell sorrel
#

the blending between virtual camers is great

vagrant heart
shell sorrel
#

and the dolly camera's and what not are very nice for hand made camera movements in cutscenes

vagrant heart
#

what are dolly camera's

shell sorrel
#

lets you define a spline that the camera follows along

rocky canyon
#

the one w/ the highest priority will become ur main camera

vagrant heart
#

Although splines can be pretty complex, I don't know how does unity handle them

shell sorrel
vagrant heart
vagrant heart
shell sorrel
#

also its really nice for framing of things, expecially in 3rd person games where you dont want the player right in the middle of the screen

rocky canyon
#

Dolly

#

Unity has its own spline system now doesn't it?

#

im guessing thats what cinemachine is using

shell sorrel
#

yeah really just a curve follow, they just call it dolly to use real film terms

rocky canyon
#

hence why i call it CameraRig

shell sorrel
rocky canyon
#

need to figure out how to implement the term Grip

#

lol

rocky canyon
shell sorrel
rocky canyon
#

ohh thats cool

rocky canyon
shell sorrel
#

music production was much more fun but still pretty tedious

rocky canyon
#

lmao the last part of that sentence is the WOORST

#

i ahve this nice setup and i still have to edit almost all my vocals

shell sorrel
#

also sometimes i will just make things flow better and changing the timing a little

low wasp
#

Good afternoon, How is everyone doing this fine Sunday afternoon? I am having a heck of a time trying to get my game over screen to pop and disable movement or the renederer for the player. It seems in the list of actions only a few get done and/or it just does not run them. I also do not get any errors. So that make me think it is running just not as I intended. In gameOver, it will disable the CarSpawner and the cars stop spawning. It sets the gameOverScreen as active. It also logs the Game Over! What it does not do that I can tell is disabling the player input or the renderers. If I uncomment out any of the lines, the ones below won't run or don't show up in the screen. If I move the commented lines to the bottom. Everything works except for the disabling of the player input or the renderer. Would anyone be able to point me in the right direction?

https://hastebin.com/share/ajebagifib.csharp

rocky canyon
rocky canyon
#

also.. show us the Disable() function..

low wasp
# rocky canyon also.. show us the `Disable()` function..

So, I found out why I was not getting an error. I had them turned off in the console. For the renderers, I get the error, Object reference not set to an instance of an object. For the disable, I was just trying to use the same code in my player controller. It just says:

'''cs
private void OnDisable()
{
move.Disable();
}
'''

low wasp
ashen frigate
#

do u know of any good video for joystick movement like if you push the stick a bit it will walk and if you push it all the way it will run ?

shell sorrel
#

You can get a Vector2 back from your joystick input, the length of that vector will already be greater or smaller depending on if the stick is pushed alot in a direction or just a little

#

can scale up that vector to use it directly, or you can use the length of the vector and a curve to choose how fast you want for any given vector length

ashen frigate
#

is there a code i can look at ? im kinda confused by all of that

#

im using the new inputs

#

btw

green owl
#

hi, does anyone know how to disable and enable emmision of material but with code

steep rose
shell sorrel
steep rose
#

oh, even simpler lmao

#

thats pretty nifty

shell sorrel
#

but yeah i don't really know a guide or anything, but sure the docs can show how to get that information and do basic input

steep rose
#

i mean if it just give you a vector2 you can just compare a value from it to whatever threshold you set

shell sorrel
#

the most basic case is just multiplying that vector from input by your speed, and it will scale it smaller if you push the stick only a little

#

though to get more control, i will do speed and directions independently, so will first get speed by taking the vector length and using that with a animation curve to remap the number to what ever i want

#

then will multiply that by my normalized vector

steep rose
#

but im not sure why they wouldnt make running togglable 🤔

#

or just make it a setting for either or

shell sorrel
#

most games still let you walk slower with less stick push

ashen frigate
#

is it called axis deadzone in the new input ?

shell sorrel
#

with run being its own modifer on top

ashen frigate
shell sorrel
#

no its not, axis dead zone just defines how much the stick has to move to do anything

#

no need for a processor

#

just make the type 2d vector
then when you read it with read value do ReadValue<Vector2>()

steep rose
ashen frigate
#

do i need to make a new run input in the input acction asset ?

steep rose
#

you can if you want it togglable but dont use a vector2 for it if thats what you want

shell sorrel
#

nah would want it for move

steep rose
#

but like passerby said, use the joystick inputs and multiply by some arbitrary float to get desired speed

shell sorrel
#

really just google stick movement unity input system or search it on youtube

#

sure that will give a starting point

ashen frigate
shell sorrel
#

would just get things working first, then after that can build on it to get the correct speed for the vector length on the stick

steep rose
waxen adder
#

Is there some way to tell in the editor what the "true dimensions" in unity units an object is? I know in code you can do something like check the bounds, but I just want to be able to check at a quick glance

wintry quarry
#

Not really, and it's not exactly clear what you are interested in. Presumably the size of the Renderer bounds?

waxen adder
#

Renderer bounds yeah, though with the objects I'm using they are more or less equivalent to the collider

shell sorrel
#

yeah assuming you just want its bounding box, could get that in a editor script and display it

wintry quarry
#

Nothing built in but it wouldn't be that complicated to write an editor script for it

waxen adder
rocky canyon
#

using UnityEditor;

shell sorrel
#

can define a custom window/panel you can dock that will show you the extra information you want

#

can have it just follow what the selection is

rocky canyon
#

make sure to put it in an Editor folder

#

then u should be golden

waxen adder
#

Gotcha, appreciate it!

#

Oh that's so cool

shell sorrel
#

yeah unity is very customizable, you can create new windows like this, toss custom stuff in its menus as you want

ember tangle
#

opinions on an in-line if statement if (!entity.target.targetPathing.enabled) { this.target.targetPathing.enabled = true; }

frosty hound
#

Just remove the braces if it's a single line?

waxen adder
#

Oh, nvm there's thankfully a built in class for selections

eternal needle
cosmic dagger
marble hemlock
#

trying to learn inventory systems and scriptable objects are coming back up
i checked with the official unity account and to clarify: the data they store will persist throughout different scenes right?

eternal needle
wintry quarry
marble hemlock
#

i gotta get it done regardless ig

#

why scriptable object
why not mono behavior
why not a custom class

rich adder
eternal needle
# marble hemlock trying to figure out how to do an inventory system with the proper ui has been b...

🤷‍♂️ i cant really suggest much based on what you're saying. if you have a specific issue then share that
just some general advice, first work on the inventory without UI. UI is just gonna be used to interact with your existing inventory. An inventory is just a list of objects. A scriptable object would be used here purely just to provide your objects with data. You can read and forget about the scriptable object immediately

rich adder
#

100% make a simple inventory on your own, start with simple collections and def without UI at first

marble hemlock
#

okay we'll just sideline the UI for a bit then

#

i feel like i kind of have ideas of how it would work but id have to try
ill return in 2 days and if i dont have the basics down then im going to accept defeat and the player will just have to move everything one by one

waxen adder
#

How can I run my DisplaySelectionInformation function the moment there's a new selection? Right now, it seems I have to mouse over the window for it to run.

My class as of right now:
https://pastebin.com/mtgeSKhW

#

Ah, the good old Repaint function. I remember this from school lol

rocky canyon
#

its for drawing icons.. but anytime the editor repaints the icons get updated

waxen adder
#

Right, I forgot about that lol

shell gorge
#

Hi, I have a main menu on unity and would want to know how to make it to play the game when “play” is pressed

shell gorge
#

K Ty! I’ll look at this

shell gorge
shell sorrel
#

well first stop using notepad

#

!ide

eternal falconBOT
shell sorrel
#

these will show you how to setup a proper IDE, which will help you alot while writing code

shell gorge
#

Okay, idk how to use that

shell sorrel
#

what the bot posts shows how to setup a proper IDE, unity install visual studio for you

silk night
rich adder
shell gorge
#

How is it horrible?

rich adder
#

too many reasons to list, formatting issues, no syntax error highlighting, no intellisense etc. etc

shell gorge
#

Oh.

#

What do I use then?

silk night
#
  • No Code formatting
  • No highlighting
  • No error display
  • No auto completion
  • No Unity integration
shell sorrel
eternal falconBOT
shell gorge
#

Oh. Okay

shell sorrel
#

when you installed unity did you let it install VS for you?

silk night
#

Free: VS Code
Free with more power but imo not needed: Visual studio
Paid: Rider

rich adder
steep rose
#

VS is preferred

rich adder
#

VS has been an absolute shitshow for me lately for some reason, just crashing constantly

shell sorrel
#

yeah for a beginner just use the VS that unity installs with its self

rich adder
#

I wish i knew..the latest updates.. me think so

shell gorge
#

Can someone tell me what to do here, like where to make it so it can load the game?

steep rose
rich adder
#

it crashes usually when have multiple ones open with unity. which was never the case

shell sorrel
rich adder
shell sorrel
#

would focus on those 2 things first

steep rose
rich adder
#

and All the Windows 10/11 SDKs are beefy

steep rose
#

well thats windows 🤷‍♂️

#

windows is notoriously heavy

shell sorrel
#

making me glad i just use Rider and really dont touch any windows .net stuff

rich adder
#

yeah much better now doing .net core because its multi platform

#

fuck the windows sdk and UWP tbh

shell gorge
#

Why are y’all so worried about me using notepad for, it’s what I use to open scripts.

#

Just tell me what to do so I can do it

rich adder
steep rose
silk night
#

rider for the win

shell sorrel
steep rose
rich adder
shell sorrel
#

also sounds like you just want people to do the work for you, this place is not about that

silk night
rich adder
shell gorge
steep rose
#

well when VS eats my PC ill switch lmao

#

it probably will soon, these load times are nuts notlikethis

silk night
#

!code

eternal falconBOT
rich adder
silk night
#

Please ues a paste site 😄

umbral hull
#

myb

steep rose
rich adder
rich adder
steep rose
#

read the bot

umbral hull
#

can someone help me? im trying to figure out why im getting this error...

Assets\movement.cs(39,19): error CS1061: 'WheelCollider' does not contain a definition for 'breakTorque' and no accessible extension method 'breakTorque' accepting a first argument of type 'WheelCollider' could be found (are you missing a using directive or an assembly reference?)
https://hatebin.com/fjadbjrgqy

wintry quarry
#

fix your typo

rich adder
umbral hull
#

we love coding 🙂

#

thanks

rich adder
shell sorrel
silk night
umbral hull
eternal falconBOT
steep rose
#

follow this

#

depending on your IDE

#

and how you installed it

shell gorge
rich adder
shell sorrel
silk night
shell sorrel
#

like when i was doing tech art as a contractor and needed my own maya that was miserable

shell gorge
#

Idk how to download it, “🤔” dosnt help.

rich adder
shell sorrel
silk night
shell sorrel
rich adder
shell sorrel
shell sorrel
rich adder
# steep rose hehe just use gimp

gimp (i still use it over PS at times and I own PS lol ) doesn't even come close to PS and also I need something in comparison to After Effects/Premiere.
Tried Davinci and alike, they're ok but not as good

umbral hull
steep rose
silk night
shell sorrel
steep rose
shell sorrel
#

but the 3 affinty tools are great for the price

shell gorge
shell sorrel
silk night
#

and the 2 times something wasnt working in rider / webstorm they responded in <24h and fixed it in a week

shell sorrel
rich adder
shell sorrel
#

krita would be better

steep rose
shell sorrel
#

no gimp just bad

steep rose
#

gimp is good

#

krita also good

shell sorrel
#

if i had to use it i would charge more

shell gorge
#

I think I need one person to DM me about it, I think it would be easier for me

steep rose
#

just follow what we said

rich adder
steep rose
#

and you will be fine

shell sorrel
eternal falconBOT
rich adder
#

if setting up an ide is this complex to you, making a game wont be any easier

shell gorge
shell sorrel
#

everything about making a game, will be about problem solving, and breaking problems down

#

Visual Studio

silk night
#

VS = visual studio

rich adder
shell gorge
#

Visual studio can that be downloaded?

silk night
#

yes

shell sorrel
shell gorge
#

Okay, thank you, I’ll download it now

rich adder
#

check your system you might have already installed it via unity hub

shell sorrel
#

literally follow the guide

#

we linked it 8 times now

shell gorge
#

Is this it?

#

Wait no

steep rose
#

what

shell gorge
#

I don’t think so now

steep rose
#

how

shell gorge
#

Obviously not

shell sorrel
#

you were linked a guide so many times

silk night
#

Yes, "clion" is actually "visual studio", same letters, letter by letter

steep rose
#

you trolling?

shell gorge
#

No!

shell sorrel
#

it shows you everything needed, where to get things and how to configure

shell gorge
#

I have a disability and I’m trying very hard to understand.

#

Please stop putting that emoji, I’m not trolling at all, I don’t have a reason to troll.

#

Thank you.

silk night
shell gorge
#

Anyways I installed it

rich adder
steep rose
#

follow the installer instuctions

shell gorge
#

Okay.

steep rose
#

then once installed come back and we will lead you to what you need for unity

shell gorge
#

Hold on

#

Forgot where the instructions are

rich adder
steep rose
#

you can ALT + TAB to find the panel again

rich adder
#

quit being a child

shell gorge
#

Just don’t be harsh on me.

#

I’m trying my hardest.

rich adder
#

try harder then

#

we linked to it like over 8 times already

steep rose
#

and follow the instuctions and you should be good

shell gorge
#

So THATS the instructions right?

shell gorge
#

thank you.

rich adder
#

Start with number 1. work your way through steps until "Check for updates" section

ivory bobcat
#

Reminder that step 3 is important and something that you'll need to select on your own during the installation.

shell gorge
#

Why not just tell me what to do with the main menu part?? That would’ve been much easier

shell sorrel
#

also the message with setup instructions lets people choose the option that applies to them most

steep rose
shell gorge
#

Okay.

#

I already have someone helping me so thanks

steep rose
#

does the ternary operator ? work with booleans? like
boolean ? //dosomething : //dosomethingelse?

silk night
shell sorrel
#

var value = condition ? ifTrueValue : ifFalseValue;

steep rose
#

hm, alrighty thanks guys 👍

shell sorrel
#

both branches of it must be the same type

hollow dawn
#

Hi trying to learn the code for basic movements, could anyone help me with a wiki or a code? thx!

wintry quarry
eternal falconBOT
#

:teacher: Unity Learn ↗

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

hollow dawn
#

though im trying not to watch tutorials

shell sorrel
#

you will need to know some basics first

#

but break the problem down

wintry quarry
shell sorrel
#

learn about how to move a transform or rigidbody via code

#

learn how to read input

hollow dawn
#

oki thanks!

keen jacinth
#

Could someone give me some help?
I'm trying to make the delivery script
I'm using mouse click to move
I am currently suffering from some problems;
My player (any block) keeps flickering the base of the map
and if I hold and drag the mouse, instead of it stopping in the place I clicked and/or held, the block slides to wherever it wants
NOTE: you can't see the pointer

wintry quarry
keen jacinth
#

one moment...

#

Is there any problem sending the code here? ?

wintry quarry
eternal falconBOT
steep rose
eternal falconBOT
steep rose
#

please follow the bot you just provided

keen jacinth
#

the notes are in PT-BR

wintry quarry
#

This is a problem

#

and it explains your shaking player.

#

You have to move Rigidbodies via the Rigidbody.

rich adder
#

also just note if you plan on using walls and navigation, you should probably use navmesh instead of Vector3.MoveTowards. Or you can still use rigidbody just pass it the waypoints from navmesh

wintry quarry
#

Not only that but the position you're moving it into is presumably inside the floor since you're directly doing target = hit.point; where the raycast hit the ground

#

hence the violent shaking into/out of the ground

#

Presumably your player's pivot is in the center of the capsule

keen jacinth
#

I understood, but I wouldn't know how to apply this in the code

rich adder
#

or use maybe offset / plane ?

mortal spade
#

is there really no way to read this property of Rigidbody from script? i cant use velocity cuz thats a Vector3, this is pretty much exactly what i need since im trying to see if the speed is higher than a constant

#

but rigidbody.speed doesnt exist

rich adder
#

rigidbody.velocity.magnitude

keen jacinth
#

I'm taking a while to respond, because I'm trying to apply what you're saying

#

I'm using Google Translate to read what you're saying xD

mortal spade
#

this was it thanks :D

steep rose
#

how would i find the closest transform to another transform in an array? would i use a for loop?

rich adder
#

linq maybe or write your own Icomparer class (using Array.Sort method)

#

or good old fashion loops lol

rich adder
#

then you do

var compare = new DistanceComparer(transform);
Array.Sort(closestTransforms, compare);```
hollow dawn
#

How come when i give my object a new script the script program opens and its just a blank page? How come it isnt the normal page with the bacis lines it gives you like unity engine and mono behavior

rich adder
#

screenshot

hollow dawn
#

of the script page or?

rich adder
#

yeah , whatever opens

hollow dawn
rich adder
hollow dawn
#

yea

rich adder
#

can you screenshot rq Preferences in Edit -> Preferences -> External Tools page

hollow dawn
#

for refrence i created a folder and then put the script in the folder then dragged it into the player asset

wintry quarry
#

I would probably not use a rigidbody/collider for this at all

#

I would probably do like a CircleCast each FixedUpdate from the paddle's previous position to its current position

rich adder
#

I would code in directions using vector3.reflect and such methods instead of triggers

hollow dawn
rich adder
# hollow dawn

close VS try clicking Regen Project files then open script again

#

if its still blank open up solution explorer window view in VS

hollow dawn
#

idk if this helps but it seems to show up on the right side just not when i open it

rich adder
#

so there is a disconnect happening somewhere

hollow dawn
#

ok

leaden cliff
#

Same about navarone's idea, I don't have much idea how to apply it.

hollow dawn
#

i think i found it, the script is in my player asset under sample scenses (the compontent is in there) though in the asset section the player doesnt have the compenent

wintry quarry
rich adder
# leaden cliff Same about navarone's idea, I don't have much idea how to apply it.

for mine was basically just suggesting, to instead of calculate the bounce directions via rigidbody bounce (I find this to have less control for me esp with how unpredictable physics material bounce is)
I opt in for using methods such as Vector3.Reflect and use casts, like a spherecast/circle for example to bounce off colliders and get the point for my reflect. I'm not expert though because I still get the sweats with trig math 😅
https://docs.unity3d.com/ScriptReference/Vector3.Reflect.html
(so far only done for games like Pong, Breakout etc..) got much more control and precise results including adding specific "angled hits"

keen jacinth
#

Okay, I think I managed to solve it...

rich adder
keen jacinth
#

Yes,
This is code using the 'character controller', I applied gravity and with that I adjusted the ''tremors'' that were giving

#

and the problem was Rigidbody

rich adder
#

yes but now with AI code you know 0 of how any of it is working..

#

also " problem of it sliding sliding" is very vague

keen jacinth
#

yes, I'm using GPT to adjust the code, I'm ''doing'' this in Python and passing my code to GPT to change

cunning raven
#

hi, is there a way to know if an animation has been completed?

rich adder
keen jacinth
rich adder
#

or what i do is just use Animtion Events and call it a day (this is diffcult if you have many transitions)🤷‍♂️

keen jacinth
coarse juniper
#

i need help inporting a map

rocky canyon
#

help will likely be hit or miss Mattheus, its like someone that was once a professional lego builder building a house out of timber, it falling on someone then him asking help from a carpenter to make his job easier by helping repair the fallen house and paying the insurance claims foor freeee lol

rich adder
rocky canyon
#

why not just learn c# out-right

keen jacinth
#

I have good programming logic, I really didn't want to waste my weekend studying, but rather thinking and getting frustrated, that's what I like about programming

rich adder
#

if you plan on making a game in unity you should lean c# period

rocky canyon
#

then that just means ur 1 step closer than the average beginner would be to learning how to code in c#

rich adder
#

anything you're doing in the ai wont get you very far at all without that base knowledge

rocky canyon
#

actually ur even closer.. b/c u know basic programming and structure

rich adder
#

C# is easier than python

rocky canyon
#

i would agree

keen jacinth
#

My didactic way of learning is a little exotic

rocky canyon
#

ur just using a translator to copy and paste stuff

rich adder
#

whatever you're doing now clearly ain't working chico lol

keen jacinth
#

I already work in the technology area, but I am a data engineer

rocky canyon
#

but i guess its still a form of learning.. if u take that gibberish.. try to use it, realize it doesnt work.. and then end up fixing it

#

then u by definition have to be learning

#

that is if youre fixing it

rich adder
rocky canyon
#

lol fr

rich adder
#

literally for data science

rocky canyon
#

ud be great at making inventories and stuff

cunning raven
#

i hate python, one space fk everything

rich adder
#

GOAP or is it Utility ?

keen jacinth
#

I understand what you are talking about and it is justified

rocky canyon
#

i once wrote a discord bot.. now i'll never touch the stuff again

#

mmaybe for machine learning..

keen jacinth
#

I like python, I've done several atrocities on it

#

Russian roulette to delete the system32 folder

rocky canyon
keen jacinth
#

keeps sliding infinitely, But that's enough for today, I work tomorrow and I drank a little today

rocky canyon
#

looks like how a rigidbody might act.. and the forces just doing their thing..

#

once u do the lil circle manuevr it has force sent out diagonally.. and just keeps taking u that way

#

then ur normal inputs clash over that to get normal movement + that odd diagonal

keen jacinth
#

having, now I'm going to sleep, thank you very much for the conversation and the help ❤️ ❤️
Tomorrow night I will try to solve this problem

#

''problem'', physics is not a problem xD

near jewel
#

uh heya quick question! what kinda variable would i use if i wanted to store multiple values? i'm trying to make a leveling system and i need to have different values stored for each level (exp til next level, defense increase, str increase, ability to gain, etc) and i was wondering if there was some sorta variable i'd use for that or if it's better to just make a class with one object per level for it or something like that

near jewel
#

okay thank u

wintry quarry
near jewel
#

i mean yeah i was only really asking because idk what would perform better

#

idrk

#

i'm not that good of a coder lol

wintry quarry
#

Why are you worried about performance here?

near jewel
#

lemme rephrase that, i don't really know how classes work but i assume since i'm creating lots of objects they'd take up space in memory or storage

wintry quarry
#

Yes, data takes up memory

#

that's how it works

#

that's what memory is for, to store data.

near jewel
#

yeah fair

worthy veldt
#

how do you check which classes inherits your base class quickly among many references ?

wintry quarry
#

There's no getting around that. If you want to store information, it takes up space. This isn't a problem.

teal viper
#

In VS I think it's called "find all implementations" or something like that.

worthy veldt
#

i got it, for visual studio, in solution explorer you expand the class file, then right click on your class item. then select "derived types"

marble hemlock
#

i can add things to the list
problem is that im not sure how to make it just add it once, and then destroy the object, but also not destroy the reference in the proces

#

trying to find the hastebin link

ivory bobcat
#

!code

eternal falconBOT
ionic raven
#

Are you trying to make an inventory system or something?

marble hemlock
#

yes

ionic raven
#

What do you want to do with the objects you add to your inventory?

marble hemlock
#

I don't understand

#

well the end goal is to have the objects be represented in an item slot, but for now im just trying to figure out how to add things to lists

#

currently im not even sure im going in the right direction here, because while the thing does get added to the list, im not sure how i control quantities

#

or how i will have it be represented in the slots

ionic raven
#

Can i see your code for inventory?

marble hemlock
#

originally right under line 72 i just had it destroy the game object it hit, but doing that removed the reference, and now im just kinda stuck

ionic raven
#

Do the items get added more than once? is that the issue?

marble hemlock
#

will record

#

leaving it so it doesnt destroy it doesnt really cause a problem. it lets me infinitely click it, but i kind of need to have the item slots organize it properly

ionic raven
#

I can show you how i have my inventory pickup done if you want

marble hemlock
#

im just not sure what im doing tbh
i can add it to the list but im not sure how im supposed to remove it but also store its data

marble hemlock
#

this is rough ;-;

ionic raven
#

this is my pickup method

#

hopefully the comments added make sense to you

teal viper
marble hemlock
#

im going to try to start over

#

not the entire thing but just the part where im asking it to add an item

ionic raven
#
  • Press E,
  • Shoot raycast
  • assign obj to the object that the raycast hit
  • get the colliders and the rigidbody
  • turn off the colliders and make the rigidbody kinematic
  • set parent to my hand object, local location to 0,0,0 and rotation to 0,0,0
  • Just realise that i left out the part where i add the item to the list
#

wait, no i didn't lol

#

Can i DM you?

#

@marble hemlock

keen wasp
#

Hello, this is one of my first times coding and Im watching a tutorial to help me get started. It was going good but I ran into a issue of then I did public GameObject pipe; the game object would not show up in my inspector.

cs
// 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PipeSpawnScript : MonoBehaviour
{
    public GameObject pipe;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        Instantiate(pipe, tansform.position, transform.rotaion);
    }
}
worthy veldt
#

tansform.position is this typo or is it actually wrong

keen wasp
#

Oh whoops.

#

I'm still not getting the GameObject in the inspector.

worthy veldt
#

pipespawnscript already attached to gameobject in inspector ?

keen wasp
#

I think so

worthy veldt
#

no error at all ?

keen wasp
#

One second Ill send a picture

eternal falconBOT
worthy veldt
#

you typo on rotaion too ?, fix your IDE first

ionic raven
#

double check your spelling errors

keen wasp
#

I just looked at IDE and it is up to date

wintry quarry
#

you clearly have a compile error

#

open your console

#

and configure your IDE

ionic raven
#

tansform.position and transform.rotaion

rich adder
keen wasp
keen wasp
#

I got the GameObject to work

rich adder
# keen wasp I fixed those typos

Im showing you what a configured IDE looks like, fixing typo now wont help you for future syntax / spelling issues without configured IDE

keen wasp
#

I changed some code on one of my other scripts

worthy veldt
#

problem solved then ?

keen wasp
keen wasp
worthy veldt
#

now i want to know, what tutorial instantiating in update. can you link the video ?

wheat wave
#

I hope there's a timer that controls that instantiation, yeah

rich adder
#

yeah def missing a timer or something

keen wasp
rich adder
#

you def copied wrong then

#

aside from spelling

keen wasp
#

Yea I think we are going to add one because he does some things wrong to show what happens then goes back and changes it

rich adder
#

actually you havent finished that part, he does it and then adds timer

keen wasp
#

yea

rich adder
#

its always good to watch a video like this a few times before copying the code
its easier to learn what video is about without code at same time

keen wasp
#

Im at 22:30 so I have a ways to go

rich adder
#

reflect wouldnt replace triggers thats what casts would do

#

reflect just to give the ball more precise control idk how precise you need the paddle hit

knotty gust
#

could anyone help me figure out why im not getting any collision detection from my enemy and bullets when the enemy has a rigidbody component attached to it, compared to when the enemy doesnt have the component attached to it and i do get detection, this is the case for both projectile/rigidbody based bullets and raycast weapons

eternal needle
nocturne kayak
#

Hey, can anyone give me a hand here?

#

I have two transformer handles using MetaXR All-in-one SDK through the One Grab Translate Transformer

#

Problem is

#

when i switch between the X and Z axis, the parent transform resets, if i move it in a single axis it works fine

#

if anyone's interested, this is what the OneGrab translate transformer looks like

tulip pilot
#

Alright I need some help, I've been trying to make this setup work where we can set a Target RPM, Voltage, Max Torque and Max Current as well as a Load Torque and simulate how the motor will work as in how much torque and current it will need to spin the gear at the target RPM and whether it will reach the Target RPM before hitting Max Torque or Max Current or not.

I have attached the Pair of Scripts below (they are AI Generated because I cannot figure this out for the life of me) which control the Roatation of the Gears and govern the system.

elfin hatch
#

Trying to learn/use coroutines. I started a coroutine that has a "yield return new WaitForSeconds(5f);" inside of it, then after the coroutine I did a debug.log to see if it was delayed, but the debug.log happens instantly.
Does Unity not wait for that coroutine to finish before executing the next line(s)?

marble hemlock
#

ive decided to completely sideline the inventory system

#

the solution to one's problems is to pretend they dont exist until i inevitably have to circle back around to it

eternal needle
verbal dome
eternal falconBOT
tulip pilot
tulip pilot
#

This problem has been stumping me for the better part of a week

nocturne kayak
elfin hatch
tulip pilot
verbal dome
nocturne kayak
tulip pilot
#

ah ok my bad

nocturne kayak
#

Me, i'm losing hair over my issue there

tulip pilot
#

same

#

at this time I am cursing every single individual who encouraged me to take up CompSci

eternal needle
# tulip pilot This problem has been stumping me for the better part of a week

there really is a lot of code to go through here, and it doesnt really look like you wrote what the problem was tbh. though i just noticed you said it was AI generated. you'll probably not get help with that here. Start debugging and try to find what the actual issue is. go through the values yourself and see which dont line up

tulip pilot
#

okay

#

thanks

elfin hatch
#

also i don't currently trust AI with math very much

tulip pilot
#

If I were to start over, what approach should I take for the same Objective

#

that being to Simulate a Motor and a Load

eternal needle
tulip pilot
#

I have never used unity ever in my life

eternal needle
#

if you're familiar with coding, even outside unity, this really shouldnt be hard to debug for what line is going wrong. Knowing why its going wrong may be unity specific if you didnt make an error in the equation

ruby python
#

Morning all,

So, I'm experimenting with MoreMountains Feel to control the steering of a vehicle, and so far it's working great (does exactly what I need it to do), but now I'm trying to apply the Y rotation value (That Feel assigns) of a SteeringController Empty to the .steerAngle of my WheelCollider, but as you can see from the image, the rotation.y value is very different (the steeringController empty is set to have a rotation.y value of 15 when the logs were triggered).

Is there some kind of conversion I need to do to get an accurate value?

eternal needle
tulip pilot
#

just throw all the physics out right now

#

a hinge joint will only spin thing a

eternal needle
tulip pilot
#

I want the thing b to be spun by thing a

ruby python
eternal needle
eternal needle
tulip pilot
#

The Gears must only Spin, slow down when Load is too high and so forth

#

I think the Script I am using has become so Bloated it's practically unusable

drowsy oriole
#

So I want to make a script add a string to a list of strings in another gameobject

eternal needle
ruby python
drowsy oriole
#

When the object is added to your cart, the name of the cosmetic is put into the buyer with a string

eternal needle
ruby python
eternal needle
ruby python
nocturne kayak
#

How'd i go about accessing the owner of a script component?

#

for some reason adding .gameObject at the end doesn't work.

ruby python
verbal dome
#

Every Component class does have a gameObject property

verbal dome
#

Ah nevermind that doesnt work like I remembered lol

#

I thought there was a method to extract one axis

ruby python
nocturne kayak
# verbal dome At the end of what?

I'm using meta's all in one XR SDK, in a script there's a var called _grabbable, when i tried to debug print that variable, it gave me a grab component within an object, which is expected

verbal dome
#

I mean, it does work. What did you try?

nocturne kayak
#

however, when i try to drbug print _grabbable.gameObject, it returns an error

#

as if _grabbable (being reffered to as IGrabbable) doesn't have a .gameObject

verbal dome
#

Are you sure that grabbable is a component though?

#

Ah IGrabbable, looks like an interface

nocturne kayak
#

(real quick how do i do small code blocks here?)

verbal dome
#

If you definitely need its gameobject and it is a component, you can cast it to Component first

eternal falconBOT
verbal dome
nocturne kayak
#
        public void EndTransform() {

            Debug.Log("Owner of this shit is " + _grabbable);
            _grabbable.Transform.position = new Vector3 (0, 1.431f, 0);
           

        }
verbal dome
#

Might need to wrap grabbable in paranthesis too, not sure

nocturne kayak
#

gives this

#
      public void EndTransform() {

          Debug.Log("Owner of this shit is " + _grabbable.gameObject);
          _grabbable.Transform.position = new Vector3 (0, 1.431f, 0);
         

      }
ruby python
nocturne kayak
#

gives this

verbal dome
#

Oh if the IGrabbable interface has a Transform property then use that to access gameObject

nocturne kayak
nocturne kayak
#

How do i do that?

verbal dome
#

Or .Transform.gameObject, not sure if it prints the same info

nocturne kayak
#

Alright, that compiled

#

let me try it out

#

Shit

#

that works

#

now my question is

#

why does that work

verbal dome
#

Well every Transform is attached to a gameObject

nocturne kayak
#

oh

#

ok

#

i think i got it

#

i'm still not used to thinking of the Transform as a component itself

verbal dome
#

And so is every component, but you are dealing with an interface, not a component type directly

nocturne kayak
#

Alright, i tried some stuff and

#

it still doesn't solve my problem

nocturne kayak
nocturne kayak
#

I managed to do that, it doesn't solve anything.

#
   public void EndTransform() {

       Debug.Log("Owner of this shit is " + _grabbable.Transform.gameObject);
       _grabbable.Transform.gameObject.transform.position = new Vector3 (0, 1.431f, 0);
      

   }
#

this causes the same problem

#

kinda nearing my (limited) wit's end here

ruby python
#

I'm becoming very frustrated. lol. Surely there's a way to convert a quaternion to euler, without you needing to know what the euler is in the first place? lol.

elfin hatch
#

To convert from Euler angles to quaternions, you can use the Quaternion.Euler function.
To convert a quaternion to Euler angles, you can use the Quaternion.eulerAngles function.

lost crest
#

hi does anyone know how to see custom event parameter statistics within dashboard!? i see how many tiems event got called but i dont see a parameterthat i pass in !?

example i have a buy event .. that records how many times people bought items right.. i also pass in how many coins got spent but these coins are not showed anyware within dashboard!?

i see it as a parameter uder event explorer but they aint sohwing up in dashboard when i create a report

ruby python
verbal dome
verbal dome
#

Maybe show more of your code

ruby python
ionic raven
ruby python
#
        if (Input.GetKeyDown(leftKey))
        {
            wheelFLturnController.PlayFeedbacks();

            Vector3 wheelControllerNewRotation = wheelSteeringControllers[0].rotation.eulerAngles;
            Debug.Log("Wheel Collider Rotation = " + wheelSteeringControllers[0].rotation.y);
            wheelColliders[0].steerAngle = wheelControllerNewRotation.y;
        }

That's the entirity of the code that's delaing with this. The feel controller is what is rotating the option on the keypress, and that works fine, reports the correct rotation in the inspector etc.

It's just getting that value and feeding it into the WheelCollider.steerAngle. 😕

verbal dome
#

Not the same thing at all

ruby python
#

Sorry, I changed the debug to check something and forgot, but using this...........

        if (Input.GetKeyDown(leftKey))
        {
            wheelFLturnController.PlayFeedbacks();

            Vector3 wheelControllerNewRotation = wheelSteeringControllers[0].rotation.eulerAngles;
            Debug.Log("Wheel Collider Rotation = " + wheelControllerNewRotation.y);
            wheelColliders[0].steerAngle = wheelControllerNewRotation.y;
        }

Does the same thing.

verbal dome
#

🤷‍♂️idk what are wheelsteeringcontrollers. I assume they are transforms? Are you 100% sure you are looking at the correct object?

#

Also what you see in the inspector is local rotation. Here you are using world space rotation

ruby python
verbal dome
#

You are likely using the wrong object then

#

Or something else is resetting its rotation between frames

ruby python
#

Definitely not the wrong object 😕

Thanks for trying to help though, I do appreciate it. I've asked the question in the Feel Discord too, in case it's something to do with the way Feel works.

verbal dome
#

Didnt know you are using an asset.
It might be an execution order issue. If you are currently using Update, I would try LateUpdate @ruby python

ruby python
#

Aaah, that's a fair point, that didn't occur to me.

#

Dear god, now I feel like a complete idiot. lol. LateUpdate fixed it. Thank you.

verbal dome
#

Nice

ruby python
#

Hate it when it's something really stupid like that. lol.

burnt vapor
#

Make them yourself

#

If you simply want to debug how the event is called, you can also just create a general method to call the event, and then log the parameters being send before invoking the event

#

But with how many events an application might have it makes no sense to add statistics to all of them

lost crest
#

i know how teh event is called .. i want to trakc how many coins users spend buying items , and how many they gain selling them simple as that

#

but anyways thanks i guess unity is not that advanced to trakc such simple things

burnt vapor
#

It's a game engine, it doesn't support these niche features. It's not hard to add these yourself anyway

lost crest
#

lol they track ur current user acqusitions but cant track a simple float form a event ..

#

yeah point on bud

eternal needle
#

it takes literally 10 seconds for you to write the code to track this yourself. its not about them being able to. if unity even tried to keep track of these things, itd most likely be using reflection and would be just worse in every way.

#

unity doesnt care about such a niche use case

burnt vapor
#

I think I was clear, what you ask for is something you have to do yourself

#

If that's something you don't understand then I'm afraid your expectations of a game engine is too high

eternal needle
#

no i dont do your work for you

lost crest
#

here we go

burnt vapor
#

If you don't know how to do this yourself then I suggest you !learn Unity. Maybe you could even begin with learning c# first before taking on Unity depending on your experience.

eternal falconBOT
#

:teacher: Unity Learn ↗

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

lost crest
#

did i say that i dont know how to do it !? im allreayd trakcing that within firebase .. and there it works simle as that .. in unity analitycs it dos not thats why im here asking for info ..

#

and you guys are werry helpfull thanks a lot 😉

burnt vapor
#

Great, then I'd suggest you figure out how to send analytics data to Firebase and send this data each time your event is called

#

Again, niche use cases are rarely supported. Look more broadly on the matter and you'll see it's often quite simple to implement

lost crest
#

as i said this part is allready done. question was simple if you could track a float/int from custom event within unity analytics ..

burnt vapor
#

The answer was ** probably not**, but somehow this was too difficult to accept for you judging by the conversation that proceeded

#

Also, if you are aware this exists, then what is the problem? Call these methods when your event is invoked.

lost crest
#

for get it

eternal needle
astral falcon
lost crest
#

cause this value is alrleayd there within event right

burnt vapor
astral falcon
lost crest
astral falcon
#

ah okay

lost crest
#

no

#

my firebase allreayd reflects this.. lets say 2 identical events..

in firebase i call sellItem(itemPrice) in firebase it sohws me how many sell items evnets ogt called and whats the total value of itemPrice accumulated

#

within unity dashboard i do the same tihng but i see only event count

astral falcon
lost crest
#

even thoes itemprice is part of the event

lost crest
#

basicaly a lot more hustle

astral falcon
#

I guess its in the matter of time firebase has been around and being used vs analytics being younger. But yeh, if it does not fit your needs, just stick to firebase or try to combine them or do the little extra work if you want to analytics. guess thats all there is to conclude

burnt vapor
#

Then perhaps this could work for you

#

Like I said the analytics part are not something I'm too familiar with, but it seems unlikely that these are just baked into random parts of the code. It really depends on your needs.

leaden pebble
#

Hey Hey!
Is there a Rule of Thumb what I want in the ECS Subscenes and what not ?

hexed terrace
tulip crystal
#

So i was trying to learn unity with c# which course do i do

#

Anyone ?

gray steeple
#

. here @tulip crystal

tulip crystal
#

@worthy veldt

#

Where

gray steeple
#

check the 2 pin messeges

tulip crystal
#

Bruh which course

gray steeple
#

click into to c#

worthy veldt
#

im currently working on cooking/crafting part, certain ingredient cannot be processed certain way aka you cant cut water, cant tenderize egg, etc.
currently i have the information required for crafting kind of detached. i leave the value 0 if something isn't meant to be processed a certain way.

#

so how do i approach this, i want to have somekind of bool in editor that expands when its true, so i can input the required data for crafting

#

instead of leaving many empty

#

i could separate them into multiple classes but it feels like that will make it unnecessarily complicated

#

what should i look into ? interfaces ?

tulip pilot
#

Alright gents, I have made progress

#

now I need to figure out how to have a Slider Component in the UI [MotorSpeed] change the value of a variable [speed].

teal viper
eternal needle
# worthy veldt what should i look into ? interfaces ?

Im somewhat confused what you're trying to solve here. Is it just that you want it easier to setup crafting recipes so that you dont have a ton of options visible at once?
You could look into editor scripting to show options based on a condition. I think there are some premade assets which have attributes for this as well.

#

You could try to attach functionality with interfaces and classes, but this really depends what you're doing. I'm assuming you'd do an action to an object and itd just turn into another object. The code for this would likely be the same across most actions

worthy veldt
#

yes the code is similar, but the required value will be different across different process. for meat i would make 4 cuts at 60 work per segment = x milisec per segment times 4. tenderizing would be 10 smacks 20 work per smack etc

wanton canyon
#

I have this code on all my slime. what it does: looks for slimes that bump into each other does X. this one in particular is spawning a new slime. Since it's on every slime, of course this ends up spawning two. Any ideas how to make it spawn one, while leaving the script on every slime still?

burnt vapor
#

I can't think of a simple way

worthy veldt
#

handle the spawning on different script

burnt vapor
#

If you want a not-so-simple way, create a lock

#

For example, SemaphoreSlim

#

If it's locked, don't spawn

#

If not, you're the first slime to enter

#

Though this solution sucks

burnt vapor
wanton canyon
#

I dont believe I used a lock before so I would have to look into that

burnt vapor
#

You can also use the lock keyword

worthy veldt
#

send the location to the spawnmanager, instantiate there

burnt vapor
#

But idk how you can tell the other slime to just not spawn anymore then

burnt vapor
slender nymph
#

honestly the suggestion of handling it on a different script would probably be easier. just have each pair of colliding slimes contact that other component and provide the pair that are colliding, then like pairs are filtered down to just one by that script, then toward the end of the frame it spawns one slime for each of the remaining contact pairs

burnt vapor
#

You could maintain a counter which the slimes make go up on collission

#

Then, at the end of a frame, divide it by two and spawn the number of slimes. It's just having to maintain a reference to the slime so you know where to spawn it

#

Basically what Boxfriend said in that case

wanton canyon
#

OK thanks will give another script a try !

carmine lagoon
#

i have a question. i have this bullet that is instantiated by a turret and I was thinking of making a function that once the target is dead the bullet is destroyed. so no random bullets flying out the map. I came to the knowledge that what i did was deleting the prefab instead of the copy. so my question is where do i put the function of destroying the object. the script of the bullet or on the script of the tower?

elfin hatch
#

self destruct the bullets after x time?

carmine lagoon
#

wait hatebin is not working

#

when i save it it doesnt generate a code

slender nymph
#

either one works if you want to do it after a certain amount of time, you can pass a delay to Destroy so you could instantiate it then immediately call Destroy with that delay, then if it hits the enemy or whatever it will destroy it like it already does (i assume), but if it misses it will then still be destroyed after that delay time

carmine lagoon
elfin hatch
#

hard to say without knowing ur game though 🙂

elfin hatch
#

you mentioned tower though, is it a tower defense?
you might want to pre-calculate whether the bullet will kill that target or not, so you can change target for new bullets while the old bullets are still travelling.
that would make your turrets seem smart and not waste shots on things that are going to die

carmine lagoon
#

their targets rather

elfin hatch
carmine lagoon
#

oh that makes sense

#

thanks for that

#

That actually makes so much sense

verbal dome
#

Since instance ID's are never equal it will always filter out one of the objects

wanton canyon
#

it's spawning two wailing @verbal dome any idea what I did wrong?

#

I just had to make sure they were gameobjects haha, it works now, thank you!!

gaunt ledge
#

does someone know if there is a way of doing the following

    if(_interactionState == (InteractionType.Building | InteractionType.Buying | InteractionType.Expending)) 
        _currentState = CharacterState.Normal;

instead of the following

    if(_interactionState == InteractionType.Building | _interactionState == InteractionType.Buying | _interactionState == InteractionType.Buying) 
        _currentState = CharacterState.Normal;
ivory bobcat
eternal falconBOT
gaunt ledge
#

come on*, its understandable the way I put it without me needing to post on this site

ivory bobcat
#

Small bits of code with the inline guide else use a free code sharing service (links provided above)

gaunt ledge
#

okay

#

does someone know if there is a way of doing the following

        if(_interactionState == (InteractionType.Building || InteractionType.Buying || InteractionType.Expending)) 
            _currentState = CharacterState.Normal;

instead of the following

        if(_interactionState == InteractionType.Building || _interactionState == InteractionType.Buying || _interactionState == InteractionType.Buying) 
            _currentState = CharacterState.Normal;
#

now I'm happy

#

I didn't realise that you can do that

languid spire
gaunt ledge
#

not any way of making it shorter?

verbal dome
#

Switch also prevents you from making duplicates like you have in your second example

languid spire
#

switch is much more readable and maintainable

gaunt ledge
#

yeah, I realised that... okay, gonna use switch

keen dew
#
if(_interactionState is InteractionType.Building or InteractionType.Buying or InteractionType.Expending)
burnt vapor
burnt vapor
#

Oops, missed the picture below it

thorny basalt
gaunt ledge
gaunt ledge
burnt vapor
#

Pattern matching exists for this like Nitku showed

thorny basalt
#

Doesn’t that only work for types and enums though?

languid spire
drowsy oriole
#

When the object is added to your cart, the name of the cosmetic is put into the buyer with a string

gaunt ledge
#

later, Already got what I wanted, thanks for the help tho

drowsy oriole
#

I need to make a script for that

burnt vapor
thorny basalt
formal hill
#

Anyone have any idea why this wont work?

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

public class SubtitleController : MonoBehaviour
{
    [SerializeField]
    public List<string> Subtitles;
    public List<float> timeToWait;
    public GameObject subtitleText;

    public Wizardthings Wizardthings;

    public void SubtitleStart()
    {
        if (Wizardthings.linePlaying) 
        {
            StartCoroutine(TheSequence());
        }
        
    }

    IEnumerator TheSequence()
    {
        if (Subtitles.Count != timeToWait.Count)
        {
            yield break;
        }

        while (true)
        {
            for (int i = 0; i < Subtitles.Count; i++)
            {
                subtitleText.GetComponent<TextMeshProUGUI>().text = Subtitles[i];

                yield return new WaitForSeconds(timeToWait[i]);
            }
            subtitleText.GetComponent<TextMeshProUGUI>().text = "";
        }

        

    }
}
formal hill
deft grail
languid spire
#

yes, you really need to add some logging

formal hill
formal hill
languid spire
formal hill
languid spire
formal hill
#

oh

languid spire
#

you dont need the while loop at all, the for is enough

formal hill
#

Oh alr thanks!

#

But now I need to get it running somehow

languid spire
#

so find somewhere to call SubtitleStart();

formal hill
#

Like where? It should run when my lineplaying is = true

#

Should I make an update void and add it there?

languid spire
#

why would it do that if the method is not called?

verbal dome
#

Methods dont get automatically called unless its one of the Unity methods (Update, Start etc.)

cosmic quail
languid spire
# formal hill That's not too hard

not how I would do it

public void Start()
    {
        StartCoroutine(TheSequence())
    }

    IEnumerator TheSequence()
    {
       yield return new WaitUntil(() => Wizardthings.linePlaying);
umbral hull
#

question. how can i use a timer script i made, to use that as a win condition? i want to disable the movement script i have when the timer runs out

formal hill
# languid spire not how I would do it ```cs public void Start() { StartCoroutine(The...

I just put it like this

IEnumerator TheSequence()
{
    if (Subtitles.Count != timeToWait.Count)
    {
        yield break;
    }

    for (int i = 0; i < Subtitles.Count; i++)
    {
       subtitleText.GetComponent<TextMeshProUGUI>().text = Subtitles[i];

       yield return new WaitForSeconds(timeToWait[i]);
    }
    subtitleText.GetComponent<TextMeshProUGUI>().text = "";
    
    yield return new WaitForEndOfFrame();
    Wizardthings.linePlaying = false;

}```
deft grail
languid spire
umbral hull
deft grail
umbral hull
#

can i post pictures in here or will i get in trouble?

formal hill
deft grail
polar acorn
umbral hull
#

lol

languid spire
#

Wizardthings.linePlaying = false;

formal hill
languid spire
formal hill
languid spire
#

if you must use Update you want to do that immediately the coroutine starts

umbral hull
formal hill
# languid spire if you must use Update you want to do that immediately the coroutine starts

So just like this

 IEnumerator TheSequence()
 {
     yield return new WaitForEndOfFrame();
     Wizardthings.linePlaying = false;

     if (Subtitles.Count != timeToWait.Count)
     {
         yield break;
     }

     for (int i = 0; i < Subtitles.Count; i++)
     {
        subtitleText.GetComponent<TextMeshProUGUI>().text = Subtitles[i];

        yield return new WaitForSeconds(timeToWait[i]);
     }
     subtitleText.GetComponent<TextMeshProUGUI>().text = "";

 }```
languid spire
#

dont need the first wait, it's pointless

formal hill
#

oh yeah true

umbral hull
formal hill
languid spire
# formal hill oh yeah true

actually, looking at what I think is the logic you are trying to implement you probably want to move this
Wizardthings.linePlaying = false;
to after the first if statement

formal hill
#

Why?

languid spire
#

because you want to wait until the Subtitles List is full

#

but still try to run the coroutine until it is

umbral hull
umbral hull
polar acorn
umbral hull
umbral hull
polar acorn
umbral hull
polar acorn
umbral hull
# umbral hull to rephrase, im trying to make it so that when the timer reaches 0, the player m...

i wanted to use my timer script as a reference:

{
    [SerializeField] TextMeshProUGUI timerText;
    [SerializeField] float remainingTime;
    // Update is called once per frame
    void Update()
    {
        remainingTime -= Time.deltaTime;
        int minutes = Mathf.FloorToInt(remainingTime / 60);
        int seconds = Mathf.FloorToInt(remainingTime % 60);
        timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
    }
}

so i can then make a win condition within my player script

#

im unsure how to set this up tho

#

i want to be able to access the remainingTime specifically

steep rose
#

are you trying to access it from another script?

#

or from the inspector?

umbral hull
polar acorn
umbral hull
#

player script to reference a timer, so that when the timer runs out i can halt the player script

steep rose
#

if you are trying to access that variable from another script you must make that variable public and remove the serializedfield and go into the script you want this variable on and use Getcomponent function to get the script

#

and then use the variable

#

and for the inspector either make it public or private with [SerializedField] (this way is preferred if you do not need to access this variable)

formal hill
umbral hull
polar acorn
steep rose
languid spire
formal hill
languid spire
#

also it makes absolutely no sense to check something for null after you have already used it

formal hill
languid spire
#

switch the if statement the other way round

formal hill
#

ok

polar acorn
languid spire
#

if you cannot understand basic logic, programming is not the job for you

polar acorn
#

Ah wait, just got into this, I thought the issue was a null check was failing to detect a problem, seems like it's just a pointless null check and the error would have already occurred

#

still scrolling back up

formal hill
# languid spire if you cannot understand basic logic, programming is not the job for you

Oh come on. I do understand why it didn't work now, either way it still doesnt work

NullReferenceException: Object reference not set to an instance of an object
SubtitleController+<TheSequence>d__7.MoveNext () (at Assets/Scripts/SubtitleController.cs:38)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <54724222b7684530a2810ae1eac94ec7>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
SubtitleController:SubtitleStart() (at Assets/Scripts/SubtitleController.cs:22)
SubtitleController:Update() (at Assets/Scripts/SubtitleController.cs:33)

polar acorn