#💻┃code-beginner

1 messages · Page 196 of 1

flat slate
#

i made a ontriggerenter2d event but the problem is that the Children of the Object where the colliding script is collides aswell with the other objects

#

how can i avoid that

swift crag
#

There are several ways to get input.

cosmic quail
earnest atlas
#

They made it like this.

I did like onDisable

flat slate
#

but it ignores that the children has got another tag

swift crag
#

The former makes sense for non-buttons

#

things that don't "happen" at a specific moment

#

The latter makes sense for buttons

#

you want to do something in response to the Fire action being performed

earnest atlas
#

Im just confused a bit how everything is called what is better and what is corect

faint sluice
timid saffron
#

oh thanks man minor mistake again. this part is alittle hard and overwhelming sorry

cosmic quail
earnest atlas
#

So second one is better considered it wont get called constantly?

swift crag
#

Neither is "better"

#

They're two different use-cases.

faint sluice
swift crag
#

I use both.

#
            Vector2 moveInput = moveAction.action.ReadValue<Vector2>();
            Vector3 worldMove = entity.transform.TransformDirection(new Vector3(moveInput.x, 0, moveInput.y));

            Vector2 lookInput = lookAction.action.ReadValue<Vector2>();
            lookInput += gyroLookAction.action.ReadValue<Vector2>();
swift crag
#

I use ReadValue for things I need values from every frame

#
            foreach (var actionRef in callbacks.Keys)
            {
                actionRef.action.performed += callbacks[actionRef];
            }

I subscribe to the performed event for things that I need to run a method in response to.

faint sluice
faint sluice
swift crag
#

callbacks is a :

Dictionary<InputActionReference, System.Action<InputAction.CallbackContext>> callbacks;
#
            actions.Add(walkAction);
            actions.Add(crouchAction);
            actions.Add(runAction);

runs in Awake

#

I just did this because I didn't like the repetitive subscribe / unsubscribe code

faint sluice
#

Ahhh lmao

swift crag
#

I'm not using the PlayerInput to directly call methods

#

just InputActionReference fields

faint sluice
#

How do you get rid of an "unwanted action" in this method??

swift crag
#

i don't understand what you mean

faint sluice
#

Say you don't want to subscribe to crouch anymore in following builds

swift crag
#

then I'd remove it from the dictionary

faint sluice
#

Wouldn't actions get messed up?

swift crag
#
            callbacks[interactAction] = Act;
            callbacks[discardAction] = Act;
#

(the method looks at the action that triggered it to decide how to handle the input)

swift crag
#

everything in that list gets enabled

swift crag
swift crag
faint sluice
swift crag
#

i shouldn't have anything enabling individual actions

faint sluice
#

I'll probably still stick to my caveman ways as it's easier to read and ignore but cool to learn new ways catto

quick dawn
#

` Vector3 followPositionPlayer = Vector3.Lerp(transform.position, physicsPlayer.position, Time.deltaTime * menuFollowPositionSpeed);
Vector3 followRotationPlayer = Vector3.Lerp(transform.eulerAngles, physicsPlayer.eulerAngles, Time.deltaTime * menuFollowRotationSpeed);

    Vector3 followPositionHead = Vector3.Lerp(transform.position, physicsPlayerHead.position, Time.deltaTime * menuFollowPositionSpeed);
    Vector3 followRotationHead = Vector3.Lerp(transform.eulerAngles, physicsPlayerHead.eulerAngles, Time.deltaTime * menuFollowRotationSpeed);

    transform.position = new Vector3(followPositionHead.x, followPositionPlayer.y, followPositionHead.z);
    transform.eulerAngles = new Vector3(followRotationPlayer.x, followRotationHead.y, followRotationPlayer.z);`
#

can someone help me fix the euler angles lerp please

#

it snaps weirdly

#

and when i tried quaternion lerp it didnt work

timid saffron
#

and what Ive realized is that I wrote this code and thought made sense (I think it does) this code is for destroying animals if their position is greater than...

#

but what Ive realized is clones of prefabs Z value dont increase or increase very little amounts

#

even though they are very far away

faint sluice
quick dawn
polar acorn
timid saffron
#

it is prefab

polar acorn
timid saffron
#

these are spawned

#

you mean spawn manager?

polar acorn
timid saffron
#

this?

#

spawnmanager spawns clones of this

#

im not sure if its like parent and children

#

I use this code to call them

polar acorn
#

You know what nevermind I've decided I don't care

#

I don't have the patience to play 20 questions with someone who doesn't understand what I'm asking

#

I'm too tired today

quick dawn
#

thats deep

timid saffron
#

yeah

#

I didnt assing any parent or children so I didnt quite get what youre asking for

#

this is the best I can show you

summer stump
#

See the thing right above the thing you circled on the left

#

That's the parent

#

Wait, maybe i'm wrong

#

I can barely read anything with that color

quick dawn
#

can somebody help me change the vector lerping to quaternion lerping pls

summer stump
#

Ok yeah, that is the world position

quick dawn
#

i tried and it didnt work

timid saffron
#

Fox(clone)
down arrow
SM_fox_01
sm_fox_02...

#

you said you couldnt read so I wrote what wrote there 😄

timid saffron
#

okay didnt see that

summer stump
#

The sm ones are children of the prefab it looks like (as you showed with the fox)

#

So it's local position

#

