#💻┃code-beginner

1 messages · Page 766 of 1

placid jewel
#

no we mean the new input system

fast relic
#

the new input system pretty much handles all of that for you without the need for a giant switch statement mess

cloud fox
#

well I gues not main worry

fast relic
#

you'd probably never want to hardcode your input

worthy forum
#

you can do that with the new input system, and its more broader as you setup abstract inputs, where any key can be used for it

placid jewel
#

New input system can do basically everthing you are doing and do it easier AND it will actually be supported

cloud fox
fast relic
#

trust me learning the new input system is worth it

cloud fox
#

where could I find a good tutorial explaining the new input system

placid jewel
cloud fox
#

besides docs I'm quite busy

#

I know that's a crappy answer but

fast relic
#

most tutorials i've seen massively overcomplicate it, i recommend you just read the docs

placid jewel
#

Docs is probably easier and more useful than any tutorial

cloud fox
#

guess I'll read tmr then lol

worthy forum
#

most easiest basic way to use it. is using the playerinput and sendmessage

cloud fox
fast relic
worthy forum
#

basically you would need to created a method for each of the inputACtions

worthy forum
ashen trail
#

guys what is this error?

fast relic
worthy forum
#

depending on my use case i either use the PlayerInput for quick access of the InputActions, mostly for local co-op

worthy forum
ashen trail
#

can i use the old stuff in the new unity version?

fast relic
#

you technically can, but really shouldn't

ashen trail
#

oh

#

okay I'm going to try to use the new stuff if its better ig

ivory bobcat
worthy forum
#

isn't it mostly there for backwards compatibility and transferring to the new

ashen trail
#

i read it but i dont know wher the setting is to let me use the old system

worthy forum
#

its in the other or extra section in the player settings

ivory bobcat
#

The new input system makes compatibility with input devices more flexible and provide a lot of extra functionality.

worthy forum
#

and if you want to do easy couch co-op, the playerInput allows that to happen and it will require the new input system

ashen trail
#

okay I will use the old system for now then try the new one

#

thanks for putting up with my questions guys

worthy forum
#

if you are in a time crunch, use what you are comfortable with unless you want to learn via trial by fire.

#

prototypes are also meant for testing a game concept, not necessarily optimal

hot wadi
#

PlayerInput allows quick set up, but it feels less flexible when it comes to event handling

worthy forum
#

you can still access the C# events for it

#

via playerInput.actions["ActionName"]

naive pawn
#

definitely not.

#

@ashen trail i didn't see anyone answer you properly fully, so may as well -
with a PlayerInput, you can use methods in your class like you have, but you will have to configure it properly
for a method receiving CallbackContext, you'd set it to unityevents and assign the method.
for send messages, the method would need to receive an InputValue.

ashen trail
#

Thanks for taking the time to help me, I figured out the movement(probably not how i should do it but it works)

naive pawn
ashen trail
#

well I put some other stuff but this is basically it

i used the old unity movement system because I'm more familiar with it and dont understand the new one

naive pawn
#

there is definitely a learning curve, but if you take the time to understand it it'll be worth it - it's much more flexible and imo easier to use once you do get the hang of it

naive pawn
meager siren
#

any of you know how to check if your moving or not use InputActions? Mine works like this but I kinda need to check if im moving for the next part and idk how to do it with what I have

naive pawn
placid jewel
naive pawn
meager siren
ashen trail
meager siren
#

the ones closed work

naive pawn
meager siren
#

it works so its fine

naive pawn
#

is true literally doesn't do anything lmao. you can use booleans directly

#

that's the point of a boolean

meager siren
#

right

#

I forgot about that

naive pawn
#

and ReadValueAsButton exists to respect pressPoint, rather than checking if it's fully depressed (which it may not reach if it's an analog input)

meager siren
#

alright

placid jewel
meager siren
#

yeah I know

#

dw

naive pawn
#

maybe don't dismiss things you don't understand lmao

meager siren
#

that sounds dumb

naive pawn
#

anyways, you can check if you're receiving move input by just checking if input is Vector2.zero

meager siren
#

I undertand it

#

I just forgot about it

placid jewel
meager siren
#

alright

naive pawn
#

also, is is a specific thing, for most comparison you'll probably want == instead (though you don't need it in this case, since booleans)

naive pawn
meager siren
placid jewel
#

if(bool) is functionally the same as if(bool == true)
And if(!bool) means if(bool == false) or if(bool != true)

placid jewel
#

Ok good

meager siren
#

I just forget that you could do that

naive pawn
#

it sounds like you didn't know then...

meager siren
#

Cause, I stopped focusing on unity for like

naive pawn
#

this isn't a unity thing

meager siren
#

ik

#

omg

#

its C#

naive pawn
#

it's fine to not know things

#

maybe don't dismiss stuff if you've forgotten too then lol

placid jewel
#

We're getting away from the topic

naive pawn
#

getting defensive will just make us waste more time telling you things

meager siren
naive pawn
#

stop getting defensive and accept the advice, that's what im trying to say

meager siren
#

thanks to both and im out

naive pawn
#

you mightve known it before, but you clearly aren't applying it, so why get defensive/dismissive that our advice is wrong lmao

placid jewel
naive pawn
#

you weren't in the code that you sent

meager siren
#

well i just did when I was reminded

naive pawn
#

you're still doing is 1f there

meager siren
#

yeah not that part

naive pawn
#

i am also referring to that part

#

that doesn't respect presspoints and does not account for analog inputs

meager siren
#

im referring to the boolean part

naive pawn
#

cool, but there's also another part that ive given advice that you've also dismissed

meager siren
#

ik

naive pawn
naive pawn
placid jewel
naive pawn
#

so you'd rather the point just get lost to the ether if the receiver doesn't get the point?

placid jewel
#

The way you've been phrasing it feels demeaning

meager siren
#

ReadValueAsButton doesn't exist for me

naive pawn
#

ah whoops, that's for CallbackContext

placid jewel
# placid jewel No

I'd rather you rephrase until it's clear to the reciever while not being insulting

meager siren
#

there is ReadValueAsObject

naive pawn
#

it's IsPressed for InputActions

meager siren
#

ah

#

alright

naive pawn
placid jewel
naive pawn
#

yeah, that's somewhat of a necessary tradeoff

placid jewel
#

I disagree

naive pawn
#

you're free to

placid jewel
#

It's counterproductive to the goal of helping someone to make them feel bad about making mistakes

naive pawn
#

none of my messages were about making mistakes being bad, it's about not fixing them (when given easy instructions on how to) that's bad

#

the dismissal/defensive attitude is definitely bad, it hinders a lot of receiving more info or better advice

placid jewel
#

Yes but people become less likely to change their attitude when insulted

#

If you want to help someone overcome that insulting is the exact opposite of what you should be doing

sour fulcrum
#

no one was insulted

naive pawn
#

i don't see how my messages were insulting, tbh. i'm specifically pointing out the behavior

sour fulcrum
#

something being percieved as aggressive and/or degrading is one thing but thats not an insult, those are two different things

placid jewel
meager siren
#

did feel rude

naive pawn
#

and don't get me wrong, it's a very understandable response - but it's gotta be shed for efficient communication

#

ah, efficient is not the right word.. whatever the adjective form for "efficacy" is

