#💻┃code-beginner

1 messages · Page 601 of 1

rocky canyon
#

unless it doesn't dip below 0 then that doesnt wrk lol

frigid sapphire
#

Alr I feel stupid it works now

#

But the dropped item image doesnt change

rocky canyon
slender nymph
#

ClampMagnitude could be used instead to ensure that magnitudes below 1 are allowed but it cannot go beyond 1

rich adder
frigid sapphire
#

droppedItem = Inventory.Last();

rich adder
#

ah good ol Linq

#

one sec

rocky canyon
#
   private void Update()
    {
        moveInput.x = Input.GetAxis("Horizontal");
        moveInput.y = Input.GetAxis("Vertical");
        moveInput = Vector2.ClampMagnitude(moveInput, 1);
    }``` that is cleaner thanks Box 👍
rich adder
frigid sapphire
rich adder
#

its not doing anything

frigid sapphire
#

Yeah I tried droppedItem.SourceImage but that just gives me an error

frigid sapphire
# rich adder what is the error ?

'Image' does not contain a definition for 'SourceImage' and no accessible extension method 'SourceImage' accepting a first argument of type 'Image' could be found (are you missing a using directive or an assembly reference?)

rich adder
#

your ide is not configured is it?

frigid sapphire
#

ide?

rich adder
#

yeah like your code editor

#

thats not a property on Image

#

it should show you all the correct properties you can use

frigid sapphire
#

Yeah I don't remember configuring anything

rich adder
#

!ide

eternal falconBOT
frigid sapphire
#

Oh I got it to work its droppedItem.sprite

rich adder
#

yes..

#

but make sure IDE is configured

rocky canyon
frigid sapphire
#

Yep got it

rocky canyon
#

def snappy af now

#

lost my ball

red igloo
rocky canyon
#

u can apply ur own gravity to it when its not grounded

rich adder
rocky canyon
#

u can just crank up the gravity in general.. but may need to adjust ur forces

rocky canyon
rich adder
#

you can omit that and do
rb.velocity = (horiz, rb.velocity.y, vertical)

cunning rapids
#

If it's RB just decrease air drag when not grounded

rocky canyon
#

^ pass in its own y velocity in that slot

rich adder
#

if you keep it at rb.velocity.y it gets affected by gravity as normal

cunning rapids
#

Or just go edit -> project settings -> physics -> change y gravity from there

rocky canyon
#

its more about him manually changing his velocity than that

#

good guess tho.. thats what i defautled to as well.. then i remmebered the code

cunning rapids
#

I just came here so idk what's the main goal here

rich adder
#

if you want custom than yeah do yvelocity * customGravity

cunning rapids
#

Just took an educated guess

rich adder
rocky canyon
#
    private void FixedUpdate()
    {
        // Preserve the Y-axis velocity (gravity effect)
        float yVelocity = rb.velocity.y;
        movement = new Vector3(moveInput.x * moveSpeed, yVelocity, moveInput.y * moveSpeed);
        rb.velocity = movement;
    }
red igloo
rocky canyon
#
using UnityEngine;

public class BallController : MonoBehaviour
{
    [SerializeField] private Rigidbody rb;
    [SerializeField] private float moveSpeed = 100f;

    private Vector2 moveInput;
    private Vector3 movement;

    private void Start()
    {
        rb = this.GetComponent<Rigidbody>();
    }

    private void Update()
    {
        moveInput.x = Input.GetAxis("Horizontal");
        moveInput.y = Input.GetAxis("Vertical");

        // Clamp the magnitude to ensure it doesn't exceed 1
        moveInput = Vector2.ClampMagnitude(moveInput,1);
    }

    private void FixedUpdate()
    {
        var rbY = rb.linearVelocity.y;
        movement = new Vector3(moveInput.x * moveSpeed,rbY,moveInput.y * moveSpeed);
        rb.linearVelocity = movement;
    }
}
``` this is ^
cosmic dagger
#

It's best to make a custom gravity component and attach it to the GameObject. Then you would scale by the value on that component (which internally scales by a global custom gravity) . . .

rocky canyon
#

^ aye.. man knows his physics

rich adder
#

pretty good idea

rocky canyon
#

i hardly ever use the mass of an object tbh lol

rich adder
rocky canyon
#

i probably should more often 🙂

rocky canyon
rocky canyon
rich adder
rocky canyon
#

URP Template and BiRP Templates planned
with ur necessities..

  • 2D package
  • Cinemachine
  • TMPro Essentials
  • Possibly PrimeTween
rich adder
rocky canyon
rich adder
#

all you need is something like the packages manifest...

slender nymph
# red igloo

you must be using a slightly older unity version, it's just velocity on that rather than linearVelocity like in 6