To be clear, the things with a down arrow are called parents (if collapsed, it's a right arrow)

swift crag
#

Understanding the Transform hierarchy is very important.

#

It's fundamental to how your objects are positioned in the scene.

#

The relevant point here is that, if your parent is scaled up, a small change in your local position results in a huge change in your world position.

#

If your parent's scale is [10, 10, 10] and your local position is [1, 2, 3], your world position is [10, 20, 30]

shell sorrel
#

the concepts of transforms, parent objects and child objects also carries over into DCC apps like blender and maya as well, pretty much anything with 3d and a lot of 2d things as well

swift crag
#

(assuming that the parent is not rotated and is at the origin)

timid saffron
#

I also tried local.transform

#

instead of transform

#

but that didnt do much

swift crag
#

it sounds like you just tried random changes until it kind of worked

#

did you read anything we wrote?

summer stump
#

You just need to look at the parent transform

noble summit
#

what does ForceMode.Impulse do

timid saffron
summer stump
noble summit
#

no i need a quick summary of one sentence on to what it does

summer stump
swift crag
timid saffron
noble summit
swift crag
#

I should point out that the second page I linked, indeed, has two-sentence descriptions

swift crag
noble summit
noble summit
summer stump
swift crag
#

this is ridiculous

summer stump
swift crag
#

put down your phone and read a single page of text

timid saffron
#

this was what I was trying to do

noble summit
summer stump
noble summit
#

huh.

summer stump
swift crag
noble summit
summer stump
noble summit
#

so impulse is just removing framerate stuff

swift crag
#

no, it is not "just removing framerate stuff"

noble summit
#

thats what im seeing

swift crag
#

it applies an instantaneous force to the rigidbody

polar acorn
noble summit
#

doesnt seem very instant to me

median ruin
#

why does this happen, I'm very confused?

noble summit
summer stump
rocky canyon
#

ur using names you probably shouldnt use

median ruin
#

Hmm okay I see

quick dawn
#

euler didnt work

median ruin
#

But why would it care?

quick dawn
rocky canyon
#

outside the code block

swift crag
#

without the big popup getting in the way

summer stump
swift crag
#

the entire script would be ideal

quick dawn
#

mbmb

summer stump
median ruin
# swift crag Show all of the code
public class UIPopupTrigger : MonoBehaviour
{
    // Start is called before the first frame update
    private bool IsTriggered = false;
    private GameObject Trigger;
    private GameObject CursorText;
    private DetectArea PopupTrigger;
    [SerializeField] string text = "Press E to interact";

    void Start()
    {
        Trigger = transform.Find("proximity").gameObject;
        Trigger

        CursorText = GameObject.Find("GameManager/GameHUD/Popup/CursorText");
        //textmeshpro
        CursorText.GetComponent<TMP_Text>().text = text;
        CursorText.SetActive(false);
    }
}
swift crag
rocky canyon
#

well if u just put Trigger out in the open w/ nothng ele it'll error

swift crag
#

Trigger is not a valid statement

polar acorn
rocky canyon
#

finish the line 😉

swift crag
#

it's been left hanging

quick dawn
summer stump
quick dawn
#

alr ill change it

#

but im js tryna figure out the quaternion problem

#

bc it doesnt work at all then

summer stump
#

Well the dt was part of the problem I bet. But I suck at rotations.
Is there a reason you chose lerp other rotation methods though?

swift crag
#

Quaternion.RotateTowards will steadily rotate towards a target.

summer stump
#

The whole code is wild honestly, not sure what the goal even is

quick dawn
#

im restarting

spice breach
#

I'm attempting to make a maze generator that can choose from different Node prefabs, the generator works, I'm having trouble selecting a random Prefab to use for the maze

swift crag
#

Your types don't match.

#

prefabChoice is an array of GameObjects

#

But you're trying to store the instance into a MazeNode variable

#

Perhaps you meant to have an array of MazeNodes?

#

If you instantiate a component, Unity copies the entire game object

spice breach
#

cant believe I made that mistake

spice breach
swift crag
#

you can make an array of whatever you want

spice breach
#

ended up getting an error telling me that the object i wanted to instantiate was null but it fixed itself somehow

swift crag
#

there's nothing special about GameObject

swift crag
ivory bobcat
#
- GameObject[]
+ MazeNode[]```
polar acorn
wanton cargo
#

Hi so I can't seem to figure this out, I have a robot arm with two bones and it needs to calculate the angle at which the bones have to be in order for the end of the second bone to end up at a target position, but I have no idea how to approach this

#

Preferably while rotating on only one axis

swift crag
#

this is inverse kinematics

wanton cargo
#

i was trying that but I can't get it to work right, it either messes up completely or ends up on the completely wrong position, or uses multiple axis

wanton cargo
#

Feels a bit dumb to ask but.. how would I define what axis it should rotate on 😅 as I need it to do it in 3d space but only on the local x axis

shell sorrel
#

transform.rotation = Quaternion.AngleAxis(30f, Vector3.right);
would rotate 30 degress around the x axis

wanton cargo
#

I understand that but I meant with IK

#

apologies for confusion

shell sorrel
#

oh now its a much more complex question

wanton cargo
#

yeah 😅 i have been stuck on this for a few days now

swift crag
#

I would suggest making the most basic IK setup possible

verbal dome
#

I dont really use builtin IK but the axis would probably be your limb's "right" axis (often transform.right) or a cross product of the two limb's directions wont work if the limb is straight

short hazel
#

Some IK rigs have a polar bone, which dictates towards where the bend is directed, but I don't know if Unity has support for that built-in

swift crag
#

I imagine it's different in 2D

swift crag
wanton cargo
#

Yes it's in 3d

swift crag
#

I'm not sure I got that in my head, sorry

wanton cargo
#

No problem haha

swift crag
#

2D IK won't help you here

wanton cargo
#

ok that's what I assumed, but worth a shot I suppose

swift crag
#

I also haven't really used Animation Rigging much

#

that's a 3D package

wanton cargo
#

I had a working IK setup before but I couldn't get it to work with constraints

swift crag
#

I mostly use FinalIK, which is third-party. I need to give Animation Rigging another go

wanton cargo
#

FinalIK is 90$ 😭

swift crag
#

Yep. It works real nice, though!

wanton cargo
#

I do not have 90$ to spare 🫡

#

so I will try to find an alternative

earnest atlas
#

Gimp 😄

summer stump
#

Gimp is nice though for sure

earnest atlas
#

no idea I came late

summer stump
swift crag
#

yes, we're talking about inverse kinematics

rich adder
wanton cargo
#

I managed to solve my problem 🤠 package called Animation Rigging

rich adder
#

buggy but getting ok

wanton cargo
tender breach
#

How do I change the variable of a clone?

#

I'll show the code when I feel like it.

slender nymph
#

Instantiate returns a reference to the instantiated object. so you use that reference to access any public members

tender breach
#

I don't understand what you mean by that.

slender nymph
#

that's too bad. you didn't bother showing code so i cannot suggest any other info 🤷‍♂️

rare basin
wanton cargo
rare basin
#

oh lord

#

that is unreadable

wanton cargo
#

brother discovered an if statement and used it everywhere

earnest atlas
#

Whoever delt with Unity FPS assets on player controller. How does it read movements and presses?

summer stump
#

It's wild how much better the formatting is, and yet still so horrific

tender breach
#

I formatted it!

wanton cargo
#

We know!

#

😂

slender nymph
# tender breach Here's the code: https://pastecode.io/s/xp91ias7

you have been told time and time again that you need to fix the formatting for your code. i'm sure you've also been told at least multiple times that you should be sharing your code using a site that adds syntax highlighting because that terrible formatting + lack of syntax highlighting makes that entirely unreadable

summer stump
tender breach
#

I formatted it! Honest!

earnest atlas
#

AHAHaha

#

It was worse?

#

And my teacher complained that looking into my code was bad

summer stump
slender nymph
earnest atlas
#

https://hatebin.com/

This is unity asset player controller. How does it get movement and other things? I cant find references to inputs?

short hazel
slender nymph
earnest atlas
slender nymph
#

make sure you've selected the save button on there. or use a different site if you cannot get that one to work

earnest atlas
#

I did

#

It broke

slender nymph
#

it's a good thing there was an entire second half of that message with an alternative suggestion

scarlet skiff
#

why wont it accept he script?

earnest atlas
#

hatebin broken

#

!code

eternal falconBOT
earnest atlas
#

I think I found it, its directly accessing inputs huh

slender nymph
#

it uses the Input System with the PlayerInput component to get input

earnest atlas
#

yeah it just does it differently from what I got told

#

Also it has this bait

#

It exists, but it appears not to be used for anything

slender nymph
#

it is used for the input . . .

earnest atlas
#

Probably on phone

#

Its not accessed anywhere at player

slender nymph
#

the PlayerInput component sends the input messages to the StarterAssetsInput component. the FirstPersonController component access the StarterAssetsInput component for the input

slender nymph
earnest atlas
#

But this code has not a single reference that PlayerController accesses

#

wait

#

OMg

slender nymph
earnest atlas
#

What happens if I generate another instance of this class?

#

Or there only can be one? (or it explodes)

slender nymph
#

wdym by generate another instance? none of these are singletons. you can have as many different instances of these objects as you'd like

earnest atlas
#

Well last time I generated another istance of controllers they broke

#

Might have been my fault

#

But not sure

slender nymph
#

again, what do you mean by generated another instance

earnest atlas
#

StarterAssetsInputs Inputs
Inputs = new();

slender nymph
#

well that's just incorrect

#

you do not new() components

earnest atlas
#

that just example

#

If there are 2 components will it break or not?

slender nymph
#

surely you know how to read, right?

earnest atlas
#

Link?

slender nymph
earnest atlas
#

I mean

#

Okey gonna test if it explodes

#

Issue is not that its singleton

#

Or not

#

Issue is if there are multiple instances of this Component aparently

slender nymph
#

do you know what a singleton is? it's literally a type of object that forces only a single instance to ever exist. these components are not singletons therefore more than one can exist at any given time

polar acorn
earnest atlas
#

you dont understand what I mean

slender nymph
#

of course how you use something also matters

slender nymph
earnest atlas
#

As mentioned I have mentioned to mention that when I created that class twice controlls broke

slender nymph
#

i know perfectly well that you are likely experiencing issues where all of the objects with these components on them are all reacting to the same input. of course that has nothing to do with having more than one of these components on it

#

the issue is obviously that they are all set up with the same input

#

for future reference, try fucking explaining what is happening instead of assuming everyone can read your mind and knows exactly what you mean when you say things explode with more than one of those components

earnest atlas
#

Issue mostly comes with me not knowing terminology and thinking that I explained it in a wrong way.

slender nymph
#

the issue is that you didn't explain anything at all

earnest atlas
#

Im pretty sure I did.

#

Anyway how does Unity Input system actually references this class?

slender nymph
#

it doesn't

#

the PlayerInput component sends messages to all of the components on the same object

edgy sedge
#

Getting this error
IndexOutOfRangeException: Index was outside the bounds of the array.
o
ShopStart 0 (at Assets/Scripts/Shop.cs:29)

Where it brings me to

    void Start()
    {
        for(int i=0; i<=9; i++)
        {
            products[i].SetActive(false); //Error

        }

        Refresh();
    }```
flat slate
#

yo i want my player to be in a fighting state when he is punching so that every time he is punching a bool gets true for 5 sekonds and then turn to false

earnest atlas
#

the way I learnt it used autogenerated class

flat slate
#

how do i do that

earnest atlas
#

Gonna look into guide

flat slate
#

i tried to do it with Ienumerator

#

but its not that effective

slender nymph
slender nymph
flat slate
#

okay

#

/code

#

!code

eternal falconBOT
earnest atlas
edgy sedge
earnest atlas
#

found it

slender nymph
slender nymph
modest dust
rich adder
#

yes you lack the basics of working with array

flat slate
#

the problem is that when i punch the first coroutin estarts but when i start punching when the first coroutine is still running the "isfighting" bool will be set to false fto fast

polar acorn
edgy sedge
polar acorn
rich adder
edgy sedge
flat slate
rich adder
polar acorn
faint sluice
modest dust
flat slate
#

!code

eternal falconBOT
edgy sedge
flat slate
#

wait

slender nymph
#

you don't check if isfighting is true anywhere

polar acorn
flat slate
#

what do u mean?

#

so the first one is just for checking if he is attacking

polar acorn
flat slate
#

isfighting is for something else

faint sluice
flat slate
#

i try to stop all coroutines beore starting the coroutines

#

works now

#

thanks

earnest atlas
slender nymph
earnest atlas
#

I went page by page

#

They do the same thing i did

slender nymph
#

apparently not

#

they very clearly use the PlayerInput component there

earnest atlas
#

Where is the no autogenerated class

slender nymph
#

literally the first part

earnest atlas
#

Link

#

I might be blind but what they did so far is almost the same

slender nymph
#

it's literally the first fucking part of that course you linked

#

i don't even see anywhere that they do use the autogenerated c# class for that

earnest atlas
#
{
   Vector2 movementVector = movementValue.Get<Vector2>();
 
     movementX = movementVector.x;
     movementY = movementVector.y;
}```
slender nymph
#

yes, that is literally not using the autogenerated c# class

earnest atlas
#
public void OnMove(InputValue value)
{
    MoveInput(value.Get<Vector2>());
}```
slender nymph
#

that is using the PlayerInput component. just like the StarterAssetsInput component does

earnest atlas
#

WHAT is calling ONMOVE?//

slender nymph
#

the PlayerInput component

#

it does not call it directly, it sends the OnMove message to all components attached to the same object

earnest atlas
#

So basically if I create Shoot inside the controll component I need to create OnShoot so it gets a call?

slender nymph
flat slate
#

can u do 2 colliders in one object but they collide with diferent objects?

earnest atlas
#

yes]