lone tundra
#

stupid question but is it possible in python to have code print an input question and then print a new line under it before the input question is answered?

ashen trail
#

guys I'm not gonna lie

I may possibly, probably, just maybe, followed a youtube tutorial blindly and now I have no idea why my game object wont follow my players rotation

sour fulcrum
lone tundra
#

oh

#

idk

#

is python used in unity?

naive pawn
#

but you can just print stuff before the input call

sour fulcrum
#

no

naive pawn
#

no

lone tundra
#

oh

placid jewel
naive pawn
radiant voidBOT
ashen trail
sour fulcrum
naive pawn
#

see if mousePos seems right, see if rotz seems right, etc

placid jewel
sour fulcrum
#

agree to disagree there

naive pawn
ashen trail
#

stuff pops up at the bottom when i have error but i will check

naive pawn
#

you should have a console open regardless, that's were debug values will be shown

placid jewel
sour fulcrum
ashen trail
#

stupid question incoming here

could it be because im using a vector 3 in a 2d environment or it supposed to be like that

naive pawn
#

@ashen trail wait, was the issue in the rotation or in the shooting or the graphics of the player or what exactly?
im noticing that the gameobject you're rotating is not the root of the player

naive pawn
ashen trail
#

ok

#

also im noticing that the black gameobject is rotating just not moving around the player

placid jewel
# sour fulcrum personally i think its the internet and if the person asking for help doesn't wa...

Ok, let me rephrase, I don't think it's that the person asking for help should have the onus on them, but I do think that neither group should respond to rudeness with rudeness. I think it's perfectly reasonable to calmly point out that a certain behavior or message was rude, and attempt to defuse the situation. But responding with more rudeness cannot help in any way. The best case situation is that the response is ignored, and the worst case is a spiral of more and more rude replies.
I think when in a position of trying to help someone especially, knowing that people often might be frustrated with the issue they are trying to solve already, the attitude of "one side is asking for something" isn't productive. It's much better to take the approach of "never attribute to malice what can be attributed to unintentionality" and attempt to help rather than provoke.

meager siren
naive pawn
ashen trail
#

so I put an empty game object around the player(the black thing u see)

and i want it to follow the mouse position around the player so then i can later program shooting in that direction

idk if that answers ur question

naive pawn
ashen trail
#

oh mb

#

ig it isnt empty

then just he black square thats small

naive pawn
#

do you mean the "create empty" menu item? that just creates a gameobject without anything inside, once you add components it's no longer empty lol

placid jewel
ashen trail
#

create empty

naive pawn
#

so that black dot is the rotatepoint?

naive pawn
#

but is is pattern matching, which includes comparison as part of it

ashen trail
#

its what should follow the mouse around the player

sorry im new to all this programing terminology

naive pawn
#

the extra pattern matching would be the undesired bit

naive pawn
placid jewel
meager siren
ashen trail
naive pawn
#

no, what i was saying was that x is true is the same as just x

#

the is true is unnecessary and not doing anything

naive pawn
meager siren
naive pawn
#

i have no idea what you're trying to say now

#

just forgetting stuff isn't a crime, you don't have to find justification for it

placid jewel
# meager siren Im just lazy

Do you mean that as in, like you were looking for the first thing that came to mind instead of the easier thing that would have required a few more seconds of thought

naive pawn
# ashen trail yes.. i think

so what you have is a black dot that's offset from the player and rotating on its own, rather than orbiting the player
you'd have to either change the offset (position), or have an intermediate gameobject in the player that rotates instead

meager siren
naive pawn
#

do you want the black dot to rotate and point in the direction as well?

ashen trail
#

yes

meager siren
#

which was before... My brains gone off track

naive pawn
naive pawn
ashen trail
#

yes

meager siren
naive pawn
# ashen trail yes

so you'd need a hierarchy like this, basically:

A
|- B
   |- C