rocky canyon
#
{
  "dependencies": {
    "com.unity.2d": "latest",
    "com.unity.cinemachine": "latest",
    "com.unity.textmeshpro": "latest",
    "com.unity.inputsystem": "latest",
    "com.unity.shadergraph": "latest",
    "com.unity.vfxgraph": "latest"
  }
}```
rich adder
rocky canyon
# red igloo

oh yea, sorry about that.. the newer versions of unity have velocity deprecated

rich adder
rocky canyon
#

theres angularVel and linearVel now

rich adder
#

you can recognize old functions in new api and can be changed but old API has no clue what new API is

#

for the old api its nonsense

rocky canyon
#

yea, unity tells me would u like to change API to work w/ older blabla

rich adder
#

ya I think it autoconverts them or something

rocky canyon
rocky canyon
#

backup? pfft

rich adder
#

live dangerously

rocky canyon
rich adder
#

my projects are my new Rogue like. As soon as I hit a NRE I will delete the project

rocky canyon
#

not sure what'd i do if i lost my scenes and settings folders 🤪

rocky canyon
#

i want to keep my templates third-party free

#

for the most part

rich adder
#

we can also add custom repos

rocky canyon
#

ive gotten tired of duplicating template projects

#

gonna try out custom templates for a bit..

#
  • i can use custom icons 👀 weeeeeee
rocky canyon
rich adder
#

1 more reason custom templates button in hub would be neat

#

browse.. -> templateFile -> bamm new template added

red igloo
rocky canyon
#

thats rotation..

#

u never actual control any of hte rotation

#

u can tick the Freeze Constraint on all the rotations

rich adder
#

probably collding with the ground its making it rotate

rocky canyon
#

if u want..

#

if not u can set its angularVel to 0 in code

rich adder
#

yeah youd have to freeze constrain

rocky canyon
#

when not actively pressing inputs

red igloo
#

I want it to rotate only while moving

rich adder
#

apply your own rotation

#

cause technically you're pushing the ball not rotating it

rocky canyon
#

^ the ground is wats rotating it

rich adder
#

angularVelocity rotates it

rocky canyon
#

my internet is running like molassis

red igloo
#

how much MBPS do you guys get?

rocky canyon
#

not as much as advertised thats for sure

#

500 or so i think

rich adder
#

what confuses many is also Megabits vs Megabytes

#

ISP are sneaky they advertise megabits usually

rocky canyon
#

yea i get mbits / sec

#

i think they all are

ivory bobcat
#

I'm assuming you're referring to download speed (megabytes per second). It would be dependent on your Internet service provider. If you're referring to Unity's network speed (max threshold), I'm uncertain.

red igloo
#

I remember when I use to get 50 + MBPS lol

rocky canyon
#
    private void Update()
    {
        moveInput.x = Input.GetAxis("Horizontal");
        moveInput.y = Input.GetAxis("Vertical");

        moveInput = Vector2.ClampMagnitude(moveInput,1);
        shouldSpin = moveInput != Vector2.zero; // are we inputting?
    }

    private void FixedUpdate()
    {
        var rbY = rb.linearVelocity.y;
        movement = new Vector3(moveInput.x * moveSpeed,rbY,moveInput.y * moveSpeed);
        rb.linearVelocity = movement;

        if(!shouldSpin)  rb.angularVelocity = Vector3.zero; // should we spin?
    }
}
red igloo
#

now I get around 300 +

rich adder
#

they're diff lol

rocky canyon
#

SPIN B GONE

ivory bobcat
rich adder
#

50Megabits is pretty slow lol

#

thats like 6 Megabytes a second

rocky canyon
#

i supposedly get 500 rofl

rich adder
#

damm thats ruff

rocky canyon
#

not too bad..

#

we have lots of devices streaming

rich adder
#

thats like 12 MegaBytes

rocky canyon
rocky canyon
#

theres bad weather.. so that kinda influences it too

#

i have no idea why. but it does

rich adder
#

hmm was expecting more tbh

rocky canyon
#

ahah scrub trying to flex

rich adder
#

im also pretty far from my router and its wifi

rocky canyon
#

same.. if i had hardline it'd be much much higher

rich adder
ivory bobcat
#

Yeah and depending on the server (website), you'll get different rates - real world application. Speed test servers are usually pretty fast.

red igloo
rich adder
#

my friends have like Gigabit connections (they really do be flexing ) lol

rocky canyon
#

sorry i thought that was more obvious

#

altho im not sure what ur equivilent to angularVelocity is

cunning rapids
rich adder
#

yes its a shitty marketing tactic

rocky canyon
#

lmao.. steam be putting out 12mb/s tops

rich adder
#

making ISP sound stronger than it is

rocky canyon
#

net nuetrallity?

rich adder
#

wow 300mbs! oh.. thats only 30MBs..nvm

cunning rapids
#

50 MB/s is like 400 Mbps

ivory bobcat
rich adder
#

yeah its misleading af for your average folk

rocky canyon
#

in ur case @red igloo you may want to modify the angularDrag to stop it from spinning

rich adder
#

they need to stop making games that are like over 100GB I wouldn't mind slow internet..

cunning rapids
#

There used to be an issue in Europe where they'd confuse Watts for brightness

#

Instead of lumens, which is the actual unit of brightness

#

So to represent power they'd use kWh/1000h

#

Which is just insane

rocky canyon
#
    [SerializeField] private float stopSpinDrag = 5f; // Higher value makes it stop spinning faster
    [SerializeField] private float normalDrag = 0.05f; // Low value allows normal movement```
```cs
     // instead of instantly stopping rotation like I do..
     // you can set the angularDrag to a really high number to stop it
     // and set it back to a normal drag value when ur not
        rb.angularDrag = shouldSpin ? normalDrag : stopSpinDrag;```
cunning rapids
rocky canyon
#

Europe kinda weird anyway.. i mean yall drive on the wrong side of the road.. for comparison

#

😈

ivory bobcat
cunning rapids
#

But yeah it can be weird there for sure

rocky canyon
#

esp yalls measurement system..

#

its bad enough i gotta use meters in all my software

cunning rapids
#

What's wrong with metric 😭

rocky canyon
#

i got a note-card with conversions

#

like im a grandma baker

rocky canyon
cunning rapids
rocky canyon
#

1 meter = half a characters height

#

ezpz conversion

rich adder
cunning rapids
rocky canyon
rich adder
#

its wild. Once we hit 1TB games

rocky canyon
#

call of duty is by far the Biggest game ive owned

cunning rapids
ivory bobcat
rocky canyon
#

lmao ive gottent to where i dont even update it until my friends want to play

rocky canyon
#

Update Queued! <- yea, and you'll stay that way 😈

#

2.39mb to be exact

ivory bobcat
cosmic dagger
ivory bobcat
#

Or double disk

rocky canyon
#

ya, sometimes my ISP wigs out and i get higher Upload speeds than download

cunning rapids
rocky canyon
#

its not very common tho

cunning rapids
rocky canyon
#

130 mb upload is intense

polar acorn
rich adder
#

yeah not much good there without streaming or anything'

rocky canyon
#

mmhmm "Please Insert Disc 2"

#

tbh i was always really impressed back then how they broke up an install on 2 disks

#

but i guess Microsoft did it way before

polar acorn
# rocky canyon mmhmm "Please Insert Disc 2"

Not quite. DOOM was basically three different games. You'd put in disk 1 and play Episode 1, then when you beat it you got kicked back to the menu. If you wanted to play an episode 2 map you had to put that disk in (or just copy the files over and play without the disk)

rocky canyon
#

tried to download photoshop back in teh day on dialup..
could never finish it w/o a disconnect. and then id have to restart..
took like 3 full days to finally finish it w/o failing

#

and then i think the next year Kazaa or Limewire became mainstream.. changed my world

rocky canyon
rich adder
#

ah yes I miss p2p viruses lol

rocky canyon
#

i can send u one real quick.. if ur after a hit of nostalgia

rich adder
#

when Limewire become Frostwire, things got sketchy quick

cunning rapids
rocky canyon
#

(╯°□°)╯︵ ┻━┻

cunning rapids
#

Although sometimes it feels like in practice it REFUSES to be 180 Mbps

rocky canyon
#

oh yea.. it knows ur running a speed test

rich adder
#

yeah feel like the test is inflating actual real loads

rocky canyon
#

it just exerted its entire energy for the day

cunning rapids
#

Lucky to even reach 5 MB/s lmao

rocky canyon
#

6ms ping is nuts tho

cunning rapids
#

Let alone 22

rocky canyon
#

are u sitting on top of ur ISP?

rich adder
#

its also depending on the server you're downloading FROM

rocky canyon
#

ahh yes, downgliding

rich adder
#

lol mykeyboard crazyy

cunning rapids
cosmic dagger
#

I usually have high download, but upload is always minimal . . .

rocky canyon
#

i imagine if i were hardlined i'd get 2x the speeds

#

but rightnow im just using a wifi dongle..

cunning rapids
#

Although wireless is pretty much obsolote for certain setups

rich adder
#

dammm flexing those DL speed

rocky canyon
#

pretty sh*T one at that