rare basin
flat slate
#

how

rare basin
#

add 2nd collider component

earnest atlas
#

So I was correct OnShoot

flat slate
#

but i want that they collide different

slender nymph
flat slate
#

thanks

#

thats not what i meant

slender nymph
#

then you need to explain what you mean

#

because that absolutely will allow two different colliders on the same object to collide with different objects. you just have to set up the layer overrides on the individual colliders

flat slate
#

okay

#

then im just dumb

swift crag
#

(they can be configured in the inspector)

rare basin
flat slate
#

doesnt work

#

wait

ivory bobcat
flat slate
swift crag
#

is that error actually related to the code you showed?

dire tartan
#

im trying to make an active ragdol and need some help

#

im setting the target rotation of my ragdol to another model doing animations but its not copying the animation and im not sure what to change to fix it

prime cobalt
#

Is there a way to get the current volume of an audio clip and turn it into a float? So like a head can bob around with its rotation dependant on the volume of an audio clip it plays.

ivory bobcat
#

It should be the object that contains the current status of what's being played. The clip would just be data.

prime cobalt
#

Ok thanks

ivory bobcat
earnest atlas
#

Only way to expose variable to inspector is to serialize it or make it public?

charred spoke
#

Well yes

earnest atlas
#

I just want to see sort of debug states