```where A is the player, C is the black dot

rotation is around the pivot point, which B serves as - B isn't offset from the player, but C is offset from B
then you would rotate B, which would make C basically orbit A/B
ashen trail
#

okay bet

#

ima try that

pallid flame
#

Can someone give me a good video to start learning about c#

#

And unity in general

placid jewel
# ashen trail ima try that

Also, just a note that without any tweaks for C's rotation, when you move your mouse to the opposite side of the player the rotating object will be upside down, which is totally fine if you want it to be like that but if not you'll need to tweak C a bit

placid jewel
radiant voidBOT
pallid flame
#

Thank you

naive pawn
#

if you don't want the blackdot to rotate at all you could just modify the localposition instead of rotation

placid jewel
naive pawn
#

yeah that's also viable, but if you just want to move it around a circle you don't need an intermediate pivot

#

i mean i guess you could do rotation + offset to not need a pivot even if you want the orbiting thing to rotate

#

a lot of ways to achieve it

#

a lot of ways to do the rotation math too

placid jewel
naive pawn
#

you would need the opposite, but yeah

placid jewel
#

God damn it

naive pawn
#

actually, you wouldn't need trig, you can use the direction vectors

ashen trail
#

ima be honest i think im in over my head

placid jewel
#

Where are you up to?

ashen trail
#

this is getting real confusing
in new to this

#

trying to make c rotate around b

naive pawn
#

you don't need to

#

you just make b rotate, and c will follow

ashen trail
#

yah that

naive pawn
ashen trail
#

but like make c offset from b

naive pawn
#

what you had previously was basically A -> C

#

you would add an intermediate B and move the rotating script to B instead of C

#

you can use the same method to offset as before, just have C be 2 units away from B or whatever - it's the localposition, it'll be rotated along with B

placid jewel
# ashen trail but like make c offset from b

I can draw up a shitty ms paint diagram if this explanation isn't good enough, but this is how rotation of parented objects works:
If you make B the parent of C, and move C somewhere away from B:
C will store its position relative to B
So imagine C thinking "I'm 2m to the right of B"
If B rotates, the direction of B's right changes to match the new rotation
But C still knows it's 2m to B's right
So C will automatically stay 2m to whatever B's current right direction is, the whole time during the rotation

rocky canyon
placid jewel
rocky canyon
#

just rotating a parent on its Y w/ the child object offset on the Z

ashen trail
#

OMG it worked

#

sorry im so dumb

#

my brain aint working good today ig

#

thanks guys

placid jewel
fluid ether
#

Hi, anyone knows why I'm getting this error when trying to add this script to an object in the world ? There aren't any compile issues I don't understand

placid jewel
#

Send the script?

#

!code

radiant voidBOT
placid jewel
#

@fluid ether ^

naive pawn
fluid ether
# placid jewel <@1354600398320701601> ^

yup, it's the one i show at the beginning of the video it's extremely simple but I wanted to test it
here :

using UnityEngine;

[RequireComponent(typeof(HealthSystem))]
[RequireComponent(typeof(IDamageable))]
public class Destructible : MonoBehaviour
{
    [Header("Destruction VFX")]
    [SerializeField] Animation  Anim_DefaultDestruction;

    [Header("Destruction SFX")]
    [SerializeField] AudioClip  ADefaultDestruction;

    public void DestroyObject()
    {

    }
}
fluid ether
naive pawn
#

also your file is called destructible instead of Destructible
iirc the file name matching requirement was removed in 6.0, but you could try changing the name to be sure

placid jewel
naive pawn
#

the IDamageable might be a cause, rather than RequireComponent though

fluid ether
naive pawn
#

huh, never seen something like that

fluid ether
naive pawn
placid jewel
#

Have you been able to add the script to any objects? If not, since it seems like some kind of metadata clash, it might be best to copy the script into a new file and see if that works

naive pawn
#

that might be why

fluid ether
naive pawn
#

which, if true, that's... horrifying

naive pawn
#

you would need a component that implements the interface

#

perhaps try adding an IDamageable-inheriting component first, then the Destructible component?

naive pawn
fluid ether
naive pawn
#

oh, then yeah then requiring an IDamageable doesn't make sense if you already require a specific impl

fluid ether
naive pawn
#

i don't think it's a metadata issue, it might be a caching issue

fluid ether
#

yes caching, im not too versed in that type of stuff i thought it was metadata but yeah i was thinking kind of in the same ballpark 😆

ashen trail
#

does anyone know why my bullets arnt firing?

they just kinda apear on where C(the direction they need to go) is and disapear

fluid ether
placid jewel
placid jewel
fluid ether
# placid jewel Congratulations! What did you do to fix it?

removed the [RequireComponent(typeof(Interface))] and restarted both the editor and the IDE
But i think the source of the issue was actually some weird caching issue, not necessarily the interface being there, althought that would probably cause another issue in itself

ashen trail
#

ohhh

#

ig not

#

do i just multiply the position by velocity?

placid jewel
placid jewel
ashen trail
#

oh k thanks

#

This is my bullet code

placid jewel
# ashen trail This is my bullet code

I can't tell exactly right now what the issue is, but the OnCollisionEnter2D will trigger when the bullet (which I assume has a trigger collider2d) overlaps ANY collider. So if the bullet just flashes into existance then is destroyed, try temporarily removing the OnCollisionEnter to check if that's the problem, and if it is, add a further check for specific colliders instead of just any collider.

frail hawk
# ashen trail oh k thanks

if youw ant proper collision detection you will have to use physics for your bulelts not transform position

ashen trail
#

i added a + before the = in the position and now it shoots right when i click but i want it to shoot in the direction of my cthing

frail hawk
#

and in your OnCollisionEnter method you will have to check for a specific tag

ashen trail
#

collision isnt a problem for me rn

placid jewel
#

Give it a rotation when it spawns that's the same as object B's rotation

sour fulcrum
ashen trail
frail hawk
#

if you bullet comes in contact with any collider it will immediately be destroyed, including the spawn position(gun or player)

ashen trail
placid jewel
ashen trail
#

so the black dot is the direction where i want my bullet(the triangle) to go, right now it is doing that but only for the first bullet(its a prefab)

#

i think thats because in some of the prefabs code i refer to another object

so it doesnt let me override all the prefabs if that makes sense

cedar peak
#

does unity not have a redo buttom cntrl shift z isnt working

ashen trail
#

shift z

#

just that i think

ashen trail
#

I GOT IT TO WORKKKK

#

only for like 3 projectiles for some reason but still

slow mantle
#
    public List<Upgrades> productionUpgrades;
    public List<Upgrades> substanceProduced;
    public Upgrades productionUpgradePrefab;

    public Transform productionUpgradesPanel;



    [SerializeField]
    public BigDouble[] productionUpgradeBaseCost;
    public BigDouble[] productionUpgradeCostMult;
    public BigDouble[] productionUpgradeBasePower;
    public string[] productionUpgradeNames;
    public string[] substanceProducedNames;

    public void StartUpgradeManager()
    {
        productionUpgradeNames = new[] {"Ghost", "Spider", "Skeleton"};
        substanceProducedNames = new[] { "Ectoplasm", "Silk", "Misunderstandings" };
        productionUpgradeBaseCost = new BigDouble[] { 25, 100, 1000 } ;
        productionUpgradeCostMult = new BigDouble[] { 1.5, 1.75, 2, 3 };
        productionUpgradeBasePower = new BigDouble[] { 1, 1, 1 };```

I fell asleep before I got to send anything more, whoops.
frail hawk
slow mantle
#

I'm unsure where to start with this.

ashen trail
#

Like a few bullets will fire normal then it will freeze and no more will fire until i click the exit program button and restart it @frail hawk

sour fulcrum
#

!code

radiant voidBOT
opaque mural
#

Uh is unity free enough for making and publishing a small indie game?

sour fulcrum
#

yes

ashen trail
#

when i try to fire it pauses my game

sour fulcrum
#

are there errors

tiny island
#

Hello , i'm currently making a project with some classmates and we want to do a simple unity game for a arg but they want in sais game to be able to have a text files pop up in the games files after a input but i find it difficult to find any help on how to do it on the internet.

Could someone tell me if such thing are possible on unity and if so could help me?

nocturne kayak
#

hello guys i'd like to understand why this little script spawn a hundred , thousand copies even when there is a for loop ?

sour fulcrum
#

its not

#

which can mean a couple things

#

one guess would be, does that purplecube perfab have that script on it?

nocturne kayak
#

maybe unity didnt load but it would be weird ?

frail hawk
nocturne kayak
#

one sec

sour fulcrum
ashen trail
#

it pauses my game when i shoot

sour fulcrum
#

ok

nocturne kayak
frail hawk
ashen trail
#

@frail hawk and it sends that

#

idk show to deal with it though

sour fulcrum
ashen trail
#

how do i post it as code

placid jewel
#

!code

radiant voidBOT
nocturne kayak
#

no this is still spawning a thousand cube

nocturne kayak
worthy forum
nocturne kayak
#

wait i check

sour fulcrum
nocturne kayak
#

ooohh

frail hawk
#

on your prefab there seems to be the same script , so every prefab on start uses the same loop

nocturne kayak
#

ty

ashen trail
nocturne kayak
#

i didnt think of that

worthy forum
#

a quite recurisive problem

sour fulcrum
nocturne kayak
#

that makes sense now

ashen trail
#

@sour fulcrum does an image work?

sour fulcrum
#

i cant see the projectilebehaviour component in that photo

ashen trail
sour fulcrum
#

ah there we go

#

sometimes this is tricky to explain

worthy forum
#

are you dynamically referencing orbitC

sour fulcrum
#

but your bullet prefab can only reference things in the context of that prefab

worthy forum
#

or you manually referenced it?

sour fulcrum
#

its manually as shown in the stuff theyve posted

worthy forum
#

oh yea the game isn't running

ashen trail
ashen trail
sour fulcrum
#

you can't drag and drop orbitC into the prefab if orbitC is not a part of the prefab

ashen trail
#

oh

sour fulcrum
#

it's like selling a microwave that comes with the wall outlet it's built to plug into

#

it doesnt make sense

ashen trail
#

sure

#

so is there a way to make it work or can u not use orbitC with the prefab?

worthy forum
#

so the logic that is spawning in the prefab should set the orbit point as well

#

or you can use a find object by name, but that isn't the best practice.

#

its quite bad

ashen trail
#

the orbitC is just connected to something else inside of the player that gives it its position and stuff

ashen trail
placid jewel
placid jewel
#

Since you're instantiating by reference to the bullet's script, you could do