cunning rapids
rocky canyon
rich adder
#

i don't stream or anything anyway

rocky canyon
#

upload speeds are slept on 😦

#

u dont miss them until u do

cunning rapids
rocky canyon
#

lol my router was 20 bux muahahah

cunning rapids
cosmic dagger
#

I know some people who get TB speeds; it's insane. I usually have 20+ connected devices though, so a lot of it is split up . . .

cunning rapids
rich adder
#

wowzer TB is insane. I only know a few Gigabits thats about it

cosmic dagger
#

I don't stream as often as I used to. Probably 5-8 going on at one time . . .

rich adder
#

Google was popular where i was it was over 100Gbits but I moved and now got different ISP

ivory bobcat
# cunning rapids It's pretty standard

Reminder that the values are simply for pinging. If you're downloading, disk write speed would be a factor as well. Writing to USB 2.0 would likely limit the real world experience to less than 20MBps and if the files are small and many.. good luck.

cosmic dagger
rocky canyon
#

vs the router i once had

rich adder
rocky canyon
#

you could sneeze and lose it in the cracks of the walls

cunning rapids
rocky canyon
#

lots of things.. time of day, hardwired vs wireless, location of ping etc

#

but yea. usually lower than in practice

#

well, i feel more poor than i did before seeing everyones speeds 🤣

#

gotta get a fun project going to relax

rich adder
ivory bobcat
#

Yeah, everything's cached onto local servers. We aren't actually accessing files or servers across the world unless they're uncommon

rich adder
#

for all you know you could be downloading something from cambodia while you're in the US

rocky canyon
#

some of those speed sites will let u chose the server u ping to

red igloo
#

is it because of my camera?

#

when I turn off the camera script it no longer stutters

polar acorn
#

It gives it time to render before moving

red igloo
slender nymph
#

obligatory: use cinemachine

trail heart
#

I would guess either
The ball is an uninterpolated rigidbody and the platform is making it move in Update
Or the platform is an uninterpolated rigidbody (or otherwise moving in FixedUpdate) and making the ball also move in FixedUpdate

red igloo
#

the stuttering is fixed btw

trail heart
#

If there's uninterpolated rigidbody motion / position being updated in FixedUpdate, moving the camera to LateUpdate won't fix it but conceals the issue

rich adder
#

a moving platform should prob be a kinematic body moving in FixedUpdate with MovePosition so its motion aligns with rigidbody

trail heart
#

But that might be good enough

raw jacinth
#

i have always the same problem

#

idee for fing a solution

rich adder
#

well u kinda just left in the middle of us debugging it so..

raw jacinth
#

no u say me to find other code application

rich adder
#

not really. I just said its another option as well since its free

#

and rider is also a bit easier to setup in unity tbh

#

you haven't actually shown which SDK version you installed, did you restart afterwards?
where are you launching VS from ? show

raw jacinth
#

unity dont use C# language

rich adder
#

unity's api certainly uses c#..

raw jacinth
#

i install this

#

it is a SDK?

rich adder
#

and did u restart

raw jacinth
#

yes

rich adder
#

ok show where you are launching vs from

#

is it configured in unity

ivory bobcat
raw jacinth
rich adder
#

they mentioned unity so i got confused

rich adder
raw jacinth
#

I already did that

#

and dont work

#

i use chat gpt for help me

rich adder
#

chat gpt doesnt know shit

#

install Rider and call it a day

#

I could help you better in the context of unity anyway, since this is more of a general c# issue maybe try !cs

eternal falconBOT
hot laurel
#

your .csproj may still link to old sdk or dont have link at all

raw jacinth
#

ty

tough tartan
#

what would i do if i wanted when all enemies are not active, the next scene is opened?

rich adder
tough tartan
#

like in a script would i need a list or what

#

or make an empty gameobject holding all enemie

rich adder
#

well you want to keep track of all enemies somehow

#

arrays / list work best

tough tartan
#

how would i put the enemes into a list tho

#

cuz im used to having variables not proper objects

rich adder
#

it depends if they are spawned at runtime or have fixed number

tough tartan
#

fixed number

rich adder
#

if they're in the scene already make an array of whatever type your enemy is

#

[SerializeField] private Enemy[] enemies;

#

then select all enemies you want and put them in inspector field

tough tartan
#

how exactly

#

this is an enemy

wintry quarry
#

Drag and drop

tough tartan
rich adder
#

like an enemy manager or something

#

so you can loop them and check if its disabled, if one of them is enabled break the loop

keen perch
rich adder
#

you can probably make it more efficent by using events but thats a whole different monster rn..

tough tartan
#

idk what that all means bruzz

wintry quarry
#

You have a lot to learn about coding then

tough tartan
#

so would i write any cde

wintry quarry
#

Time to learn

rich adder
#

just an example```cs
foreach(var enemy in enemies){
if(enemy.gameObject.isActiveSelf == true) break; // one enemy was still active - leave loop;

//Otherwise we reach end of loop - All Enemies are disabled```

rancid tinsel
rich adder
#

oh wait nvm idk what it says scene

#

wonky

rancid tinsel
#

visual studio is being a pain again ig

slender nymph
#

the code is still wrong anyway though

rich adder
#

ya with position you need third argument for rotation

rancid tinsel
#

i see

rich adder
#

Quaternion.identity means no rotation

rancid tinsel
#

yeah i used that one

#

also i restarted VS and that seems to have fixed the error

rich adder
#

thats the first time i seen vs bugg out like that bad

#

idk where it got Scene from lol

rancid tinsel
#

yeah no clue, might be to do with the update from the other day

rich adder
#

yeah one update broke my assemblies, thats when I just went to VSC and never looked back

rancid tinsel
#

ive been hearing a lot of good about VSC, even my professor uses it

rich adder
#

idk wat they're pushing at m$ rn

rancid tinsel
#

but i hate change and im too used to visual studio lol

rich adder
#

yeah the Unity integration getting better each update

#

only 1.1 and its pretty much solid. Only cause its maintained by m$ open source community not Unity lol

hot laurel
rancid tinsel
wanton canyon
#

I am trying to insert an image into my text. I am using TMPro, and all the information online says to do "<sprite index = x". I put the sprite after conversion in sprite asset under extra settings in the text inspector, but the unity console is giving me error "invalid expression term '<'". My line of code: upgradeText.text = button.name + " " + upgradeNumber + "\n" + " <sprite index = 0> " + Math.Ceiling(minClicksToUnlock);

wintry quarry
#

(is your code editor showing you errors inline and auto completing things?)

wanton canyon
#

Never, I use Sublime and turned off all those features

wintry quarry
#

Well you have a syntax error

wanton canyon
#

I tried getting rid of the "" around <sprite index = 0> but that didnt work either. Im worried that <sprite index = 0> only works if I use it in the text field in the inspector, because I need to script all the text for these buttons

wintry quarry
#

What you're describing is a C# compiler error because you've written invalid C# code

