#💻┃code-beginner

1 messages · Page 723 of 1

rich adder
#

oh true. I meant like in general

languid pagoda
#

So I am simulating an engine and gearbox in unity. Clutch is sitting right between the engine and gearbox and it determines if the torque from the engine can pass into the gearbox.

The clutch has a value "clutchStiffness" the stiffer the clutch the more quickly it will disengage.

My gearbox script has a variable that im currently assigning int he inspector "shiftDuration" and valid values are between 100 and 500 milliseconds.

Anyone know a decent math equation I could use to make it so the shift duration is assigned based on the stiffness of the clutch? stiffer clutch = shorter shiftDuration?

naive pawn
#

there are several

#

you gotta decide what kind of curve you want though

frigid iron
#

I'm trying to drag the soup pot object, but it's moving along a weird axis (my camera is in orthographic view btw)

naive pawn
#

but yeah overall - pick some fixed points, specifically the max and min, and perhaps decide what "half" stiffness should translate to

#

or maybe make it linear, that's also an option

#

figure out what curve you want from there

#

then find an equation to fit the curve

frigid iron
languid pagoda
naive pawn
#

animationcurve doesn't change the amount of variables, it just changes where/how you define the curve

frigid iron
hallow acorn
#

if i have multiple of the same component on one gameobject, can i create an array of them in the order they are listed in the inspector and if yes how would i do that? thanks in advance

cosmic dagger
#

So, you can do it, just by manually adding them . . .

hallow acorn
inland sun
#

Guys, I lowkey want to make a game, but I'm completely new to this and could use some help.

naive pawn
#

please do not crosspost

ivory bobcat
#

Refactored your code to remove unnecessary component calls and to cache the display panel cards rather than accessing children.

  • cardButtonPrefab is now a CardUI rather than a GameObject
  • Removed the panel and instead provided an array of 4 for the explicit child slots
  • Manage a list of buttons (CardUI) instead of traversing from parent to children.
  • Decoupled button creation logic to be reused when refreshing display
    https://paste.mod.gg/kldkparvpiih/0
tacit prism
#

the way i have my characters camera and direction set up, im pretty sure i can just make all of the movement options move him "forward", that way the direction controller bound to wasd controls which direction he goes, whereas asd is just making him move in that direction that points. is this a good idea? im shifting this from character controller to rigidbody + capsule collider

faint tulip
#

i got a question how can i add a lock or unlock on the player input?
something like if you enter the area the player will be locked in place and cant move or look around
i cant find some similar ideas in the internet

rich adder
ivory bobcat
rustic moat
rocky canyon
#

~~i just do a simple early return:

if(standBy)
{
  return;

  //else
  HandleInput(); //or
  HandleMovement();
}
```~~
rustic moat
rocky canyon
#

same thing for the Camera Controller ^ that way i can have both ignore my inputs/movement
moveScript.standby = true;
camScript.standby = true;

rocky canyon
#

wait.. somethings not right

#
void Update()
{
    if (standBy)
    {
        return;
    }

    HandleInput();
    HandleMovement();
}```
#

there thats the correct way ^

rustic moat
#

That's better

rocky canyon
#

ya had a brain fart

halcyon lion
#

I'm getting so confused rn. I'm trying to follow a tutorial and all of a sudden VS code won't let me type anything

#

how do I fix this?

rich adder
versed fjord
rich adder
versed fjord
rich adder
halcyon lion
versed fjord
rich adder
halcyon lion
#

oh no it just wasn't letting me type, apparently I had accidentally gone out of inset mode or something

versed fjord
halcyon lion
#

I was just in the middle of coding and it stopped letting me type, I think I accidentally pressed ctrl but IDK

#

well I say in the middle of coding, I was following a tutorial, I have no clue what I am doing rn

rich adder
#

just copying code, not learning much

midnight blaze
#

i dont feel like its worth it to make a whole thread in code general but how the hell is this script printing out this value twice per frame? and at two different values?
there is no refrence to 100 anywhere and it works perfectly fine

halcyon lion
#

I don't know what I should do to learn the language right now but youtube says to watch tutoorials on there

rich adder
halcyon lion
#

@rich adder do you know what I can do / where I can go to start learning C#?

rich adder
midnight blaze
halcyon lion
#

@rich adder giving the codecamp a try, so far it's going well

#

thanks for the help on getting started

halcyon lion
rich adder
#

syntax, variables, datatypes etc.

halcyon lion
#

so should I just do all of them or are some more valuable than others?

rich adder
halcyon lion
#

ok well I'll do some today and then have a break so I'm not trying to cram it all in at once

#

thank you very much for all the help

languid pagoda
#

why is there a value displaying as -3.7604e-05 in the inspector? its supposed to be a float whys the random e- in there?

peak shard
#

Short hand for x10^ pretty sure. Means Exponent. So a big (or small) negative number it seems.

languid pagoda
#

just display my number

#

i need to copy the float into some code now and I am not sure what the value is

#

well really im trying to assign the default value. public float pex4 = -3.7604E-05f;

will that just work? it compiles

eternal needle
eternal needle
peak shard
#

Yeah calc just outputs it as -0.000037604 (if I entered it right, the e-05 is weird)

#

So basically 0

formal osprey
#
Allocation of 66 bytes at 0000018AC05000D0

43 3a 5c 62 75 69 6c 64 5c 6f 75 74 70 75 74 5c  C:\build\output\

75 6e 69 74 79 5c 75 6e 69 74 79 5c 52 75 6e 74  unity\unity\Runt

69 6d 65 5c 45 78 70 6f 72 74 5c 44 65 62 75 67  ime\Export\Debug

5c 44 65 62 75 67 2e 62 69 6e 64 69 6e 67 73 2e  \Debug.bindings.

68 00 .. .. .. .. .. .. .. .. .. .. .. .. .. ..  h.

Allocation of 66 bytes at 0000018AC0500070

43 3a 5c 62 75 69 6c 64 5c 6f 75 74 70 75 74 5c  C:\build\output\

75 6e 69 74 79 5c 75 6e 69 74 79 5c 52 75 6e 74  unity\unity\Runt

69 6d 65 5c 45 78 70 6f 72 74 5c 44 65 62 75 67  ime\Export\Debug

5c 44 65 62 75 67 2e 62 69 6e 64 69 6e 67 73 2e  \Debug.bindings.

68 00 .. .. .. .. .. .. .. .. .. .. .. .. .. ..  h.

Allocation of 66 bytes at 0000018AC0500010

43 3a 5c 62 75 69 6c 64 5c 6f 75 74 70 75 74 5c  C:\build\output\

75 6e 69 74 79 5c 75 6e 69 74 79 5c 52 75 6e 74  unity\unity\Runt

69 6d 65 5c 45 78 70 6f 72 74 5c 44 65 62 75 67  ime\Export\Debug

5c 44 65 62 75 67 2e 62 69 6e 64 69 6e 67 73 2e  \Debug.bindings.

68 00 .. .. .. .. .. .. .. .. .. .. .. .. .. ..  h.

TLS Allocator ALLOC_TEMP_TLS, underlying allocator ALLOC_TEMP_MAIN has unfreed allocations, size 198

Internal: Stack allocator ALLOC_TEMP_MAIN has unfreed allocations, size 198

To Debug, run app with -diag-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.

...

My project is currently being flooded with these errors by the thousands and using gigabytes of ram

#

(just editor open, not playing.)

frigid iron
#

How do I destroy a prefab instantiated in one script in another script?

languid pagoda
languid pagoda
eternal needle
languid pagoda
#

so what e-05 just move decimal places to the left 5 places and add 0's where needed?

eternal needle
languid pagoda
#

or is this just valid? public float pex4 = -3.7604E-05f;

eternal needle
languid pagoda
#

0.00003456

peak shard
languid pagoda
eternal needle
#

though i do find it incredibly suspicious this is the exact value you would need especially when dealing with floats

languid pagoda
peak shard
#

If that's the value then that's the value 😄

eternal needle
#

change iterations to a smaller or larger number and notice how it starts to just be wrong compared to doing 0.1 * iterations manually

peak shard
#

Damn, even 7 iterations it starts to deviate

languid pagoda
#

definitely being used in a long chain of math

#

no idea what the correct value to use here would be tho since 0 makes the car drive weird

frigid iron
#

How do you detect when a mouse drag has ended, like OnMouseDrag() but for when it is released?

languid pagoda
eager stratus
#