worthy forum
# ashen trail sorry but im new idk how to do this

so the code that is spawning the projectile can have a reference to the orbitc. so when you instantiate the bullet, you should also access the bullet component with .GetComponent<>(); and use a function to set the orbit

ashen trail
#

okay I'm going to try to do that

placid jewel
#

You could do something like```cs
ScriptName bullet = Instantiate(...) //replace ScriptName with the actual name

placid jewel
worthy forum
#

that is if has the reference to the prefab as the desired class

placid jewel
#

It's in the other script that was sent earlier

sour fulcrum
#

it instansiates them as a gameobject

#

it could be changed to that

ashen trail
worthy forum
#

yup

placid jewel
sour fulcrum
#

yes but your field type for projectileprefab will have to change from GameObject to projectileBehaviour

#

and you might need to drag the prefab back into it in inspector

placid jewel
#

Unless it was changed

placid jewel
#

Ah

worthy forum
#

yea i missread, it is supposed to be the class of the prefab you are spawning

placid jewel
worthy forum
#

so if it is being instantiated as a gameobject you would need to use the getcomponent<>()

#

or that ^

ashen trail
#

i put a get component thing in there

ivory bobcat
#
public projectileBehaviour ProjectilePrefab;
``````cs
        if (Input.GetButtonDown("Fire1"))
        {
            var bullet = Instantiate(ProjectilePrefab, transform.position, transform.rotation);
            bullet.OrbitC = OrbitC;
        }```
worthy forum
#

pretty much that

sour fulcrum
#

or projectileBehaviour bullet = Instantiate(ProjectilePrefab, transform.position, transform.rotation); if you don't like using var

ashen trail
#

im getting an error still, I apprieciate ur guys help and support, however its 4am rn and im really sleepy so I think i have to go

worthy forum
#

sleep and look at your code with fresh eyes

ashen trail
#

goodnight guys thanks for the help

rocky wyvern
#

anyone know if there is something synonymous to like UnityEngine.Component[] comps = gameObject.GetComponents<Type1, Type2, Type3>();

#

I cannot simply get all components and check vs an array or similar of the components I want since I cannot use nullable types in a NativeArray

naive pawn
#

what exactly are you trying to do?

rocky wyvern
#

I am trying to add select component objects that I need to use in ecs systems to entities

naive pawn
#

I cannot use nullable types
i mean, any class is nullable

rocky wyvern
#

eg. animator or script to control health bar

#

this is not a dots related question

naive pawn
#

isn't ecs part of dots? im not super familiar

rocky wyvern
#

my problem is not with the dots part

#

dont worry about the context it doesn't really matter it's a basic thing

#

but I just would like some way to get an array or list of components of specific types

#

without like if comp == typeof(comp1) || comp == typeof(comp2) ... comp == typeof(comp17)

naive pawn
rocky wyvern
#

sorry

naive pawn
#

you want multiple speciifc types, right?

rocky wyvern
#

specific types plural

naive pawn
#

it kinda sounds like an https://xyproblem.info to me, but i don't really have the background knowledge of ecs to really tell (that's why i redirected)

#

what's wrong with just doing multiple GetComponents for each type you want?

rocky wyvern
#

just feels like a bit bloaty

naive pawn
#

you could also GetComponents<Component> or similar to get all components, i believe

rocky wyvern
#

having 20 of those

#

like yeah there is no issue with it at the end of the day but

naive pawn
#

you need to specify 20 types anyways

rocky wyvern
#

feels a lot less neat

sour fulcrum
#

(ecs is apart of dots afaik)

rocky wyvern
#

because I don't see why it something like GetComponents<//multiple types here> doesn't exist tbh

#

wanted to ask in case there was something similar and I simply wasn't aware of it's existence

naive pawn
rocky wyvern
#

its not xy problem though

sour fulcrum
naive pawn
#

it'd have to be 1 overload for 1 type, another for 2 types, another for 3 types, etc, to some arbitrary limit

#