charred spoke
#

Debug states of what ?

earnest atlas
#

Basically see values without using serialize

#

Its not possible?

charred spoke
#

Debug.Log exists

earnest atlas
#

Not log

ivory bobcat
#

Sounds very explicit..

earnest atlas
#

Just show variables without making lines of variables with serialize

ivory bobcat
#

"making lines"?

charred spoke
#

The variables need to be serialized in order to appear in the inspector

earnest atlas
#

I just dont want this

#

its a metoforical representation

ivory bobcat
swift crag
#

You're going to need to do something for each value you want to view, yes

#

It is annoying that there's no built-in "display" feature

ivory bobcat
#

Hopefully it isn't a wanting to type less issue.

earnest atlas
#

does serialize works when you have multiple variables in line?
Like
bool a,b,c,d

graceful citrus
#

the code below is producing the image above. why are the prefabs being made in this pattern? i want them randomly across the map but thats not what its doing at all

    [SerializeField] private playerJoin players;

    [SerializeField] private GameObject radio;

    void Start()
    {
        for (int i = 0; i < 100; i++)
        {
            instanting(radio);
        }
    }
    void instanting(GameObject instantObject)
    {
        transform.position = new Vector3(UnityEngine.Random.Range(-384, 384), 512, UnityEngine.Random.Range(-384, 384));
        GameObject instance = Instantiate(instantObject, transform);
        if (instantObject == radio)
        {
            instance.GetComponent<threeDimensionalAudio>().clint = players;
        }
    }
modest dust
earnest atlas
#

You mean in VS studio?

modest dust
#

In Unity.

graceful citrus
#

it is a distinct curve

ivory bobcat
#

They're referring to the unity inspector

graceful citrus
#

you'd think with randomness that wouldn't happen

#

but it seems unrandom

night mural
#

is it really consistent every time?

modest dust
graceful citrus
#

it seems so

#

its literally supposed to be random

#

its not even supposed to be a straight pattern

#

its supposed to be random points on a lateral grid

night mural
#

but they're the same every time?

graceful citrus
#

but its creating a completely out-of-left-field pattern

graceful citrus
night mural
#

you mean like a...random pattern?

graceful citrus
#

i see no reason it would do that

night mural
#

do what

graceful citrus
#

make the pattern it does

median ruin
#

how do you know when an animator finish animating it's state?

night mural
ivory bobcat
#

I'm assuming they're referring to this

graceful citrus
#

they call start at the same point, then disperse in this pattern

#

this pattern

#

again

#

a second time

#

tf is happening

earnest atlas
#

Quantum Mechanics

#

Nothing is random

ivory bobcat
#

It would seems you're only offsetting the object relative to the previous

