#💻┃code-beginner

1 messages · Page 194 of 1

swift crag
#

since it may have a non-zero rotation

#

thanks to Coordinate Space Hell

summer stump
#

Yeah, that's fair.

#

I made it sound like there was no reason to, I was more curious why in this case it was needed

warm anvil
#

Thanks for the reply Sexy. I'm still learning how unity works with situations with a canvas and grids for in this case an inventory system.

That being said, still lot to learn - I wouldn't really call it hyper specific - I'd honestly think this would be a pretty common occurrence really. two grids on the same canvas (plus or minus a few other components) but will most likely have these components from what I've seen)

The ask is can a gamepad cursor travel between the two grids automatically or as you and I think are saying is that input has to be reviewed when you reach a border and move to the next grid if performed - again, or, does the native grid component just know what grids are on screen at any given moment

#

hope that makes it a bit clearer than mud 🙂

timid saffron
#

cache?

swift crag
#

The default navigation mode is "Automatic"

#

It tries to find a Selectable object in the direction you navigate

#

You can test it out using the arrow keys on your keyboard.

#

It often works well, but it can have weird hangups

faint sluice
swift crag
#

You may wind up needing to manually define navigations for each selectable element

summer stump
summer stump
#

Just save it as a variable

warm anvil
#

cool - thanks guys!

swift crag
#

"Explicit" mode lets you assign a Selectable for each of the four cardinal directions

timid saffron
#

like this

faint sluice
#

Is it for controllers only or works for PC too?

swift crag
#

as I said, keyboard arrows can be used to navigate

#

as can WASD

timid saffron
#

well nevermind i dont know caching or using stuff later ill look into it later

storm imp
#

first one is his second is mine what am I doing wrong?

faint sluice
swift crag
#

go read the documentation I just linked first

#

and the rest of the UI documentation, tbh

swift crag
#

what is the problem?

late tapir
#

How do you resolve this error, any ideas?

swift crag
#

...you have both URP and HDRP packages installed

swift crag
#

is there a particular reason you have both

storm imp
# swift crag what is the problem?

he didn't get this pop up what did I do wrong?https://www.youtube.com/watch?v=JIsRH7hXpDQ timestamp 2:00

This tutorial series teaches you how to take 360 images and make a virtual tour with points of interest in unity.

Follow me on twitter https://twitter.com/JamesDestined
Follow me on instagram https://www.instagram.com/artbydestined/
Buy my pieces on redbubble http://DestinedArt.redbubble.com

Any comments or questions welcome. Enjoy the video!

▶ Play video
swift crag
late tapir
swift crag
#

I remember encountering it before, but I forget what causes it

faint sluice
swift crag
summer stump
# timid saffron

No, I mean the instantiate line. Line 23 would be
variable = Instantiate

Instantiate returns a reference to the thing you instantiated

faint sluice
swift crag
storm imp
signal bronze
#

Whats wrong here? Everything works except the timeScale shit, why?

slender nymph
#

what makes you say the time scale isn't working

signal bronze
#

That when i press Escape the game is still running behind the PauseMenu canvas

slender nymph
#

and are you doing anything that actually uses the time scale?

rich adder
#

I bet they have no idea what Time.timeScale does

signal bronze
rich adder
signal bronze
#

thats what my friend said, maybe it has a different meaning in english

#

dont know

signal bronze
#

ill check it out

unreal imp
#

Guys, is there any way to fix this? I want my bullets to come out of the gun and after being fired to focus on the camera but not suddenly, but little by little they become centralized in the camera when fired, here is the code I use

        Vector3 direction = (crosshair.transform.forward - bulletSpawn.transform.forward).normalized;
        Rigidbody rb = bullet.GetComponent<Rigidbody>();
        if (rb != null)
        {
            rb.velocity = direction * shootForce;
        }