(that's what Action or Func do)

rocky wyvern
#

yeah I suppose

naive pawn
#

if this is a common operation in ecs, then there's probably a better solution in ecs

rocky wyvern
#

the core issue is just Component is nullable so cant use it in unmanaged lists

naive pawn
#

so the core issue is in dots?

naive pawn
#

if it is a common operation, or even a common operation in your project specifically, there could be better solutions in ecs, but you'd have to ask the folks in #1062393052863414313 to find out

rocky wyvern
#

I know its a very 'source: me' moment but you'd understand if you knew what I was trying to do

#

thanks regardless

naive pawn
#

yeah but i don't

rocky wyvern
#

will have to settle for just a bunch of ifs or getcomps

twin pivot
#

anyone know what the hell i did wrong here?

drowsy flare
#

I have an animation in unity with a spinning wheel. It's just two keyframes, a start with rotation 0, and end with 360.

I intend to loop this animation to get a spinning wheel, but it "eases out" at the end of the animation and slows down into 360. How can I make it keep a steady pace?

naive pawn
naive pawn
#

i believe you can rightclick to use presets as well, to get a nice linear rotation

twin pivot
naive pawn
#

click the error log, see if there's a stacktrace

twin pivot
#

nevermind it magically fixed itself thanks for the help tho

naive pawn
#

ah, transient errors...

#

it's probably not your fault then, just something went wrong internally in the editor

naive pawn
drowsy flare
blissful karma
#

yo anyone's using Cursor as ide? Im new to unity and tried to integrate but intelisense isnt working. Ive installed the sdk

only thing I havent made was installing the unity and c# extensions cuz vs studio blocked microsoft extensions for cursor

naive pawn
#

the unity and c# extensions
well, that would be how you get intellisense

wintry quarry
#

And yeah if you haven't done part of it that would be why

lunar coral
#

hi, do you guys know what's wrong in this line: Door[] doors = FindObjectsByType<Door>(); ?

sour fulcrum
#

Your ide will tell you

#

If it’s configured

lunar coral
#

I'm lazy to read a documentation on this , but I just need to put in a SortMode right?

#

SortMode.None, works? is it like finding the first one in the hierarchy?

sour fulcrum
#

No sorting is a lot faster if you don’t need to care

sour fulcrum
#

Sortmode none returns them all in whatever order ended up fastest to return

lunar coral
#

or is that like another function u'd advise me

#

K ty so much

twin pivot
#
public class LevelupButton : MonoBehaviour
{
    private GameObject _levelupScreen;
    public void OnEnable()
    {
        _levelupScreen = GameObject.Find("Levelup Screen");
    }
    public void OnClick()
    {
        Debug.Log("levelup selected");
        GameStats.isgamepaused = false;
        Time.timeScale = 1f;
        _levelupScreen.SetActive(false);
    }
}
#

the button isnt pressing for some reason

rich adder
#

event system in scene?

twin pivot
#

yup

rich adder
#

do you have cursor locked / hidden ?

slender nymph
#

unless you've changed the buttons to not have any highlighting when hovering too then it isn't responding to any input. which could mean one of a few things, missing event system, something blocking it, cursor is actually locked to the middle of the screen

twin pivot
slender nymph
#

other ui objects could be blocking it

rich adder
#

imagine if that Rect Transform of that 100 text is like HUGE and covering the buttons

slender nymph
#

for example, if someone had a UI object that looked like some girl holding a spoon and that was a raycast target and between the cursor and the button

twin pivot
#

i only have these ui objects and the hptext is not blocking anything

slender nymph
twin pivot
#

do buttons not work when Time.TimeScale is set to 0?

rich adder
#

they do

rich adder
#

or move it all the way at the top..
Bottom = Ontop of everything (for UI)

ivory bobcat
#

Your ui isn't getting highlighted when hovered over which is quite strange. This usually implies that the raytrace is either blocked or isn't happening.

rich adder
#

make sure you anchor properly and the rect transforms are proportioned cause Free Aspect can throw you off (canvas mode is important )

twin pivot
#

i do have a box collider trigger that tracks when you click it

#

right under it

rich adder
#

box collider is irrelevant unless you had Physics Raycaster on the Camera

grand snow
#

Yea you don't want or need to use physics colliders on ugui elements...

twin pivot
#

did i break my event system somehow?

rich adder
#

if only unity didn't butch the new event system that shows nothing useful for hover

twin pivot
#

i tried disabling everything and adding a fresh button but that still didnt work

rough granite
#

Is the cursor an in scene object?

twin pivot
#

nope

ivory bobcat
#

Maybe try making a new scene with the bare minimum and see if the buttons works.

#

So ideally: the camera system, buttons (enabled along with the canvas etc) and event system.

tiny island
#

hi , is it possible to add a text files in the games files after a input is pressed?

twin pivot
tiny island
# rough granite yes

tkx , i've been searching for hours how to do so but knowing it is possible already helps

grand snow
#

what does "add text files" mean?

rich adder
grand snow
#

They probably mean something else 😆

rich adder
#

virusmaker3000

fast fern
#

why do so ppl use if statements without curly brackets?

ivory bobcat
rough granite
tiny island
#

basically for a arg project i need to make a little game which when a certain event happens add txt file in the game files

rough granite
rich adder
#

unless you didn't add that..

rough granite
#

whoops

tiny island
twin pivot
#

im pretty sure it adds automatically (just checked)

ivory bobcat
rich adder
rich adder
rough granite
rich adder
#

thats why adding like 20 VM does no impact on the game than adding 20 Camera components lol

rich adder
rough granite
#

can you have multiple brains?

rich adder
#

maybe.. I dunno tryitandsee ..Probably

twin pivot
rich adder
rich adder
#

maybe the hitzone is off or something

twin pivot
rich adder
#

oh that cursor is Your OS not unity ?

twin pivot
#

yup

rich adder
#

maybe try a brand new project with same unity version and test , try to narrow down if its a project issue or editor issue

#

idk if something obvious is missing

grand snow
ivory bobcat
#

Can you show the inspector for the camera object and scene view?

limber turtle
#

i've finally sorted out my enemy navigation issue and now i want to move on to implementing items

#

does anyone have any good guides on how item systems in roguelikes are programmed?

#

i've tried asking in the ror2 modding server but i haven't had a response yet

#

i'm very new to this so i'm not entirely sure how i would do it

rich adder
limber turtle
#

ah

rich adder
#

you would be essentially cloning/following someone made up system , it may be optimal or complete shit. its a gamble

limber turtle
#

right

#

well i'm not sure what else to do here

rich adder
#

Plan out your requirements , start small, build up the system.

limber turtle
#

and if i can't get this right then i probably won't be able to move forward

rich adder
#

every complex system is just a bunch of smaller systems working together

limber turtle
#

i don't even know how i'm going to manage the inventory

rich adder
#

that initself is a problem, if you don't know your goal how can you achieve it

limber turtle
#

fair enough

#

i think i have a vague idea on what i could do

rich adder
#

research a bunch of different systems, find out about them and get a rough idea on how you could approach it

limber turtle
#

since all the items are either going to be utility, health/regen, damage or the like

#

i'll just give something a try for now

rich adder
#

eg . would it behave like Risk of Rain? or maybe Hades? etc.

limber turtle
#

risk of rain is my main idea of what to do

#

the overworld items are just sprites with different ids dictating what they look like and what they give the player

rich adder
#

implement a stat system first if you haven't then find ways to affect them

limber turtle
#

i've kind of done that

rich adder
#

if you mean visually thats the last step (sprites and all that)

limber turtle
#

i made sure to keep that in mind when i was making my player's abilities

rough granite
limber turtle
#

i have no idea

#

i asked in the server but i haven't gotten an answer about it

twin pivot
rich adder
#

you can even use a list of Scriptable Objects to serve as plain stats to add

#

like the more SO of Health you collect, the more health you have etc

#

or POCOs, or both

fast fern
grand snow
#

If the scriptable object is just a source of read only data that's a good idea

#

But may not be preferable to just use many references to one for a complex stat/effect system once applied to some entity

twin pivot
blissful karma
#

why my gameobject sprite renderer is blocked? Ive just created it in an another gameObject parent

naive pawn
#

what do you mean "blocked"

#

it's just collapsed

blissful karma
#

I mean i cannot drag and drop a sprite on there

#

and I cannot edit anything inside the Sprite Renderer

wintry quarry
#

press the little arrow here

#

on the left

blissful karma
#

god damn, sorry guys, first 30m on unity lol

wintry quarry
blissful karma
#

sure! thanks

ashen trail
#

guys how do I make my bullet fire in my game?

i want it to fire in the direction of the black square

#

!code

radiant voidBOT
wintry quarry
ashen trail
wintry quarry
placid jewel
naive pawn
ashen trail
naive pawn
#

you haven't saved

ashen trail
#

ohh

#

sorry

wintry quarry
ashen trail
placid jewel
naive pawn
#

oh whoops, mb

naive pawn
wintry quarry
#

ah

#

I see it was a blank link

ashen trail
#

do u guys see the code now?

naive pawn
#

yep

#

what was the issue you had?

placid jewel
ashen trail
# naive pawn what was the issue you had?

when i click my bullets only can fire for a little bit of time like 2 secs, then when i click anothor bullet doesnt fire

bullets only work at the beginning of my game

cunning crystal
placid jewel
naive pawn
#

it's in the player movement thing for some reason

ashen trail
placid jewel
#

yes

ashen trail
#

there in the player movement script

wintry quarry
#

also their projectiles don't care about player forward

placid jewel
#

Oh I'm unfamiliar with pastebin I hadn't realised I could see both scripts

cunning crystal
naive pawn
wintry quarry
ashen trail
#

when i click this is what happens

i get that error

placid jewel
#

How is your bullet stored? Is it with a prefab?

ashen trail
#

i think it is a prefab

placid jewel
#

It is

naive pawn
#

did you take that screenshot at runtime?

ashen trail
#

no

should i get one like that too?

naive pawn
#

why is there a bullet in your scene

#

did you assign that as the ProjectilePrefab

ashen trail
#

no reason really

ashen trail
naive pawn
#

you did, and then you assigned the OrbitC from within the scene, didn't you

ashen trail
#

yah

naive pawn
#

that's probably part of the cause

#

so first off, remove that Bullet object in your scene

placid jewel
#

First thing is you need to assign the ProjectilePrefab as the one from your Scripts folder (But maybe take it out of scripts as well)

naive pawn
#

instead of GameObject, type the prefab field as the component that you actually care about, projectileBehaviour

ashen trail
#

is the problem that they arn't both prefabs? the bullet and orbitc

naive pawn
#

then you can assign OrbitC when you instantiate

sour fulcrum
severe dagger
#

hi

#

when i created a new project, it came with a input action by default (universal 2d) , was i not supposed to remove that?

#

i've a bird in scene but it isn't showing up anymore

#

i tried disabling everything i can

#

i appreciate any help on this

naive pawn
severe dagger
#

oh

naive pawn
#

your bird is showing up fine though

#

not sure what you're talking about

severe dagger
#

its not in game

naive pawn
#

ah, that could be a number of things

#

is your camera offset on Z properly

placid jewel
#

It's z value is at 8

naive pawn
#

and if it was the position, it'd be fine

placid jewel
#

So it is

naive pawn
#

this is also the code channel and that's not a code issue, actually

placid jewel
#

Can you send a screenshot of the camera the way you did of the bird in the inspector?

#

True

naive pawn
placid jewel
slender nymph
#

if the camera is at Z:8 then the bird is behind it on account of it being at Z:0

severe dagger
#

aight . sorry for bringing it in wrong channel

naive pawn
severe dagger
#

i dont think camera is in z axis

slender nymph
naive pawn
slender nymph
#

ah my bad

dusky cedar
#

Anyone know of some good game ideas to make as a begginer? I have like 2 months expierence probs by now but not sure what to make.

ashen trail
naive pawn
#

snake, flappy bird, minesweeper, pong

dusky cedar
#

done flappy bird and pong, I only really do 3d in the engine as find it more fun

slender nymph
#

then make 3d flappy bird, pong, minesweeper, or snake

dusky cedar
fossil axle
#

hello im not really sure why this started happening lately but for some reason, i keep getting this message seemingly randomly and it infinitely loops which messes up my animations i worked on, whether i saved or not

#

does anyone know why this happens?

rich adder
# fossil axle

try close unity, deleting library folder, open project, let it rebuild..then open scene again

broken hull
#

using System.Runtime.CompilerServices;
using Unity.VisualScripting.InputSystem;
using UnityEngine;
using UnityEngine.ProBuilder.MeshOperations;


public class Player : MonoBehaviour

{

    [SerializeField] float moveSpeed = 7f;
    [SerializeField] float rotateSpeed = 10f;
    [SerializeField] private GameInput gameInput;
    private bool isWalking;
    private void Update()
    {
        float playerRadius = .7f;
        float playerHeight = 2f;
        float moveDistance = moveSpeed * Time.deltaTime;
        Vector2 inputVector = gameInput.GetMovementVectorNormalised();
        Vector3 moveDir = new Vector3(inputVector.x, 0, inputVector.y);
        bool canMove = !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight,  playerRadius, moveDir, moveDistance);
        if (!canMove)
        {
            //Cannot move towards moveDir;
           Vector3 moveDirX = new Vector3 (moveDir.x, 0, 0);
            canMove = !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight, playerRadius, moveDirX, moveDistance);
            if (canMove)
            {
                moveDir = moveDirX;
            }
        } 
        
        else
        {
            Vector3 moveDirY = new Vector3(moveDir.y, 0, 0);
            canMove = !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight, playerRadius, moveDirY, moveDistance);
            if (canMove)
            {
                moveDir = moveDirY;
            } else
            {
                //cannot move
            }
        }
        if (canMove)
        {
            transform.position += moveDir * moveDistance;
        }
        isWalking = moveDir != Vector3.zero;
        transform.forward = Vector3.Slerp(transform.forward, moveDir, Time.deltaTime * rotateSpeed);
    }
   public bool ISWalking() {
        return isWalking; }
}
#