#

Textmesh pro isn't really involved yet at this point

#

Can you show the full code and the full error?

#

It would really help you to use a properly configured IDE to avoid this kind of thing too

wanton canyon
rancid tinsel
#

im confused - I can't create a monobehaviour with the new keyword, but I also can't AddComponent?

rich adder
#

otherwise you need typeof

rancid tinsel
#

oh

#

thats so confusing

#

thank you

wanton canyon
hot laurel
#

upgradeText.text = button.name + " " + upgradeNumber + "\n" + <sprite index= 0> + minClicksToUnlock;

#

this doesnt look allright

rich adder
wintry quarry
wanton canyon
#

oh my gosh I am silly, I thought it was line 77 for some reason, thank you

wintry quarry
#

IDE would help avoid those errors 😉

#

You can turn off autocomplete

#

While still having error highlighting

wanton canyon
#

oh???

wintry quarry
#

Yes in VS the autocomplete is called Intellisense

hot laurel
wintry quarry
#

It's configurable on the options

hot laurel
#

nvim also have nice support for lsp errors

coral cape
#

I have my objects height and with right on the edges in rec transform, but what are these big light gray boarders around the text and how do I adjust their size?, theyre blocking interactions I have

rich adder
#

also not really code related q

warm mason
#

hi question, whats the best way to import and animate a character for my unity project? I have the character created with armiture/bones, etc. but no animations or anything.
Should I animate everything in blender or should I import it into unity before or whats the process? never done it before 😄 any tips/advice?

summer thorn
#

are classes internal by default?

hot laurel
steep rose
# warm mason hi question, whats the best way to import and animate a character for my unity p...

You could animate the character either in blender or in unity, I usually do the former because I am used to blender. As for the importation process you could use the FBX file type and unity should automatically make GameObject bones which you can animate in unity itself if you have not used blender for animation already. (unity will see the animations you made in blender as well if you select the animation button when exporting)

warm mason
steep rose
#

yes you can drag and drop the FBX file into unity's asset folder and it should just work

swift crag
#

notably: if you want to change the model, just overwrite the existing model file

#

unity will reimport it, and existing uses of the model will update

warm mason
#

im not expert but i can simply just scale down, right?

wanton canyon
#

it's best to have correct scale in Blender before importing

warm mason
#

i mean like

#

i dont know the units or conversions or what it would be

#

if that makes sense

wanton canyon
timber tide
#

1 blender unit can be compared to 1 unity unit

silk night
#

(with the right export settings, default is 1:100)

swift crag
#

export from blender with "FBX All" instead of "All Local" to get models to come in with a [1,1,1] scale

#

either way: try to have the scale correct in Blender in the first place

#

it makes things simpler

warm mason
#

i mean thats my scale rn

#

just 1

#

but in unity its a giant ;p

timber tide
#

also applying transform will produce less crazy units

warm mason
#

ok so

#

FBX all and check apply transform?

timber tide
#

Im actually not sure what the Apply Transform there related to

warm mason
#

oh

timber tide
#

but I click it anyway lel

warm mason
#

the warning sign scares me ;3

silk night
#

hover over it

#

and it will tell you why its there

timber tide
#

Object mode -> Ctrl A -> All Transforms

summer thorn
warm mason
#

so.. im confused. what SHOULD my scale be? cuz 1 is a giant. should i change it to like .1 or something?

timber tide
#

Sure, but after you do, Ctrl A before export

#

this will set a transform identity

warm mason
#

okay i understand

#

i mean it looks relatively okay in unity at .1 scale so

summer thorn
#

In vscode, after creating a script via dotnet new, I tried renaming the top of the hierachy from csproject to something else and now everything has fallen apart and won't run.. what can I do?

silk night
#

we cant help you without showing us any errors

polar acorn
#

Regenerate csproj files probably

summer thorn
summer thorn
#

When I try running .net generate assets I get this error

polar acorn
summer thorn
#

Could not locate .NET Core project in 'test'. Assets were not generated.

#

"test" is the name of my renamed project that i deleted, then deleted again from recycle bin

polar acorn
#

You really shouldn't be doing much in Visual Studio, Unity handles almost all of it

hot laurel
#

well its not unity related, it generated project via dotnet new

polar acorn
#

Then why is it in the unity server

spark knoll
#

Hey, dumb question but where can I learn C# in for unity? best yt or site

eternal falconBOT
#

:teacher: Unity Learn ↗

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

spark knoll
#

which one would you recommend?

heady remnant
#

I'm kinda learnig a little bit from chtagpt

spark knoll
polar acorn
heady remnant
#

but i'll need a new one

summer thorn
polar acorn
#

This isn't the place to ask about non-Unity C# stuff

#

There's a C# discord

summer thorn
#

Oh alr I'll try that

timber tide
#

hey, vscode is friend

frigid sequoia
#

Can I just tell this to not send a console error if the NavMesh does not exist or do I have to create a condition for it to skip it?

wintry quarry
#

If condition

frigid sequoia
#

Cause I don't really need that reference for anything else

#

So having a reference to that is kinda useless otherwise

wintry quarry
#

Remember exceptions don't just send console errors they also stop your code from executing any further

frigid sequoia
#

Yeah, it's the last step of that code fragment

wintry quarry
#

That code but what about the code that follows the method

#

You really don't want to be throwing exceptions randomly

frigid sequoia
#

It just happens that this can sometimes execute the first frame before the NavMesh has been enabled so it returns error

#

But other than that is fine

polar acorn
#

If statement

wintry quarry
#

Better yet fix your initialization sequence

dark laurel
#

imho I'd warn/log on something like that every time, even if you don't think it can happen, it invariably will during development.. even just:

var destination = GetAgentDestination();
if (destination == null)
{
  e("Destination was null. This is a bug.");
  return;
}
agent.SetDestination(destination.position);
#

e() is shorthand for debug.logerror or whatever

frigid sequoia
#

But if it's just the first frame does not cause any issue

dark laurel
#

then use a flag to see if it's initialized..

bool _isInitialized = false;
void Update()
{
  if (!_isInitialized) return;
  ...
}
#

