#archived-code-general

1 messages Β· Page 399 of 1

vestal arch
dusk apex
swift falcon
#

Unity have spent many years migrating to new .net, just wait a little more shall we 🀣

swift falcon
vestal arch
#

how about discord on your pc

swift falcon
#

Nah too lazy to install

vestal arch
#

im really not sure what the issue there is

swift falcon
#

Or open whatever

vestal arch
#

sounds like a you problem; don't make it all of ours too

#

you don't even need to install discord

dusk apex
vestal arch
#

you can open it on the browser

swift falcon
#

Oh

#

Okay txn didnt know

#

Hi everyone I am stuck on my dev may I have some help plz ? Its about to aline my player gameobject to the animation (the animation has Root T modifications)

vestal arch
#

!ask

tawny elkBOT
vestal arch
#

see the last point specifically

dusk apex
small schooner
#

@vestal arch Why my brain told me interface is not an inheritance, because any class can have any interface and any number of interfaces. When inheritance it is like a tree, so I would rather say class can inmplement many interfaces rather then class inherit from many interfaces

swift falcon
#

lol, lmao even

vestal arch
#

i have no idea what you're trying to say

small schooner
#

Okay parent can have children, each chield can have many own children that is inheritance. but with interface any of this class can implement same interface

vestal arch
#

if you accept polygamy you can have as many parents as you want

small schooner
#

not biological parents

#

you can only have 2 biological parents

vestal arch
#

if you accept polymorphism you can have as many parents as you want

leaden ice
#

Decompilation is not allowed to be discussed here

halcyon swallow
crisp minnow
#