guyss help i can't move

#

is there anything wrong with script

dusky cedar
#

best way to test your script and get information whats wrong etc is chatgpt or grok i think its the fastest way to analyse it

broken hull
#

this is uity error

broken hull
#

it didnt help

#

instead it was showing more errors

polar acorn
broken hull
#

no

#

alr nvm

#

there was a flaw in code

polar acorn
#

Then the message doesn't mean anything

broken hull
#

i fixed it

broken hull
polar acorn
#

It says that Adaptive Performance isn't going to be doing anything until you finish configuring it, but if you don't intend to use it anyway it doesn't matter

broken hull
#

it had nothing to do with

#

it was misplacement of else statement i had to place in under if statement

undone ledge
#

I'm making a custom level for a game I like which will require some custom code and I see that the scripts the developers made have these nice UIs that let you easily set numbers and add objects and such. How can I add these to my scripts?

slender nymph
#

those are just serialized variables. either public or marked with the SerializeField attribute

wintry quarry
#

!learn

radiant voidBOT
wintry quarry
#

This stuff is covered pretty early on

undone ledge
#

I haven't done them, no

wintry quarry
#

yeah you're toouching on a pretty basic functionality of scripts in Unity here.

fallen forum
#

Can I have some help with a health bar?

slender nymph
#

!ask

radiant voidBOT
# slender nymph !ask

: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 #🌱┃start-here

slender nymph
#

pay particular attention to the last couple points

compact sandal
#

int randomIndex = Random.Range(0, _nestSpawnPoint.Length);
Vector3 pos = _nestSpawnPoint[randomIndex].transform.position;
Quaternion rot = _nestSpawnPoint[randomIndex].transform.rotation;
_antNest = Instantiate(_antNestPrefab, pos, rot);

im trying to instantiate something from a prefab and keep the instance,. But for some reason when i do this in the awake function, it breaks out of it on the last line here and no instance is created. Does anyone know why?

slender nymph
#

it breaks out of it on the last line here
what do you mean by this

cosmic dagger
slender nymph
#

gotta have commands at the beginning of messages with the new bot

cosmic dagger
#

What, for real?

slender nymph
#

yup, can't do !code however

#

!code works

radiant voidBOT
cosmic dagger
#

That's madness . . .

ashen trail
#

I cant see my ui text in my game

any reason?

slender nymph
#
  1. not a code issue
  2. it's not actually within the bounds of your canvas
wintry quarry
ashen trail
#

oh okay

#

thanks guys

#

its not letting me move the canvas for some reason

like i want it over my camera

wintry quarry
#

that's not how it works

ashen trail
#

so i have to move my project insde the canvas?

wintry quarry
#

no

#

you have to move your UI inside the canvas

#

the canvas will be overlaid on the screen

#

Double click the canvas in the hierarchy

#

so you can see the full thing. Then you can lay out your UI inside it

#

ignore the game world objects when working on the UI

#

And again this is not a code discussion

ashen trail
#

ohh

wintry quarry
ashen trail
#

okay i did it thanks for the help

tired python
#

i wanna use a use a Spline data type and name it ObjectSpline, but i don't get how it's not working. I thought i would just smack the Spline highlighted in blue inside the hierarchy into ObjectSpline slot that was supposed to appear, but it somehow did not. i am kinda confused

slender nymph
#

it's a probably SplineContainer not a Spline

tired python
slender nymph
#

what are you actually trying to accomplish here? because from what it sounds like, you want a reference to the existing object in your scene. which contains a SplineContainer component

tired python
#

i wanna access the ElpasedTime and Duration properties of the spline to make the t ratio