(and set the flag to true whenever you know it's ready to use)

frigid sequoia
#

Yeah, so the easiest way is just to get a reference to the NavMesh

#

Oka

#

I just wondered if you could just say, "try this but if does not happen is alright"

wintry quarry
#

What actual exception are you seeing?

frigid sequoia
#

That you cannot really set anything from a agent that is not on a NavMesh cause the agent fails to exist until the NavMesh is

wintry quarry
#

NullReferenceException?

#

Something else?

#

What's the actual error?

frigid sequoia
#

I just changed the logic, huh, that should not happen right?

#

Oh, no, I think I see the issue now, isCombatTimeRunning and the NavMeshEnable happen at the same frame on the game manager

coral spear
# heady remnant I'm kinda learnig a little bit from chtagpt

🌍 Get the Premium Course! https://cmonkey.co/csharpcompletecourse
💬 Learn by doing the Interactive Exercises and everything else in the companion project!

🔴Learn C# Intermediate FREE Tutorial Course! https://youtu.be/I6kx-_KXNz4

🎮 Play my Steam game! https://cmonkey.co/dinkyguardians
❤️ Watch my FREE Complete Courses https://www.youtube.com/wa...

▶ Play video
#

I'd recommend this tutorial series for whoever is starting with c# and Unity. Or you can buy some books online to get the fundamentals as well

rich ice
# spark knoll Hey, dumb question but where can I learn C# in for unity? best yt or site

check out unity !learn or some online resources like
w3schools
brackeys
Code Monkey
microsoft docs
unity docs
and many more. google as always is going to be the best method for finding help (if all else fails, ask here)

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich ice
#

tools like ChatGPT also work. its prone to error though. in the worst case scenario, can be a bit of a bugger to debug, even for more experienced devs

#

also check the pins

warm mason
#

does anyone have any good resources to really learning C#/unity? Everything I run into is mostly just "Heres how to do this" but not how and why it works.

It gets frusturating when everything you read is just telling you how to do things but not actually why you're doing those things or why it works.

#

i didn't scroll up or see that btw ^^^

#

lol

split solar
#

hey so i made a minecraft like mesh but how do i add textures to each face? i want to be able to customize it. already got uv mapping done

timber tide
#

where did you do the uv mapping

split solar
#

perchunk on the whole mesh

minor reef
#

I have a small C# problem and I have to go to bed

#

If someone could call me for just a few I would appreciate it

naive pawn
#

just ask

#

!ask

eternal falconBOT
split solar
naive pawn
naive pawn
naive pawn
#

see one of the artist channels

split solar
#

it is a coding issue?

minor reef
naive pawn
split solar
#

yes a procedual mesh that is not premade

naive pawn
#

oh i see

#

probably setting materials or smth.... idrk that kind of stuff

minor reef
naive pawn
#

start with a description please

minor reef
#

I was following a character controller Brackey's tutorial and obviously made a very small mistake somewhere

naive pawn
#

discord can't embed mkv, convert it to an mp4 so it can be embedded

#

(also, so what's the issue)

ivory bobcat
minor reef
#

let me record again

naive pawn
#

you could just go convert the recording you already have

ivory bobcat
#

Just post the !code using an external link and explain what's happening and not happening

eternal falconBOT
naive pawn
#

also for future reference, a textual description would be easier than audio

naive pawn
#

paste a link to the site here instead of sending a screenshot

#

text is much more useful to us

minor reef
naive pawn
#

thank you

minor reef
#

When I start walking I teleport

naive pawn
#

after you teleport, you said you "weren't moving", but have you checked the inspector on the player to see if that's actually the case

minor reef
#

No I was moving but there was a barrier at spawn

naive pawn
#

can you show the inspector of the player

minor reef
#

Like the console?

naive pawn
#

no, the tab that says inspector that's on the right side by default

#

bruh you showed the thing i asked for last lmao

#

so it's scaled by a factor of 100.

it should probably not do that.

#

that's gonna skew other measurements

minor reef
#

so 1?

naive pawn
#

yeah, and then scale the mesh to make it an appropriate size

minor reef
#

Non-code related

#

how can I invert the look controls? I used Cinemachine

naive pawn
#

you don't have look controls

#

it's just following where you're going

minor reef
naive pawn
#

independant of the movement?

#

and you don't have a script for that?

minor reef
#

I don't think so

naive pawn
#

it's probably a cinemachine thing then, i haven't used cinemachine so i can't really help you. try asking in #🎥┃cinemachine

minor reef
#

goodnight

jovial pilot
#

Hi, im making a bird game. Does anyone knows why my bird cant stay on my cube? i put box collider, rigidbody (use gravity). My bird keeps going up down (stuttering)

jovial pilot
#

and yes, my ground cube has box collider

echo ruin
#

The information you’re giving is a bit vague. Have you checked to see if the collider on the bird is centered and sized appropriately for the bird? Have you done the same for the cube? Have you made sure that the colliders aren’t set as triggers?

jovial pilot
thin stream
#

playerRB is null! Cannot jump. Make sure Rigidbody2D is assigned.
UnityEngine.Debug:LogError (object)
PlayerMovement:Jump () (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:89)
PlayerMovement:<Awake>b__10_2 (UnityEngine.InputSystem.InputAction/CallbackContext) (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:48)
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr) i always get this error but the rb is active on the player ?

#

that always happens when i hit a enemy and restart and want to jump

fossil drum
thin stream
#

but the thing is i already looked into that i rewrite it again and again and still have the same issue

slender nymph
#

then show the relevant !code, preferably the entire PlayerMovement class so we can see where it is being assigned

eternal falconBOT
slender nymph
#

and do you see any of the other logs from that component in the console?

thin stream
#

beside of that not

slender nymph
#

what happened in the 3 seconds between the last successful jump and this attempt? that can help narrow down what may be happening

#

actually wait, your console is in collapse mode. turn that off and screenshot the entire thing

thin stream
#

the player loses after respawn his rb collider?

#

seems like

slender nymph
#

Is that all of the logs in the console or are there perhaps more above what you've shown

#

Because if I had to guess there's probably a much earlier log about the object not having a rigidbody and the component is probably attached to more than one object in the scene

#

Search your scene with t:PlayerMovement to check for duplicates

fossil drum
#

My guess is that the restarting of the scene removes the link with the RigidBody which he set in the editor.
Not sure how he's restarting it, if he just instantiates a new Player again.

#

But you can check that by just looking at the component after it has restarted the scene if it still has a link with the public rigidbody

thin stream
#

if i add that in console it does works then i can respawn again and jump again

#

and now does it work lmao?

slender nymph
#

I said search the scene not the console. You're hiding your logs by searching the console like that

thin stream
#

ok give me a sec

#

this is the playermovement

slender nymph
#

Is this search during or outside of play mode

thin stream
#

now gonna try it when i play

slender nymph
#

Do the search when the error starts happening

thin stream
#

it seems like it works perfectly rn

#

now it does work?

#

when i did search in console "t:playerMovement" after that it worked

#

what could be the thingy here?

slender nymph
#

most likely you changed something and didn't realize. searching the scene/console doesn't do anything

fossil drum
#

You also still get the error in the console at second 6

thin stream
slender nymph
#

you had error pause enabled before. so absolutely nothing has changed if you are still getting the error

#

add this log to the beginning of the Jump method and show the console when you get the error. i also recommend turning Error Pause back on so we can see exactly what is happening at the time of the error
Debug.Log($"Jump invoked on {name} ({GetInstanceID()}, with rigidbody {playerRB} and grounded state {isGrounded}");

thin stream
#

okk

slender nymph
#

please make your console window bigger so we can see the relevant logs

#

also are you certain you actually added the log i provided? because theoretically we should be seeing it above the error and also separately above the following jump attempted log

thin stream
#

ok

#

and yes

slender nymph
#

so where's the log i provided?

thin stream
#

where to find it

slender nymph
thin stream
#

do i need in code?

#

to look for that

#

or

#

playerRB is null! Cannot jump. Make sure Rigidbody2D is assigned.
UnityEngine.Debug:LogError (object)
PlayerMovement:Jump () (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:89)
PlayerMovement:<Awake>b__10_2 (UnityEngine.InputSystem.InputAction/CallbackContext) (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:48)
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
this?

slender nymph
#

no, i asked you to add a log to the code and you assured me that you had done so. you clearly did not.

thin stream
#

explain it better, because i dont find any log for it

#

or where i can find

#

i did added

#

wait

#

this is the jump

#

so the debug is there also

slender nymph
thin stream
#

ok lemme try

#

playerRB is null! Cannot jump. Make sure Rigidbody2D is assigned.
UnityEngine.Debug:LogError (object)
PlayerMovement:Jump () (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:89)
PlayerMovement:<Awake>b__10_2 (UnityEngine.InputSystem.InputAction/CallbackContext) (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:48)
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)