So how would I go about getting a standard object (not a game object) to destroy itself? I saw something about an IDisposable interface, but I'm not completely sure it's what I want for this usecase.

    {
        //The idea is that this is an object that exists in a JRPG enemy's AI to help decide what action it should take and what target it should apply to.
        //For instance, when a player party member attacks this enemy, one of these MemoryObjects is created with a threat value (the damage value of the attack) that attack accrued.
        //Each memory (stored in a list obviously) is only supposed to last a limited number of time, though, and once that time is elapsed then the MemoryObject is meant to stop existing.
        //I would really prefer the object internally decide when it should stop existing rather than an external source doing it, though.

        public float threatValue { get; private set; }
        float memory;

        public MemoryObject(float threatValue, float memory, TimeEvent timer)
        {
            this.threatValue = threatValue;
            this.memory = memory;
            timer += Decay;
        }

        void Decay(float decay)
        {
            memory -= decay;
            if (memory <= 0) 
            { 
                Debug.Log("A memory was forgotten");
                //This is where I would call what ever function I need to call to delete this object entirely. I just don't know how to do that 
            }
        }
    }```
languid pagoda
eager stratus
languid pagoda
eager stratus
#

If I try "This = null" it tells me "This" is readonly

languid pagoda
#

show me the code where you actually create the object via new MemoryObject

oblique copper
#

can someone help me w something
whats a unity VER file
and how can i use this >>> 876c10dd-339f-465a-aa58-23990e93d5e2

eager stratus
languid pagoda
eager stratus
languid pagoda
#

ok you're not understanding what im saying

#

the only way to destroy this is by setting all variables that reference this instance to null

eager stratus
languid pagoda
#

not without unsafe code and manual memory management and changing it from a class to a struct no

languid pagoda
eternal needle
eternal needle
#

you dont need to destroy it yourself. when something stops referencing it, it will be destroyed

languid pagoda
# eager stratus So I can't get the object to destroy itself then
public unsafe struct Foo
{
    public void* ptr;
    public Foo Create()
    {
        ptr = Marshal.AllocHGlobal(Marshal.SizeOf<Foo>()).ToPointer();
        var foo = new Foo();

        UnsafeUtility.CopyStructureToPtr(ref foo, ptr);
    }

    private void Destroy()
    {
        Marshal.FreeHGlobal((IntPtr)ptr);
    }
}

this MIGHT work im not an expert with unsafe code.

eternal needle
#

this is so incredibly unnecessary and shouldnt even be a suggestion

languid pagoda
eager stratus
# eternal needle you dont need to destroy it yourself. when something stops referencing it, it wi...

The idea is that I really don't want to have to communicate with an outside system (that being the list that holds the memories) if I don't have to. The idea is that these objects exist in a dictionary and, rather than the object telling the dictionary to delete it, the dictionary doesn't bother itself with if a certain object is supposed to be there or not because it's only ever looking at objects that are

languid pagoda
eternal needle
languid pagoda
proper needle
ancient anchor
#

hi

eternal needle
eager stratus
proper needle
#

anyone know what this is

eager stratus
ancient anchor
#

I'm new to learning coding but I'm not sure where to start. Can anyone give me advice?

eternal needle
proper needle
eternal needle
proper needle
#

theres also a unity course somewhere

ancient anchor
proper needle
eager stratus
proper needle
#

does setactive not work with instances

eager stratus
#

The only other alternative I can think of is having the object tell the list its time has lapsed through like an event or something and give it the information necessary to remove it from the list

eternal needle
#

no matter what you do, the class holding the list needs to remove the MemoryObject from its list

#

theres no alternative

proper needle
#

this might help

eager stratus
proper needle
#

if u can access it

languid pagoda
proper needle
eternal needle
#

oh i thought you linked to the message below that

proper needle
eternal needle
tall bridge
#

just started 10 minutes ago but idk if i did this correct i believe it makes the cube invisible

eager stratus
tall bridge
#

did i do something wrong

proper needle
#

wait

eternal needle
proper needle
#

if i call an instance it doesnt return anything i assme?

eager stratus
tall bridge
eternal needle
languid pagoda
proper needle
#

i just chatgpted it and turns out i was supposed to have a period and not an equals

#

im so dumb lol

eternal needle
eager stratus
eternal needle
languid pagoda
# eternal needle 🤷‍♂️ if you think trying to lead people away from awful advice is condescending...

No bro I could care less if they used unsafe code. You caught the end of a conversation was rude and then suggested the same thing that was suggested 15 minutes prior to that when he was saying "I dont wanna do it the right way".you sit in here every day saying condescending shit. You got 400 pages of post in the unity discord and if we scroll through them you're being rude in most of your posts. Like dont you have something better to do than spend your time being an asshole to new programmers?

#

that was a rehtorical question you have 400 pages of posts we know you got nothing better to do. stop typing to me

eternal needle
rocky canyon
#

u can always block 'em and still provide ur feedback whenever u want.
bawsi's alright in my book.. but i have dozens of others blocked that like to gatekeep my advice..
nothings stopping u from keeping on keeping on

eager stratus
#

I figured I could skip the need for that

#

And it appears I was wrong

eternal needle
#

MemoryObject doesnt need to know about a single thing outside

#

can you show how you set that up?

past sentinel
#

how do i fix this while still allowing jumping? if i jsut normalize it all it prevents jumping

eager stratus
#

Otherwise what's the event that's flagging its time as having lapsed doing?

#

Does it not need a function connected to it to mean anything?

languid pagoda
eternal needle
eager crow
#

can anyone help me make it so where when I hold the button down to move, it stays moving? it is not working while I hold A or D down.

eternal needle
eager crow
#

in the OnMove function

rocky canyon
past sentinel
#

!code

eternal falconBOT
rocky canyon
past sentinel
rocky canyon
#

that way when im not grounded my movement speed is about 1/4 of what i allow during grounded movement

past sentinel
#

thats my player movment. my game is about scaling so thats why i multiply stuff by the player scale

eternal needle
eager stratus
# eternal needle i dont know what functions or "it" is in some of this. itd be a lot easier to un...
{
    protected delegate void MemoryDelegate(StatBlock source, MemoryObject memory);

    protected class MemoryObject
    {
        event MemoryDelegate onExpiration;
        public readonly StatBlock source;
        public float threatValue { get; private set; }
        float memory;

        public MemoryObject(StatBlock source, float threatValue, float memory, TimeEvent timer, MemoryDelegate removeMemory)
        {
            this.source = source;
            this.threatValue = threatValue;
            this.memory = memory;
            timer += Decay;
            onExpiration = removeMemory;
        }

        void Decay(float decay)
        {
            memory -= decay;
            if (memory <= 0) 
            { 
                Debug.Log("A memory was forgotten");
                onExpiration(source, this);
            }
        }
    }

    [SerializeField] float memorySpan;

    //Instead of an int, I need a list of memory objects that decay over time and adding them all together creates a threat level
    //protected Dictionary<StatBlock, int> threatDictionary = new Dictionary<StatBlock, int>();
    protected Dictionary<StatBlock, List<MemoryObject>> threatDictionary = new Dictionary<StatBlock, List<MemoryObject>>();

    public void AddThreat(ref StatBlock statBlock, int value) //Actually, I think I should let the AI decide how long it should remember things for
    {
        //if (!threatDictionary.ContainsKey(statBlock)) { threatDictionary.Add(statBlock, value); return; }
        //threatDictionary[statBlock] += value;

    }

    void RemoveMemory(StatBlock source, MemoryObject memory) { threatDictionary[source].Remove(memory); }

    public virtual void ExecuteAI(StatBlock myStatBlock)
    {
        
    }
}```
#

This is how I interpreted your solution of using events

past sentinel
rocky canyon
# past sentinel im unsure on how id quite impliment that becuase my current system seems quite d...

you still have if(!isGrounded) right here...

you could have (two) different versions of ur targetVelocity

 // step 1 decide base velocity
    Vector3 targetVelocity = orientation.TransformVector(moveVector) * moveSpeed;

    // Step 2: apply different values to target Velocity depending on grounded state or not
    if (isGrounded)
    {
        targetVelocity *= 1f; // multiplier for clarity
    }
    else
        targetVelocity *= 0.4f; // nerf multiplier
    }

    // step 3.. send it to ur move function
    moveDir = Vector3.Lerp(moveDir, targetVelocity, Time.deltaTime * acceloration);```
eternal needle
rocky canyon
#

the codes basically the same... (its arranged a bit differently but its all practically the same)
you get input -> you mix that with ur variables -> u send that to the function

adaptation big part of learning.. check examples.. see how they differ
try to figure out why they differ
try to see the outcome of the code.. regardless of the steps it takes

eager stratus
rocky canyon
# rocky canyon you still have if(!isGrounded) right here... you could have (two) different ver...

so in this example u can pretend ur targetVelocity is 10...
in the if statement -> if ur grounded its 10 * 1 = 10 (normal)
if ur not grounded its 10 * .4 = 4 (slower)

edit: like directly from my script
https://paste.ofcode.org/WS6VupuAwjTMQwRZM3vEkp
if you look you can tell im just doing two calculations
1 for when im grounded and 1 for when im airbourne

its using the exact same Inputs but my speed multiplier and dampening modifiers are different
so depending on what im doing my Vectors are going to be FULL strength or they're gonna be HALF strength for example

proper needle
eager stratus
#

Although, if necessary, it shouldn't have to have a source either

tall bridge
#

Is this correct

eternal needle
rich adder
rocky canyon
#

= is assignment... ur setting myName to Fred on that line..

#

if my name isn't Jimmy set my name to Fred

rich adder
#

the first if statement will always be true

rocky canyon
#

that too

#
myName = "Jimmy";

if(myName == "Jimmy")
{
  // myName is Jimmy
  Cube.SetActive(true);
}
else
{
  // myName is anything *but* Jimmy
  Cube.SetActive(false);
}
``` makes more sense
eager stratus
#

Although I did not know you could cast actions that way. That is incredibly convenient

past sentinel
rocky canyon
#

angle wall launching? ohh i didn't know that was the main issue lol

#

yea, i wasnt considering that.. sorry

past sentinel
#

yeah i assumed being launched off the wall was clear enough of an issue

rocky canyon
#

i thought u were controlliing it with ur Input

past sentinel
#

ah

rocky canyon
#

soo i wasn't addressing the actual issue mb

past sentinel
#

yeah i guess i was a little unclear

#

i assumed the issue was obvious

rocky canyon
#

soo the walls cause it to get launched?

past sentinel
#

yes. all slopes really

rocky canyon
#