the result (they don't even shoot) =

rich adder
# signal bronze ill check it out

When timeScale is set to zero your application acts as if paused if all your functions** are frame rate independent**. Negative values are ignored.

lost anvil
#

Why isnt the drawer opening?

#

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

public class DrawOpen_D1 : MonoBehaviour, IInteractable
{
public bool isOpen = true;

public void Interact()
{
    Debug.Log("open");
    transform.Translate(0, 0, -2);

    if (isOpen == true)
    {
        transform.Translate(0, 0, 2);
        Debug.Log("close");
        isOpen = false;
    }
}


// Update is called once per frame
void Update()
{
    
}

}

eternal falconBOT
lost anvil
#

mate

signal bronze
#

But the code is suposed to work like that isnt it?

sterile radish
#

hi! im making a tower defense game and i wanted to show the range of a tower to the player. how would i go on about doing that? is there a way to change the radius of an object through code?

rich adder
rich adder
#

two very different questions btw

rich adder
#

what

rich adder
rich adder
sterile radish
rich adder
#

and the standard answer to "Can it be done"

#

is usually Yes

sterile radish
rich adder
sterile radish
#

my tower's range

rich adder
#

@lost anvil its not diffcult, read the bot message it tells you how. I cannot read it properly on the phone

swift crag
lost anvil
#

its not that deep but okay

swift crag
#

objects don't really have a "radius". They have a position, rotation, and scale.

swift crag
rich adder
swift crag
#

<@&502884371011731486>

signal bronze
rich adder
lost anvil
#

you did yeah i didnt know i had to put my code or whatever a certain way and i didnt see the point of it

rich adder
lost anvil
#

yeah because im new chill out lad

rich adder
#

why would you make it diffcult to read the code if you want help on it?

sterile radish
rich adder
#

thats counter intuitive and waste of time rn

iron parrot
#

!mute @lost anvil 2880 take a couple of days to grow up and stop being an edgelord or don't come back at all

eternal falconBOT
#

dynoSuccess keraunos5900 was muted.

swift crag
#

then just scale it

rich adder
swift crag
#

Unity won't have exactly what you want built-in

#

you need to use the systems it provides to create new systems

sterile radish
signal bronze
swift crag
#

If it's a 2D game, a SpriteRenderer should do the trick

signal bronze
#

ill be back in a minute

#

Here, i now think it actually stops the game but i thought it didnt because of the sound and the camera (sorry xd), how can i fix that?

rich adder
#

how (script) are you moving the camera?

#

unless you're using * Time.deltaTime
typically a camera look system doesn't have anything that pauses on timescale

signal bronze
#

the camera and movement is from a free asset i took from the store

#

its too big to be sending ss

rich adder
#

disable the scripts

signal bronze
#

ill try

rich adder
#

learn events and make an event

naive lion
#
        {
            if (rayHit.collider.GetComponent<EnemyHealth>().enabled)
            {
                gameObject.GetComponent<EnemyHealth>().Damage(damage);

            }```

Is this the proper way to damage via a raycast?
naive lion
#

noted, what would you recommend

rich adder
naive lion
#

ah alright

#

awesome thanks ill use that

rich adder
# naive lion ah alright
if (Physics.Raycast(mainCamera.transform.position, direction, out rayHit, range, whatIsEnemy))
        {
            if (rayHit.collider.TryGetComponent(out EnemyHealth enemyHealth))
            {
                    enemyHealth.Damage();
            }
        }``` 🙂
naive lion
#
            if (rayHit.collider.TryGetComponent(out enemyHealth))
            {
                enemyHealth.Damage(damage);
            }```
#

moreso this then?

rich adder
#

exactly

naive lion
#

o>

#

got it great thank you

rich adder
#

but u dont need EnemyHealth enemyHealth = null;
you can just put it on same line like my example

naive lion
#

sick thanks again

dire tartan
#

so ive got a ragdol made up of 3d objects and connnected by configured joints i have a script so whenever something is grabbed by the hands it holds the object but if moving too fast the object goes inbetween the body parts and the character breaks

rich adder
signal bronze
#

@rich adder I did it, but now i have a problem with the cursor, like when i close the menu its suposed to go away but when i click it doesnt

timid saffron
#

How can I make array [3]'s spawn time 5? (int animalnumber= Random.Range(0, animalprefabs.lenght)

dire tartan
rich adder
rich adder
signal bronze
rich adder
eternal falconBOT
rich adder
#

!screenshots

eternal falconBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

signal bronze
#

whats that?

rich adder
#

use your eyes and read it

rich adder
signal bronze
#

thats a good point

rich adder
timid saffron
#

good?

summer stump
timid saffron
#

yeah i mean except for that

#

the logic is it good

#

im sure it can be more optimized tho

rich adder
#

yes for example avoiding repetition of similiar code

signal bronze
#

now it works perfectly

#

thanks bro, u r a great teacher

rich adder
rich adder
#

since you cannot pass arguments to method, in Unity's Invoke/Invoke repeat

storm imp
#

how come I can't add the montreal botanical garden in winter image that I put in the sprits folder onto the Source Image?

rich adder
#

also not a code question

#

Texture and Sprite are not the same

storm imp
rich adder
#

I can tell from here its not a sprite
the others were, how much you want to bet 😏

dire tartan
#

im pretty sure the issue is in my grab script but im not sure whats wrong about it

#

am i allowed to send vids to show issues?

rich adder
#

code too

storm imp
rich adder
dire tartan
#

i thought it was mp4 my bad

rich adder
storm imp
summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

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

dire tartan
graceful citrus
#
core.AddForce(new Vector3(context.action.ReadValue<Vector2>().x, 0, context.action.ReadValue<Vector2>().y) * 500, ForceMode.Force);

how do i alter this so that the movement is relative to the camera? i tried a couple things but they didn't work very well

river roost
river roost
#

converts it from world space to local space

dire tartan
# dire tartan

im using configurable joints to make ragdol movement but whenever something is grabbed the hand goes further then it should how do i limit that?

graceful citrus
#

what do you mean? i don't understand what you mean by "converts it from world space to local space"

river roost
#

World space is the "normal" space, where position Y is up and negative Z is back
Local space is what you use when you move an object, where the blue arrow is the positive Z direction

#

Your inputs are in world space but need to be converted to the camera's local space

swift crag
#

Local +Z is the direction you are facing

river roost
#

oh yeah sry

graceful citrus
#

i know that part

#

but like

swift crag
#

No, you're correct, Bobbo

graceful citrus
#

how do i word this...

swift crag
#

in local space, your forward vector never changes. It's always (0, 0, 1)

graceful citrus
#

i don't know in what context i put "tranform.transformdirection"

river roost
swift crag
#

Ah, you changed it :p

swift crag
graceful citrus
#

where do i throw in "transform.transformdirection"

swift crag
#

Transform.TransformDirection takes you from local space to world space

#

If you want to know which world-space direction is "right" for you, transform Vector3.right into world space

river roost
#

_cameraTransform.Transfor....

timid saffron
vague dirge
#

Quick question, I have an issue that I never understood : I have a character and a checkbox to know if it's on ground, and if it is on ground I set my gravity velocity to 0, but when my program runs, my character sinks into the ground ; despite 0 force being applied, why so ?

timid saffron
#

how would you combine them two

#

using less codes and avoiding repetitive codes

rich adder
#

so if you want a specific animal just pass the index

#
void Method()
{
  SpawnAnimal(3)//spawn horse
  SpawnAnimal(Random.Range(0, animalNumber.Length)); //random animal
}

void SpawnAnimal(int animalNumber)
 {
     var selectAnimalPrefab = animalPrefabs[animalNumber];
     Vector3 spawnPosition = new Vector3(Random.Range(-spawnRangeX, spawnRangeX), 0, spawnPositionZ);
     var instantiateAnimals = Instantiate(selectAnimalPrefab, spawnPosition, selectAnimalPrefab.transform.rotation);
 }```
ofc you gotta play around with the spawn time stuff in a coroutine too
carmine sierra
#

how can I instantiate at the position of an object which isn't the object the script is inside of

graceful citrus
#

i kinda get it

summer stump
#

That's all the detail I can give without more detail from you

carmine sierra
#

it's the second parameter that needs to change right

jaunty heath
#

dont guess

rich adder
#

also configure your IDE

#

if its not suggesting the signatures

astral notch
thorn holly
astral notch
thorn holly
vague dirge
#

Yes a kinematic body

slender nymph
#

you cannot assign velocity or use forces on a kinematic rigidbody. how are you actually moving it

vague dirge
#

With transform.position

rich adder
#

oof

thorn holly
#

How are you checking if it’s on the ground?

vague dirge
#

Maybe it's not the best option I dunno

summer stump
thorn holly
vague dirge
thorn holly
summer stump
thorn holly
slender nymph
#

pretty sure they mean Physics.CheckBox

summer stump
#

So with CheckBox() not a checkbox

thorn holly
#

I’d reccomend remaking your movement system unless you’ve spent a ton of time on it

timid saffron
queen adder
#

i didn't know if i should put it on wich channel but help

#

i am trying to make the unity window change places

#

but only the canvas does

#

for my html site

vague dirge
# summer stump It is not

The thing is I had first a Character controller and i used .Move(), and now I'm trying to switch to a RigidBody, but the only provided method that could replace it that I found was rigidbody.velocity. But know I'm using a kinematic, so the only thing I found was directly moving the transfotm

queen adder
#

ok

summer stump
#

You trying to do it with code?

thorn holly
queen adder
#

yes

#

wait

thorn holly
queen adder
vague dirge
queen adder
#

here

thorn holly
queen adder
#

the whole window

vague dirge
summer stump
slender nymph
fiery fjord
vague dirge
summer stump
# vague dirge Wait what

Both moveposition and transform.translate or transform.position = will teleport the player

But moving the transform while using a rigidbody makes them fight and is not a good idea

#

If you have a rigidbody, use the rigidbody

timid saffron
# rich adder wdym

Ive been trying to implement the example you wrote into my code. you wrote spawnanimal(3) but i need to make spawnanimal variable actually spawn animals so Ill have to copy and paste the code in spawnanimal codeblock

#

or if theres a way I can make it access the codeblock below

summer stump
queen adder
#

yes

rich adder
queen adder
#

but i mean you still gotta know some unity to do it

#

idk what to do

summer stump
rich adder
summer stump
#

It shouldn't actually have anything to do with unity at all

It would be the same as moving an image or video lower

timid saffron
timid saffron
#

here

#

this spawnAnimal doesnt do anything

#

i have to make it spawn animals

rich adder
#

you're changing SpawnRandomAnimal to SpawnAnimal
nothing more @timid saffron

vague dirge
thorn holly
summer stump
vague dirge
#

Okay gotta check em thx

summer stump
thorn holly
pine bone
#

Hello guys, i'm making a modular ship building system but i'm stuck.

newAttachment.ConnectTo(attachment);
UpdateAttachmentVisibility();

The ConnectTo function sets the positions of the attachments together, and the update attachment visibility function loops through all attachments and make them visible if they are available. However the updateattachmentvisibility function runs before the connection, causing some weird glitches. How can i make the update attachment always run after the connection is done

timid saffron
thorn holly
swift crag
#

Perhaps you have code that runs in Start or Update

#

and that needs to execute before UpdateAttachmentVisibility runs?

pine bone
swift crag
#

yeah, sounds like you have code in Start that needs to execute first

pine bone
# thorn holly So you want to wait until all the attatchements are done and then run UpdateAtta...
  public void AttachmentClicked(Attachment attachment)
  {
      ShipModule selectedModule = shipModules[selectedModuleIndex];
      GameObject moduleObject = Instantiate(selectedModule.prefab);

      Attachment newAttachment = moduleObject.GetComponentInChildren<Attachment>();
     // StartCoroutine(AttachmentClickCoroutine(newAttachment, attachment));

      newAttachment.ConnectTo(attachment);
      UpdateAttachmentVisibility();

      print("Clicked on attachment");
  }```

This runs when the user clicks on an attachment
pine bone
swift crag
#

Yes, and that already happens

#

Your code doesn't run out of order

#

Programming would be a nightmare if line 2 could run before line 1

pine bone
swift crag
#

Because you probably have code that runs in Start

#

and that needs to execute before UpdateAttachmentVisibility works properly

thorn holly
swift crag
#

Start runs on the first frame after something is created

swift crag
swift crag
graceful citrus
pine bone
swift crag
#

transform the input vector from the camera's local space to world space

#

When you push the W key, you want to move forwards

#

But what is forwards?

#

If you just move in the world forward direction, then you move in the same direction no matter how the camera is rotated

#

You want to move in the forward direction of the camera

pine bone
swift crag
eternal falconBOT
swift crag
#

And we want to convert it into a world-space direction

#

We accomplish that with _theCamera.transform.TransformDirection(moveDesire);

graceful citrus
#

i understand local and global and all that

swift crag
#

then what's the problem?

graceful citrus
#

the problem is i don't understand how to do that

#

how do i make it from global to local

#

idk what i do to turn my code into that code

swift crag
#

i'm not sure you understand it

#

since you just said "global to local"

#

which is precisely backwards

#

all you need to do to go from local space to world space is to use transform.TransformDirection

#

it takes a local-space vector and returns a world-space vector

#

that's it

#

If your camera is rotated 90 degrees to the right, TransformDirection will turn a forward vector into a right vector

pine bone
swift crag
#

If it's rotated 180 degrees to the right, it turns a forward vector into a backward vector

graceful citrus
#

but where? where do i use "transform.transformdirection"

#
core.AddForce(new Vector3(context.action.ReadValue<Vector2>().x, 0, context.action.ReadValue<Vector2>().y) * 100, ForceMode.Force);
#

within this

#

to replace new vector3?

swift crag
#

break that line up. it's a long mess

swift crag
#

call it moveVector or something

swift crag
#

It looks like that assigns spriteRenderer and coll

#

you didn't actually say what the problem was

#

does it involve those two variables?

pine bone
graceful citrus
#

wait

#

do i just literally replace new Vector3 with camerTran.TransformDirection

#

lmfao

#

i just did that and i think it worked

swift crag
#

well, no, you pass the vector to TransformDirection

pine bone
swift crag
#

I don't know what "become weird" means

pine bone
swift crag
#

Do these objects have rigidbodies on them?

pine bone
#

no

timid saffron
#

works

#

optimization 😎

#

wait

#

better now

#

you like the optimizaton?

rich adder
swift crag
# pine bone no

hmm, I'd have to stare at this a bit longer to offer more suggestions.

pine bone
swift crag
#

Oh, you know

#

Try running this before updating visibility

pine bone
#

what

swift crag
#

When a Transform component changes, any Rigidbody or Collider on that Transform or its children may need to be repositioned, rotated or scaled depending on the change to the Transform. Use this function to flush those changes to the physics engine manually.

#

Yeah, that's almost certainly the problem.

#

The physics system doesn't realize you've moved the colliders until the next physics update

timid saffron
swift crag
#

So the collider positions are bogus

timid saffron
#

actually if i didnt misunderstand your code it would have taken much less

swift crag
#

It thought they were still at the world origin, or wherever they happened to start out at

pine bone
swift crag
#

Yes, it does

#

I do 3D almost exclusively, so I always forget about 2D...

#

The other method wouldn't help

pine bone
#

oh my days

#

it worked thank you so much

swift crag
#

nice (:

#

that's a tricky one

pine bone
#

lol

#

i would have never been able to fix this

#

thank you

rich adder
timid saffron
#

no the example was fine 🙂 i didnt know the thing you write after void could be used in other voids

summer stump
timid saffron
#

thats why I was confuesd

summer stump
#

Think of methods as just a keyword that replaces the code
It is the EXACT SAME as writing the stuff inside the method where you call it

timid saffron
#

yeah I dont know their names fully so I just call them thing thanks 🙂

#

But I got the logic

#

so thanks

rich adder
#

Next is replacing Invoke repeating with Coroutines 🙂
so the Time Between spawns can be also changed on the fly

west sonnet
#

How can I move an object relative to it's parent?

#

I have an object. When it's collided with, I want it to move to the top of it's parent object

#

I know how to parent it via script, but not exactly sure how to move it

rich adder
#

parenting already moves it relative to parent tho

west sonnet
#

But right now, the object basically just sticks to it's parent wherever they collide, but I want the object to basically teleport above it's parent when they collide

rare basin
#

transform.localPosition set it to 0,0,0

#

then it will be at parent's position

west sonnet
rich adder
slender sinew
#

yes

rare basin
#

5,0,0 is 5 on the x relative to parent position

#

etc

storm imp
#

time stamp 8:19 what does he mean by the opposite? https://www.youtube.com/watch?v=JIsRH7hXpDQ

This tutorial series teaches you how to take 360 images and make a virtual tour with points of interest in unity.

Follow me on twitter https://twitter.com/JamesDestined
Follow me on instagram https://www.instagram.com/artbydestined/
Buy my pieces on redbubble http://DestinedArt.redbubble.com

Any comments or questions welcome. Enjoy the video!

▶ Play video
rich adder
#

8:27

#

they are doing the Opposite of setting it active..

#

pretty self explanitory

graceful citrus
#

i want to animate the legs on a ragdoll character. im pretty sure if i animate the legs in any way, even when i move to an animation not involving the legs, the legs will become rigid and move towards position and rotation (0,0,0). is there a way around this?

timid saffron
graceful citrus
timid saffron
#

0 errors

#

so I tried coroutines (first time) as navarone suggested but this coroutine doesnt seem to work

#

my goal was to set horsespawn time to 10

rich adder
#

omg why SendMessage

#

should never use that

shell sorrel
#

just call the method you want directly

rich adder
#

those are IDE messages / suggestions

timid saffron
#

is the logic correct? @rich adder

rich adder
#

the same way you called other methods?

shell sorrel
#

well where does SpawnHorse Exist?

rich adder
#

yeah the method right under it

shell sorrel
#

oh its literally on the same object

#

just do SpawnHorse(); instead of send message

rich adder
#

please tell me you did not write that from gpt

timid saffron
#

here

timid saffron
shell sorrel
#

show the code

timid saffron
rich adder
#

you named your local variable the same as your method

#

so it puts using the local variable priority

#

and you cannot run a string like a method xD

timid saffron
#

ok

#

we cool now

shell sorrel
#

generally people use lowercase first letter for local variables

#

also why is the var even called SpawnHorse

rich adder
shell sorrel
#

its not being used, but also where its fed in, you have SpawnHorse2 and SpawnRandomAnimal, with the function not using the data at all

rich adder
timid saffron
#

it doesn work anyway it constantly spawn horses now

rich adder
#

exactly

timid saffron
#

i think coroutines are big brain for me right now i should probably look into them later

rich adder
#

if you want them to be separate coroutines pass in a Func/Action

shell sorrel
#

would just make so you can pass in the function for it to call

#

or use a enum and a switch

timid saffron
#

well I dont know enum or switch or func action so this probably is too much for me right now Im deleting the part with coroutines for now and return to Invokerepeaters

shell sorrel
#

or you could just have 2 coroutine functions

#

instead of sharing them

timid saffron
#

code example please?

#

like this

#

this is my code right now

rich adder
rich adder
#

and why is SpawnHorse2 still there lol

rich adder
rugged iron
#

When I run SceneManager.LoadScene(SceneManager.GetActiveScene().name);
it keeps buffering and doesn’t reload, does anyone know why?

rugged iron
#

Like it shows it’s loading but it says app not responding

rich adder
shell sorrel
#

does the loaded scene also call to load the same scene

#

or contain code with a infinite loop

rich adder
#

Ahh yes good question, maybe its recursively calling

rugged iron
#

It runs using
button.onClick.AddListener(Restart); in Update()

shell sorrel
#

also why would you want to load the active scene

#

is it for like resetting things?

rugged iron
#

Yeah

shell sorrel
#

yeah its because you added Restart to the button many many many times

rich adder
#

esp without cleaning up

shell sorrel
#

so when the button is clicked its calling Restart thosands of times

rugged iron
#

Alr

shell sorrel
#

you only want to add the listener once

#

do it in Awake

#

not Update

rugged iron
#

Thanks

rich adder
#

OnEnable AddListener
OnDisable RemoveListener

#

i generally do that

rugged iron
#

Kk

shell sorrel
#

or the above, is a good option since that will disable the button for you if you disable the object

rugged iron
#

Ok ty

carmine sierra
#

Ive been searching but cant find an instance where they transform an object in another object's script

astral notch
#

transform means an objects values in world space. position rotation and scale. To get a reference to another objects transform, a beginner way is to make a public variable called "public Transform otherTransform". Now in the editor, you can select which transform is to be targeted by this variable. Then you can use otherTransform.position

carmine sierra
#

thanks ill try that

silver wasp
#

Hello! I have a really weird problem, I'm making a small multiplayer game with joystick controls and all that, I'm using netcode for gameobjects, and my player is like being overridden by the second player, do anyone know about some good unity 3d mobile tutorials? or where could I get someone to help me review my project?

astral notch
rich adder
carmine sierra
#

or gameobject.position

astral notch
#

position is not a property of a gameobject, it is a property of a transform

rich adder
astral notch
carmine sierra
rich adder
carmine sierra
astral notch
#

yes

carmine sierra
#

like weapon.transform.position

#

would i need to use getcomponent on transform

silver wasp
timid saffron
astral notch
#

so you have two ways here. Either you make a reference to your gameobject and then use getcomponent transform to get its transform. OR you directly reference the transform

storm imp
rare basin
storm imp
#

Where do I put it? cuz as you can see in the video he doesn't show where he's putting it is it directly after public void HideImage()?

rare basin
#

put it wherever you want it to execute

#

dont blidnly cope/paste code you dont understand

timid saffron
#

for now it works

#

I dont know why it wont use coroutineInterval I write in pharantesis but it works for now

shell sorrel
#

pass the variable coroutineInterval would work

#

you got 2 things with the same name again

#

for a function paramater coroutineInterval

#

and a field with the same name

#

yield return new WaitForSeconds(coroutineInternal); would do that then delete the
private float coroutineInternal = 10f; you got at the top

astral notch
#

A good habit could be adding _ before private variables

shell sorrel
#

well in this case it is just duplicate

#

i use the _ convention but also just dont end up with duplication of names like that because its confusing

astral notch
#

yup

queen adder
#

I need an alternative text engine/solution that can draw the entire text as 1 draw call instead of each letter individually, which seems to be the way Textmeshpro works. So if you have overlapping letters and fade out, theres an undesired alpha overlap. Don’t have this issue in Godot or html5 canvas.
The text outline is applied to each character individually so the alpha overlap is really visible when your text is 50% transparent in a canvas group

shell sorrel
#

TMP is not doing each character as a draw call

#

but it is doing a quad for each character

rare basin
#

do you even know how draw calls works?

#

if there would be 1 draw call per 1 character

#

most of bigger unit games will be unplayable even in 30fps lol

shell sorrel
#

am assuminmg there problem is with how TMP builds its mesh to draw

queen adder
#

i have tried for 2 years to fix this

#

and just draw the whole thing as one

#

i think the whole system has to be changed or rewrite shaders

#

this is most simple repro i can do in a new project

#

just change character spacing to a negative value and change opacity of canvasgroup

shell sorrel
#

you might be able to fix this with the blending mode in the shader

queen adder
#

in Godot you can just make a node with a canvaslayer and everything under it will fade as one like a flattened png

shell sorrel
#

dont know without testing

queen adder
#

i tried that

#

changing the blend mode broke antialiasing

#

and made the text choppy

#

but it did fix the issue

shell sorrel
#

chances are what Godot is doing writing all the SDFS in into one buffer then putting that on geo and running the shader on it

#

while unity is putting each char onto a quad in a mesh, then running the shader on it

queen adder
#

yes thats probably what godot is doing

#

and i need something like that in Unity

#

another solution i saw was to use RenderTexture

#

but it complicates things so much

#

when i have lots of texts that i'm trying to animate, position, and scale for different aspect ratios

carmine sierra
#

Why do some tutorial videos for 2D unity set mouse position as a vector3 then set the z to 10?

carmine sierra
queen adder
#

all i know is godot 4 added canvaslayer where EVERYTHING under the node is like 1 flat png

#

i didn't know it would be so hard to do in Unity

#

i can do it in html5 canvas too

#

with pixi.js

#

i considered buying Super Text Mesh asset for $95 but i dont know if it has the same problem, there's no free trial

shell sorrel
#

unity is 3d at its heart no matter what, so issue comes from that since it wants to approach everything with meshes and shaders

queen adder
#

😦

shell sorrel
#

if the chances to blending mode could not do it

shell sorrel
#

then its a hard thing to fix if wanted for all text

weary robin
#

some of my code isnt wokring

#

idk where

shell sorrel
#

sicne more or less comes down to rendering texture to a buffer instead of using it directly

queen adder
#

Note: The CanvasGroup uses a custom shader to read from the backbuffer to draw its children. Assigning a Material to the CanvasGroup overrides the builtin shader. To duplicate the behavior of the builtin shader in a custom Shader use the following:

#

idk

shell sorrel
#

then rendering that buffer out as a image later

queen adder
#

i really need a solution

#

Blend One OneMinusSrcAlpha

#

i dont even know which combo would do it

short hazel
eternal falconBOT
weary robin
queen adder
#

this is with blend off

weary robin
#

how can i check

short hazel
weary robin
#

ok

#

ty

short hazel
queen adder
#

i tried all of these:

Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency
Blend One OneMinusSrcAlpha // Premultiplied transparency
Blend One One // Additive
Blend OneMinusDstColor One // Soft additive
Blend DstColor Zero // Multiplicative
Blend DstColor SrcColor // 2x multiplicative
``` no work
weary robin
timid saffron
#

done

quick kelp
#

post this here before but deleted it cause i thought i solved it

i didnt solve it i still cant figure this out

rare basin
#

!code

shell sorrel
#

!ide

eternal falconBOT
languid spire
queen adder
#

AFTER 2 YEARS I FIXED IT

#

with 1 line

#

BlendOp Max

#

in the shader

short hazel
#

If you're not sprinting, then start sprinting
Makes more sense

timid saffron
vague dirge
#

I'm currently trying to use RigidBody.MovePosition(), but it almost doesn't move when I start playing. I then saw that I had to put it in FixedUpdate(), but do I need to put the line of code that set the velocity, that is in my Update ? Because I just moved the MovePosition, but it doesn't seem to work

languid spire
shell sorrel
#

so they will become the exacty same value on both vars

timid saffron
# languid spire

i know. im just trying to understand wwhy that guy did something like that

languid spire
shell sorrel
#

they should just have a _currentSpeed

#

that they set to either move or run speed as needed

quick kelp
#

im adding a current speed now

timid saffron
#

not about u

quick kelp
#

as i just realized what was happening

languid spire
#

then you read it but did not understand it

short hazel
#

+1 on following naming conventions though :)

timid saffron
shell sorrel
short hazel
#

Again, it's a mistake. moveSpeed here refers to the current moving speed, not some preset speed

quick kelp
#

implemented a walkspeed to update the movespeed that fixed it
thanks guys 🙂

winter prawn
#

Is it better to serialize private variables than just making them public?

quick kelp
#

its litterally making a walk speed serialzefield then just replace what code was there

shell sorrel
#

its a nice option since it lets you expose and save it in the inspector but not let other objects change it

jovial sable
#

Hows it going, I want to learn how to code c# but dont know where to start. Any Ideas

shell sorrel
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

unreal imp
#

why my tracer isnt rendering? 😭 Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2f, Screen.height / 2f, 0f)); RaycastHit hit; if (Physics.Raycast(ray, out hit, shootRange)) { if (hit.collider) { LineRenderer tracer = Instantiate(tracerPrefab, muzzle.position, gunHolder.rotation); tracer.SetPosition(0, muzzle.position); tracer.SetPosition(1, hit.point); Destroy(tracer.gameObject, tracerDuration); } if (hit.collider.CompareTag("Toilet")) { hit.collider.GetComponent<ToiletBehaviour>().hitsReceived++; } }