slender nymph
#

where is the log that i gave you

thin stream
slender nymph
#

please learn to read

#

i told you to put it at the beginning of the jump method

thin stream
slender nymph
#

okay so the issue seems to be that your Jump method is still subscribed to the input action's event but since you create a new instance of PlayerControls and subscribe in Awake that shouldn't be possible

thin stream
#

and how to fix that?

slender nymph
#

disable/dispose controls in OnDestroy

split solar
#

hm so let's say we got a matrix for chunks, how does one draw the mesh efficiently?

thin stream
slender nymph
#

what do you mean by that

thin stream
#

i dont see the controls in ondestroy

slender nymph
#

huh?

thin stream
#

or where to find it

slender nymph
#

OnDestroy is a method, controls is literally the name of one of your variables

thin stream
#

or you mean this? // Input-afhandeling
controls.Land.Move.started += ctx => direction = ctx.ReadValue<float>();
controls.Land.Move.canceled += ctx => direction = 0;
controls.Land.Jump.performed += ctx => Jump();
}

slender nymph
#

well first of all, you should at least be able to find controls since, as i already pointed out, it is one of your variables. and second, if you don't even know what MonoBehaviour.OnDestroy is, you should start by going through the pathways on the unity !learn site

eternal falconBOT
#

:teacher: Unity Learn ↗

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

slender nymph
#

nah, i'm done helping you now

thin stream
#

i sended u the script and u didnt even help to find them Monobehauvior.Ondestroy

slender nymph
#

you didn't even bother googling it

thin stream
#

i did

#

but i dont get it this way

slender nymph
#

then go through the pathways on the unity learn site

#

you're very clearly missing some fundamentals, so go learn them

thin stream
#

i dont

#

they always said if it works it works :d, and at some point when i dont use the pause console thing it works like normal

#

i can respawn

#

and jump

#

and still get hitted

#

but the error still appears

#

but works

slender nymph
#

ignoring your errors just because it isn't pausing is stupid

thin stream
#

nowp

#

it isnt stupid, bc as long the functions u needed does the job it will work

slender nymph
#

ah yes, then when your players get multiple game overs and their logs are being spammed with errors because you decided not to bother fixing them so the performance of the game is degraded i don't want to see you coming back crying about getting help fixing it

#

i also don't help people who refuse to bother learning the basics so i'm just going to block you now. good luck with ignoring your errors instead of the super easy fix 👍

thin stream
#

lmao😂 , with the wrong leg out of them bed

slender nymph
#

i just don't help morons who refuse to read the information presented to them 🤷‍♂️

thin stream
#

uhm u ever heard of non fast readers or people that just doesnt get it easy right bcs of stuff (adhd & autistic etc) bcs that shit and programming things while already fucked is fucked

#

it is not about refuse read

#

cause i read everything

#

btw i already found it

#

see

slender nymph
zinc lintel
lavish magnet
#

So in my game bascially you shoot barrels, when i shoot a barrel i want it to chip, i have split the model in blender into sdiferent parts of the barrel, and i also have a mesh where its all intact, but the mesh intact whilst separated just looks way different even when all parts are there. whats the best part to, when the barrel is shot a particle system plays where some pieces of the barrel flies out, and the actual barrel model visibly has a random part missing

night raptor
hexed terrace
remote lynx
#

IEndDragHandler doesnt get called when the drag ends but when u releade the buttom

#

İs there an event that runs when u stop dragging?

slender nymph
#

what does it mean to "stop dragging" in this case

remote lynx
#

When u dont move ur finger

#

Like the mouse stays in place

slender nymph
#

and how are you supposed to determine that the actual intention was to complete the drag and not just pause moving for a moment?

remote lynx
slender nymph
#

then you'll just need to check that the position hasn't changed within some arbitrary time

naive pawn
#

yeah doesn't sound like you want dragging

remote lynx
#

Ye but this is a mobile game and there are multiple touches

naive pawn
#

dragging is a composite action, mousedown + move + mouseup

remote lynx
#

Can you get the touch id on pointer down?

naive pawn
#

yes, but you wouldn't use pointer down for this

remote lynx
#

What do i use?

slender nymph
#

all of these interface methods that have been mentioned so far receive a PointerEventData parameter that contains info you may find useful

naive pawn
remote lynx
#

Yea i will manually track the movement but how do i get the touch drom poonter events

slender nymph
remote lynx
#

İ couldnt find it in that

slender nymph
#

did you try looking harder?

remote lynx
#

Hold on

#

There is pointerId but it isnt the touch index

remote lynx
#

İt is id not index it is a number like 1513...

slender nymph
#

what is the point of getting that anyway?

remote lynx
#

To get the touch and get rhe delta of the touch

slender nymph
#

why do you need to get the touch for that? the PointerEventData already contains the delta

remote lynx
#

Which event do i use ?

#

PointerDragEvet only works when you move the pointer/touch

slender nymph
#

And if you just need to determine if the pointer has stopped moving, you just need to figure out when OnDrag has not been called within whatever arbitrary time you pick

remote lynx
#

Which loop does event system run on?

viral stag
#

Does anyone know any tutorial or place to help. I am making a 2D game and I need to make barricades that ask a question which needs the correct answer to pass and not sure in how to do it. Thank you

remote lynx
#

Like Update LateUpdate FixesUpdate?

slender nymph
# remote lynx Which loop does event system run on?

i don't see the relevance in that question. just timestamp the last time the drag happened, once the time elapsed since that timestamp is beyond some arbitrary value you pick then it has "stopped dragging" (according to your logic)

hasty dragon
#

what is the method that returns a bool for if the game object is active?

slender nymph
cosmic dagger
viral stag
#

Yeah

brisk echo
#