slender nymph
#

neither of those are properties on a Spline

#

those sound like things that are likely related to your SplineAnimate component though

tired python
slender nymph
#

considering you already have a reference to the SplineAnimate component, yeah. but also what specifically are you doing with those properties? 🤔

tired python
#

to do that, i need to use the evaluatetangent method, which requires an arg called ratio t, which i can get by doing ElpasedTime/Duration

slender nymph
#

then you do still need a reference to the SplineContainer

tired python
#

so, my code was working perfectly before, then i tried changing the diff objects to [serialisedfield] which i think kinda broke the code?

slender nymph
#

show what the code currently looks like

tired python
slender nymph
#

so what exactly is "broken"?

raven marsh
#

Hi guysss

#

new dev here

tired python
#

when i press space, the ducks should spawn...

slender nymph
#

you enabled the one you were cloning which means it is also moving so it gets destroyed

#

also why do you have a separate "Duck Script" with the component that is only supposed to be on the ducks on it?

raven marsh
#

can anyone teach me the basics of scripting, or any tuto

slender nymph
#

!learn

radiant voidBOT
raven marsh
#

ah i see

slender nymph
#

there are also beginner c# courses pinned in this channel

raven marsh
#

tysm

tired python
slender nymph
#

preferably you'd be using a prefab rather than a scene object so you can't run into this issue

tired python
tired python
slender nymph
#

i still think you should consider using a prefab instead of cloning a disabled object

#

but what you need to do to fix what you've shown should be fairly obvious

tired python
#

i think i do understand it, lemme explain then, and you tell me whether it's right or wrong

#

so before i even start playing, i have a object Duck, and when i reference this object inside the DamnDeseDucks script by dragging it onto the variable listed in there, this Duck gets referenced by adress. so when i do press space, and then it destroys itself, it returns a null reference anytime i start pressing space after it because thie Duck object gets destroyed. this doesn't rly explain to me why enabling the cloned ducks makes them work though...

slender nymph
#

it's not "DamnDeseDucks" that is breaking here, it's your poorly named ISpawnable which is breaking when the object is destroyed because it's trying to reference that destroyed object. Although presumably your extra DamnDeseDucks component that isn't even on a duck for some reason probably references that duck that was getting destroyed. So what you need to do is remove that object entirely because it is pointless. Then also fix your spawning logic so that the instantiated objects are enabled after being instantiated or you need to make that initial Duck into a prefab so that you can clone the prefab and they will be instantiated enabled

tired python
# slender nymph it's not "DamnDeseDucks" that is breaking here, it's your poorly named ISpawnabl...
using UnityEditor.ShaderGraph.Internal;
using UnityEditorInternal.VersionControl;
using UnityEngine;
using UnityEngine.Splines;
using System.Collections;
using System.Collections.Generic;

public class DamnDeseDucks : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    [SerializeField] private GameObject Duck;
    [SerializeField] private SplineAnimate aniSpline;
    Queue<GameObject> cloned_ducks = new Queue<GameObject> { };
    void Start()
    {
        aniSpline.Completed += onComplete;
        Duck.SetActive(false);
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log($"Ratio t is: {aniSpline.ElapsedTime / aniSpline.Duration}");
        if (Input.GetButtonDown("Jump"))
        {
            Debug.Log("Space is pressed.");
            GameObject temp_duck = Instantiate(Duck, Duck.transform.position, Duck.transform.rotation);
            temp_duck.SetActive(true);
            cloned_ducks.Enqueue(temp_duck);
        }
    }
    void onComplete()
    {   
        GameObject ducktodestroy = cloned_ducks.Dequeue();
        Destroy(ducktodestroy);
    }
    void spawn()
    {
        
    }
}

i tried out something like this, but i still don't understand, how the hell was the code working previously with 2 different classes then??

#

how

slender nymph
#

spawning should not be handled by the thing that is getting spawned

tired python
#

i think i misunderstood you then

#

" So what you need to do is remove that object entirely because it is pointless." oh...not remove the class

#

mb

slender nymph
#

yes, remove the random "Duck Script" gameobject that served no purpose except to cause issues

tired python
slender nymph
#

which error is it showing now

tired python
#

should i send a list of imgs and show what is being referenced where along with the code again?

slender nymph
#

that's not an error. and you just need to enable them immediately after instantiation like i suggested.
or use my other suggestion and use a prefab instead of a disabled scene object as the cloned object

tired python
slender nymph
#

show the code on the "DamnDeseDucks" class

tired python
#
using UnityEditorInternal.VersionControl;
using UnityEngine;
using UnityEngine.Splines;

public class DamnDeseDucks : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    [SerializeField] private GameObject Duck;
    [SerializeField] private SplineAnimate aniSpline;
    void Start()
    {
        aniSpline.Completed += onComplete;
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log($"Ratio t is: {aniSpline.ElapsedTime / aniSpline.Duration}");
    }
    
    void onComplete()
    {
        Debug.Log("Duck will be destroyed.");
        Destroy(Duck);
        Debug.Log("Duck was destroyed.");
    }
}
slender nymph
#

and are you passing its own gameObject to Destroy?

#

(hint: probably not)

tired python
#

i don't think i am....

#

what do i even put inside the Duck variable...i am assuming it's supposed to be the cloned duck

slender nymph
#

why do you still have that

tired python
#

maybe i misunderstood

slender nymph
#

yes, the DamnDeseDucks component belongs only on the ducks

#

and i really wish you used sensible names for things

#

this component is what effectively manages each individual duck

tired python
#

it's on the duck

slender nymph
#

and notice how nothing is assigned to the Duck variable. not that the variable is even needed considering every component already has a reference to its own GameObject using the gameObject property

tired python
hazy crypt
#

theres some youtube videos that could show you

tired python
slender nymph
# tired python i will read up on it

read up on what? naming? your names are just bad in general because they imply they are used for different things which is probably leading to a lot of this confusion.
"DamnDeseDucks" despite implying it manages more than one duck is only controlling one duck at a time, it's basically a DuckController. Your "ISpawnable" component implies it is something that can be spawned and that it is an interface. It should have a name more like "Spawner" or "DuckSpawner"

slender nymph
tired python
#

ah ok

slender nymph
#

wdym? that's a complete statement

tired python
#

oh wait

#

it worked

slender nymph
#

i was telling you to notice in your own screenshot that literally nothing is assigned to that variable. then i went on to tell you what you should be using instead

tired python
#

i don't know how but it worked

#

i just assigned the duck to it and it started working

slender nymph
#

right, but again that variable is absolutely pointless. you already have a reference to the gameObject via the appropriately named property called gameObject

tired python
slender nymph
#

provided you actually pass the gameObject property to Destroy, yes

tired python
#

so just so that i don't misunderstand, what you are saying is that there is a way to make a script reference a gameobject which it's attached to without manually doing it in the inspector...ryt?

tired python
#

O_O gameObject is the GameObject the script is attached to

hazy crypt
#

you can ask it to search for other objects by names or tags, or you can search for the gameobject component in parents and children

tired python
#

now onto the next part of the project

hazy crypt
#

oh yeah, you dont have to reference the game object that the script is attached to, but if you want to remind yourself in the code you can type "this." before your code eg. position = this.transform.position