#

Visually

graceful citrus
#

but what do i do to stop that

#

do i wait a second between each one

#

each instantitiate

night mural
#

is your camera oriented correctly? we're looking at x/z right now?

#

or x/y?

graceful citrus
#

x/y

#

its supposed to be x/z

#

in the code, y is fixed

#

yet, the y is changing in this pattern

night mural
#

so we're looking at x/z?

graceful citrus
#

no we're looking at x/y

night mural
#

but you set y to be 512 always

graceful citrus
#

i am just as confused as you are

night mural
#

what's it look like from another angle? i remain unconvinced

ivory bobcat
graceful citrus
night mural
#

oh what are you even doing here

graceful citrus
night mural
graceful citrus
#

ik

night mural
#

you should be spawning your object, then setting its position to your random value

graceful citrus
#

but when you spawn a prefab it spawns at the object

#

i mean that would also work probably

#

ill try that rq

polar acorn
graceful citrus
polar acorn
#

It spawns at the location you specify in the parameter

#

if you don't provide one, it uses the value of the prefab itself

median ruin
#

Is there a way to tell when an animation is done? I've tried using normalizedTime and the length of the animation but I couldn't get it to work properly.

graceful citrus
rancid tinsel
#

since its max exclusive, would i need to do blockPrefabs.Length + 1 in order to have all the options in the array be possible?

polar acorn
median ruin
#

uh oh I see

#

I was wondering what you used those for lo

polar acorn
ivory bobcat
shell sorrel
#

inclusive for floats

graceful citrus
#

i read the docs 🤓

rancid tinsel
polar acorn
shell sorrel
rare basin
graceful citrus
#

can i make my terrain collider thicker

#

or, in general, can i make a mesh collider thicker

polar acorn
#

You shouldn't need to

median ruin
#

is

public bool State {
        get {
            return state;
        }
        set {
            state = newState;
        }
    }

preferred over

public bool GetState() {
    return state;
}
public bool SetState(newState) {
    state = newState;
}

or the otherway around?

night mural
#

colliders don't really have a 'thickness', they are a boundary line

polar acorn
#

Colliders don't have "thickness", they're always just triangles/quads

rare basin
graceful citrus
slender nymph
ivory bobcat
polar acorn
#

Now you can do both

graceful citrus
polar acorn
graceful citrus
#

i understand that colliders do not actually have Collider.Thickness();

polar acorn
# median ruin I do like that

You'll just need to make sure GetState and SetState modify a different variable, like a private _state variable. Otherwise you'll have a recursive loop

graceful citrus
#

thats what thats about

night mural
graceful citrus
#

to confirm, with continuous detection, i can go at any speed and never phase through?

night mural
#

or up the physics step which is pretty low in unity by default

polar acorn
short hazel
graceful citrus
#

actually i have no idea if unity had terminal velocity

polar acorn
median ruin
#

Is there a downside to just doing