Hi, I'm making a third-person character using a Character Controller, and was wondering if the movement script should rotate the whole game object or just the body visuals? Hierarchy is as follows:

  • Player (Root, has CharacterController)
    • Body (Visuals)

An example of movement style is Yooka-Laylee.
Character move forward and backwards in the directions of the camera but moves sideways facing to the side of the camera.

I figured this can be done easily enough by just rotating the body visuals only, but when I factor in other things such as Hitboxes for swords etc, should I rotate the whole game object or just the visuals and Hitboxes?
The character has a sword attack, so the attack hitbox needs to be properly aligned.

Just wondering which is the better approach for down the line.

slender nymph
#

rotate the root object so that it is always pointing the correct direction and you won't have to separately account for directional stuff

thin stream
#

is their an option to remove to get the full game at 1 screen without camera followement?

#

cause when i press play it doesnt follow the player?

#

i dont get an error also

brisk echo
swift crag
#

I try to make the character root have an accurate position, rotation, and scale

#

that way, I can do whatever the hell I want with the child objects (e.g. make the body shake around) and it doesn't mess with my game logic

lapis yew
#

Hmmm shaking children

#

I love that

swift crag
#

remember to reap your children!!

lapis yew
#

The harvest is bountiful

cerulean badger
#

I want to group methods from an external script in a dictionary, like:

public AnotherScript script;
Dictionary<string, ??> dict;

void Start(){
  dict = new Dictionary<string, ??>{
    {"Method1", script.Method1},
    {"Method2", script.Method2}
  }
}
#

but idk the name of the type the methods are

slender nymph
#

if they all return void and have no parameters then the type would be System.Action

#

but also why would you want to do this

cerulean badger
#

what if they're void but have parameters?

polar acorn
#

There is almost certainly a better way to do whatever it is you're trying to do

cerulean badger
cerulean badger
slender nymph
#

click the link and find out

visual linden
#

They posted what they were trying to do. If you suspect that they're approaching the problem the wrong way, or think what they're asking doesn't make sense, you can just ask for more information.
Referring someone to xyproblem instead of just telling them you don't understand what they're going for is not really a nice thing to do, and probably makes the person feel like they did something wrong.

slender nymph
#

i asked for clarification and also shared the xyproblem link to show why the clarification was needed. your pointless interjection about what is and is not "nice" is not needed here

burnt vapor
#

Also, https://xyproblem.info/ is a very informative site that thoroughly explains why their question might have to be reconsidered. That's likely something they didn't realize and it greatly helps if they read more about it.

visual linden
swift crag
burnt vapor
#

One thing I do think people have to realize is that linking sites like this is not in any way supposed to be a discouraging thing. These things happen so often that sites like these are really useful instead of explaining the problem ourselves.

#

Same with telling people how to screenshot, or to share code, or how to ask questions in general.

visual linden
#

No, that's fair. Maybe I just have a habit of baby'ing people a bit more because it's #💻┃code-beginner 😅

summer thorn
#

How would I add custom methods to string data type? public override string ToString() {content here} seems to override an existing method, but I'd like to add a new one

gaunt oar
#

Is it a channel for newbie?

slender nymph
#

by the sound of it, you are probably asking about extension methods? but you gotta provide more context

gaunt oar
#

I just have an idea and hear about unity 😅

summer thorn
polar acorn
swift crag
#

Yep, that's what you're looking for.

summer thorn
#

Thank youu

slender nymph
#

note that extension methods are basically no different than regular static methods in a utility class, they can just be called as if they are an instance method on specific types of objects

#

so you won't get access to anything that isn't public on the type

cerulean badger
#

well, in the meanwhile I found another solution to what I want to do, but if you're up to explain me, I'd appreciate how you do what I was talking about before just for the knowledge

slender nymph
slender nymph
stone flower
cerulean badger
visual linden
slender nymph
visual linden
#

👆 At this point I will agree

cosmic dagger
edgy tangle
#

Mainly, if you want to use the legacy input system, offload input gathering to a separate MonoBehaviour which raises events for inputs

#

Then any class which cares about input will just subscribe to those events

clear isle
#

Hey guys, I have a question, I have started to make a voxel engine within Unity to help with my future games, but I saw the news that Unity 7 will have significant (good) changes. Do you think I should wait for a beta of Unity 7 where the core CLR and .NET 9.0 have already been implemented?

edgy tangle
#

Then you’d have the ugly if/else or switch but it’d be hidden off into one class

#

Other option is use the “new” Input system

clear isle
naive pawn
silk night
visual linden
clear isle
silk night
#

Time waiting will be far larger than the time you need to upgrade

visual linden
silk night
#

even if the jump is a major version unity usually stays reasonably backwards compatible

clear isle
silk night
#

we had smaller projects upgrade from 2021 to 2023 (6) that only needed a package update and code changes in like 5 places after

silk night
#

also jobs do a lot more than tasks 😄

clear isle
silk night
#

You give up simplicity for performance

#

most of the time you are absolutely fine doing a computation on the main thread, simpler but slower

steep whale
#

anyone know why this is scaling a tilemap insanely small and no amount of code or inspector adjustments makes it bigger or smaller?:

using UnityEngine;
using UnityEngine.Tilemaps;

public class ScaleTilemapTiles : MonoBehaviour
{
    public Tilemap tilemap;
    public Vector2 scale = new Vector2(0.5f, 0.5f);

    void Start()
    {
     
        if (tilemap != null)
        {
            
            BoundsInt bounds = tilemap.cellBounds;
            foreach (var position in bounds.allPositionsWithin)
            {
                Tile tile = tilemap.GetTile<Tile>(position);
                if (tile != null)
                {
                    
                    tilemap.SetTransformMatrix(position, Matrix4x4.Scale(new Vector3(scale.x, scale.y, 1)));
                    Debug.Log("Scaling tile at position: " + position);
                }
            }
        }
        else
        {
            Debug.LogError("Tilemap not assigned! Please assign a tilemap in the inspector.");
        }
    }
}
frosty hound
#

You have your scale variable set to public which means it will be overridden by whatever value is in the Inspector.

#

Generally speaking, don't give your public variables a default value for that exact reason, and modify it on the component itself.

#

If you are changing it in the inspector ... then no idea, bad matrix math? 😬 Debug log the scale to verify

steep whale
rich ice
eternal falconBOT
rich ice
#

just makes it a little easier for us to read

winter creek
#

Hello, i need to put several colliders on my character, and link a script with OnTriggerEnter on each one,
Is it necessary to put as many rigidbodies as colliders?

steep whale
scenic crystal
#

hey guys question my instructors asking me to insert this here

#

and i have no clue how

hexed terrace
#

Type it..?

scenic crystal
#

but i have

hexed terrace
#

like, put the cursor where you want to add stuff .. and type what you see..

scenic crystal
#

it keeps giving me some weird error

hexed terrace
#

You have not

#

sorry, yes you have, the second screenshot is too pixellated

hexed terrace
#

You haven't typed exactly what was said either (you missed the { })