When I have SplineContainers passed in as prefabs into an object, can those pefabbed splines transform be modified in any way or should I instantiate them directly in the scene, correct their positions and pass them into the container that way? It works when dragged in (they automatically take the parent's transform) but not when passed in as prefab

pure grove
#

private void UpdateSelectionIndicator()
{
// Calculate the index of the selected button based on currentRow and currentCol
int index = currentRow * HERO_COLUMNS + currentCol;

    // Get the button corresponding to this index
    selectedButton = characterSelection.buttons[index];

    // Update the position of the selection indicator (anchor to the top-left of the button)
    RectTransform selectionRect = gameObject.GetComponent<RectTransform>();

    // Set the selection indicator's parent to be the selected button (this should be done only once)
    gameObject.transform.SetParent(selectedButton.transform, true);
    gameObject.transform.localScale = Vector3.one;

    // Set the anchor and pivot to the top-left of the button
    selectionRect.anchorMin = new Vector2(0, 1);  // Top-left corner
    selectionRect.anchorMax = new Vector2(0, 1);  // Top-left corner
    selectionRect.pivot = new Vector2(0, 1);      // Pivot at top-left corner

    // Position the indicator at the top-left of the button
    selectionRect.anchoredPosition = Vector2.zero;
}

How can I convert this to make it work with netcode? SpawnStateException: NetworkObject can only be reparented after being spawned
UnityEngine.Debug:LogException(Exception)
Unity.Netcode.NetworkObject:OnTransformParentChanged() (at

Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false. This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues.
UnityEngine.Transform:set_parent

leaden ice
#

something is very wrong with whatever you're doing

floral rain
#

Hey guys. My Unity project works fine, but when I build it, I get this:

#

Using Unity 6.25f1

#

I really don't know how to fix this serialization issue. I've tried reimporting everything to no avail.

#

Looking at the logs seems like pretty much all monobehaviours are misbehaving...

cosmic rain
#

!code

tawny elkBOT
cosmic rain
#

The error actually explains that.

pure grove
floral rain
#

I'm using newtonsoft's JSON for serializable calsses, but I have done so in the builds prior as well

cosmic rain
verbal hazel
#

how can I figure out what the massive holdup is here? I don't understand how one line can take 17k ms but when i drill into it, I don't see 15k+ ms of that accounted for.

cosmic rain
steady bobcat
tired widget
#

once i go into play mode, everything is deleted from my scene besides my canvas. how do i fix this?

modern creek
#

Seems like a silly question - but anyone know how I can easily delete item 0 from a list in the inspector without manually re-linking all the other items? (order matters so I can't just drag the nth to the 0th position)

modern creek
modern creek
quartz folio
#

Or select it and press del

modern creek
#

Oh! I thought that always deleted the nth element.. TBH I didn't even realize you could select a list item

#

Worked great, thanks much.

tired widget
#

also my lighting only works for level 1 for whatever reason

modern creek
#

how are you creating your lighting in scene 2?

#

(and how are you doing it for scene 1?)

#

sounds like you're either not bringing your lighting into the scene, or you have different camera settings on 1/2

tired widget
modern creek
#

I can't really tell what you're showing me.. but on one of the lights, you have a global light, and the other you have a spot light? And those objects are both in level 1 and level 2?

#

snap a pic of your hierarchy when you're editing level 1 and level 2 - and highlight your lights

#

i'm about to go AFK though so might not be able to help you .. but maybe someone else'll see what you've done.. but I suspect you've deleted your game objects, either by loading the scene, or something else

robust trout
#

Is nullability generally used in Unity? If I enable it my ide lights up like crazy, however I don't really want to have things be null without specifically typing it as so

cosmic rain
#

References would be null, unless you explicitly assign something to them.

robust trout
#

Right, I'm just curious if most unity developers enable it

cosmic rain
#

I don't think so. It might be useful in simple programs, but games are way more complex and nuanced.

#

I guess it's also partly a preference thing.

quartz folio
#

It's a little annoying around serialization, and UnityEngine.Object subtypes' fake-null

#

but it does help to weed out basic logic errors in normal functions

zenith acorn
#

when I'm trying to convert the render pipeline

#

It asks me to save scene for some reason

cosmic rain
#

Or used the sample scene. It's known to cause all kinds of issues.

zenith acorn
#

Indeed

#

For some reason my scene suddenly changed to a new scene

pearl burrow
#

any good soul/mathematician that would spend some time with me finding a good exp progression in my game?

mental reef
#

I had the sample scene completely reset on me once. Good practice is to scrap the sample scene and create a new one

simple egret
#

Sometimes after a restart or a crash it'll open this "default scene" with nothing in it. You just have to find your saved scene in your assets and open it again

#

By default it opens your last active scene IIRC, which is why people are sometimes surprised that they lost all changes where in reality they didn't

zenith acorn
#

Is there a limit towards unity's instantiate?

#

So I made a for loop that supposed to loop 5 times and the instantiate code inside it

#

However it only spawns 3 of the game object for some reason

swift falcon
#

hey is anyone familliar with people playground if you do pls dm meπŸ˜‡

thin aurora
thin aurora
#

If this is happening, the code's behaviour intentionally spawns 3

#

If you want help, share the !code and somebody can point out the problem

tawny elkBOT
zenith acorn
#

and sometimes they collide with each other and causes them to reach the max collisions when spawned

sonic swan
#

if i were to go about adding weight to my object how would i . by weight i mean the ability for a player to sit on a pulley and that actually affecting them and bringing them down or up?

swift falcon
swift falcon
#

oh alr thanks

thin aurora
#

I don't know what People Playground is, but generally discussions involving modding something are not allowed here

swift falcon
#

hmm i dont mean by cheating by the term modding i meant like adding more variations to the game it includes coding

dense helm
#

hi guys just started unity, is it allowed to ask dots/ecs question here? thanks!

thin aurora
#

But again, if you want help you'd have to post your question

swift falcon
#

ooh alr

#

thx

round trellis
#

I currently have a chest, which I want an animation to play, when I enter the BoxCollider, how can I access the animation?/Play it when the box collider is triggered

#

The script is only for testing rn

sonic swan
dense helm
round trellis
dense helm
eager tundra
#

yeah, for ECS you should avoid inheritance

round trellis
#

nvm then

#

scratch what I said

eager tundra
#

you should probably ask at #1062393052863414313
but one alternative is to have tag components instead of one big component with all of the bool values

#

or enableable components

dense helm
#

gotcha thanks

eager tundra
#

having them as separate components makes it easier to query

dense helm
dense helm
#

an advice of sorts

eager tundra
#

that's a bit too broad, but I would say to keep managed and unmanaged code as separated as possible

dense helm
#

no i mean I have another question, is it alright to ask u?

eager tundra
dense helm
# dense helm Ill just ask if you guys dont mind. Would this be considered bad practice for ec...

so i guess my question would be an extension of this. Since I'm using a client side prediction for character controller, wouldnt it just be right to update these properties in client side? I am wondering since because when i'm updating these properties in predicted simulation system groups and while they do update in both server and client they often differ in results or in other words its not synchronize.

round trellis
sonic swan
#

is there a openchest parameter in your animator window

round trellis
#

yes obv

sonic swan
#

and is the transition set to use the openchest parameter

round trellis
#

dont think so

#

how do I do that

sonic swan
#

click the plus sign in conditions

round trellis
#

makes sense....

sonic swan
#

also if you want no smooting frames btween animations set transition duration to 0

round trellis
#

kk thanks, it seems to be looping tho, it could be my code

dense helm
#

could be

round trellis
#

it certainly was not, thanks for ze help

sonic swan
round trellis
#

Ok lmao, I thought general was fair, since I know how to code, I just dont know all the classes, functions/methods yet

cosmic rain
#

It depends on the context. Composition means breaking the behaviour into smaller replaceable components(not necessarily unity components).

leaden ice
#

You're asking a question that is much too general. What's the specific use case you are trying to address?

#

Is the user a game developer?
End user/player of your game?

What's the feature and how do you want them to provide an implementation? In the form of C# code?

cosmic rain
#

Then use interfaces or base classes. This has nothing to do with composition though.

#

These are 2 completely separate things. I'm not sure how exactly you put them in an x or y statement.

#

Whatever fits your needs. An interface would allow them to provide an implementation for whole objects. The same thing with delegates might require you to implement many interfaces for each method you want the user to be able to override.

#

Unless I'm misunderstanding what you have in mind.

thin aurora
#

What's with people deleting messages after a conversation started? Just leave them lol

mental turret
#

i'm trying to add logitech SDK to my unity project, but its saying its not existing, can i fix this issue or just cant do anything without writing my own integration ?

#

also, the DLL is here

#

i have modified no script from the Asset Store pluygin

knotty sun
mental turret
#

thats what logitech provided if i need to edit it i will

knotty sun
#

Looks, fine ,what I would expect

knotty sun
mental turret
#

yeah it was already ready for it

distant niche
#

Why am I getting a type mismatch when I put a part of my character's rig in my public Transform property?

knotty sun
mental turret
distant niche
knotty sun
mental turret
knotty sun
#

link?

mental turret
knotty sun
mental turret
#

2023.2.7

#

f1

knotty sun
#

that's not good, not a LTS

mental turret
#

oh

#

yeah maybe thats why

knotty sun
#

let me just have a look with Unity 6

mental turret
devout harness
#

Is load order (and consequently instance IDs) deterministic in a built project?

knotty sun
# mental turret alr

I suggest you read the reviews of the asset, it looks like it does not work out of the box and needs some extra work from your side

mental turret
#

oh

devout harness
mental turret
knotty sun
mental turret
#

thats what i'm gonna try

#

nope

#

dont work

#

still getting DLLNotFound

knotty sun
#

tbh, looking at the asset I'm really surprised that Unity even accepted it for the Asset Store

mental turret
#

why ?

knotty sun
#

doesn't work, throws errors, relevant documentation is non-existant. All big red flags

mental turret
#

i mean , it might have used to work in the past, it just dont work anymore

knotty sun
#

well, that is not the impression I get from the reviews

mental turret
#

hasnt been updated since 2018 so idk

knotty sun
#

that should tell you plenty

mental turret
#

yeha

#

and the DLL on logitech website date from 2015 so even worse

devout harness
# leaden ice By... referencing them?

You either successfully made the most insane insight on the design problem I was running into, or that was a misunderstanding from my context-lacking question that conveniently worked out

Either way your answer got me to a solution, thank you!

zenith acorn
#

I have a projectile gun and I'm experiencing a wierd bug that didn't happen before I applied the bullet pool

#

For some reason sometimes when I try to shoot the gun it's flying off to a different location first

#

before proceeding to fly with it's original direction

#

and the position that it's flying to seems to be the position that the bullet pool created the bullet from

#

this is the bullet if I just enable it without doing anything

hexed pecan
#

Show the code where you spawn/launch the bullet

zenith acorn
#

The script that I applied is here

#
GameObject currentBullet = BulletPool.bulletPool[bulletType].Get();
currentBullet.GetComponent<CustomProjectiles>().Reset();
currentBullet.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
currentBullet.GetComponent<Rigidbody>().linearVelocity = Vector3.zero;
currentBullet.transform.position = attackPoint.position;
currentBullet.transform.rotation = Quaternion.identity;
//Rotate bullet to shoot direction
currentBullet.transform.forward = directionWithSpread.normalized;
//Add forces to bullet
currentBullet.SetActive(true);
currentBullet.GetComponent<Rigidbody>().AddForce(directionWithSpread.normalized * shootForce, ForceMode.Impulse);
currentBullet.GetComponent<Rigidbody>().AddForce(fpsCam.transform.up * upwardForce, ForceMode.Impulse);
#

The custom projectiles reset function seem to have no effect on it cause I tried to disable the script and it have no changes to the outcome

#

Sometimes it works perfectly fine shooting towards the angle that my camera is looking at

#

and sometimes it just fly towards the other position before flying according to the angle of my camera

knotty sun
heady iris
#

BulletPool should not hold GameObjects, yes

#

it should hold some kind of Bullet type

heady iris
#

If the bullet has interpolation enabled, it will ignore the position and rotation that got set here

knotty sun
zenith acorn
heady iris
heady iris
zenith acorn
hexed pecan
#

I would use rigidbody.position/rotation instead of transform to teleport it into place

knotty sun
#

So add a Ridigbody reference to CustomProjectiles

zenith acorn
#

Like I have a Explosion Bullet, Thunder Bullet and Split Bullet

heady iris
#

I presume you have three different pools, then

hexed pecan
#

And directly assign the bullet's velocity instead of adding forces might make a difference

heady iris
#

These three types can all inherit from a Bullet class

#

basic polymorphism

#

each kind of bullet can have its own special reset logic, if needed

zenith acorn
#

What I did until now is that all of them share the same script with different values

hexed pecan
#

Another thing to try is to wait until FixedUpdate before spawning the bullet, but that might be noticeable

heady iris
#

this will ensure the bullet is in the right place during rendering

#

I don't know exactly when an Interpolate-enabled rigidbody moves its transform

#

if it goes after you, then no harm done

hexed pecan
#

rigidbody.position should skip interpolation

#

But might wanna do both

heady iris
#

Right, I'm just not sure if it'll get positioned correctly on the frame that you spawned it

hexed pecan
#

Yeah

#

Me neither

soft escarp
#

what would be the best solution for slope movement? im using triggers to detect the ground(its very effective lol) but i have no idea how to apply that to slopes, i really have a hard time doing it ,_,

zenith acorn
#

But there's still a slight error

hexed pecan
zenith acorn
#

like due to the bullet having a trail it is now kind of obvious towards the player that where it's coming from

heady iris
#

(assuming that's what you're using)

hexed pecan
#

Diaagonal spherecast from the center of the body is what I landed on

#

For my own movement system

soft escarp
#

interesting

hexed pecan
#

I exaggerated the angle here abit

zenith acorn
#

so do I disable it first and only enable after I set the positon or?

hexed pecan
soft escarp
hexed pecan
#

Not sure if thats a criteria for you tho

heady iris
zenith acorn
hexed pecan
#

Or, well, as few as you need

heady iris
#

Useful for restarting a trail from a new position.

well there ya go!

#

Put all of this into the "reset" function on your bullets

#

Make the method virtual in Bullet and override it in the specific bullet classes

hexed pecan
#

@soft escarp The good thing about spherecasts is that it gives a smoothed/averaged normal when hitting a corner. A raycast does not

heady iris
#

That way, a bullet with five extra trail renderers can go and reset all of them

#

and the code that spawns bullets doesn't have to care at all

zenith acorn
#

I'm kind of confuse

#

By right it should work right?

heady iris
#

You forgor

#

check your syntax

zenith acorn
heady iris
#

you've tried to call Clear() on the GetComponent method itself!

zenith acorn
#

πŸ’€

heady iris
#

Also, no, bad! Make that Bullet class! Cat_Bonk

zenith acorn
#

I forgor the ()

heady iris
#

The spawning code shouldn't have to worry about all of these intricacies

soft escarp
heady iris
#
public abstract class Bullet : MonoBehaviour {
  [SerializeField] private Rigidbody rb;

  public virtual void ResetBullet(Vector3 spawnPos, Quaternion spawnRot) {
    rb.position = spawnPos;
    // etc.
  }
}

public class CoolBullet : Bullet { 
  [SerializeField] TrailRenderer trail;

  public override void ResetBullet(Vector3 spawnPos, Quaternion spawnRot) {
    base.ResetBullet(spawnPos, spawnRot);

    trail.Clear();
  }
}
#

e.g.

hexed pecan
#

So you need to make sure that the spherecast starts completely inside the player's collider

#

A tiny bit smaller, preferably

heady iris
#

alternatively, you could offset it backwards a bit

soft escarp
heady iris
#

(or maybe do both)

zenith acorn
#

but I need to rewrite the code though

hexed pecan
#

Offset from the player's bottom anchor, yeah

zenith acorn
#

Well I only clear the trailrenderer after I set the object to active

GameObject currentBullet = BulletPool.bulletPool[bulletType].Get();
currentBullet.GetComponent<CustomProjectiles>().Reset();
Rigidbody tempRb = currentBullet.GetComponent<Rigidbody>();
tempRb.angularVelocity = Vector3.zero;
tempRb.linearVelocity = Vector3.zero;
tempRb.position = attackPoint.position;
tempRb.rotation = Quaternion.identity;
//Rotate bullet to shoot direction
//currentBullet.transform.forward = directionWithSpread.normalized;
//Add forces to bullet
currentBullet.SetActive(true);
currentBullet.GetComponent<TrailRenderer>().Clear();
currentBullet.GetComponent<Rigidbody>().AddForce(directionWithSpread.normalized * shootForce, ForceMode.Impulse);
currentBullet.GetComponent<Rigidbody>().AddForce(fpsCam.transform.up * upwardForce, ForceMode.Impulse);
#

However the trail is still not being reset

hexed pecan
#

They re calling it

leaden ice
#

Also why continuing to GetComponent the Rigidbody when you already have tempRb

#

Oh somehow I misread that as calling Reset()

zenith acorn
#

Maybe I cleared it too soon or smth?

heady iris
#

oh yeah, one thing to watch out for

hexed pecan
#

What if you toggle emitting and/or enabled off and on again?

heady iris
#

Reset is a special method name for Unity

hexed pecan
#

On the trail renderer

heady iris
#

That method gets called when you reset a component, as well as when you initially add one

heady iris
#

The rigidbody moves the bullet from wherever it happened to be to the correct position after this code runs

heady iris
#

That's why you should set the transform's position immediately

#

just make sure it agrees with the position you give to the rigidbody

zenith acorn
#

Okiee

heady iris
#

Yes.

zenith acorn
#

Lemme try it

heady iris
#

That puts the bullet in the correct position instantly, and also tells the rigidbody that it should be in that position

zenith acorn
#

awwe man

#

it works now

#

thank you so much

heady iris
#

Order of operations can be very important

knotty sun
#

@zenith acorn Just a word of advice, when using object pooling you should reset them to their start configuration when you put them back into the pool not when you take them out

zenith acorn
#

Thanks for the suggestion

#

I'll definitely change that

smoky beacon
#

Hi,anyone know how I can keep the remaining particles alive after the projectile gameobject that they are attached to is destroyed? I already set up the script so they are being unparented and still alive before the parent is being destroyed. But that somehow makes them still disappear and snap to the collision point instantly. The simulation space is set to world...

zenith acorn
smoky beacon
#

yes I check it during runtime and they are succesfully unparented

hexed pecan
#

What scale does the projectile have and what is the scale mode of the particle system set to?

#

And yeah, show the code

smoky beacon
#

I just copy the whole code here in chat?

knotty sun
tawny elkBOT
halcyon swallow
#

as Confucius once said; the error in your code may be after the red error lines

knotty sun
smoky beacon
#

wait I believe Ive found the problem! When i disabled the collider for the projectile, then it worked for some reason

hexed pecan
#

But does it ever hit anything if you disable the collider

smoky beacon
#

oh yeah no that's why. So it was never destroyed... sorry. Pulling my hair here. Posting the code

halcyon swallow
#

also apart from fake confucious quotes is there a more elegant way to get the gameobject of a collider than
"raycasthit.transform.gameObject.TryGetComponent"
going through transform seems a little goofy

heady iris
#

If the collider has a Rigidbody in one of its parents, RaycastHit.transform will be the transform of the Rigidbody

#

RaycastHit.collider is the actual collider you hit

#
  • Vehicle <-- rigidbody
    • Door <-- collider

hit.transform would be the transform of Vehicle even when hit.collider gives you the collider on the Door

halcyon swallow
#

if that isnt giving me what i want then what can i do to get the gameobject a collider is attached to through a raycasthit

smoky beacon
#

There is no other collider than the parent. Still doesnt explain why the particles disappear

heady iris
#

it's pretty trivial to get the game object from that..

hexed pecan
eager yacht
# smoky beacon https://paste.mod.gg/ylacyjalzvvm/0

Seems like you just want this.

// could just have the ps in world sim space anyway
var main = ps.main;
main.simulationSpace = ParticleSystemSimulationSpace.World;
ps.Play();

// unparent from the object
ps.transform.SetParent(null, true);

// nuke the ps object
Destroy(ps.gameObject, main.duration + main.startLifetime.constantMax);
heady iris
#

And particle systems default to a scaling mode that only cares about the local scale

knotty sun
#

Also, reparenting without worldPositionStays will reset the... world position

heady iris
smoky beacon
#

Hmm ok, it looks like the particles all suddenly snap to the collision point... I'll check the worldposition

#

// Ensure the particle system continues in world space
var main = ps.main;
main.simulationSpace = ParticleSystemSimulationSpace.World;

        // Detach the particle system using worldPositionStays
        ps.transform.SetParent(null, true);
#

still didn't change anything... :/

heady iris
#

You can't just change the simulation space at the last second like that

#

All of the existing particles will now be in the completely wrong position

smoky beacon
#

it's always set to world position in the inspector

heady iris
#

Pause the game immediately after impact and select the particle system

#

there should be a window in the scene view that shows you info about the system

#

see if the particle count is zero or not

swift delta
#

what would you lads say is an okay way to deal with queueable varied actions in a game styled like the sims franchise?

swift delta
#

I am genuinely taken aback by the speed of that reply

#

was still typing out the details lol

smoky beacon
heady iris
#

ha, go ahead :p

heady iris
#

(or at least go down)

#

i want to make sure that's not somehow happening

swift delta
#

i.e. after clicking an NPC (or actor) you are now in an "action mode" of sorts. clicking something raycast-enabled will now bring up a radial menu from where the actor can pick relevant actions

#

ground:

  • go here
  • drop object here
    _ _
    building:
  • perform [work] here
  • drop off item
  • wait here
smoky beacon
swift delta
#

that kind of stuff

#

I was thinking of handling it with an inheritable BaseAction script or something similar which I could queue up in the actor's Actor script component

zealous lagoon
#

I uhh... huh?

#

its ambigious with itself?? seems tricky

heady iris
#

you've declared the same field twice

#

or you have two copies of the class in different files

zealous lagoon
#

oh

#

yeah you're right, thanks

heady iris
#

I was working on an RTS a while ago where telling a unit "attack that thing" would cause it to:

  • Try to execute the Attack action
  • Fail, because it's too far away, thus queueing a Move action in front of the Attack action
  • Wander over to the target
  • Try to execute the Attack action
  • Fail, because it's at the wrong angle, thus queueing a Rotate action
  • Rotate to the target
  • Try to execute the Attack action
  • Whack!
#

My current project uses goal-oriented action planning to let the AI figure out how to achieve things. It generates a BrainMoveAction to move to a place, then a BrainActivityAction to perform the "attack" activity

heady iris
swift delta
#

divide complex actions into smaller basic ones, and treat the big action as a sort of pseudo state machine?

heady iris
#

I recently added a way to give entities commands, actually

#

You right click on a target and get a list of every activity that makes sense for that target

#

then the entity is asked to make a plan that makes that activity possible

#

it was very fun to see that in action with very little legwork

alpine sentinel
#

Hello, it appears that Collider.attachedRigidbody is not being automatically set to a new parent's rigidbody. I have been implementing a magazine for vr use and I have added manual insertion of bullets to the top, but here is where the problem comes. The bullets get parented to the magazine in an empty transform and have their rigidbodies saved in a component "ComponentRigidbody" that also performs DestroyImmediate on the rigidbodies. The colliders of the bullets should therefore automatically attach themselves to the magazine's rigidbody, but they don't.

swift delta
#

and the list of "action that make sense" are manually assigned, I assume?

heady iris
swift delta
#

so on click you fire off multiple checks to populate the list rather than assigning things yourself

heady iris
#

The more abstract you get, the cooler the system is to describe to someone...and the more of a pain in the ass it becomes, too

#

πŸ˜‰

swift delta
#

hm so assuming I click the ground for an interaction, I would first attempt to make the navmesh check if it can go there and, if not, it will not populate the radial menu with a "go to" action

heady iris
#

so, coming back from my Architecture Astronaut hellscape

heady iris
#

So you'd have a new "action" called MoveToAction

#

You'd put that on your queue and then immediately engage the action

swift delta
#

eeh I don't know about clicking on nothing since I wanna be very strict about what is movable terrain and what's just there for the sake of being pretty or set dressing

heady iris
#

by "nothing" I mean a spot without an entity

alpine sentinel
swift delta
#

I want the game to be somewhat moddable in the future, and map designers may want things to not go somewhere

heady iris
#

or you could have the entity ask its current action how it should move

#

(I recently switched to the latter)

swift delta
#

sorry for bumping you away uldyr, I think I'm just about done brainstorming here

heady iris
swift delta
#

thanks for the different perspective fen. I was thinking a way more rigid approach to this

heady iris
#

Otherwise, I'd expect nothing to happen until the next update

alpine sentinel
heady iris
#

The only difference is that the latter has its action queue filled by player input

#

I like turning everything into an Entity where players and NPCs differ only in input

swift delta
#

as long as it's an easy to expand system I'll be pretty happy

#

as-is I'm only creating a foundation for a couple of possible projects it could branch into in the future

alpine sentinel
#

Here i print the Collider.attachedRigidbody references of every bullet in the magazine

heady iris
#

Can you share the !code ?

tawny elkBOT
alpine sentinel
#

waiterino then

#

this should be in the order of execution

#

I can answer any questions related to any method calls

#

ok and here is the thingy, there is another component called AssemblyRigidbody that is put into the root of transforms that are going to have ComponentRigidbodies made for their children to save their rigidbodies for whenever the children get parented out of the root

#

I am aware now that UpdateStoredBullets() is called before the two blocks of code in the middle, but the fact that for the previous bullets that get their Collider.attachedRigidbody printed out with the print being null means that there is a problemo regardless of sequence atm

heady iris
#

I'd be very leery about using DestroyImmediate in non-editor code

#

I wouldn't be surprised if that's what's preventing the attached rigidbody from correctly changing

smoky beacon
#

Regarding my previous problem.. If I just added a slight delay (0,1) before the projectile was destroyed then Unity apparently had enough time to detach the particle systems completely.. so now it works

alpine sentinel
heady iris
#

That sounds very odd

alpine sentinel
#

Although whenever running for the first time, everything does work in the sense that the glock parts (slide, barrel, spring assembly) have their colliders attached to their parents' rigidbodies

smoky beacon
#

Yeah i know. I got the idea when I tried to grab the projectile and unparent it when pausing the game while it was in air, and then it worked fine. Still don't understand why, but that's part of game dev I guess

snow lantern
#

Hi, and merry Christmas.
I'm wondering if anyone has experience with potentiometers as inputs for Unity?

#

This is what I'm working with.

#

Potentiometers are model rv24yn 25f b502 0701c 321 - company called OMTER

snow lantern
#

It's not working very well.

heady iris
#

ah, so you do have valid input from the device?

#

although it appears to be either -1 or 1 on both axes

cold parrot
snow lantern
#

Anyway, I'm attempting to figure out the controls.

hexed pecan
snow lantern
hexed pecan
#

Explain that you have -1..1 and nothing in between

somber nacelle
#

i imagine that has something to do with the fact that the binding path specifies it is "XinYeDigital"

#

digital input would typically only be -1..1

#

well and 0

alpine sentinel
#

@heady iris lmao, I have fixed it by simply having implemented a "SyncComplexColliders" method that does .enabled = false; .enabled = true; on all of the ComplexColliders of a given GameObject. I do this immediately when parenting a new bullet to the magazine and i found out that i needed to do it one fixed update later when removing a bullet.

#

Thank you for having at least mentioned Physics.SyncTransforms()

modern creek
#

If I wanna have some UI in my 3d game that's placed near units in the world (ie, "popup" info dialogs that appear above the unit, regardless of zoom/location of the camera), should I do that in the world, or just on the canvas and figure out a raycast location? Is there a standard way of doing this?

#

(health bars comes to mind)

#

Oh, and I also didn't want to deal with having that UI rotate towards the camera

wicked scroll
#

Depends what your needs are. For healthbars you can do something like this pretty easily: https://www.stevestreeting.com/2019/02/22/enemy-health-bars-in-1-draw-call-in-unity/
but if you want to display something more complex, I'm not sure it'd be worth it, so yea either worldspace canvases or some math on a screenspace canvas.

#

you can use in-world sprite renderers too which works ok, but IIRC there are some gotchas with sizing

modern creek
#

Yeah, when I think this through some more.. I don't think I want UI floating off screen if the camera isn't looking at it so .. I'm gonna need to roll my own with raycasting

#

ie, if there's an active unit that's offscreen, I probably want some sort of triangle at the edge of the screen that the user can click on to snap the camera to that unit

#

And yeah - I read this article a few weeks ago, I think. I don't have many units (~20?) so I don't need to go nuts with the canvas optimization.. but it looks like he's doing what I was hoping to avoid - ie, calculating the rotation and handling the rendering manually

#

my poor man's version will just slap them in a higher layer (instead of doing them in shaders)

wicked scroll
#

part of why I like that post is that he explains his reasonining for why he's doing it this way, which is useful even if you decide to do it another way

modern creek
#

yeah.. I'll read it again more closely today

wicked scroll
#

if you just have 20 things I would probably just use worldspace canvases since that sounds like the least amount of work and it probably won't matter

modern creek
#

yeah

#

the normalization of the items towards the camera is nice

#

didn't think of jus grabbing the camera's .forward property and calculating a normal vector on each ui element

#

I'll have to see if it works seamlessly with cinemachine but I imagine the cinemachine vcams have the same properties as normal cameras

#

at a minimum, a .forward vector i can use

#

TextMeshPro comes with an object that renders in the world without needing it's own canvas. Are there elements in IMGUI that have the same? (I suspect not, and that I need a canvas for these)

leaden ice
wicked scroll
#

isn't IMGUI the immediate mode one that doesn't need a canvas at all?

leaden ice
#

also yes that^

#

You mean UGUI

modern creek
#

wait.. am I confusing UGUI and IMGUI

#

yeah - UGUI

leaden ice
#

I don't think TextMesh is really part of UGUI, but it does exist.

modern creek
#

the TextMeshProUGUI component renders in the canvas, but tmp also comes with the TextMeshPro item which renders in the world (really nicely, might I add)

#

I have some aftermarket UI libraries though, so.. yeah, nevermind - I'm gonna need to make a canvas for this

leaden ice
#

Yes and Unity has a TextMesh component that is equivalent to TextMeshPro

modern creek
#

Oh, I remember that.. it's been years since I used it

leaden ice
#

(not gui)

wicked scroll
#

but you'd lose out on all the scaling features that canvas comes with

modern creek
#

Now I'm wondering if I should just do this all in UI (instead of in the world) and just... manually calculate the location in the screen to show this stuff instead of trying to do this all in the world

wicked scroll
#

also totally valid

modern creek
#

Yeah.. and like I said, I have this aftermarket shit (which I like) which probably would be a hassle to figure out how to make work without a canvas

#

soft masking

#

there's some notes about using it with canvas shadergraph

#

hm.. will ponder what I wanna do.. but I think I just wanna find the quickest way, it's just for a demo

zenith timber
young geyser
#

Any coder wanna make a top down rpg?

modern creek
#

(use unity forums for collab seeking)

#

And also.. you're gonna find yourself pretty quickly banned by crossposting it as much as you are...

young geyser
winter matrix
#

hey yall. having issues with builds in Unity 6. Basically, it does make the build, but then it hangs on "Running Backend", basically indefinitely (I tried it last night when i went to bed and it stayed there for 8 hours, haha)

#

the weirdest thing is, the build does get made, like I can then run the built game and everything. Its just, I have to force quit Unity.

knotty sun
winter matrix
#

The one in like App Data/etc/etc? Editor.log? I did but i dont see anything useful in there, no visible "error" or anything like that

halcyon swallow
#

is something up with unities default camera?
its only at 90fov, but feels very fish eye, or am i crazy

quartz folio
#

Not sure where the code question is... but field of view is vertical

halcyon swallow
#

whoops yeah not really a code question
just feels like the centre is zoomed out and the edges are more distorted to account for that
but have no real way to test this against anything else

halcyon swallow
glass sparrow
#

Is there any way to run AssetBundles in play mode (without manually using the editor menu)? I keep running into the error:
InvalidOperationException: Building AssetBundles while in play mode is not allowed, please exit play mode first.

#

Also if anyone knows, I'm trying to upload a cert.pfx to my server build, and I'm having troubles getting it into a build... I cant push a DefaultAsset when referenced.

heady iris
#

why are you trying to build an asset bundle in play mode?

glass sparrow
#

I also can't get addressable's to work again because it's a DefaultAsset

heady iris
#

a DefaultAsset won't have any actual content in it

#

perhaps a TextAsset could help you there?

glass sparrow
#

I'm thinking it will have to be...

heady iris
#

That allows you to add arbitrary text or binary content

glass sparrow
heady iris
#

it doesn't sound like you want to be trying to create asset bundles in play mode, for sure!

#

(and that's what unity is complaining about)

glass sparrow
#

I'm trying to push a cert.pfx file with my server build. Unfortunately its not really recongized as a text file. And I'm not sure if my transport will read a text file.

The .pfx is a combination of pirvate and public keys and is in binary making it more secure and it can hold both the public/private key.

I might try the .pem file and see if that works? As its in text.

heady iris
#

yeah, I'm vaguely familiar with the formats

#

Assuming you have code that can parse the format, just include the keys in a .txt file (if it's a text-based format)

#

The extension is irrelevant; you're going to reference it as a TextAsset

glass sparrow
heady iris
#

You won't be reading it directly from a file. You'll grab the .text property from the text asset

#

The extension does not matter.

#

None of the files in your Assets folder actually exist in the built game or in asset bundles

#

They're imported into internal Unity formats and eventually packed into archives

glass sparrow
#

Can a .pfx file have its text extracted though?

heady iris
#

File extensions are meaningless

#

The only thing that matters is whether the format is text-based (meaning you're meant to read it as a Unicode string) or binary (meaning that it's a completely arbitrary series of bytes)

#

Do you have code that can actually parse a .pfx file right now?

glass sparrow
#

Alright I shall push a cert.txt file as a TextAsset and see what happens?

glass sparrow
#

Not sure if it parses it, or presents it to the browser.

#

I actually have no idea.

glass sparrow
heady iris
#

hmm, it looks like Bayou expects to be given a path to a certificate file

#

If that's right, this means you need to put a file on the user's filesystem

glass sparrow
#

Correct. It's usually in the directory of my server executable when it's on my VPS. But I dont have that luxury when using deployments (Edgegap)

#

I just push a docker file.

#

So the cert needs to be INSIDE the game?

#

And accessible.

heady iris
#

does it need to be included in an asset bundle?

glass sparrow
#

I figured that would be a solution.

heady iris
#

The first thing that comes to mind is using StreamingAssets so that the file is directly copy-pasted into the build directory

#

It seems weird to include secrets as part of the built game though

glass sparrow
#

It will be on the server build

#

So clients dont actually have access.

heady iris
#

right, but I still wouldn't have that be part of the actual build

#

I'd insert the secrets separately

#

(and at that point you can just put them wherever you want)

glass sparrow
glass sparrow
glass sparrow
heady iris
#

You'd just...put the file in the container as you build it

glass sparrow
#

Hmmmm. I'd have to look into adding docker commands. Maybe I can include it with docker.

heady iris
#

Secrets should never be part of your actual build. They should be installed separately.

glass sparrow
#

You're right

heady iris
#

It'll be easier this way, too πŸ˜›

#

(actually, ideally, the secrets don't go in the image either -- you'd insert them as you start the container up)

#

Been a hot minute since I seriously used Docker, though

glass sparrow
#

Alright. I'm sure theres a docker command to include the cert with every build/container.

#

OKAY! I feel alot better, I'll give this a shot.

#

Thanks so much @heady iris

halcyon swallow
#

this might be stupid but is there a way to refrence a script like you can with a gameobject?
you can do public gameObject obj; and no matter what object you select obj.transform.up will always do the same thing
can you do a similar thing with a script?

glass sparrow
#

It has to be attached to something in the game, convention is an empty game object ?

heady iris
#

If you've got a class called Foo that derives from MonoBehaviour, you can store a reference to any instance of Foo

#

This could be on a prefab or on another object in the scene

halcyon swallow
#

how do you declare a script?

heady iris
#

you don't "declare a script"

heady iris
#

this declares a field named "something" that can hold a Foo

swift falcon
#

can i post my problems here?

#

or is there some other channel for it?

halcyon swallow
#

i realise what i was looking for was an "interface"

timid walrus
#

Hi all! everytime I save a script file in visual studio, Unity displays a "importing assets" for about 25 seconds.. anyone knows what I could do to avoid this? (I'm using Unity 6 and I already tried disabling the auto-refresh of the asset pipeline)

cosmic rain
dense helm
#

would it be considered bad practice to use a single IJobChunk for physics based character movement in Unity Entities with NetCode? (input is on seperate system btw just to be clear)

thick sentinel
#

hey guys, i am trying to get my ads work in my game but i keep getting this error

Assets\Scripts\AdsManager.cs(72,45): error CS0426: The type name 'Builder' does not exist in the type 'AdRequest'
[20:03]
No one seems to know how to solve this, i ended up joinig here

#

i'd really appreciate some help 8_____Cry

#

dunno whats going on.

vagrant blade
indigo verge
#

So, there's a lot of different ways to do this, but I want to know what would be ideal for me.

What is the best way for me to handle triggering effects based on an animation playing?

I basically want to be able to associated animations with specific triggers at specific points during the animations. It needs to be done to an extremely large number of animations, and it needs to be able to trigger a variety of unique effects.

Should I;

  1. Use Bones to drive the triggers, that are observed via code (easier to work on in the original animating side, feels inefficient though?)

  2. Use Animancer's Event system to try and add the events to the animations in Unity itself? I don't have the fancy extra-price version, so I'd be fighting with the Unshared States of the older version.

  3. Use Unity's animation event system? (I've heard it's kind of bad?)

  4. Make my own custom system from the ground up (I am an adequate enough programmer to do this, but I'd rather not if I'd just be making an inferior version of something better that already exists)

  5. Use some other (free) third-party package to do it? (If so, which one? Does anyone know?)

This is for a turn based RPG, where I want to be able to trigger stuff like unique effects, hitboxes, SFX and particles at specific points of an animation.

steady moat
indigo verge
#

Gotcha. So Animancer's event system is pretty good then?

steady moat
#

Usually, you want to double down on the asset you use.

indigo verge
#

...So you're just suggesting it because it's there? Ahh.

steady moat
#

Otherwise you get multiple way of doing the samething and it can be hard to work with it.

#

I've used the standard Animator for a lot of project. While there is issue with it, Animation Event was not one of them.

indigo verge
#

Right now, I mostly try to wrap all of Animancer's components in my own middleman classes since I don't like some of the ways it behaves. I'll look into Animancer Events, then, and see how well I can use it in my workflow.

verbal hazel
#

@dlich and @steady bobcat thanks for the tips yesterday about my performance issues. I think I've tracked it down to how I was loading my addressables. You guys pointed me in a direction I hadn't thought of. thanks πŸ™‚

heady iris
#

I mostly use Animancer events. I only use the normal animation events in like...one place, for footstep sounds

#

I think, at least.

indigo verge
tepid crane
#

Any ides about making hitmarkers that allign with where the hit occured?

cosmic rain
sonic swan
#

if i have a system where my players has to snap to a position to do a takedown animation . how do i smoothly reach instead of just teleporting

cosmic rain
sonic swan
#

But if its being cover it just ends up glitching with the terrain

cosmic rain
#

"cover"?

sonic swan
#

Cover as in like behind an object

#

So player-box-enemy

#

So when leaping the box gets in the way

#

Lerping

cosmic rain
#

I don't understand how that's related to the original question.

#

If you have difficulty explaining the issue in words, record a video.

#

Or use proper translation tools, assuming it's a language barrier.

sonic swan
#

So if a player is taking down an enemy it checks if it can with a trigger collider now if it teleoports to the kill position its fine but if I lerp the movement and there is an object the player will collide with the object and get stuck there.

vestal geode
sonic swan
#

Alright

vestal geode
# sonic swan Alright

I'd say most commonly in those situations you first align the characters to face each other, then move either of them next to the other so the animation aligns and connects
There's no obvious solution what to do if the level geometry allows there to be obstacles in the way or a sloped ground underneath
Most games where that kind of fighting occurs keep the environments sparse to make it simpler
But references help here a lot, like how Dark Souls games connect the stab animations
Another technique is to only visually move the characters to do the animation, then lerp them back afterwards so obstacles are effectively ignored

#

I think Skyrim and Dark Messiah used that one

sonic swan
vestal geode
#

It sounds simpler

sonic swan
#

It does but I would prefer to have a more seamless transition so I'll mess around with the info you gave above and try to figure out Smth if not I always can do that

rigid blaze
#

could i get a hand

#

i have this problem where my attack hitbox just lands the hit on the dummy before i even click attack

heady iris
#

you'll need to provide much more information than that!

vestal arch
#

you're gonna need to provide more details

heady iris
#

incredible jinx

rigid blaze
#

yep

#

got it hold up

#

imma screen rcord firzzt

rigid blaze
#

heres the health bar function

#

with the death function and take damage function

zenith acorn
zenith acorn
rigid blaze
#

how would i do that

mossy shard
zenith acorn
rigid blaze
#

oh i see

#

which tick?

zenith acorn
#

this one bro

rigid blaze
#

oh im stupid mb

#

now since i have it disabled

#

i just have to renable it in script when i letf click right/

zenith acorn
#

I thought your script already does that

rigid blaze
#

no

zenith acorn
#

isn't the attack area your polygon collider?

rigid blaze
#

yes

mossy shard
#

or when it ends deactivate

rigid blaze
zenith acorn
rigid blaze
#

thats what im thinking

mossy shard
rigid blaze
#

the problem is

#

it should be working by acitvatting and deativating

#

thats what the script does

rigid blaze
#

but its not

zenith acorn
#

did you assign the collider?

rigid blaze
#

ah i see

#

i think its because im deatcitvting the script attackArea

#

not polygon collider?

zenith acorn
rigid blaze
#

im so confused

zenith acorn
#

You should make a polygon collider variable

#

and assign it

#

to the polygon collider

rigid blaze
#

ye

#

thtats what im doing rn

#

but i think i found the original reason why

#

ye i fixedit

#

yunno why?

zenith acorn
#

nicee

#

cause your attack area assigned wrongly?

rigid blaze
#

basically the get child function

#

i had ground check as the first child

#

not attackarea

#

i just had to swap them

#

omfg

#

took me like 1 hour

#

u see the get child line?

heady iris
#

If you need to refer to a specific thing, then you should just use a serialized reference.

#
[SerializeReference] private AttackArea attackArea;
soft escarp
#

how can i make the player move a little in the direction the player was moving before it stopped in the air?
it feels like im hitting a wall when jumping and stopping in air

spare dome
soft escarp
spare dome
#

You switched to AddForce or were you originally using AddForce?

scenic pewter
somber nacelle
#

show !code

tawny elkBOT
languid hound
#

So I'm calculating the move direction by projecting my move vector onto a slope but for some reason this causes incredibly sensitive horizontal movement (looking even slightly left or right will cause the player to move more horizontally on a slope than they would on a flat surface). Is there a way to prevent it?

#

Sorry for no attached examples I'm having issues getting stuff working but I'll send some ASAP

heady iris
#

Are you normalizing the vector after the projection?

scenic pewter
heady iris
languid hound
heady iris
#

normalizing alone would be inappropriate, yes

#

that'd give you a completely fixed magnitude, no matter how strong your move input is

languid hound
scenic pewter
soft escarp
languid hound
#

@heady iris #archived-code-general message
Here's the only changes

  • projectedDirection isn't normalized anymore
  • linearVelocity is set to projectedDirection + Vector3.up * target now
heady iris
#

also, in what way is it now "really sensitive"?

#

What happens if you remove the projection entirely?

somber nacelle
languid hound
#

Unity finally opened!!!! I can take a recording quickly

languid hound
heady iris
#

(also i'm bouncing in between here and vrchat so i will be away for a few minutes)

languid hound
#

It's literally EXACTLY how I want it but the capsule struggles to stay upright

heady iris
#

ping me when you have that new recording

languid hound
#

Alright

scenic pewter
#

thanks

#

(it was 3am i was tired)

spare dome
# soft escarp i was and i am using addforce

Okay so you were originally using AddForce and the problem is now fixed? (I'm guessing you were either modifying the transform or were overriding the velocity of the rigidbody)

heady iris
#

One thing I don't like about this code is this part:

float target = (targetHeight - playerBody.position.y) / Time.fixedDeltaTime;
playerBody.linearVelocity = new Vector3(relativeDirection.x, target, relativeDirection.z);

You're handling the Y axis differently from the other two axes. But you're also trying to allow for movement on a slope

#

Instead of giving the Y axis special treatment, you should be applying this correction based on the surface normal

languid hound
#

@heady iris
First clip is with projected movement which causes slow uphill movement and weird sensitivity with horizontal movement

Second clip is exactly what I'm going for (always consistent movement no matter what exactly like source engine games) but has the downside of sinking a tiny bit when going uphill and being a bit too high when going downhill

languid hound
#

The idea is it's a floating capsule so I kind of shouldn't have to deal with slopes or stairs etc, and it works but there's the issue on the second clip

heady iris
#

i just noticed that your code is completely ignoring projectedDirection

#

that's probably not helping

heady iris
languid hound
heady iris
#

ah, forgor

heady iris
#

But this doesn't work on a slope

#

Your movement vector should contain X, Y, and Z components

#

And if you need to push yourself out of the ground, you may also need to move in the X, Y, and Z directions

#

This is the same reason you have to use Vector3.ProjectOnPlane to calculate the movement direciton

languid hound
#

Ohh yeah I completely get what you're saying now

#

Should I project the correction of the capsule's height onto the normal?

heady iris
#

Instead of messing with components, try to stick entirely with things like Vector3.Project and Vector3.ProjectOnPlane

#

Multiply the correction factor with the normal vector, yeah

#

you wouldn't be projecting anything in this case -- you have a direction (normal) and a magnitude (correction factor)

#

You'd use Vector3.Project if you needed to find out how much of one vector aligns with a second vector

#

(ProjectOnPlane calculates that, then removes it from the original vector!)

#

Also, to get consistent move speed, you need to fix the magnitude of projectedDirection

#

If you aren't looking perfectly parallel to the surface, projectedDirection will have a smaller magnitude than relativeDirection

#

Some of the vector got lost

#

You can fix this by normalizing the result, then multiplying it by the magnitude of the original vector

#

(You should only do this if the resulting vector is non-zero)

#
projectedDirection = projectedDirection.normalized * relativeDirection.magnitude;
languid hound
#

Wait I'm a bit confused again. Why would I need to push out in different directions or do projection if the only goal is hover above a certain point by a certain amount?

#

Also it seems like that did help substantially with movement on slopes but unfortunately the horizontal issue is still there and slope movement is really close but not as fast as flat ground movement

heady iris
#

I'm not talking about how to do the height correction here

#

I'm talking about the movement direction

#

Oh, I see.

languid hound
#

Sorry I don't think we were on the same page lol.. what're you thinking rn?

heady iris
#

You're making the player float a certain distance above the ground

languid hound
#

Yeah to avoid handling stairs and slopes and stuff similar to how Valve did it

heady iris
#

I thought this was a correction to push the player out of the surface

#

That would depend on the ground angle

#

But this does not

languid hound
#

Ah right yeah sorry lol should've been clearer

#

Just to clarify if you look at the 2nd clip do you kind of see what I was explaining?

heady iris
#

and running uphill will shove you into it

heady iris
soft escarp
languid hound
#

Horizontal movement seemed a bit more sensitive based on the angle of the slope if the movement was projected but I think it was kind of a given issue since I'm well.. projecting..

heady iris
#

Which direction is this in? Down and up the slope, or left and right on the slope?

languid hound
#

I think the issue is down and up the slope feels too slow because I'm projecting on the normal (where left and right wont be influenced since it's only angled upwards) but left and right on the slope feel weird because they're going at the normal seed

heady iris
#

This suggests that part of your code is still giving the Y axis "special treatment"

languid hound
#

The Y axis isn't my issue with projected movement because the jitter issue is fixed using that

#

Wait I just had an idea

heady iris
#

What happens if you completely got rid of the velocity that's based on (targetHeight - playerBody.position.y)?

languid hound
heady iris
#

If projectedDirection is correct, then you shouldn't need any correcting factor to move around at a constant height

#

barring small errors as you reach the slope

languid hound
#

Because it's trying to reach what would be the perfect offset from the ground when there's no velocity

#

But it's reaching the perfect offset while the player is moving so it looks like the player is sinking / raising on slopes

#

I wonder if I can just add the projectedDirection's y onto the targetHeight

#

Ok no nevermind I just shoot into orbit

languid hound
spare dome
# soft escarp no

No what? I'm trying to see if your problem still persists, does it?

languid hound
heady iris
#

(the code shared earlier constructs the final velocity vector using target for the Y component)

languid hound
#

Yeah it literally just throws out projectedDirection as a whole because it didn't really help

heady iris
#

Imagine you're moving up an 89 degree slope.

Almost all of your movement is in the +Y direction.

If you discard that component, you have almost no velocity left

#
projectedDirection *= speed;
projectDirection.y += target;

basically

languid hound
#

projectedDirection helps because it accounts for the verticality of the slope which I don't really want to do so I don't really feel like projectedDirection will help me

#

I don't want to adjust the speed or moveDirection at all for slopes since it doesn't work with what I want (source movement pretty much) but I need to compensate for the moveDirection in the targetHeight

heady iris
#

Suppose you're trying to move at one billion meters per second

#

Would it make any sense to completely discard the Y component of your movement direction?

#

that's probably going to lose a lot of your speed...

languid hound
#

The idea is the y component will never be used because the floating part of the movement handles that for you

heady iris
#

No, it does not!

#

It might if you weren't projecting the movement vector

#

Because, in that case, you'd get your full speed on the X and Z axes

#

Then it would snap you down to the ground very quickly

languid hound
#

Yeah that's what I want

heady iris
#

Calculate how much extra Y velocity you need to correct your height and add that to the movement vector

#

Don't replace the Y component entirely

#

Right now, you're losing a significant chunk of your speed when moving on a slope

#

This is why I think it's a very bad idea to ever give an axis "special treatment"

#

Do not think of movement as an "XZ thing"

#

That's only valid when on perfectly flat ground

languid hound
heady iris
#

I'm not saying to cause Y velocity to "build up"

#

I'm saying to not completely ignore the Y component of your attempted movement

#

You are currently ignoring it.

#

This will make you go down slopes slowly.

#

I would expect your height offset to mostly correct for that

#

But, notably, when going up a slope, you'll be attempting to move into the floor

#

since you discarded the Y component of your movement vector

languid hound
#

Oh wait I've been severely misunderstanding

languid hound
#

Wait I think I know I'll try quickly

visual fjord
#

How can move a gameobject that have a rigibody kinemactic?

compact spire
#

What is everyones opinion on writing your own finite state machines vs using an asset to help manage them?

heady iris
#

It just won't get affected by physics

languid hound
heady iris
heady iris
compact spire
#

I would see for animation it would be really complicated. Mine is a bit simpler, I'm just thining about possible ways to avoid it becoming a rats nest down the road.

heady iris
#

Although, to be fair, I'm also not using it much like a traditional FSM

#

I explicitly request state changes instead of having rules that I regularly check

#

I'm just interested in running code when entering/exiting states and asking if I'm allowed to transition between two states

languid hound
#

It's practically identical to what was in the pastebin because I haven't found a way to approach what you're saying

heady iris
#

Don't set the y component.

#

Add to it.

compact spire
#

@heady iris That's an interesting thing way to go about it.

heady iris
#

Yeah, it barely even works as a state machine anymore, haha

#

It's just...states

#

I do have a few "transitions" -- I try to enter the idle state every frame, for example

#

But it's mostly explicit

visual fjord
#

Thanks

languid hound
# heady iris Add to it.

I'm sorry but I genuinely don't get what you're asking for I cant just add to it (unless I'm just completely misunderstanding what you're asking for again) because I'd need to adapt the target variable to be a spring and even then it wouldn't fix my issue because it's still not account for the offset that moving up / down the slope would create

#

Also just to clarify we're both on the same page when it comes to the movement variable right? (I'm only trying to use projectedDirection to account for the movement not for the actual movement velocity itself)

heady iris
#
relativeDirection.y += target;
#

That's it

languid hound
#

That does nothing for me because relativeDirection.y is 0 everytime anyways

heady iris
#

oh, you're not using projectedDirection now, I see

languid hound
#

Yeh

#

Also I made this but didn't post it I dunno if it'll help get my point across

heady iris
#

That is not correct, and it will slow you down when going uphill (unless the physics engine happens to push you out of the surface in exactly the right way

languid hound
#

The capsule never makes contact with the surface because it's floating off the floor

heady iris
wheat spruce
# compact spire What is everyones opinion on writing your own finite state machines vs using an ...

https://github.com/dotnet-state-machine/stateless I've used this before, its quite good. But from experience, state machines never seem to be worth it for me, I find they end up making the code too much of a problem to handle and it would have been easier to just do things manually without a bunch of state logic

GitHub

A simple library for creating state machines in C# code - dotnet-state-machine/stateless

compact spire
#

I don't know how you would completely avoid a finite state machine in circumstances where one is applicable

heady iris
#
Vector3 rawMovement = CameraManager.Instance.GetMoveDirection(moveDirection); // compute how the player *wants* to move
Vector3 movement = Vector3.ProjectOnPlane(rawMovement, surfaceNormal); // reject the part that aligns with the surface normal
movement = movement.normalized * rawMovement.magnitude; // restore the original magnitude
movement *= moveSpeed;

// calculate the "target" value here

movement.y += target;

playerBody.linearVelocity = movement;

This is what I would do.

compact spire
#

this library does look interesting htough

languid hound
languid hound
heady iris
#

It restores the original magnitude of the movement vector.

languid hound
#

I've just done that and it still feels off

#

Nevermind I'm tripping it actually is accurate

#

My only issue with it the weird horizontal movement feel still

wheat spruce
# compact spire I don't know how you would completely avoid a finite state machine in circumstan...

I mean the overengineered idea of having the FSM handle very simple logic that could handled with a simple if condition

Say you had a player that can jump, but you cant jump when youre in water. You could have a state for OnGround that can move to InWater or IsJumping, but then you cant go from InWater to IsJumping. It's perfectly reasonable to do that, and I wouldnt say its wrong to do so.

At the same time, you could just have an if statement that only allows jumping when not in water without the need for an entire FSM implementation

#

the tradeoff is that it wont be as robust as a genuine FSM

compact spire
#

lol I can't just write hmmm

#

I'll have to think on that, maybe I will go with something basic.

#

underengineering a solution vs overengineering

#

I hate writing something and getting like 80% through it, make a mess and then have to refactor it, but that sometimes is how things go

#

and I'm not sure if using chat-gpt is helping me or hindering me lol

soft escarp
spare dome
tawny elkBOT
soft escarp
#

i sent it to you on priv

spare dome
#

please send it here so others can comment

soft escarp
spare dome
#

this line would probably do it as you are doing a direct velocity change on the rigidbody
_rb.AddForce(AirTtoGrav.Evaluate(Airtime) * Vector3.down, ForceMode.VelocityChange);

#

you could probably change it to ForceMode.acceleration

soft escarp
#

it just makes the player super floaty and doesnt fix my issue

i just want to do something like in quake/TF2/portal where no matter if you hold the movement keys, when you gain enough velocity, it just makes you fly

spare dome
#

I have never seen that done in the source engine, Are you talking about strafing? Does removing the AirTimeHandler fix the issue?

soft escarp
spare dome
#

well yes but we need to debug to find what is causing the issue, narrow it down to a function or line

soft escarp
#

i dont think that its a issue with something in my code but rather that there is something missing
i just want to give the player a little push of force when no input is given

#

a short representation on how i want this to be

spare dome
#

well there is an issue with your code as you said when you are jumping if you stop doing input your player just stops in place, which is an undesired effect. So you need to debug to find what is causing that. You can cheat it but it may cause more issues later down the road.

spare dome
#

Actually, I just tried your code out and your issue is not happening for me, I just changed the isgrounded code, the slope angle code and the cantjump function to get rid of the errors.

#

And got rid of some variables

soft escarp
soft escarp
spare dome
#

I'll send the code, keep in mind it was a very quick edit

soft escarp
#

and please send the video of how this looks for you(send it on mediafire or google drive or anything + im not on my pc now)

spare dome
#

seems to be working fine for me

#

I would have to test a bit more with the animation curves

#

sweet Idea with the animation curves though, I might have to use that ( as I have my own source engine/ quake 2 movement with strafing)

heady iris
#

animation curves are great for whenever you need to remap a value

visual fjord
#

The code :

#
public class bullet_space_ship : MonoBehaviour
{
    public float speed;

    Rigidbody2D rb2D;
    void Start()
    {
        rb2D = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        rb2D.MovePosition(transform.position + Vector3.right * Time.deltaTime * speed);
        // transform.Translate(Vector2.right * speed * Time.deltaTime);
    }
}
somber nacelle
#

i imagine that there is some other code destroying it

ocean hollow
visual fjord
soft escarp
spare dome
#

no

#

I thought I was

ocean hollow
spare dome
#

Rb drag is zero, sorry πŸ˜…

visual fjord
#

Wait, i discovery thing

soft escarp
#

so do i need to lower the speed and set drag to 0 or is there a better way to solve this?

spare dome
#

you could probably set drag to 0 or 1 and lower speed to your liking, this is what happens what I set mine to 3 drag

#

you can see when I let go of input

#

and when I hold it

soft escarp
#

yes, this is what is happening to me

spare dome
#

I would set drag to 0 or 1 (depending on if you need it or not) and lower speed a bit to compensate

soft escarp
#

but anyway, how does drag work? how can i calculate how much speed it drains by moving a rigidbody against a collider

visual fjord
#

Forget it, i resolve it

spare dome
lucid brook
heady iris
#

Spherecasts don't hit anything they start inside of

#

Consider combining it with an OverlapSphere call

lucid brook
#

Thanks!

heady iris
#

You could also start the cast a bit further back

lucid brook
#

That's also a good idea

lapis nexus
opal pine
#

Hey guys. Before I go ahead with an idea that im having. I just want to know if its possible. Im looking at doing a doom clone with multiplayer. My question is how would I tackle the enemy sprite look at and sprite change between different players. Would I just locally render them? Would that be the best?

peak gull
#

is there a way to have individual objects to have their own time scales, or change their physics to emulate slowed down time?

rain minnow
vestal arch
#

what's with all the ellipses you're using lmao

rigid island
peak gull
#

i may be stupid, cause i cant find anything online about local timescale

rain minnow
rain minnow
rigid island
vestal arch
#

it's really offputting

rain minnow
vestal arch
#

because only the negative one makes sense in this context

rigid island
rain minnow
#

somebody gets it . . .

vestal arch
#

they aren't adding anything after it though

rain minnow
#

aren't i? thinksmart

vestal arch
#

like there's not really any continuation when you just leave it as the final message

rigid island
#

not every thought needs to be written lol

vestal arch
#

and the unwritten thought just seems negative in that case

rigid island
#

they could be pondering the issue further?

rain minnow
#

but it's not my final message, or else i'd never come back here, lol . . .

vestal arch
rain minnow
vestal arch
#

maybe this is old people stuff 🀷

rigid island
#

perhaps. I did more often on Aol Aim and IIRC

rigid island
vestal arch
rigid island
#

gen z making a big deal out of nothin

vestal arch
#

no it really does feel hostile lol
the extra ellipses without any thought after it seems disapproving

#

like you're hesitant to even say anything

rigid island
#

language has soften up

rain minnow
#

as i've stated, it has more than one meaning. even the video demonstrates it's intended use (which doesn't point to a negative), though i'd do some self reflecting if it feels hostile in nature to you . . .

vestal arch
#

...yes, the video shows that the non-negative, intended use now violates the maxim of quantity, so it now feels unnatural.

rain minnow
#

these young'uns ruin everything, i tell ya . . . πŸ˜†

vestal arch
#

well, this just devolved into a generational quarrel.... i tried to show why it's hostile to me, but of course, your way is correct and im just willfully misinterpreting it...

#

languages evolve, and if you refuse to adapt with it, kinda reveals some stubbornness in your character...

rain minnow
rain minnow
sharp sable
#

is there a way to make VS22 use System.Collection.Generic by default when adding List variables, instead of using NUnit.Framework

#

minor thing but so annoying

peak gull
rain minnow
sharp sable
#

started happening after upgrading to unity6

peak gull
#

from what ive researched it only applies to anything that is not related to rigidbody physics

#

which i kinda wanted to apply to physics

rain minnow