public bool state = false;
```?
graceful citrus
rare basin
graceful citrus
#

actually drag = 0

rare basin
#

in the 1st option

graceful citrus
#

so in terms of physics, that wouldn't make sense

polar acorn
earnest atlas
median ruin
night mural
# graceful citrus does unity not have a maximum fall speed

Your life will be much easier of you watch this and have an actual understanding of how the physics engine works. It's probably not how you are imagining:
https://www.youtube.com/watch?v=NwPIoVW65pE

GDC

In this 2015 GDC talk, QWOP creator Bennett Foddy explains how to make your game feel solid without writing your own physics engine or breaking your entire game.

GDC talks cover a range of developmental topics including game design, programming, audio, visual arts, business management, production, online games, and much more. We post a fresh G...

▶ Play video
short hazel
polar acorn
earnest atlas
#

yeah found it

graceful citrus
#

but i suppose coding that is more intensive than just getting pretty close

polar acorn
night mural
#

even in scientific applications, they're just doing approximations (better ones, but still)

bold wren
#

can someone explain why unity is changing the unitystream.unity3d to unitystream.unity3d.tmp?

night mural
slender nymph
bold wren
graceful citrus
#

idk what i was thinking about that

night mural
slender nymph
night mural
#

and constraining yourself to it will make your life really hard

graceful citrus
#

i mean true

#

also that would involve simulation every subatomic particle

#

and if unity can barely run a couple thousand navmesh agents, it sure as hell can't run enough subatomic partles for anything visible to the naked eye

earnest atlas
#

The moment normal pc can run that optimization in code probably will go to second plan

#

Or compiler will do most of the job

carmine sierra
#

hi i think I have an issue with this line, I dont see the sprite so could it be something to do with the camera's z position?

graceful citrus
#

im unsure the technical terms on rendering

slender nymph
languid spire
graceful citrus
#

ok turns out unity is much better at handling things then i thought

#

i can spawn thousands of rigidbodies at little to no impact on performance

#

im chilling turns out

languid spire
carmine sierra
eternal needle
graceful citrus
#

what do you suggest?

eternal needle
#

🤷‍♂️ i dont even know what you're trying to do. also "it works on my machine" is nice and all, until someone else runs it and gets confused how this game even got published when it runs at 2fps

warm depot
#

Hello, is it possible to create a game object outside of classes and then reference them inside classes?

graceful citrus
#

i have code intended to spawn 5 rigidbodies in random places but i felt the primal urge to turn 5 into 1000 and it surprisingly worked

eternal needle
rough valley
#

I have a problem, when I have one button it works normally, but when I have more than one, they both stop working

#

Can someone tell me why?

#

Or how to fix this

carmine sierra
#

should i make all GUIS UI objects?

summer stump
#

Is one button covering the other?

rough valley
#

No

eternal needle
warm depot
graceful citrus
#

and fall to the ground

carmine sierra
rough valley
#

The red button is the back button (back to main scene) and the "Upgrade1" for a upgrade @summer stump

summer stump
rough valley
eternal needle
polar acorn
# rough valley

And if you delete either button, the other one works normally?

summer stump
#

The scaling and size seem messed up perhaps?

rough valley
eternal needle
# graceful citrus they all spawn in the air

and all are colliding with each other? Use the profiler and see for yourself how the performance is. Also remember what i said above, it runs on your machine but if someone runs it and gets 2fps, they are refunding your game

carmine sierra
#

should all menus be UI's

summer stump
rough valley
carmine sierra
summer stump
#

they can be worldspace ui if you want 🤷‍♂️

polar acorn
carmine sierra
carmine sierra
#

i should probably just learn how to use it

summer stump
#

you can have it overlay the camera if you want

polar acorn
# rough valley

Do you get any errors in the console when you try to run the game with both buttons on it

summer stump
#

you can have it be its own scene too

#

it depends on what you want

graceful citrus
carmine sierra
#

I was just thinking it might be harder to reference but it shouldn't be right

summer stump
#

perhaps easier, because UI usually exists before the scene starts

#

but not always

rough valley
polar acorn
carmine sierra
#

i have a general question, as a beginner whos basically making multiplayer angry birds but with the barebones features, do you think a month and a half to complete it is do able

polar acorn
carmine sierra
#

using mirror networking

polar acorn
carmine sierra
#

so what should I consider for multiplayer while im developing it

polar acorn
#

You shouldn't

carmine sierra
#

I need to though

polar acorn
#

why

carmine sierra
#

already written it up that itll be multiplayer

carmine sierra
#

it will just be two players

#

room based network

polar acorn
rough valley
#

I did

carmine sierra
rough valley
#

Object reference not set to an instance of an object

polar acorn
summer stump
#

If you develop the game for singleplayer and decide to do mp, you'll be rewriting most of your code (basically starting over)

At least huge chunks of it

warm depot
#

how would I get Destination over across these classes

summer stump
eternal needle
polar acorn
frigid sequoia
#

Just a tiny detail to have in mind on the future, when I am checking for stuff like... is something within the range of X; the if should be a < or <=; does this have any significant impact in performance or it doesn't matter?

polar acorn
frigid sequoia
#

Is not really relevant, the differnece is nimial, that's why I am asking, cause I have found this case several times, and I don't know if I should be doing a <= when a < would do almost exactly the same

polar acorn
#

There is no better or worse

#

just use the one you want

warm depot
frigid sequoia
ivory bobcat
#

If it were me, I'd reference an instance of the other object and access a public member

summer stump
warm depot
#

oo

#

what does a public member variable look like

summer stump
ivory bobcat
#

It'd have the public accessor next to it

polar acorn
warm depot
#

so it'd be like
public GameObject catObject;

polar acorn
#

probably

warm depot
#

and
public Vector2 Destination

#

but then how do I grab from the other class

carmine sierra
#

theres no better feeling than fixing a bug youve been working on for 2 hours

warm depot
#

getcomponent

summer stump
dull arch
#

why is my asset fly up and falling down

polar acorn
#

Do you mean an object in the scene?

dull arch
#

lol

polar acorn
# dull arch yes

Then either you've got code moving it up, your gravity is upside-down, or your camera is upside-down

dull arch
#

well my gravity is 3

#

no sorry 4

#

my camera doesnt look upside down

#

and i touched any script in this project yet

#

Is either supernatural or this is the biggest upside in history

polar acorn
#

Show the inspector of the object

warm depot
polar acorn
dull arch
warm depot
#

I don't understand what fields I'm supposed to fill in with what

summer stump
polar acorn
summer stump
#

You would be getting CatRoam is FMState is a MonoBehaviour somewhere down the line

summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

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

carmine sierra
#

Question, is the trouble and time needed to learn how to make a simple two player multiplayer game not worth it? Should I resort to making my game pass and play despite it being a worse experience

#

considering a 6 week deadline

shell sorrel
#

why a 6 week deadline

#

that is very short even for experieced people to make a good product

rocky canyon
#

u probably wont have a multiplayer game done in 6 weeks

shell sorrel
#

you are still learning

carmine sierra
queen adder
#

multiplayer is easier than fading ui as one element

rocky canyon
#

use a canvas group..

queen adder
#

id recommend fishnet

#

i use pro

rocky canyon
#

why am i having dejavu?

queen adder
#

haha

#

look at the X reacts

carmine sierra
shell sorrel
rocky canyon
#

brainstorming / outlining stage prob

median ruin
#

How do you update navmesh via code?

carmine sierra
rocky canyon
#

do local multiplayer

eternal needle
carmine sierra
summer stump
carmine sierra
#

room based connection

rocky canyon
#

local multiplayer is the middle ground between single player and multiplayer

#

ohh if its a connection its still technically full multiplayer

#

i mean 1 screen 2 players

shell sorrel
carmine sierra
rocky canyon
#

ez sauce

ripe shard
#

Some people like to make ui harder than it is.

north kiln
queen adder
#

the solution with render textures taking up the entire size of screen negates performance by 2-3x, the other solution involves rewriting the whole ui system from what i was told

rocky canyon
queen adder
unreal imp
#

Guys, is there any way to do something like this? Is it about reducing the distance from where the bullet takes a collision with the forward of the crosshair? and also when it hits with that forward, the forward of the bullet will be the same as that of the crosshair. heres a cheap graphic

carmine sierra
carmine sierra
#

i know i want it to be a client-server connection

summer stump
queen adder
# rocky canyon ez sauce

now try outlining the text, thick enough so that the outline of letters overlap, then do the same test.

carmine sierra
#

it will be hosted on one player's compute

rocky canyon
#

ya, i dont overlap my text..

carmine sierra
#

and the other player will just connect to it

rocky canyon
#

just simpler to avoid some problems..

#

by not creating them in the first place ;d

queen adder
#

maybe its integral to the games design

#

to have outlines like that on the text

#

and you cant just “not do it” to avoid the issue

rocky canyon
#

if it was then id still probably not do it.. i seen ur issue the other day.. try not using TextMeshPro/ overlapping text/ or maybe make a graphic out of the text and just fade the graphic instead

ripe shard
#

before you do UI in a game, learn what your UI framework is capable of and can do simply. Staring with a fancy idea that needs 100s of shims and extensions and complaints in a forum is a bad design.

queen adder
#

and you seriously post a gif of yourself changing the canvasgroup alpha like i dont know how it works…

median ruin
#

Why doesn't this work "NavMeshBuilder.BuildNavMesh();"? NavMeshBuilder doesn't seem to have a method called BuildNavMesh..?
I'm trying to rebuild the navmesh in a script.

shell sorrel
#

if its intergral to the game design, it should not be a big deal doing the work rendering to texture, or messing with the stencil shader

queen adder
#

the problem i guess is choosing a 3d engine trying to make a true-2D game

#

because unity uses meshes for everything

eternal needle
north kiln
queen adder
#

godot and html5 canvas

rocky canyon
spiral narwhal
#

How would I get a random Vector2 that is inside a collider?

queen adder
#

but godot 4 cannot export to web with C# backend yet

north kiln
#

It seems like they just have a render texture

shell sorrel
eternal needle
rocky canyon
#

i know u can use bounds and stuff for more primitive colliders i think

summer stump
ripe shard
#

you can just setup skia in unity and then write its buffer to a render texture

queen adder
#

what’s skia?

ripe shard
#

what all browsers use to draw 2D

#

might be a bit low-level, and you have to DIY the whole interactivity bit on top of that yourself

queen adder
#

i have an idea. a component you can attach to a ui gameobject. then it will calculate the bounding size of the object and all its children, create new canvas with camera render mode and camera rendering to a rendertexture of this calculated bounding box size. then it would replace the original element with a rawimage showing the rendertexture

#

could it be done?

#

i think there will be scaling issues

#

with mouse events but yeah

#

thats my current working idea

#

i just gotta make it

rocky canyon
#

if theres something about unity you dont like you can always make stuff for it..

#

then you can turn around and make an asset from it.. and make some monah 💸

shell sorrel
rocky canyon
#

cha-ching

queen adder
#

i dont know about the cost of creating new separate camers and render textures for each set of elements i wanna do this for, but if the RTs arent full-screen maybe its cheaper

carmine sierra
#

this might be a stupid question but if I get a nullreferenceexception error when it should have occured, is it a bad thing despite the rest of the code still working?

queen adder
#

cameras in unity are pretty optimized tho, right

shell sorrel
carmine sierra
rocky canyon
#

if its a null error from your code you need to fix it asap

ivory bobcat
summer stump
carmine sierra
#

a bit more variables up top

rocky canyon
#

it'll tell us if the null error is a problem.. or if its a unity bug (that a restart) could solve

queen adder
carmine sierra
summer stump
carmine sierra
rocky canyon
#

show console error

queen adder
#

anyways, the problem with scaling comes from moving the elements from the original canvas onto another one. it has to be at the exact same transform and the second canvas would need the exact same canvasscaler properties for it to work

carmine sierra
summer stump
ivory bobcat
#

It's null. Determine why.

queen adder
#

im gonna work on a prototype

carmine sierra
#

i know why it's null

#

but do I need to change it

summer stump
carmine sierra
#

as it is working as intended

rocky canyon
#

a null error is bad

carmine sierra
#

just that it is also intended that clicking the object when weaponinstance is null won't do anythinhg

rocky canyon
#

it'll probably break ur code if thers any code running after the error

summer stump
#

That is an unnassigned reference error

rocky canyon
ivory bobcat
#

Unhandled errors will ruin your game

summer stump
#

Not a null reference error

carmine sierra
rocky canyon
#

if it could be unassigned then u should change ur code to react to that..

#

when it gets used.. check if its there first..

shell sorrel
carmine sierra
rocky canyon
#

if(weaponInstance){//now run code that uses weaponInstance}

summer stump
summer stump
short hazel
#

Exceptions, as their name suggest, are exceptional. They should not happen during normal operation.
If one occurs, no code after it will be executed on the method for that frame

shell sorrel
rocky canyon
#

yup, ez fix.. change ur code around a bit to account for that possibilty

carmine sierra
#

I will fix it though thanks

summer stump
#

At LEAST that frame will be ruined

rocky canyon
#

lol, very minimum

carmine sierra
#

i see

summer stump
#

If you see an error, stop everything you are doing and resolve it

shell sorrel
#

if something is aloud to be null and you dont want to use said thing if its null just null check it with a if statement

#

if its not to supposed to be null fix it

short hazel
#
obj.transform.position = Vector3.one; // let's say this throws an exception
Debug.Log("sample"); // this will NOT be executed
rocky canyon
#

^ so depending on when the error happens it can be minor.. or can ruin the entire script

ivory bobcat
#

Or other things on the stack that's being resolved as well

rocky canyon
#

the final goal is to have ur console appear like this 🙂

#

Debugs get removed from normal builds right?

short hazel
#

They get written to the player log file, IIRC

#

Which can slow down the game

carmine sierra
rocky canyon
#

u need code to deal with it if it is

#
if(weaponInstance)
{
      //now run code that uses weaponInstance
}```
#