tired python
hazy crypt
slender nymph
hazy crypt
#

hey boxfriend, any chance you could help with an issue im having? you seem knowledgeable

slender nymph
#

!ask

radiant voidBOT
# slender nymph !ask

: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 #🌱┃start-here

hazy crypt
#

yes i asked in unity-talk alredy

#

was hoping to redirect your attention 😉

grand snow
hazy crypt
#

okay thanks

onyx geyser
#

could there be a particular reason that when i use getaxisraw ("Horizontal") it'll only one of the two keys?

#

i press the other key attached and it does nothing

#

it moves in the right direction with W and D, but otherwise I can't use S and A

ashen trail
#

guys how do I use and refer to something in the inspector, in a prefab

#

!code

radiant voidBOT
ashen trail
rich adder
onyx geyser
#

i'm asking why neither Vertical nor Horizontal aren't accounting for their negatives

rich adder
onyx geyser
#

already checked

sour fulcrum
onyx geyser
#

can confirm that the negatives are still the opposites

ashen trail
sour fulcrum
#

it's available to read again if neccasary

rich adder
ashen trail
#

ima scroll up till i find it ig

onyx geyser
#
if (Input.GetAxisRaw("Vertical") == 0)
{
    rigidBody.AddForce(transform.TransformDirection(0, 0, force * Time.deltaTime * tSpeed));

}
else
{
    rigidBody.linearVelocity = Vector3.zero;
}   

if (Input.GetAxisRaw("Horizontal")  == 0)
{
    rigidBody.AddForce(transform.TransformDirection(force * Time.deltaTime * tSpeed, 0, 0));

}
else
{
    rigidBody.linearVelocity = Vector3.zero;
}
#

it looks wonky but it's because i'm trying somin

#

I had written this before and encountered the same issue, so i changed it out for keys instead, and then someone sent me their code for movement, which worked on their end, but DID NOT work on my end

rich adder
#

press both A/D and see if you get the correct vals first

onyx geyser
#

*assuming it should appear in console or something?

rich adder
#

yea you put it in update ?

onyx geyser
#

hmm, nothing is showing up in the console.

rich adder
#

are logs enabled?

onyx geyser
#

i assume you mean player logging?

rich adder
onyx geyser
#

yeah i have that

#

nothing

#

is showing up there

rich adder
#

then your script isn't running 🤷‍♂️

#

did you put the code in update?

onyx geyser
#

yeahj

rich adder
#

is it on an active gameobject , and is enabled

onyx geyser
#

yeah

#

W and D work fine

#

but A and S don't

rich adder
#

forget that

onyx geyser
#

and it responds to the force

rich adder
#

im talking about the logs

#

are the logs printing at all

onyx geyser
#

nothing is being printed in the logs when I do anything

rich adder
#

but is it printing "horiz 0" at least or not printing at all

onyx geyser
#

nothing at ALL

rich adder
#

send the code in its entirety through site

sour fulcrum
#

(Did you save the script)

onyx geyser
rich adder
#

!code

radiant voidBOT
sour fulcrum
#

Your saying lol but something you’ve said isn’t true so

onyx geyser
#
{
    public int force = 10;

    [Range (0f, 100f)]
    public float tSpeed;
    Rigidbody rigidBody;

    float horizontal = 0f;
    float vertical = 0f;

    

    void Start()
    {
        rigidBody = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    private void Update()
    {
        Mathf.Clamp01(force);
        var horiz = Input.GetAxisRaw("Horizontal");
        var vert = Input.GetAxisRaw("Vertical");

    }

    private void FixedUpdate()
    {

        

        Vector3 moveDir = new Vector3(horizontal, 0, vertical);

        if (Input.GetAxisRaw("Vertical") == 1)
        {
            rigidBody.AddForce(transform.TransformDirection(0, 0, force * Time.deltaTime * tSpeed));
        }
        else
        {
            rigidBody.linearVelocity = Vector3.zero;
        }   
        
        if (Input.GetAxisRaw("Horizontal")  == 1)
        {
            rigidBody.AddForce(transform.TransformDirection(force * Time.deltaTime * tSpeed, 0, 0));
        }
        else
        {
            rigidBody.linearVelocity = Vector3.zero;
        }

    }
#

no i'm saying lol because that's the first thing i checked

#

theres some other nonsense in here

rich adder
#

bro didnt even put Debug.Log

onyx geyser
#

ffs

#

going to throw myself into a blender

rich adder
#

also every time you don't press a Horizontal or Vertical so when you press one you immediately override it with 0

onyx geyser
#

so you're not gonna believe this, it still doesn't work

rich adder
#

what doesn't work

onyx geyser
#

the uhh

#

debug

rich adder
#

computer is never wrong so you probably did it wrong

onyx geyser
#

you'd think

rich adder
#

either again you didn't put the line or didnt save

sour fulcrum
#

(We know)

rich adder
#

it should print at least 0 even if somehow the Horizontal/Vertical was busted

onyx geyser
#

right, it should, and i followed the steps to it, but

#

i'm not

#

i'm not seeing it

rich adder
#

ok well show something

onyx geyser
#

show something?

rich adder
#

yeah like idk show the game running or something with the console window ?

#

or that you put the line in and saved

#

I can't see your computer what can I do with little info you give

onyx geyser
rich adder
#

the logs are literally disabled

#

I even said make sure they're not

#

can't trust anyone on the internet lol

onyx geyser
#

man

rich adder
#

that saying 999+

onyx geyser
#

i apologize, I am still unfamiliar with how logs work

#

I turned them on

rich adder
#

ok so now what does it print when you press A or D. do you get 1 and -1

onyx geyser
#

well, now that we got that figured out, it IS reacting to WASD

#

yes

#

-1 and 1

rich adder
#

so A/D does work for horizontal

#

then something is wrong with how you apply that

#

tSpeed is also 0 I dont even know how you claimed this moved at all

onyx geyser
#

tSpeed is just a multiplier

#

it's force that moves it

rich adder
#

and its 0

#

anything times 0 is .... 0

onyx geyser
#

I can edit through the bar?

#

and change it to 100

rich adder
#

i guess but you still aren't applying it with the horiz or vert

onyx geyser
#

it'll be really funny if it is tSpeed

rich adder
#

you made different variables and are applying none
rigidBody.AddForce(transform.TransformDirection(moveDir) * etc

#

horizontal = Input.GetAxisRaw("Horizontal");
vertical = Input.GetAxisRaw("Vertical");

#

that should probably work, or maybe InverseTransformDirection(moveDir)?..forgot which..

#

that clamp01 is also doing nothing by itself btw

onyx geyser
#

guhh.. i think i need to take a break and come back to this later

#

the previous code I had worked by seperating each direction into if inputkeys, and just adding -force to the if that belong to A and S

meager siren
#

Hiya friends

#

family and hopefully human beings

#

What are some functions to use for camera bobbing?

rich adder
#

sin/cos

meager siren
#

that depends on speed? But for now, just for sprinting and walking?

rich adder
#

or like use the built in noise from cinemachine

meager siren
#

noise?

meager siren
#

I see

rich adder
#

most games don't bob the camera itself though, usually its done on the meshes / whatever you're holding

meager siren
#

Let me show you rq

#

what my player is set as

#

You move the cameraholder