thats a new one for me.. (i've seen people get stuck on walls)

past sentinel
#

just the walls are themost angled and this the easiest to see

past sentinel
#

but if i just force all speed to be normalized suddenly jumping is really bad

rocky canyon
past sentinel
#

and i dont wanan add a physics material to it becuase then id need to do it to cubes too and it still wont solve the root of the issue

rocky canyon
#

ohhh.. ur setting ur velocity (directly).. not adding it..
when u run into an angled wall or slope its probably ur horizontal velocity being projected into the surface normal (just as u said)

#

i think its killing the "natural" physics of unity's physics system.. b/c ur overwritting

eternal needle
rocky canyon
#

if u use AddForce instead of overwritting the velocity it may work

like instead of setting the force / velocity directly you can take the velocity you desire.. and then subtract it from the force u have.. and that should be able to used in AddForce as a velocity change

Vector3 velocityChange = targetVelocity - new Vector3(rb.linearVelocity.x, 0, rb.linearVelocity.z);
rb.AddForce(velocityChange, ForceMode.VelocityChange);```

and something along the lines of "project along the ground"
eager stratus
past sentinel
#

i remeber thats why i was setting it instead of adding

#

ok well that wotks but now i dont have gravity

rocky canyon
past sentinel
rocky canyon
eager stratus
#

@eternal needle After having shuffled everything around it now looks like this

{
    protected class MemoryObject
    {
        event Action<StatBlock, MemoryObject> onExpiration;
        public readonly StatBlock source;
        public float threatValue { get; private set; }
        float memory;

        public MemoryObject(ref StatBlock source, float threatValue, float memory, Action<StatBlock, MemoryObject> removeMemory)
        {
            this.source = source;
            this.threatValue = threatValue;
            this.memory = memory;
            onExpiration = removeMemory;
        }

        public void Decay(float decay)
        {
            memory -= decay;
            if (memory <= 0) 
            { 
                Debug.Log("A memory was forgotten");
                onExpiration(source, this);
            }
        }
    }

    [SerializeField] float memorySpan;

    //Instead of an int, I need a list of memory objects that decay over time and adding them all together creates a threat level
    protected Dictionary<StatBlock, List<MemoryObject>> threatDictionary = new Dictionary<StatBlock, List<MemoryObject>>();

    public void AddThreat(ref StatBlock statBlock, int value) //Actually, I think I should let the AI decide how long it should remember things for
    {
        MemoryObject newMemory = new MemoryObject(ref statBlock, value, 10, RemoveMemory); GameManager.instance.onUpdate += newMemory.Decay;
        if (!threatDictionary.ContainsKey(statBlock)) { threatDictionary.Add(statBlock, new List<MemoryObject>() { newMemory }); return; }
        threatDictionary[statBlock].Add(newMemory);
    }

    void RemoveMemory(StatBlock source, MemoryObject memory) { threatDictionary[source].Remove(memory); }

    public virtual void ExecuteAI(StatBlock myStatBlock)
    {
        
    }
}```
past sentinel
#

oh wait no the y is being set to 0

#

or no it shouldnt be

rocky canyon
grand snow
#

Why is this in the beginner chat

rocky canyon
#

instead of 0 use rb.linearVelocity.y or rb.velocity.y if its the older unity

past sentinel
eternal needle
rocky canyon
eager stratus
past sentinel
grand snow
#

someone using ref and event properly is no beginner to me

eager stratus
rocky canyon
#

by the way.. @past sentinel dont get discouraged.. having a good controller makes or breaks a game..
and it does take a while to get it worked out and working like u need it to
i've been working on mine for years now and its progressively getting better and better

past sentinel
rocky canyon
#

so take ur time.. make sure to understand how its working.. logging ur values.. all that good stuff

#

and just keep on keeping on

grand snow
rocky canyon
#

and let the regular gravity still work

eager stratus
rocky canyon
#

not exactly sure how.. in ur setup but doable i believe

grand snow
rocky canyon
#

ya, that code gives me anxiety.. thats how i know its not beginner 👀 lol

#

the only things i can understand are the //s 🤪

eternal needle
rocky canyon
past sentinel
rocky canyon
#

ofc.. understandable

#

i found that finding free character controllers like the one i wanted to build really helped me out

#

i would open them in a seperate projects and then take my time dissecting them.. (reverse engineering)

#

line by line.. figuring out how they do what i want to do..

#

then it was about adapting it.. asking questions about things i didn't understand.. following up by reading docs and stuff about methods i hadn't seen or used before.. and just attempting to piece it together

rocky canyon
# past sentinel but also the reason im not using the gravity thing normally on RB's is becuase i...

altho i will say.. u can still use ur rb.linearVelocity.y * scaleModifier but with a scale multiplier..
so its using regular gravity right... if ur scale modifier is 1 its just the same as it normally would be

if u had something scaled at 2 it'd be rb.linearVelocity.y * .5 or 2 depending on which way ur scaling..
and it still should work.. ur physics is gonna take care of the regular gravity.. and u just grab that value during the frame.. and add ur multiplier..

        Vector3 vel = rb.velocity;
        vel.y = vel.y * scaleModifier;
        rb.velocity = vel;```
#

with that said tho
scaling doesn't affect gravity 🤪
a basketball and a bowlingball are gonna fall the exact same speed 😛

past sentinel
rocky canyon
#

very true.. im just messing with ya 😛

#

but that is a trick
when objects are HUGE they appear to be moving much slower

past sentinel
#

i want physics to feel the same no matter the scale

rocky canyon
#

soo like a Titan walking thru a city would use an animator thats slowed down..

#

so its solid in concept 👍

past sentinel
#

but i dont want that i want them to feel the same becuase consitansy is good to avoid confusion

#

(also i was curious if even AI could help. it could not)

rocky canyon
#

well im kinda unsure of what the scaling is for then?
b/c they'd be consistent no matter what the scale

rocky canyon
past sentinel
#

this is what was happining to the player too and you could quickly see why having what feels like 0 jump when small would be bad

grand snow
#

I haven't been following but pesky air resistance makes things accelerate differently in the real world (see the feather + bowling ball experiment)

past sentinel
#

i was jsut yapping about why i scale gravity in my game

#

and its to make it feel more correct

#

even if it would be techniclly wrong

grand snow
#

well there should be better means to reflect the real world better (if thats your aim)

past sentinel
#

i mean its a game. its about what feels good and to me it feels better to have a cube fall at the same speed regardless of scale

wintry quarry
past sentinel
#

and i can then use this for puzzles. small cubes fall slower so you can have more airtime to go into a door or whatever

wintry quarry
#

I call it the "godzilla effect"

rocky canyon
#

aye i like that ^

past sentinel
rocky canyon
#

interesting

past sentinel
#

but i guess i shove this issue back to the back burner becuase im still lost on any idea on what to do to prevent it

wintry quarry
rocky canyon
#

ya i got u 👍

past sentinel
#

its not that big of a deal currently so

eager crow
#

I am struggling to make the OnMove function work while being held. It only works once when I tap the key but movement keys should work while being held and I can't figure out how to get it to work that way.

past sentinel
eternal falconBOT
past sentinel
#

makes it easier to see

eager crow
#

like this?
'''cs
//private void OnMove(InputValue inputValue)
{
rb.linearVelocity = inputValue.Get<Vector2>() * speed;
}'''

past sentinel
#

its ```

#

not '''

#

a backtic usually above tab

eager crow
#
private void OnMove(InputValue inputValue)
{
    rb.linearVelocity = inputValue.Get<Vector2>() * speed;
}```
#

I see

#

I am using the input system and I am struggling to make the OnMove function work while being held. It only works once when I tap the key but movement keys should work while being held and I can't figure out how to get it to work that way.

#

can anyone help me figure this out please?

wintry quarry
#

if you want to do something every frame, use Update

#

you can store the latest input data in a variable here, then use it in Update

eager stratus
#

Well, FixedUpdate if you're using physics

wintry quarry
#

Sure, it won't matter either way in this particular case

eager stratus
# eager crow can anyone help me figure this out please?

I believe I had something similar that looked like this

{
    //Main serialize fields
    [SerializeField] InputActionAsset actionMap;
    [SerializeField] float moveSpeed;

    //Component cache
    Rigidbody rb;

    //Misc variables
    Vector2 moveVector;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        //Make sure there's a third person camera and that its subject is this
        if (ThirdPersonCamera.instance == null) { Destroy(this); }

        //Cache components
        rb = GetComponent<Rigidbody>();

        //Activate and link action map
        if (!actionMap.FindActionMap("Player").enabled) { actionMap.FindActionMap("Player").Enable(); }

        //Set up movement controls
        InputAction movePlayer = actionMap.FindActionMap("Player").FindAction("Move");
        movePlayer.performed += (InputAction.CallbackContext cc) => { moveVector = movePlayer.ReadValue<Vector2>(); };
        movePlayer.canceled += (InputAction.CallbackContext cc) => { moveVector = Vector2.zero; };
    }

    // FixedUpdate is called once per physics iteration
    void FixedUpdate()
    {
        if (moveVector != Vector2.zero)
        {
            float trueMoveAngle = ThirdPersonCamera.instance.transform.eulerAngles.y + Vector2.SignedAngle(Vector2.up, new Vector2(-moveVector.x, moveVector.y));
            Vector3 trueMoveVector = new Vector3(Mathf.Sin(Mathf.Deg2Rad * trueMoveAngle), 0, Mathf.Cos(Mathf.Deg2Rad * trueMoveAngle)) * moveSpeed * moveVector.magnitude;
            rb.linearVelocity = trueMoveVector + Vector3.up * rb.linearVelocity.y;
            transform.eulerAngles = Vector3.up * trueMoveAngle;
        }
    }
}```
#

I'm not sure how to use the actual Input Action component. Honestly it's a miracle I even figured out what lambda functions do

eager crow
#

so would I change the line to vector2 = inputValue.Get<Vector2>()

#

new to C# coding

#

then put that vector2 variable in the update?

eager stratus
wintry quarry
eager crow
#

what value does the inputValue.Get<Vector2>() return?

eager stratus
#

The way mine is set up, it only has to read an overhead Vector2 that has its value changed through lambda functions called in start

eager crow
#

1 and -1?

wintry quarry
eager stratus
wintry quarry
#

yes -1 to 1 generally

#

it depends

#

if it's mouse input it could be different

eager stratus
#

W = 1 y
A = -1 x
S = -1 y
D = 1 x

wintry quarry
#

also it's a 2sd vector so it's (x, y)

eager stratus
#

One thing that I found nice about the new input system is that it's not possible for it to have a magnitude beyond 1 like the old system

eager crow
#

ok it kind of works

#

but now it seems the gravity of the object is off cause it falls down super slowly

#

and it seemed to have disabled my jump feature

#

but it does move left and right while the button is held

eager stratus
eager crow
#

is there a way where I can only collect the x value of it then?

#

using the function

eager stratus
rocky canyon
#

rb.linearVelocity = new Vector2(horizontal, rb.linearVelocity.y, vertical);

#

^ u can feed the .y right back into it

#

therfor ignoring it (letting unity physics do its thing)

eager stratus
past sentinel
#

@rocky canyon with my system do you know the ebst way to have my player stick to the ground when they are grounded?

eager crow
#
private Vector2 playerInput;

private void OnMove(InputValue inputValue)
{
    playerInput = inputValue.Get<Vector2>();
}

private void Update()
{
    rb.linearVelocity = new Vector2(playerInput, rb.linearVelocity.y);
}```
#

this is what I have

eager stratus
rocky canyon
#

not sure that works with urs or not

wintry quarry
eager crow
#

so I would change the OnMove function then?

private void OnMove(InputValue inputValue)
{
    playerInput = inputValue.Get<Vector2>();
}```
#

oh I got it work

#

thank you both for the help 🙂

eager stratus
eager crow
#

I used PraetorBlue's method and it worked

#

I put rb.linearVelocityX = playerInput.x * speed;
and it worked

tacit prism
#

i want all of my wasd to only move forward, in 3d, how should i go about that

reason being i have the way my direction is working already set up

wintry quarry
tacit prism
wintry quarry
#

but like

#

you want all of the buttons to do the same thing?

tacit prism
#

i dont have to worry about it, pressing D makes my character face right, and S makes my character face backwards

#

so if they move the direction they are facing then it should control it just the same

#

im moving from a character controller to a rigidbody + capsule

eager stratus
#

This appears to just return a vector in what ever direction the transform is facing

tacit prism
wintry quarry
#

Do you want D to make you walk forward or not?

#

You want S to make you walk forward?

#

Or do you only want W to make you walk forward

#

because when you say "I want all my WASD to walk forward" it soudns like you want all of those buttons to make you walk forward

eager stratus
wintry quarry
#

I'm pretty sure what they actually want is to move in the direction of the WASD vector but in relation to the direction the camera is facing

#

anyway it's going to be impossible really to answer this without seeing your existing code, as mentioned above

tacit prism
eager stratus
wintry quarry
eager stratus
#

Either that or it genuinely doesn't matter because the camera's rotation isn't suppose to change

tacit prism
wintry quarry
# tacit prism https://paste.mod.gg/wvyvczonbwnd/0

So you've already got it here:

            Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
            playController.Move(moveDir.normalized * plyMvspd * Time.deltaTime);```
But you have a problem - you seem to have both a CharacterController and a Rigidbody on this object
#

You need to pick one or the other

tacit prism
#

im replacing the character control with rb

#

thats the whole point of this, so i can use isGrounded

wintry quarry
#

then you just do rb.linearVelocity = moveDir.normalized * plyMvspd;

#

and get rid of the CharacterController and all the code related to it

#

You'll also want to be doing rb.rotation = Quaternion.Euler(0f, angle, 0f); instead of transform.rotation = Quaternion.Euler(0f, angle, 0f);

#

as a rule of thumb if you have a Rigidbody you should never directly modify the Transform

tacit prism
#

in the end im just trying to make a movement system similar to Sky: CotL

wintry quarry
#

no idea what that is

tacit prism
#

pretty popular "cozy" game

wintry quarry
#

i mean a video of the movement would be better

#

but have you tried the code?

tacit prism
#

Sky:CotL is c++ with a custom engine, i only barely know c# and unity so...

#

i can show a video though, have it currently installed because theres some ideas from it i want to test, like volumetric clouds

wintry quarry
#

adjusting your code as I mentioned above will get you part of the way there (it won't adjust for the camera rotation).

#

but as you said that can be added later

tacit prism
#

someone told me to use lerp on reddit for the non-instant movement when turning around and such

wintry quarry
#

worry about getting it working first

tacit prism
#

true

wintry quarry
#

But you're already using SmoothDampAngle

#

which will make it "non instant"

#

at least the rotation of the character visually

tacit prism
#

im having an issue with my character sliding across the surface, so they move extra when turning around

#

yeah the angle isnt instant, but the velocity is

wintry quarry
#

did you add the else block like in my example code?

tacit prism
#

shit didnt notice it

eager stratus
tacit prism
#

im just learning this so slow, i work 40+ hours a week and i have familial obligations

#

im trying to learn, but most of what i learn from is videos that poorly explain how the syntax works with the functions and objects

wintry quarry
#

You're not really going to learn it if you're just copying code, you'll want to try to understand what it's doing

#

when you understand it you'll be able to tweak it to your liking

#

You may also want to spend some time learning C# itself if the language is giving you trouble

#

outside the context of games

tacit prism
#

i did the microsoft c# course for about a week

wintry quarry
#

that's a good start

#

it's definitely going to take a bit before you're "fluent" though

tacit prism
#

but after a certain point it just felt kinda...console specfic? i guess. Like arrays and booleans and such are all useful, but learning how to make a folder through a terminal seems kinda useless for me..

wintry quarry
#

true enough

tacit prism
#

im sure it has its application somewhere, like puzzle games that suddenly make folders appear on ur desktop but ya know

#

that aint me

wintry quarry
#

regardless the syntax for calling functions and passing parameters and capturing return values and writing functions are all relevant

#

no matter what it is that the functions ultimately do

eager stratus
#

What I did was try to recreate Triple Triad while looking up every little thing on Google such as "how make object move in code?"

tacit prism
#

i mean when i see someone do vector3.something = new vector(smth, smth, smth ,smth, smth)

doesnt exactly look like the console.WriteLine they taught you for 4 modules straight KEKW

#

i know its just gonna take time, but im impatient asf :(

wintry quarry
#

I presume they teach constructors at some point 🤔

languid pagoda
#

anyone ever expirimented with brushmodel tires? got any links about them?

fierce halo
#

Hi, I wanted to ask about Animation Rigging, and I encounter this error about Burst Job abort. console error below. Does anybody know how to solve it?

System.InvalidOperationException: The PropertyStreamHandle cannot be resolved.
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ffc9c78949e (Unity) burst_abort

rocky canyon
# tacit prism the camera does effect the movement im noticing, but ill figure that out when i ...

ya, i tried to mention that yesterday
if ur going after the normal third-person movement style you totally need to incorporate ur camera into the code..
you can't really get the movement working without it..

unless ur talking about tank movement that would be if ur walking forward and press left at the same time it'll rotate to the left and keep moving forward (now to the left)..
-> once ur camera is involved it'd be totally different.. b/c if u were to pan ur camera around the backside of ur player now ur directions are all flipped

  1. TankStyle :
  • Input is always relative to the player’s facing.
  • Forward/backward moves along the player’s forward, left/right rotates the player.
  • Diagonal movement results in combined rotation + forward movement.
    https://hastebin.skyra.pw/tonurikuwu.csharp <- link to example code for the tank style movement (no camera involved) the rotation is similar to what u have now.. but W/S or "Vertical Axis" would then move the direction its facing..
  1. Camera-relative third-person movement (modern 3rd-person/over-the-shoulder):
  • Input is relative to the camera’s orientation.
  • Forward always moves in the direction the camera is facing, left/right moves relative to camera right/left.
  • Player rotation is independent and smoothly turns toward the movement direction.
  • If you pan the camera, pressing forward could now move the player “left” relative to their original facing — the movement follows the camera, not the player’s initial facing.
sinful gazelle
#

c# unity iap, how to check if player already bought a non-consumable item?

rocky canyon
# rocky canyon ya, i tried to mention that yesterday if ur going after the normal third-person ...

https://hastebin.skyra.pw/vipeyefibu.csharp <- link to example code for the camera-relative style movement
the camera is not attached to the player (because if it was parented to the controller and you rotated to the controller.. the camera would also rotate.. and since we're using the cameras rotation it'd rotate more and more.. and u get in a loop.. instead we just make the camera track the player
something like:

Vector3 desiredPosition = target.position + transform.rotation * offset;
transform.position = Vector3.Lerp(transform.position, desiredPosition, followSmooth * Time.deltaTime);```
in the movement script - we use the `camForward` and the `camRight` to multiply our inputs with so when we pan the camera the general directions of the player change as well...
rocky canyon
pulsar pecan
#
    float collisionDetec(Vector3 movementDirection)
    {
        Vector2 rayDirection = movementDirection.normalized;
        Vector2 origin = transform.position;
        float rayDistance = speed * Time.deltaTime;

        RaycastHit2D hit = Physics2D.Raycast(origin, rayDirection, rayDistance);
        Debug.DrawRay(origin, rayDirection * rayDistance, Color.red, rayDistance);


        if (hit.collider != null)
        {
            Debug.Log("Hit: " + hit.transform.name);
        }

        if (hit.collider != null && hit.collider.CompareTag("Collidable"))
        {
            return 0; // Block movement
        }

        return speed * Time.deltaTime; // Allow movement
    }

ive got an issue where i want the ray cast to be in front of the player. the challenge is that the player rotates to face the direction of movement. how do i set an offset so that it is always in front of the player.

the player is a capsule set to scale x:1, y:0.5, z:1

rocky canyon
#
  // --- Offset the ray origin to be in front of the player ---
   float offsetDistance = 0.5f; // adjust as needed
   Vector3 origin = transform.position + transform.forward * offsetDistance;```
pulsar pecan
#

still centered on the player

rocky canyon
#

wait.. its 2D

#

it'd be transform.right

pulsar pecan
#

lol

#

well

#

that di move it

#

transform.up was the one that did it

#

if i add more it will be perfect, thank you!

rocky canyon
#

nice to see ppl using Debug.DrawRay to visualize these things 💪

tacit prism
#

But I’ll deal with that when I get to it

rocky canyon
#

sounds like a solid plan tbh, esp if ur using Cinemachine

zenith wren
#

I have no idea where to ask this so I'm just gonna post it here but I'm currently taking the unity 6 official course and so far all the particle systems they have provided have caused these to appear, is it something to do with the particle system itself or just the particles from the project?

Some times an error saying "Invalid memory pointer was detected in ThreadsafeLinearAllocator::Deallocate!" also pops up every so often.

rocky canyon
#

probably a bug / you can just clear them

restart the project.. i get them from time to time but havent seen any in a while..

languid pagoda
#

Say I have Stack<ushort> is it possible to Take(32) from that stack somehow without looping?

eternal needle
hot wadi
#

Does anyone know how Subway Surfer and Temple Run road spawning work?

eternal needle
naive pawn
#

a Stack<ushort> contains ushorts
Take's argument is about how many values are taken

#

so you just get 32 ushorts out

#

32 isn't even near the limit of a ushort, not sure why you're asking about that

languid pagoda
naive pawn
#

it isn't

#

it's from linq

languid pagoda
#

Ah I see

naive pawn
#

with linq you'd skip then take, but that's kinda not how a stack is supposed to work

#

perhaps consider if it really needs to be a stack

languid pagoda
#

if it didn't I would use a list.

naive pawn
#

note that a FILO structure is easily implemented with an arraylist, so like List in c# would work

#

it has all the same operations and complexity (under different method names)

languid pagoda
#

Ill give that a look now thank you.

zenith wren
rich robin
#

you most likely need something else than stack

rough sluice
#

What could be the reason that road material are not loading?:

rich robin
#

this is most common reason

#

if this is the case then the problem is with shader used for material

#

for simple cases there is auto fix if you are on URP/HDRP - one of last positions in "edit" menu at top of unity got material converter

fierce halo
eternal needle
# zenith wren 6.2 is the version I'm on but this was also happening on the first version of un...

the specific version might matter here. 6.0 is the LTS version so that will be safest, along with upgrading to the latest patch version.
though either way theres nothing here for you to solve. if these warnings/errors are consistent to the point of affecting your work then you should try a different version. I did see the same consistent warnings and error when experimenting in 6.2.1 so decided to go back

fierce halo
fringe kite
#

anyone knows is it possible to identify is user was host of the room that he leaved from photon webhook plugins in playfab cloud script?

spark ember
#

anyone know about these bugs? happened whenever i try build as soon as i upgraded to unity 6.2 from 2023

#

fixed it

sage bronze
#

so i accidentally copied in a script into the urp script. i only noticed now two days after doing it. please can someone give me the script?

naive pawn
#

a script in assets?

cosmic dagger
#

huh?

naive pawn
#

what do you mean by "the urp script"

#

is urp not provided as a package

sage bronze
naive pawn
#

ok, but is that in Assets or what

sage bronze
#

ok. whats confusing is i cant find it. i searched but it's not there. i keep getting this error tho thats opening the file

naive pawn
#

cool so yeah it's in a package

#

just reimport the package, or a similar option

#

no need to get someone else's version

wintry quarry
#

And upgrade all your packages to the latest versions

naive pawn
#

damn, there's no option to just reinstall the package?

sage bronze
wintry quarry
#

Yes you do

#

That's where the error is

naive pawn
#

delete it via file explorer

#

@sage bronze you don't need to delete the entire library

#

in the packagecache, delete the urp module

sage bronze
naive pawn
#

it'll reinstall that module

wintry quarry
#

The whole thing will be regenerated if you delete it

sage bronze
naive pawn
#

hmm. the first time i tried, a lot of things were regenerated but not everything
the second time, the package didn't regenerate

#

so yeah just delete the entire library

naive pawn
sage bronze
#

if you say so

summer wren
#

Nice, I create a Desktop simulator with working window focus, taskbar items and animations.
And terminal window input and output logic 😎

final kestrel
#
{
   [SerializeField] private CinemachineCamera winCamera;
   [SerializeField] private GameObject winPanel;
   private void OnCollisionEnter2D(Collision2D other)
   {
      if (other.gameObject.TryGetComponent(out LetterCollision letterCollision))
      {
         GameManager.canPlay = false;
         winPanel.gameObject.SetActive(true);
         winCamera.Follow = letterCollision.transform;
         winCamera.LookAt = letterCollision.transform;
         winCamera.Priority = 120;
      }
   }
}

I dont know if here is the right place to ask. In my 2d game I want to focus on the transorm of my game object with my extra cinemachine camera that is specifically for zooming and following the target. I see the inspector and the follow and lookat targets assigned. However camera just refuses to follow or zoom on it.

summer wren
final kestrel
#

All right will do. Thanks.

summer wren
#

It is such a great feeling when we spend many hours or even days of frustration over some things, then it becomes fixed and everything looks and works perfectly until the next issue right?!
Just hoping that my code isn't too much for what's needed. I call many instances back and forth.

deft condor
#

Hey, ok it's probably an insanely stupid question but I can't seem to understand why am I getting this error with such a simple script can anyone with a working brain can help me out because mine seems to be in error 404 mode.

Im getting this error :
LevelNexter.cs(3,31): error CS0116: A namespace cannot directly contain members such as fields or methods
LevelNexter.cs(3,38): error CS1022: Type or namespace definition, or end-of-file expected

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

public class LevelNexter : MonoBehaviour
{
    
    public Player PlayerPrefab = null;
    LevelSelector levelSelector = null;

    void Start()
    {
        ListenSystemId();
        levelSelector = FindObjectOfType<LevelSelector>();
    }

    void Update()
    {
        if (Input.GetKeyDown("n"))
        {
            Debug.Log("n key was pressed");
        //    levelSelector.SelectNextLevel();
        }
    }
}

https://media.discordapp.net/attachments/671619810701869066/1411738920550400183/image.png?ex=68b5bfd3&is=68b46e53&hm=521a6c6152dc15ea6fc0cdbcdac41bd51e8a6ea7cc212ea6a84f3640e1b08d46&=&format=webp&quality=lossless&width=1483&height=1300

Am I completely blind ? It looks like I have closed every bracket right to me, but I guess not if I get errors.

Sorry for the stupid question,
Cheers

keen dew
#

It says the error is on line 3 (where you've made a typo)

#

Configure the !ide so that it highlights these things

eternal falconBOT
cosmic dagger
#

It's telling you the error is on line 3. Look at the line to find the mistake . . .

deft condor
#

holy guacamolly im blind

#

I did not understand it was the line, what does 31 mean ?

naive pawn
#

column (aka character) 31

deft condor
#

thanks and my bad for the dumb question

#

thanks very much

rich adder
frank linden
#

Hey guys!
I was working on a project, but my code doesnt seem to work. Where do I ask for help??
I went through all the forums and did alot of research.

deft condor
#

but good call for sure

cosmic dagger
rich adder
patent wedge
#

why does this not work?

double lastRefresh = 0;
List<string> refreshOptions = new List<string>();

for (int i = 0; i < resolutions.Length; i++)
{
    double a = lastRefresh;
    double b = resolutions[i].refreshRateRatio.value;

    if (a == b) continue;

    // refresh rate 
    string option = resolutions[i].refreshRateRatio.value + "Hz"; // might now need .value
    refreshOptions.Add(option);
    NewRefreshRates.Add(resolutions[i].refreshRateRatio);

    lastRefresh = resolutions[i].refreshRateRatio.value;
}
``` it's for a dropdown of resolutions.
naive pawn
patent wedge
naive pawn
#

debug the stuff it depends on then

frank linden
#
void moveToResource()
    {
        transform.LookAt(new Vector3(rDestination.x, transform.position.y, rDestination.z)); 
        Vector3 moveDirection = Vector3.forward * jumpStrength;
        moveDirection.y = 3;
        rb.linearVelocity = transform.TransformDirection(moveDirection);

        if (Vector3.Distance(transform.position, rDestination) <= consumptionRadii)
        {
            foodFound = false;
            Destroy(resource);
            resource = null;
            hunger -= 6;
        }
    }

    void searchForFood()
    {   
        if (!foodFound)
        {
            float nearest = Mathf.Infinity;
            Collider[] hitColliders = Physics.OverlapSphere(transform.position, vision, 8);
            GameObject nearestPlant = null;
            foreach (var plant in hitColliders)
            {
                if (Vector3.Distance(plant.gameObject.transform.position, transform.position) < nearest)
                {
                    nearest = Vector3.Distance(plant.gameObject.transform.position, transform.position);
                    rDestination = plant.gameObject.transform.position;
                    rDestination.y = transform.position.y;
                    nearestPlant = plant.gameObject;
                } else {continue;}
            }

            if (nearestPlant is not null)
            {
                resource = nearestPlant;
                foodFound = true;
            }
        }
        if (counter <= 0)
        {
            counter = timeTillJump;
            moveToResource();
        }
        
    }

so this is attached to a bunny rabit, when its hunger raises to a threshold it starts searching for food, when it finds it moves to it and consumes it, the problem i am having here is the resource variable is not getting set and hence the carrot isnt getting destroyed, so basically the rabbit is just farming the same carrot for infinite food.

#

The rDestination is being set

naive pawn
#

that is not null is questionable

frank linden
rich adder
#

yea don't think you can use that on unity objects can you ?

naive pawn
#

did you read why?

#

it doesn't make sense here

#

wouldn't you want to check for that in the foreach loop anyways

frank linden
#

check what?

naive pawn
#

check that it's a valid object

#

though.. i don't think it'd be in the colliders if it wasn't valid

#

(btw, the else continue; is unnecessary)

frank linden
naive pawn
#

redundancy

frank linden
#

removing it

rich adder
naive pawn
#

huh, they said rDestination was getting set tho 🤷

#

use mp4 so it embeds in discord

rich adder
#

its weird cause they are just checking for any collider in that layer, but no a component check

frank linden
naive pawn
#

what layer is the carrot on

frank linden
#

layer 8

naive pawn
#

well then yeah the layermask thing is wrong

rich adder
#

layerIndex and Layermask != same

#

int layerMask = 1 << myGamObject.layer;
or
LayerMask mask = LayerMask.GetMask("whatever");

frank linden
#

so I do ```csharp
LayerMask layer = LayerMask.GetMask("Plant");

naive pawn
#

you should have it serialized tho tbh so you don't have to work with the magic string

rich adder
#

or just like you know make a field

rich adder
#

[SerializeField] LayerMask hitLayers

#

set it in the inspector

frank linden
#

ohk

#

like Serialize LayerMask plantLayer and then use it in sphere func

#

right

rich adder
#

correct (don't forget to set it in the inspector :P)

patent wedge
#

ok in my settings script i auto select the correct index for my dropdown but for some reason it's out of range?

int val = 0;

for (int i = 0; i < resolutions.Length; i++)
{
    int a = (int)resolutions[i].refreshRateRatio.value;
    int b = (int)Screen.currentResolution.refreshRateRatio.value;

    if (a != b) continue;

    // resolution
    string option = resolutions[i].width + "x" + resolutions[i].height;
    resOptions.Add(option);
    NewResolutions.Add(resolutions[i]);

    if (resolutions[i].width == Screen.width && resolutions[i].height == Screen.height)
    {
        currentResolution = val; // was i
    }

    val++;
}
naive pawn
#

what's out of range

naive pawn
#

you gotta stop playing the pronoun game buddy

#

be more specific, give adequate info

rich adder
#

shouldn't have to play detective lol

patent wedge
rich adder
#

paste the line thats throwing out of range

patent wedge
patent wedge
naive pawn
#

bro that's not even in the snippet you gave above LMAO

rich adder
patent wedge
# rich adder I dont even see it in the code
int val = 0;

for (int i = 0; i < resolutions.Length; i++)
{
    int a = (int)resolutions[i].refreshRateRatio.value;
    int b = (int)Screen.currentResolution.refreshRateRatio.value;

    if (a != b) continue;

    // resolution
    string option = resolutions[i].width + "x" + resolutions[i].height;
    resOptions.Add(option);
    NewResolutions.Add(resolutions[i]);

    val++;

    if (resolutions[i].width == Screen.width && resolutions[i].height == Screen.height) 
    {
        currentResolution = val; // was i
        Debug.Log("Yay!"); // this does get run
    }
}

resDropdown.AddOptions(resOptions); // this is filled
resDropdown.value = currentResolution;
resDropdown.RefreshShownValue();
rich adder
patent wedge
rich adder
eternal falconBOT
frank linden
rich adder
# frank linden it isnt working still

Debug.Log the hit items (in the loop if you want) and see what are the objects that it catches, start from there so you can verify its what you expect

frank linden
#

the funny thing is i tried that, the log got skipped

#

but i did that for the resource variable

rich adder
#

this is why tracking two arrays like this can be confusing

patent wedge
rich adder
frank linden
#

ig thats an empty array?

rich adder
# frank linden ig thats an empty array?

no it means there is in fact an array.
If you want to know the contents put logs in each iteration or use myArray.Length for just the Count (wont be much more help than just printing the hit cols)

patent wedge
# rich adder you said line 48 ?

yes line 48 i have it as two lists (not arrays) for simplicity. as resolutions has all resolution types including refresh rates, so i make it so that the first has all the resolutions with the same as my monitor, and the second it'll just add a new refresh rate when it sees one.

rich adder
patent wedge
frank linden
#
foreach (var plant in hitColliders)
            {
                Debug.Log(plant);
                if (Vector3.Distance(plant.gameObject.transform.position, transform.position) < nearest)
                {
                    nearest = Vector3.Distance(plant.gameObject.transform.position, transform.position);
                    rDestination = plant.gameObject.transform.position;
                    rDestination.y = transform.position.y;
                    nearestPlant = plant.gameObject;
                } else {continue;}
            }

the log isnt logging anything

rich adder
#

cause if you retrieve the wrong index for the list then your issue comes up
slight nitpick from before also, Lists are just arrays that can expand

digital stone
#

im leaking memoruy with the particle effect system

rich adder
digital stone
#
using UnityEngine;

public class Distance_Script : MonoBehaviour
{
    private Transform parentTransform;
    void Awake()
    {
        // Cache the parent transform once
        parentTransform = transform.parent;
    }

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if ( transform.position.y  <parentTransform.position.y -11)
        {
            Destroy(gameObject);
        }
    }
} ```
patent wedge
frank linden
#

i created variable, didnt use it

digital stone
rich adder
frank linden
#

using it also, nothing changes

frank linden
#

instead of the LayerMask variable

rich adder
frank linden
#

but now that i changed it, nothing happens

#

Collider[] hitColliders = Physics.OverlapSphere(transform.position, vision, plantLayer);

#

it is set in the inspector

rich adder
frank linden
rich adder
#

as I said, the indeces don't match

#

you're off by about 1

#

look over your code again careful and you will see. I can't do a full view rn cause on mobile but you can verify

patent wedge
rich adder
rich adder
frank linden
#

no it doesnt

#

ahh

#

got it

rich adder
#

then how is overlap supposed to hit it 🥲

patent wedge
#

oh! it happens everytime i change the resolution. i know you said about it before but the error didn't point to it.

frank linden
#

box collider trigger should work right

rich adder
#

yeah any collider but if this is 2D colliders you need Physics2D.OverlapCircle
oh its 3D. then yeah you're good nvm

frank linden
#

well then how was the rDes being set

languid pagoda
languid pagoda
frank linden
rich adder
frank linden
#

it is the destination of the resource (food here)

languid pagoda
rich adder
rich adder
frank linden
#

i can send the function if u want

rich adder
#

on mobile its easier to see it in a dedicated code paste site and discords awful code embed

frank linden
#

the whole file?

rich adder
#

whole is fine

frank linden
rich adder
frank linden
#

will change tht

languid pagoda
# rich adder I mean sure some stuff got axed but "worst commercial game engine" is a stretch

Dots has been out for years. Still no built in animation system. The engine is on its 5th version of multi-player libraries. They come out with all these new features that are half finished with incomplete tooling. It took until Unity 6 to get rid of random progress bars that would halt your work for 3 to 5 minutes. There are a ton of community implemented features that most engines have built in for example world streaming and imposter systems. I can't think of any other commercial engine that has these issues.

Don't get me wrong I do like Unity but there are so many issues that other engines don't seem to suffer from. There is a reason most studios favor unreal and imo it's because they know every feature in the engine is going to polished complete and have 100% of the needed tooling put of the box

frank linden
#

but unity is kinda intuitive, getting things started

#

i tried godot, didnt understand a think

rich adder
frank linden
#

unreal, well thats for nasa engineers

languid pagoda
rich adder
#

one very popular game. Marvel Snap.. all unity

#

the list goes on

languid pagoda
#

You honestly gonna try to argue that unity gets more use than unreal

rich adder
#

you can take any top 10 games and 8/10 probably unity

frank linden
#

and probably 0/10 care if we argue guys 😅

rich adder
#

Unreal runs like shit, but big studios dont care because they dont have to pay money to mantain their own engine anymore

frank linden
#

@languid pagoda, might be the worst but stillgets people into game dev, and thats enough no?

rich adder
#

..anyway no point of arguing about it anyway, it makes no difference what we think in the grand scale of things.. Use whatever engine fits your project and move on.. the end result is the only thing that matters

languid pagoda
#

Unity gets more use out of hobbyists. Unity has 2 successful titles that I am aware of tarkov and marvel both of those games had to implement major systems to accommodate for missing/incomplete/non performant systems

patent wedge
frank linden
#

and people getting into the hobby is great

languid pagoda
#

But I prefer Unity myself I like it better but these are the types of discussions that need to be had to make the engine better

rich adder
frank linden
#

either companies use in house or smth commisioned, so laymen like us are more important

languid pagoda
rich adder
cosmic quail
frank linden
#

isnt Ue in house itself?

cosmic quail
#

and all the successful indie games that i know are made in unity

rich adder
languid pagoda
rich adder
#

sounds like you have a personal vendetta thats clouding your facts

frank linden
#

what if unity is bad and ue is good? nothing changes will it

languid pagoda
rich adder
#

I get it, I'm hurt we still dont have CoreCLR while unity is pushing AI bullshit...I dont disagree that they have poor management but the engine itself...thats another story

rich adder
languid pagoda
rich adder
#

isn't ECS Physics supposed to be a custom built physics engine as well ?

#

you have 2 other options no?

#

Havok is probably one of the best out there..

frank linden
#

how do i implement thirst feature guys

#

i mean the water

languid pagoda
#

If you want good vehicle dynamics in your game get ready to write your own suspension with raycasts and your own tire friction code using brush model or pacejka formula. Meanwhile unreal engine has simulation grade vehicle physics out of the box

rich adder
frank linden
#

should i make it out of plane or smth else

languid pagoda
rich adder
cosmic quail
frank linden
#

and nav what would you recommend, hunger based system like this, where you eat you survive or something like energy based system

languid pagoda
rich adder
#

the amount of "out of the box" they need just to keep up makes sense

#

Input system on Unreal was dog shit, it is compared to new Unity Input system.. I see unreal has finally copied a similiar system

cosmic quail
languid pagoda
#

I mean unity went what? 5 years with no officially supported multi-player solution as well

rich adder
languid pagoda
frank linden
languid pagoda
#

You don't have to jump into c++

rich adder
#

what happen to Verse 😂

languid pagoda
#

No idea what that is lol

rich adder
frank linden
languid pagoda
frank linden
#

i am making an eco type sim

rich adder
frank linden
#

player is just an observer

languid pagoda
rich adder
languid pagoda
rich adder
languid pagoda
#

I have embedded it into unity in the past and it executes code just as fast as c# without any memory bottlenecks

languid pagoda
rich adder
#

yes but I suppose there is a reason it never took off. I'm not technical enough to know those so I'm not sure.

#

Make your own engine with it thinksmart

languid pagoda
# rich adder Make your own engine with it <:thinksmart:1202247906455982142>

Oh I'm good bro I already embedded it into unity. It has a ton of use in game modding. San Andreas multi-player mod features 1k player servers that ran well and all the game modes were made with pawn.

A lot of the reason why it never caught on is because it's advertised as a 32 bit language but it's as simple as changing one definition in a header file to make it work for 64 bit systems

rich adder
#

oh that just went up in my book.
sa-mp was the shit

#

no idea it was using Pawn

languid pagoda
#

Essentially pawn compiler would calculate all the needed memory for the scripts and then the runtime would then allocate it all up front in one linear block that made the cpu really happy

#

It's an awesome little language though. The ide even has a full debugger like visual studio with breakpoints etc

grand snow
#

Is this related to source pawn

west sonnet
#

I'm really struggling to figure out how to create a weapon system where the player can switch , drop and pick up weapons. Does anyone know any good tutorials that go over that? I'm struggling to find one

wintry quarry
#

The biggest thing is to make sure you have properly separated the three incarnations of the weapon:

  • the version of it in the game world
  • the version of it in the inventory
  • the version of it it when you're actually holding it

It's best to keep these distinct from one another

tacit prism
#

character now moves forwards based on camera orientation. Sprint no longer works, despite rb.velocity being tied to plyMoveSpd, it seems as though the speed the rigidbody can move is capped around 5-10f. 50 makes barely a difference compared to 5. I want to set up sprinting, but if the speed is capped like this i wont be able to do what i want. https://paste.mod.gg/ttmjkoonrpoy/0

languid pagoda
#

idk much about sourcepawn i just know the interpretter they made is not as performant 🙁

grand snow
#

Thought as much. All these scripting langs are cool but doesnt help learning em when a new one exists each week

#

sourcepawn is alright but tbh all I have done with sourcemod has been c++

#

which they neglect

languid pagoda
#

I have a pawn abstract machine written in asm that is called to from C# it runs game code so good. The only real annoying this is that objects do not exist, so I have to keep dictionarys of objects and pass the key to pawn as an "ID" so to speak.

#

still works fine but can be annoying when exposing new systems to the scripting language

tacit prism
languid pagoda
#

so yes that makes sense

grand snow
west sonnet
#

Can I add a Transform of a gameobject inside a prefab into a Scriptable Object?

grand snow
#

You need to ref the prefab asset

west sonnet
#

In the ScriptableObject?

grand snow
#

I dont think it will work to ref a child inside a prefab asset

#

But you can try it and see ™

tacit prism
#

which is why im confused

grand snow
languid pagoda
grand snow
#

Yea pointers are not reliable in a managed language

royal charm
#

just started unity (switched from making a game on roblox studio and want to make it in unity) and everything looks so daunting

grand snow
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

languid pagoda
# tacit prism which is why im confused
float plyMvspd = plyWlkSpd;

        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            plyMvspd = plyRunSpd;
            isSprinting = true;
        }

Each frame you assign the move speed to walk speed, then on the key that you press a button you change movespeed to run speed. So this code causes your player to only sprint on the single frame the key is pressed then it goes back to walkspeed

royal charm
west sonnet
tacit prism
#

honestly i like unity's ui a little more than unreal, however there are some...other things about it that are questionable

still trying to learn the terrain editor for unity, but i think thats more because im bad at art.

grand snow
timber tide
#

UI like the inspector cause the actual UI tools are horrible

languid pagoda
tacit prism
timber tide
#

UI Toolkit is legit though

grand snow
#

😭 oh no assigning text is soo hard

#

Ive made do for many years

languid pagoda
west sonnet
timber tide
#

UGUI is bad because it tries to be like flex but it fails at everything that flex does right

grand snow
tacit prism
#

but yippee, i have base movement set up, next up is jumping

languid pagoda
west sonnet
tacit prism
#

honestly if it werent for the fact unreal didnt save 2 of my projects in a row properly, i wouldnt have started learning unity instead

languid pagoda
grand snow
#

There is no sane reason to think about trying to reference a child of a prefab because its not in a scene, its an asset.

languid pagoda
#

Question is there a way to add your own event triggers to the ui event system? or are stuck only with onselect onsubmit ondeselect etc?

tacit prism
grand snow
tacit prism
#

that was the second project, that made me swap

languid pagoda
grand snow
ember valley
grand snow
tacit prism
#

but amazing job

languid pagoda
ember valley
languid pagoda
#

Does ui toolkit work with the ugui canvas?

grand snow
#

its seperate but unity 6.3 added world space support for ui toolkit

languid pagoda
#

im not on 6.3 unfortunately

#

also I dont like I have to learn some markup language to use it

grand snow
#

Then if you want to use UGUI you can just make some components yourself to aid how you build your UI

languid pagoda
#

Yes I know

#

but still it should be included in the engine

grand snow
#

well it wont happen so thats the end of that

languid pagoda
#

The bones for it are already there

#

So back to my original question is there a way to create our own event triggers or are we stuck with the default ones?

grand snow
#

whats is a trigger? A UnityEvent?

#

you can use then yourself if you want reflection based subscriptions

#

OnClick on Button is a UnityEvent thats invoked when its clicked

kind cave
languid pagoda
#

Im trying to create my own trigger for the event

grand snow
#

Ah these are from event system and no you cannot make more
you are confused I think

#

These are called based on pointer interactions on a ui gameobject

#

You can respond to these via this component or yourself via interfaces but you cannot make more

languid pagoda
#

unfortunate

languid pagoda
#

so is it at all possible to write a custom data binder ?

grand snow
#

yea ofcourse

cosmic dagger
#

You can write your own custom code to create a custom event that you can expose yourself . . .

grand snow
#

You can use UnityEvent, SendMessage(), c# events, reflection... You can do many things yourself

languid pagoda
grand snow
languid pagoda
tacit prism
#

quick question, how are hitboxes made for players in games. Do you use the capsule collider (lets say a hitbox that determines whether a sword hitting you deals damage)

i want to know because im setting up jumping next.
Im not sure if i want to set up a floating capsule with a raycast that slightly raises its location, making it look like the player is on the ground when really its floating a little higher, or if there is an alternate item used for hitreg on players

i want to use the floating capsule, so that small surfaces sticking out of the terrain wont get the player stuck, and the player can just move over them

#

so is there a seperate tool for hitreg?

languid pagoda
#

Like do I really gotta use reflection to set up my own inspector like this?

short hazel
#

Yes that is how these fields and methods are retrieved to be displayed in these lists

languid pagoda
# tacit prism quick question, how are hitboxes made for players in games. Do you use the capsu...

Depends on the game. Counter strike hitboxes are a ton of seperate box colliders. I would avoid capsule collider approach. If you use capsule colliders things like animations will not effect the hitbox. So if you use the capsule approach you're going to have to adjust the size and position of the capsule if your player crouches for example. But with the way counterstrike does it each collider is assigned to the bone it represents so it just stays in the the correct place automatically.

rich adder
#

interestingly new CS2 uses capsules

cosmic quail
languid pagoda
rich adder
languid pagoda
#

Never really gave it much thought though.

rich adder
#

I thought the curvature creates complexities.. But I assume for accuracy capsules are a must

languid pagoda
cosmic quail
tacit prism
#

wondering:

can i assign enemy attacks to a certain layer
make my initial capsule that controls player movement ignore said layer
and then assign capsules based on the bone structure for the player to get hit by said enemy layer

#

not proficient with unity so idk if thats possible or not

languid pagoda
tacit prism
#

or at least reasonable

languid pagoda
#

layermask is what you want

tacit prism
#

im using layermask for jumping, cool it has that application as well

#

thankes

deep merlin
#

Does anyone know how to set a variable in Unity's visual machine if a condition is met (such as if the "this" object's Z position is x)

rich adder
deep merlin
#

I don't know any good resources for visual machine

languid pagoda
short hazel
#

Sphere is just "is the position within the radius" so it's faster

cosmic quail
cosmic dagger
#

Capsule would be faster because it's just a position and a radius . . .

languid pagoda
#

I mean either way isn't the box just a distance check as well? Either way its addition/subtraction on a 3d vector

cosmic dagger
#

The problem (not really a problem) with box collisions is when it is rotated. Those calculations cost more . . .

languid pagoda
#

Honestly I am glad we dont live in a time where chosing box or sphere will make an actual impact.

rocky canyon
#

i 🧡 choices

cosmic dagger
night raptor
#

There are a lot of factors that goes into the equation of separating colliders. All of the primitive collider shapes are very fast though. I have always been told sphere is fastest and then capsule and box. Probably depends on way too many factors to give any proper comparison in general cases

cosmic dagger
#

True, as long as you choose the collider that best fits the object's shape, you're good . . .

cosmic dagger
# languid pagoda

You wouldn't be able to add to this because those options are pulled from the EventTriggerType enum. Your best option to create your own component with a custom drop-down of your custom events . . .

languid pagoda
#

What I am trying to do is be able to select a variable on a specific object in the inspector

cosmic dagger
#

You should be able to find the editor file they used to see how they achieved it . . .

rocky canyon
#

say I have gameobjects

  • Root (Master Switch/Functionallity)
    • Graphics (animation)
    • Collider

right now I have a script called SwitchLink on the collider w/ reference to the MasterSwitch class on the root.. and I use a tryget for the raycast for the collider

is there a better more fundamental way of doing this?

#

i dont really like looping thru children or up to the parent.. (no clue why)

#

i got this round-about kinda way to access everything i need but just trying to minimize.. and now that i think about it this concept would apply to alot of my objects since they all have their own Collider object as a child..

#

so if i could realize some nifty way that im missing it'd be soo cool

silver copper
#

I need developers

cosmic dagger
rocky canyon
# cosmic dagger You use `TryGet` because it's not assigned and you want to make sure it is befor...
using UnityEngine;

// SpawnCampGames
public class LabRaycaster : MonoBehaviour
{
    public SwitchLink currentTarget; // link component on collider
    private Camera cam;

    void Start()
    {
        cam = Camera.main;
    }

    void Update()
    {
        Ray ray = cam.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            // Check if the hit object has a SwitchLink
            SwitchLink link;
            if (hit.collider.TryGetComponent(out link))
            {
                currentTarget = link;
            }
            else
            {
                currentTarget = null;
            }
        }
        else
        {
            // Hit nothing
            currentTarget = null;
        }
    }
}
``` basically it'll be the only interactions i'll have in this demo... (just getting `SwitchLink`) via raycast
#

i just use trygets for the easy out lol

cosmic dagger
rocky canyon
#

i thought about doing Interfaces.. but they're really not needed since i only have (1) interactable

silver copper
naive pawn
#

!collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

rocky canyon
#

but whether its an interface or just a class doesn't really matter to me right now.. just wondering if there was a "trick of the trade" i might be missing

silver copper
#

!collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

cosmic dagger
#

☝️ There you go . . .

rocky canyon
#

i mean i could just put the collider on the root

#

but i thought i was being clever by having them their own object

#

if(Input.GetKeyDown(KeyCode.E)) currentTarget.switchMain.Toggle(); i guess this is clean enough

#

crying over spilt 🥛 i guess lol

rocky canyon
cosmic dagger
#

Also, I believe you can do:

if (hit.collider.TryGetComponent<SwitchLink>(out var link))
{
    currentTarget = link;
}
else```
to remove `SwitchLink link;` . . .
rocky canyon
#

ohh true... theres soo many different variations of TryGet i get confused

cosmic dagger
#

If you place the collider on a specific layer and use that layer mask, you can remove the entire TryGet because you'd know it has the component (if the collider is not null) . . .

lethal meadow
#

how can i remove triangles from a mesh at runtime?

rocky canyon
#

get mesh
get original data
rebuild it ignoring the ones u want to remove
apply new triangles list
Recalculate Mesh (normals/bounds/etc)

lethal meadow
#

would i not get indexing issues

rocky canyon
#

if you remove triangles that leave behind vertices.. you'll need to rebuild the vertices array as well

lethal meadow
#
for (int i = 0; i < vertices.Length; i++)
{
    if (updatedVertices[i].position.x == 21741000)
    {
        continue;
    }
    else
    {
        vertices[i] = updatedVertices[i].position;
    }
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
meshFilter.mesh = mesh;
#

like this?

rocky canyon
#

not sure.. i think if u remove triangles but keep the original vertices array untouched it shouldnt cause any issues

lethal meadow
#

21741000 is what i put the x at when i want it to be deleted

#

because that causes indexing problems

rocky canyon
#

Right now you’re “deleting” a vertex by shoving it way off at x = 21741000.. i thnk, im not 100 sure.. im just googling as i go..

but I think that doesn’t actually remove it — the vertex still exists in the array, and** if any triangle index points to it you'll error out**

lethal meadow
#

i do that in a compute

#

after i have to rebuild the array of positions and then set it to the mesh

#

if it has the high x value i just skip it

rocky canyon
lethal meadow
#

i mean if i could do it in the compute even better

#

i dont think i can though

rocky canyon
#

Instead of skipping those “deleted” verts, just keep their slots in the array and put them at some safe place (like (0,0,0)).
That way, indices still match up.
Triangles that reference them will collapse into degenerate (zero-area) faces → they won’t render, no explosions.``` does this sound like something useful?
lethal meadow
#

no

#

ive tried that it just causes large stretched vertices

#

ive tried collapsing into neighbouring verts too and it causes the same issue

rocky canyon
#

the only thing im seeing is something about Orphan Verts
if you dont delete or move verts but instead delete the triangles that use them you should have a "clean" mesh

#

but to be honest im outside my wheel house on this one.. just figured i'd try to brainstorm w/ ya since im here

ancient junco
#

In the OnEnable method i am trying to add a method to an event in my other class. but its null, i think the awake function not been called yet. any ideas on how to solve this, or a better way of doing it?

rich adder
#

its not guaranteed another objects Awake will run before this objects OnEnable

neon forum
#

how do I add the drag event system to a unity class? Is it IPointerDrag? Where's the documentation for this stuff?

lethal meadow
# rocky canyon the only thing im seeing is something about Orphan Verts if you dont delete or m...
vertex[] updatedVertices = new vertex[vertexBuffer.count];
        vertexBuffer.GetData(updatedVertices);

        for (int i = 0; i < vertices.Length; i++)
        {
            
            vertices[i] = updatedVertices[i].position;
        }

        List<int> newTriangles = new List<int>();
        int[] currentTiangles = mesh.triangles;

        for (int i = 0; i < currentTiangles.Length; i += 3)
        {
            Vector3 v0 = vertices[currentTiangles[i]];
            Vector3 v1 = vertices[currentTiangles[i + 1]];
            Vector3 v2 = vertices[currentTiangles[i + 2]];
            Vector3 center = (v0 + v1 + v2) / 3;

            if (center.magnitude < 1000)
            {
                newTriangles.Add(currentTiangles[i]);
                newTriangles.Add(currentTiangles[i + 1]);
                newTriangles.Add(currentTiangles[i + 2]);
            }
        }

        mesh.triangles = newTriangles.ToArray();
        mesh.vertices = vertices;
        mesh.RecalculateNormals();
        mesh.RecalculateBounds();
        meshFilter.mesh = mesh;
#

fixed it

#

just remove the triangles and keep the vertices

#

no stringy vertices going 2171000 meters away 😍

rich adder
rocky canyon
#

all about that Continue

#

skip those mofos

ancient junco
neon forum
#

what about IBeginDragHandler and IEndDragHandler? Are those outdated?

rich adder
lethal meadow
#

you just need a ray triangle intersection function

rich adder
#

they can also work. Point is you probably get a better result start/end drag to set a bool
IDragHandler always gave me weird result but could work

rocky canyon
#

a lil AddExplosionForce at the origin?

#

this was my first time manipulating a mesh..

lethal meadow
#

i didnt think of that

rocky canyon
#

not too crazy (altho i testing w/ a cube) lol

lethal meadow
#

you could create a seperate triangle mesh and add physics and push it out

rocky canyon
#

ur own fractal destruction

#

i might see if i could make something that did that w/ any mesh

#

that'd be a cool little mechanic to add everywhere

lethal meadow
#

i'd probably do a compute shader

#

you raycast to get the mesh