anytime theres a possibility it may be null.. and you're aware of that.. you need to make sure no code runs while its null

#

or no code runs that tries to use the reference that is null

summer stump
rocky canyon
carmine sierra
rocky canyon
#

like how raycasts are normally wrapped in an if statement.. if the raycast doesn't hit anything u dont want the code to try to do anything with the hit (which wouldn't exist)

carmine sierra
#

the error is gone nwo

rocky canyon
#

edge-case <-- a case that may happen.. even if it is rare

#

like an unlikely use-case

carmine sierra
teal viper
rocky canyon
#

im 100% in agreement with this statement ☝️

short hazel
#

Edge case is a possibility you didn't account for.
Example, you open a file to write to it, but didn't account for the possibility that the file is already in use by another program, throwing an exeption when you try to open a handle to it

rocky canyon
#

Render Features are 🔥

teal viper
queen adder
queen adder
teal viper
#

Check the link above. It might give you a quick start and the ide of what you need to learn to achieve the effect.

queen adder
#

gonna look through it

#

thanks

vague dirge
#

I was wondering, my character can snap to a surface on input, as if it could stick to it, and I'm searching if it's possible to rotate also the Cinemachine camera orbits, as if the referencial was changing. Is there a way to achieve this ? Maybe it could be useful to have a way to edit the camera global axis ?