polar acorn
timber sphinx
#

Any idea why my AI is not moving on a NavMesh that was generated during runtime using NavMeshSurface? It's showing an error "GetRemainingDistance" can only be called on an active agent that has been placed on a NavMesh.", My AI IS ON THE NAVMESH and when i bake it normally not at runtime then it works.

spiral narwhal
#

Instantiate(this) will create an exact copy right? So I should use a prefab to instantiate a "base" object, right?

#

Because right now, using Instantiate(this), it seems to be in the exact same state as the copied object

shell sorrel
#

its not a exact copy

#

but very close in most case, but non serilzied stuff just starts at its defualt values

polar acorn
spiral narwhal
#

Ok

queen adder
#

@shell sorrel i fixed the earlier text issue with BlendOp Max

#

it was that simple

#

actually it only works for white text

spiral narwhal
#

Why do I get this random Unity exception?

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List`1[T] inEdges, System.Collections.Generic.List`1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.WakeUp () (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.OnEnable () (at <871096295abe423b9c0af38ec6fe4bf2>:0)
languid spire
#

Unity Editor bug

spiral narwhal
#

Ok

vague dirge
#

Ok, this may seem smth extremely simple but I'm freaking out since hours on this problem : I had a CharacterController component that I used to move my chracter. To manipulate more freely the hitbox of my character, I decided to switch to a RigidBody. I made all the necassary tweaks, except the most important : I can't succeed to replace the CharacterController.Move() function. I tried to use RigidBody.MovePosition or RigidBody.velocity =, but my character is extremely slow or just freaks out. Thanks for the help 🙏

rocky canyon
#

if its slow it probably needs alot more force to move it.. its not going to have the same kind of values the character controller was using

#

they'll usually be higher (without a multiplier of some sort)

polar acorn
ivory bobcat
#

One uses rigid body physics and the other use some custom game physics

vague dirge
#

Also some unadviced me to change directly transform.position, so I should use MovePositon ?

ivory bobcat
#

Modifying position of a transform would be teleporting

vague dirge
queen adder
#

Adding BlendOp Max to the TMP shader fixed my issue with additive overlapping text alpha, but it doesnt work for black text, the black text just becomes invisible!

vague dirge
ivory bobcat
queen adder
#

the darker the color, the more invisible is becoming

#

:/

vague dirge
north kiln
storm imp
#

why do I have so many errors? I got them after making this

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

public class MediaImage : MonoBehaviour
{
    public GameObject canvasImage;
    public TourManager tourManager;

    // Start is called before the first frame update
    void Start()
    {
        canvasImage.SetActive(false);
        
    }

    // Update is called once per frame
    void Update()
    {
        (canvasImage.activeSelf && Input.GetKeyUp(KeyCode.Escape))
        {
            HideImage();
        }
    }

    public void ShowImage()
    {
        canvasImage.SetActive(true);
    }

    public void HideImage()
    {
        canvasImage.SetActive(false);
vague dirge
queen adder
#

of #FFF

#

and becomes #000

#

but this is bad, i need it to work for black text too..

north kiln
#

It's no longer the max color of the background vs what's rendering

ivory bobcat
#

Teleporting will not comply with the interpolation settings. Move position takes it into account but it's for kinematic rigid bodies.

queen adder
#

its against the rules to commission people in this server, right?

#

well this sucks, i solved the issue but not for black text lol

north kiln
#

The bad solution is to just have another variant with min blend lol

queen adder
#

this is what it looks like with min blend

#

i need to invert it

#

i think

#

whats transparent should be black

north kiln
#

Ah, it mins the alpha channel, weird

queen adder
#

i struggled with this issue for over a year

shell sorrel
#

well the BlendOp would depend on what the Blend line is also doing

storm imp
#

There's still three errors

north kiln
#

and what is this line of code meant to be

short hazel
#

And the bottom of the code is missing, somehow

north kiln
#

perhaps offscreen, but yes it seems like it

queen adder
#

anybody used Super text mesh from the asset store before and know if it has same issue?

storm imp
north kiln
shell sorrel
storm imp
north kiln
#
(true)
{

}
#

^ invalid code

shell sorrel
storm imp
#

There's no ;

dawn sparrow
north kiln
#

No

shell sorrel
#

no

storm imp
#

But he doesn't have one in the tutorial

dawn sparrow
#

wht

north kiln
dawn sparrow
#

oh brackets

shell sorrel
north kiln
#

it'll be obvious as hell

dawn sparrow
#

yeah no you're right, i was just correcting myself saying the line won't need a ; even in ots correct form cause of the brackets

storm imp
summer stump
storm imp
summer stump
#

Yes, that is not what you wrote

#

See the missing word?

shell sorrel
north kiln
short hazel
#

Comparing it character by character on that line should fail at the very first character

summer stump
#

Where's digi, I think this is the third time his counter will go up from the same person

summer stump
north kiln
#

so it's not counter-worthy

summer stump
storm imp
shell sorrel
#

look at the end of HIdeImage

#

also look at the end of the whole class

summer stump
#

Have you done this yet? !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

summer stump
#

If not, STOP and do it

polar acorn
#

I'm still counting it

"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 146
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-2-11
languid spire
#

was told this yesterday and the day before

shell sorrel
#

you need the basics of programming first, before trying to push through a tutorial

slender nymph
north kiln
#
Do not
- Respond with new issues you have not researched.

We can't just post every little issue you have one after the other. Go away and look at it for a single minute

storm imp
shell sorrel
summer stump
#

You're about to at least be muted, maybe banned, by vertx for ignoring what they told you

shell sorrel
#

once you get some of the basics of C# under your belt, these are the kinda issues you will see and know how to fix instantly

#

like it will be impossible to no see them

polar acorn
#

It should not take ten people five days to tell you how to type the same things as a tutorial. This is no longer asking for help this is crowdsourcing your job to random people on the internet

queen adder
#

how do i remove tmp essentials that i imported to a new project?

north kiln
#

You delete it from your project, it's just in your Assets folder

storm imp
polar acorn
hazy crypt
#

Hey guys, Im playing around with adding relative force to an object and it would be super helpful if I could show the object transform, is that possible?

storm imp
#

and mine?

shell sorrel
storm imp
shell sorrel
#

also just look at the intro stuff in the learning content

north kiln
#

well apply your brain

shell sorrel
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

short hazel
#

It's pretty obvious that the second function is not ending the same way as the first one, suggesting the file isn't finished yet

polar acorn
# storm imp I can't that from the video

It's almost like all functions have the same structure that is required to make code compile so there's no point in showing the end of a file and you're supposed to actually know what you are doing enough to know that

tough lagoon
# storm imp and mine?

Another way you ask it is, what's the difference between ShowImage() which has no issues, and HideImage(), which has an issue? The main problem is some tutorials on YouTube are sketchy and you really should go through a curated place like unity learn.

#

A second hint is what you see when you hover over the red error

tough lagoon
storm imp
tough lagoon
#

Can I see the code?

#

But yes, a good rule to follow - for every open brace you should see a closed brace.

shell sorrel
#

the one for closing the class

tough lagoon
#

And don't forget to hit save after you write it.

north kiln
storm imp
summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

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

summer stump
#

Like damn, this is beyond ridiculous

#

This is not a forum for people to do the work for you

carmine sierra
hazy crypt
#

Hello all, I have a rigidbody that is flying across the world by itself

#

Not sure why

#

heres the code

#

Im not giving it any inout when I play the scene

#

and its flying east

#

Like a burd

#

Its off east for winter

#

If i comment out the euler angles line then it is okay

#

Im guessing thats the issue but im new to coding and wondering how to properly use it

#

I cant wrap my head around the documentation page so I would appreciate some help

carmine sierra
#

change the theme

shell sorrel
#

!code

eternal falconBOT
hazy crypt
#

Lik e this?

#
transform.eulerAngles = new Vector3(0f, 0f, 0f);
#

I got it

#

This is the line that causes the bug

shell sorrel
#

what is the intent of that line @hazy crypt

#

if its a rigidbody it has buttons for freezing rotations on it for you

north kiln
#

Is there a reason you're not just using rigidbody constraints to lock rotation?

hazy crypt
#

I would like to learn how transform.eulerangles works

north kiln
#

Probably best to learn while not driving a dynamic rigidbody

hazy crypt
#

I want to use this to add a rotation to my player character, I just wanted to start experimenting with a line that did nothing and add inouts to it

#

if that makes sense

north kiln
#

dynamic physics bodies shouldn't be manipulated directly via their transforms

hazy crypt
#

I had read that somewhere but im unsure how to achieve my goal i i dont

shell sorrel
#

the rigid body will have methods for rotating it adding forces like torqe to it

visual hedge
#

Turn based game. Battles / fights are happening in the BattleScene.scene
There are many different lists, including each team/side list, and so on. After battle there's transfer to outer world scene.
Question: Do I have to clear the lists after battle end? Does this information make some informative trash?
For example I have the list of all the buffs each unit has in the battle. What happens if I don't clear the list after battle? That list is not on some scriptable object. Just List<Buffs> buffs = new ();
Or are all the lists get basically trunkated automatically and this data is not gettign stored anywhere after scene exit?

hazy crypt
#

Yes im just not sure which to use to achieve the correct output

#

Ive tried adding torque and adding force, both relative and not and I ant seem to get it

#

I worked on a game years ago but I did everything except the ode and Id like to revive the project solo

#

heres the game

#

This is the movement Im tying to reccreate

#

The ball only rolls forward/backward, but rotates the whole character left and right to face a new diection

visual hedge
#

This looks fun 🙂 Sorry I have no idea how to help you, just giving you a shoutout )

hazy crypt
#

haha thanks

#

It was very fun

shell sorrel
visual hedge
hazy crypt
#

oh wait I can freexe some planes o rotation

shell sorrel
#

well if you are unloading the scene, then the lists are gone if htey were on objects of that scene

hazy crypt
#

you said that

#

That could be the ix

#

fix

craggy oxide
#

how can you stop a function from running more than once

shell sorrel
#

have a bool you set true the first time the function runs

#

then return early out of the function if that bool is true

#

if (hasRun) return;

urban rampart
#

Hi everyone, I have a prefab object that needs to create a reference to a different script upon being created in my scene. I'm trying to use FindObjectOfType however it is always returning null.

Line of code to find object: manager = FindObjectOfType<RoomPicker>();

RoomPicker is the script thats on an empty object in my scene (it is enabled)

#

I've been trying to debug this for the last 4 hours and I'm not sure what to try next

rocky canyon
#

the code should work considering RoomPicker is present, like you said..
my guess w/o seeing any code is a race condition.. your'e using the manager before it gets a chance to find the object..
perhaps all this codes trying to run in a single frame.. or perhaps the code should be run somewhere other than where it currently is.. like OnEnable vs Start.. hard to say w/o context

urban rampart
#

give me 1 second to put it into a paste bin, the find object is in the scripts start() function

rocky canyon
#
When you load a lot of objects when a Scene starts, all the awake calls will be guaranteed be run before a single start call ( though the order is not guaranteed at all). So this is when you initialize script variables. Then all the Starts are called before any Update is. This is where you get hooks into other scripts (Since they should all have initialized themselves in their own Awakes).

Now when you instantiate an object mid scene, Awake is called directly after the object instantiates, then the rest of your code continues from the instantiate line. Start is guaranteed to be called before the *NEXT* frame's update, but not necessarily anytime during this one.
urban rampart
#

that is good to know, but I also just found my problem

#

I had it as start() when it need to be Start()

rocky canyon
#

well. that should have gave you a compile error

#

or atleast a console error.. saying it wasnt used

#

but yea capital unity functions

urban rampart
#

it was only giving an error when I tried to click the button and it didn't have access to the other script

rocky canyon
#

Start() Awake() Update() etc

urban rampart
#

thank you very much for the help (what make me double check was you typing Start in your first message)

rocky canyon
#

i tend to try to remember Awake -> Set up Self
Start -> Set up Others

#

that way you avoid some of those times

carmine sierra
#

I got this error after writing a variable in wrong then correcting it afterwards?

cosmic dagger
meager gust
#

or that

cosmic dagger
#

It's unneeded . . .

carmine sierra
#

but I found an issue in the code which fixed it anyways

#

not sure why it had an effect on every single vector though

cosmic dagger
cosmic dagger
carmine sierra
#

unless system.numerics was added and removed automatically it isn't there

fickle stump
#

!code

eternal falconBOT
fickle stump
#

Hey there, it's me again with another question:
I'm working on a VR Scene where I have multiple windows that I'm interacting with, to close them.
After closing them I want to send a message to my script where it say's that i closed ALL windows. However I'm unsure how to track the statues of multiple windows without creating a check for every single one of them.
Do I create an Array and check if any of these windows are still not interacted with? Or what's the correct approach

Code here: https://gdl.space/utihiyetag.cs

#

Thanks in advance for the help

wet shore
#

!cs

eternal falconBOT
modest dust
fickle stump
#

oh wait that actually makes so much sense facepalm

visual hedge
#

lines

var source = sourceObj.gameObject.GetComponent<UnitAttributes>().Stats;

and

var source = sourceObj.GetComponent<UnitAttributes>().Stats;

basically do the same, right? And yes, <UnitAttributes> is MonoBehaviour.
and sourceObj is another script (mono behaviour class) attached to that gameObject

queen adder
#

how can i make parts of my ui fade all as 1 object

#

like a flattened png does when you change transparency

queen adder
#

i think u need rendertextures

queen adder
visual hedge
rich adder
queen adder
#

no

#

when i fade the canvasgroup with dotween, all the children fade separetly and it looks terrible

#

unity is the only engine ive used that does not have a simple solution for this

rich adder
#

oh this s a UI question

queen adder
#

its kinda

#

yea

fickle stump
#

because i think it's actually more complex than anticipated/I'm not smart enough to fix this

shell sorrel
#

everytime you open a window increment a int or add the window to a list

#

when you close one, subtract one, or remove it from the list, then return control when it reaches 0

fickle stump
#

It's a bit more complex than that I assume. Because I need to check first if the window is active or not and if it's not active then i have to add it into the list to check if it's interacted with

shell sorrel
#

ok that sounds pretty simple though you can just maintian a list of them all and check for what ever you need to on it

fickle stump
#

A list? How do you mean that?

carmine sierra
#

this line should instantiate 'weaponPrefab' at the position of 'SpawnPoint', right?

fickle stump
#

taking a look

rich adder
carmine sierra
#

yeah just found out it wasn't set active

#

when it instantiates though it flies a bit up then freezes

rich adder
#

hard to say without much detail 🤷‍♂️

fickle stump
#

._.

carmine sierra
#

besides the commenting, could anything in the code be the problem?

#

(not saying the commenting would be an issue)

rocky canyon
#

ur trying to grab the rigidbody from the prefab reference

#

instead of grabbing it from the instantiated prefab.

#

(the one in the scene)

carmine sierra
#

so should i save it as a variable THEN grab the rigidbody

rich adder
rocky canyon
#

pretty much yes

#

u want the rigidbody from the prefab clone (the one u spawn into the scene)

fickle stump
# fickle stump Ok i am a bit overwhelmed by that

What I thought would work making a script for my windows that checks which status the window has (opened or closed).

And the only way to get all of them and check if they are all set to false (closed) is with a list?

rich adder
#

imagine a box where you put all your stuff, but they are all the same thing
Like a box of fruits, you can only put Fruit inside the box @fickle stump

carmine sierra
#

but how can I instantiate it and save the variable

rich adder
rocky canyon
#

same way you assign any other variable

rich adder
#

if the Size is fixed then Array works fine

#

eg. if you dont add or remove windows to list of mantained windows to check

carmine sierra
#

like that?

rich adder
#

Array, List and Possibly a Dictionary.

#

very Important

rocky canyon
# carmine sierra
                    GameObject newClone = Instantiate(groundSelectPrefab,hit.point,Quaternion.identity);
                    Rigidbody clonesRB = newClone.GetComponent<Rigidbody>();

                    clonesRB.AddForce(transform.forward * Mathf.Infinity,ForceMode.Impulse);```
#

ive never done it but i think you can just instantiate it as a rigidbody

#

if it has a rigidbody component.. could be wrong tho id have to try it real quick

#
Rigidbody clonesRB = Instantiate(groundSelectPrefab,hit.point,Quaternion.identity).GetComponent<Rigidbody>();

clonesRB.AddForce(transform.forward * Mathf.Infinity,ForceMode.Impulse);
carmine sierra
#

why are you adding a force and using maths at the end

rocky canyon
#

im pretty sure that works.. but its ugly.. theres probably a better way to do this even.. but thats the gist.. spawn it first.. then manipulate its specific components

rocky canyon
carmine sierra
#

oh okay

rocky canyon
#

doesnt mean anything other than u can use the rigidbody reference

#

clonesRB.isKinematic = true;

carmine sierra
rocky canyon
#

i wonder what would happen if u gave a rigidbody infinity force as an impulse 🤔 rofl

carmine sierra
#

doesn't work for some reason?

rich adder
#

read the errors

#

there is always a reason

rocky canyon
#

whats the error say yea

rich adder
#

u prob orgot ;

carmine sierra
#

yeah fixed

north kiln
#

I don't know why you're still here not posting actual errors

north kiln
#

I spent like 20 minutes trying to get an error message out of you yesterday

rocky canyon
#

good job unity 🙂

#

i was expecting a crash maybe

rich adder
#

duh

carmine sierra
#

yeah haven't built a habit of checking the console

north kiln
#

But your error is right there, underlined

#

Just hover over it

rich adder
#

why did we spend time configuring it if you're not gonna use it UnityChanLOL

shell sorrel
#

most compile errors the ide will know about and for runtime errors you need to check the console

carmine sierra
#

so assumed I had to find the issue myself

rich adder
#

yes which is what you try to do before resorting to asking basic question ide answers lol

rocky canyon
#

you do need to figure out why the error occurs.. some times it tells you str8 up whats wrong, other times it takes a google or two.. always useful regardless of which scenario

#

the ide catches stuff before u make it into unity.. unity will catch most of the rest.. (like the inspector/ scene/ type stuff)

carmine sierra
#

is this not working because the instance is not instantiated yet, or because it's just flat out wrong?

#

the 'none gameobject' gets instantiated later

summer stump
#

Only types go in the angle brackets, not variables or references or anything else

rich adder
#

Would only work if WeaponSpawn was a namespace and weaponInstance was a class 😈

rich adder
#

. is the right operator to use , you're just using it wrong

carmine sierra
summer stump
carmine sierra
#

and it is fine even if the instance is not in the game at the beginning of the run test?

rich adder
#

what is currentAmmo

#

weird naming

#

You can just store it as WeaponSpawn so you don't need GetComponent

carmine sierra
#

it is a code for a slingshot so the current ammo loaded onto the slingshot is currentammo

rich adder
carmine sierra
rich adder
carmine sierra
#

ohh

#

would i make the data type a c# script?

rich adder
#

yes

shell sorrel
#

when you have a field in the inspector of a certain compoent type, you can just drag in any GO that has that component on it

spiral narwhal
#

How do I prevent a Sprite from blocking OnMouseEnter?

rich adder
#

the class is a type