#

What you've been told to type is also shit code

wintry quarry
#

Yeah this is a bad tutorial

hexed terrace
#

Transform is an accessible property for every MonoBehaviour, you do not need to ever do GetComponent<Transform>() in this situation.

just do transform.position += upDirection;

winter creek
scenic crystal
hexed terrace
#

For every { you have, you MUST have a corresponding }

scenic crystal
#

but i do

hexed terrace
#

You do not, hence the error

scenic crystal
#

i dont see what im missing

hexed terrace
#

The error tells you what you are missing - a }

#

you've messed up the closing } of the method or class

scenic crystal
#

oh whoops

eternal needle
hexed terrace
#

you could just test it - quicker than asking and waiting 😄

#

Only ONE class will receive physics events though.

winter creek
swift crag
#

I always forget which is which

#

I want to say that triggers are received on both the object with the collider and the object with the rigidbody, but I could have that backwards.

swift crag
winter creek
swift crag
hexed terrace
swift crag
winter creek
swift crag
winter creek
hexed terrace
winter creek
swift crag
#

attached to the same GameObject

#

"objects" was vague there

hexed terrace
#

aye, why I asked for clarifaction :p

hexed terrace
swift crag
#

additionally, trigger messages are sent to the game object with the collider and the game object with the rigidbody

fleet venture
#

I am really confused does OnEnable get called on like ever script inside of an object when i Instantiate one?
i would expect a inactive script to remain inactive
but it seems to get activated

swift crag
#

however, collision messages are only sent to the game object with the rigidbody

swift crag
#

If it is not yet active and enabled, the method is run as soon as it becomes active and enabled

swift crag
#

this means that its game object must be active and the behaviour must be enabled

swift crag
#

Are you disabling it immediately after instantiation?

#

That's too late.

fleet venture
#

ok ill explain my rpoblem more then

winter creek
fleet venture
#

so does intantiate instantiate the original state

#

or the current state?

swift crag
swift crag
near wadi
fleet venture
#

but i thoguth i would move in here

hexed terrace
swift crag
fleet venture
swift crag
fleet venture
swift crag
swift crag
fleet venture
swift crag
#

log to the console

#

I see nothing in here that would cause a "loop"

fleet venture
#

ye its running straight after tile = Instantiate(gameObject, transform.position, transform.rotation);

#

i checked the callstack

#

with debug mode

swift crag
#

Oh, I see

#

it's instantiating itself

fleet venture
winter creek
hexed terrace
swift crag
#

There is no way for the behaviour to not be enabled and still reach that line of code

fleet venture
#

so how do i do this then?

#

i tried disabling it instantiating and then reenabling it but that didnt seem to work either

swift crag
#

Show that code.

#

I am a little surprised that that would not work

red igloo
swift crag
#

not the Spin state

#

perhaps you meant to have two animator layers

#

that lets you play multiple animations at once

fleet venture
swift crag
#

e.g. the number of game objects in the scene is over 500

red igloo
swift crag
#

or some criteria like that

#

I've done this before when chasing down infinite recursion

fleet venture
#

oh wait

#

this time it does work

#

weird

swift crag
#

on the subject of character controllers: I've gotten some really weird and inconsistent results from those

#

They act as a collider, so if a non-kinematic rigidbody hits it, you can receive a collision message

#

You can also receive trigger messages when you get hit by a rigidbody with a trigger collider on it...sometimes?

#

or was that kinematic rigidbodies that were inconsistent..

#

I'm not sure what the best option is here, actually. My first guess would be to put a kinematic rigidbody on the same object as the character controller

#

That should allow your trigger colliders to interact with all other trigger colliders (including those without a rigidbody)

#

I need to go test all of that stuff again.

rich adder
#

btw CC does 100% work perfectly fine if other triggers do not have rigidbodies to call OnTriggerEnter

swift crag
#

when the CC moves into the trigger collider?

rich adder
#

yea

rich adder
swift crag
#

actually, that's exactly what I was testing a while ago

#

notice how it doesn't instantly hit

#

it just kind of...eventually hits

#

i'm not sure what's going on there

naive pawn
#

ah yes, eventual consistency

swift crag
#

😭

rich adder
#

makes sense since its like a query of estimation and not actual collision?

#

Idk about how unity/nvidia deals with physics queries tbh

naive pawn
#

nvidia?

rich adder
#

yea nvidia made the physics

naive pawn
#

huh..

rich adder
#

Physx

#

the character controller is directly ripped from here

swift crag
#

I'll have to go bang colliders together some more to find out what's going on there

naive pawn
#

why does "physx" sound like a medical suffix...

rich adder
#

lmao

rich adder
rich adder
#

PxUserControllerHitReport::onControllerHit basically is OnCharacterControllerHit

swift crag
#

well, yeah, that's the point :p

rich adder
#

Note that the character controller does use overlap queries to determine which shapes are nearby. Thus, SDK shapes that should interact with the characters (e.g. the objects that the character should push) must have the PxShapeFlag::eSCENE_QUERY_SHAPE flag set to true, otherwise the CCT will not detect them and characters will move right through these shapes

I guess Unity applies this for all colliders

#

or is this for pushing dynamic rb. shits confusing cause there is also CCT-vs-dynamic actors section

red igloo
rich adder
#

eg what did you try

red igloo
rich adder
#

arent you pushing it already ?

red igloo
#

Like I want to be able to grab the object and drag and push and I want the object thats being pulled or dragged react to the ground

rich adder
#

did you try the joints? what happened there?

red igloo
red igloo
rich adder
#

thats why Im asking, did you try?

red igloo
#

is that the best way to do it?

rich adder
#

its A way to do, there is no "best way" usually

#

all problems get solved in different ways

#

i think joints will be the easiest to try and most straight forward

red igloo
#

which joint would be used in this case?

rich adder
#

I had luck myself for "holding planks" and stuff

rich adder
#

FixedJoint

#

if you want more slack try the other

red igloo
#

should that component be on the player?

rich adder
#

the tricky part is your object rotates

#

so you cant just anchor it to the ball

#

you'd need a way to solve that

#

for example making ball rotate only visually and not the actual rb

#

this would let you at least split independently

red igloo
#

If I made it so when the player presses E on the object and the object rigidbody is placed in the connected body (FixedJoint) would that work?

rich adder
#

well thats normally how you fix a rigidbody to something yes

#

idk if it works, you're the one who can test it lol

ruby python
#

Hi all,

I was just wondering if someone could point me in the right direction on where to look to achieve a 'mortar shell' launch and arc.

Idea being that the rounds get launched randomly from the red x's, and impact at random points within the green circle/area.

I'd like to be able to calculate the 'arc' of travel as I want the player to be able to shoot them in mid air.

red igloo
mystic ferry
ruby python
mystic ferry
#

A solution without the joint.

rocky canyon
mystic ferry
red igloo
ruby python
rocky canyon
#

nah, i normally agree with nav. but not this time