rocky canyon
#

i'd like to believe theres a setting in the component you can use to offset the camera like that

#

"dutch angle"

#

im not gonna get lying tho.. dont know nuff about it

eternal needle
rocky canyon
#

oh ya that too, forgot about that tickbox

vague dirge
#

Do I need to add some code maybe

eternal needle
vague dirge
#

Okay thanks gonna search dat

spiral narwhal
#
Destroying assets is not permitted to avoid data loss.
If you really want to remove an asset use DestroyImmediate (theObject, true);
UnityEngine.Object:Destroy (UnityEngine.Object)

Why am I not allowed to use Destroy?

eternal needle
spiral narwhal
#

I want to

eternal needle
#

Then read the message again and you'll learn how to

spiral narwhal
#

Read my message again

#

Why

#

Not how

eternal needle
#

Destroying assets is not permitted to avoid data loss.

spiral narwhal
#

But I've used Destroy a lot and that never happened :o

eternal needle
#

Because you are now trying to destroy an asset, a file in your project

#

not a game object in a scene

teal viper
#

You probably never destroyed an asset

spiral narwhal
#
private void DestroySelf()
        {
            foreach (var drop in _drops)
            {
                if (!Chance.Of(drop.Chance)) continue;

                var amount = Random.Range(drop.MinAmount, drop.MaxAmount);
                Enumerable
                    .Range(0, amount)
                    .ToList()
                    .ForEach(_ => ItemDropService.Instance.DropFrom(
                        transform.position,
                        PlayerMovement.Instance.GetFacingDirection(),
                        drop.Item)
                    );
            }

            if (!_destroyOnDeath) return;

            UnregisterSelf();
            Destroy(gameObject);
        }
#

That last line is the one

#

I thought that just destroys the object that has the script

summer stump
#

Can you show the inspector for that object?

queen adder
spiral narwhal
summer stump
#

Do you have a variable called gameObject?

polar acorn
spiral narwhal
#

Ah

#

Yes it is a prefab

polar acorn
#

What calls DestroySelf

queen adder
#

And i understand the concept of the stencil buffer, i just dont know how to set it up globally on my ui

spiral narwhal
polar acorn
spiral narwhal
#

A tool Scriptable Object

            if (_dealDamageToTiles)
            {
                var exists = TilePlacementService.Instance.PlaceableExistsAtPosition(roundedMousePosition);
                if (!exists) return;

                var tile = TilePlacementService.Instance.GetPlaceableAtPosition(roundedMousePosition);
                tile.Damage(_dealtObjectDamage); // <--- here
                ConsumeDurability(1);
            }
#

Basically whenever the player left clicks a tile

shell bane
#

Goodnight. I have a problem and I don't know how to solve it. When I click play to move to the next screen, it says there is no camera. Does anyone know how to solve it?

polar acorn
spiral narwhal
#

It is

polar acorn
carmine sierra
#

I don’t need anything spoonfed but how would you begin to go about creating an effect like this

spiral narwhal
#

I don't want to, I want to destroy it as if it were a normal object

polar acorn
polar acorn
shell bane
#

Main camera

#

yes

queen adder
summer stump
spiral narwhal
polar acorn
polar acorn
carmine sierra
queen adder
#

isn’t the unity ui system render pipeline-agnostic?

summer stump
spiral narwhal
#

The copy of the prefab

summer stump
teal viper
spiral narwhal
carmine sierra
# summer stump What effect?

It would show a stretching triangular sort of shape (as seen in the photo) which originates at the slingshot ammo

polar acorn
summer stump
carmine sierra
#

I was going to just make a normal slingshot but I’m having issues with the projectile motion if the weapon is pulled back

summer stump
shell bane
summer stump
carmine sierra
spiral narwhal
# polar acorn which one

So at runtime I spawn a bunch of these that all have the DestroyableObject prefab. And that DestroySelf method should destroy the spawned rock, not the prefab

shell bane
summer stump
#

I am not great with 2d, but I think you could stretch a sprite renderer

polar acorn
polar acorn
# shell bane

So, I don't see a camera in the Menu scene, meaning before Jogo loads it would be showing that error. Is that first screenshot before or after starting the game and attempting to change scenes?

spiral narwhal
summer stump
#

The destroy the cached object

polar acorn
spiral narwhal
#

I don't

polar acorn
#

So then how do you intend to reference the object created by Instantiate

shell bane
#

my game always worked normally, not what changed

polar acorn
# shell bane first screenshot after starting

So, if that's what the hierarchy looks like while the message is displayed, that would be the problem. There's no camera in that scene, at least none that I can tell at a glance is a camera

spiral narwhal
#

Thank you

shell bane
#

If I add another camera, the error does not appear, and the screen does not change, it remains in the main menu

dull arch
#

can some explain what bool jump = false; mean compared to bool jump = true;

frigid sequoia
#

I cannot play an animation clip on command without an animationController right? There is no such thing as a .play for the animation component isn't it?