#archived-code-advanced

1 messages ยท Page 194 of 1

undone coral
#

@buoyant nacelle for example you might want to make a general way to retrieve attribute values that looks something like this:

int GetValue(GameContext context, GetValueContext valueContext, Entity target, Attribute attribute, int defaultValue) {
 var valueFromTarget = target.GetIntAttribute(attribute);
 var enchantments = context.GetEnchantmentsAffectingAttribute(attribute);
 var offset = valueContext.Offset ?? 0;
 var coefficient = valueContext.Coefficient ?? 1;
 return coefficient * (valueFromTarget + enchantments) + offset;
}
#

it might contain all the special case logic for what hte attribute is in one place

#

like what values can be positive and negative, etc. etc.

buoyant nacelle
#

Too late for this. I will try to understand it tomorrow.

#

Thanks though.

#

Sign up for the Level 2 Game Dev Newsletter: http://eepurl.com/gGb8eP

This is a clip from my Game Development live stream. You can watch the whole stream at https://youtu.be/ROOtDOlE8T0

๐Ÿ‘จ๐Ÿ’ป Join our community: https://discord.gg/NjjQ3BU
โค๏ธ Support the channel: https://www.patreon.com/infalliblecode

My Favorite Unity Assets ๐Ÿ’ฏโคต๏ธ
1๏ธโƒฃ Odin Inspect...

โ–ถ Play video
#

this was useful

buoyant vine
#

( wouldnt recommend them )

buoyant nacelle
buoyant vine
#

yes

#

especially the left one

#

but its up to you

buoyant nacelle
#

Why?

#

I discovered him recently

#

But didn't watch him much yet

buoyant vine
#

his "SOLID " principles video is just pure trash

#

imo

buoyant vine
#

either they are talking endlessy nonsense stuff or he codes trash

#

but thats opinionated

#

ive learned solid with java

#

so idk

#

had a harsh teacher back then XD

buoyant nacelle
#

That's good

#

Helped to build strong foundation)

buoyant vine
#

i hate him now.. but seems like its the normal adventure of teacher and apprentice

hexed aspen
#

So I've been looking at a ton of different videos on learning how to build an Audio Manager. (Trying to learn)

But nothing close to what I'm wanting to do and maybe what I have in my head is a bad idea. So I wanted to ask here.

I would like to build a Audio System that uses:

  1. Audio Source with Audio Groups (a SFX group, a Soundtrack Group...etc) or a sperate Audio Source for each kind...not sure which is best.
  2. Scriptable Objects to make managing the audio clips easy for non programmers to change things around
  3. Control when the Audio Controller is called to play, stop, Repeat audio clips based on C# Events to keep things decoupled (everything I see uses a singleton)

Has anyone seen something like this? Is this a bad idea. Ideally the reason I'm looking to do it this way is to make this system reuable in future projects so I don't need to reinvent the wheel every time.

Thanks.

undone coral
#

it's trying ot tell you to install docker

hybrid lichen
#

Yo, hello there. Do you perhaps know how come InstanceIDs are 0 in a saved .json file when you try to save the references?
Got a party layout. 3 slots. Party Member 1, 2 and 3. Actors(scriptable object class) are assigned in-game and I'd like to save the layout. Isn't there some easier way to load/save that? I made a bigger ID check (a string in the actor scriptable object class) and check what's set in the GamePrefs class which just serves as a dataholder. Saving is reading GamePrefs and from that to json. And then loading is reading from the json and setting what's in the json back into GamePrefs. Thanks!

rocky mica
#

I did a singleton manager that could be invoked from anywhere that could invoke 2 types of sounds: normal one shots and something I called monolithic (only one instance at a time)

#

SFXs were defined in a scriptable object with a dictionary of strings mapped to a SFX Object that had audio parameters (panning, volume, 3d mix, etc)

#

the audio manager, when invoked to play a new sound, then created an empty wrapper object with an audio source and all of the data from the scriptable object

#

super, super easy to work with and endless features

#

for example, with some easy overloads methods we could do random sample playback, volume/pitch randomization, perfect loops with fade in/outs and a lot more

hexed aspen
glass anvil
#

once you know those three what he said will make more sense, not as tricky as it seems

rocky mica
#

public string PlayMonolithicSFXWithLocation(string monolithicId, string id, GameObject obj, float volumeMultiplier = 1, bool loop = false, float pitchMultiplier = 1, AudioMixerGroup sfxGroup = null, bool cancelPrev = false, float seekTime = 0f)
    {
        if (monolithicReferences.ContainsKey(monolithicId))
        {
            if (cancelPrev)
            {
                StopMonolithicSFX(monolithicId);
            }
            else
            {
                return null;
            }
        }

        AudioSourceWithId aux = CreateEmptyWithSource(obj.transform, true, monolithicId);
        AudioSource audioSource = aux.audioSource;

        //Gets Data from ScriptableObject
        SceneDataSO.SoundEffect auxSfx = data.GetSFX(id);
        if (auxSfx == null)
        {
            Debug.LogError("Sfx with id: "+id+ " Not found");
            return null;
        }
        audioSource.clip = auxSfx.sfxClip;
        audioSource.loop = loop;
        audioSource.volume = auxSfx.volume;
        audioSource.volume *= volumeMultiplier;
        audioSource.pitch = auxSfx.pitch;
        audioSource.pitch *= pitchMultiplier;
        audioSource.spatialBlend = auxSfx.spatialBlend;

        //Set Defaults
        SetDefaultAudioSourceProperties(audioSource, auxSfx);
        if (sfxGroup != null) audioSource.outputAudioMixerGroup = sfxGroup;

        if (audioSource.clip != null)
        {
            audioSource.Play();
            if (seekTime > 0 && audioSource.clip.length > seekTime ) {
                audioSource.time = seekTime;
            }
        }
        return aux.id;
    }

This is is the brain of the operation @hexed aspen

#

public AudioSourceWithId CreateEmptyWithSource(Transform trans, bool isMonolithic=false, string monolithicID=null)
    {
        string id = System.Guid.NewGuid().ToString();
        GameObject emptyobject = new GameObject();
        emptyobject.transform.position = trans.position;
        emptyobject.transform.rotation = trans.rotation;
        emptyobject.name = "SFX Instance:"+trans.name;
        AudioSource source = emptyobject.AddComponent<AudioSource>();

        //Attach script that cleans up the reference
        CleanAudioSource cleanScript = emptyobject.AddComponent<CleanAudioSource>();
        cleanScript.currentSource = source;
        cleanScript.id = id;

        if (isMonolithic)
        {
            cleanScript.CleanSFXManagerArrays = RemoveMonolithicReference;
            cleanScript.monolithicID = monolithicID;
            monolithicReferences.Add(monolithicID, id);
        }
        else {
            cleanScript.CleanSFXManagerArrays = RemoveReference;
            cleanScript.monolithicID = null;
        }
        
        references.Add(id, emptyobject);
        DontDestroyOnLoad(emptyobject);

        return new AudioSourceWithId(id, source);
    }

#

this creates an empty, attaches an audio source, and attach a script for cleaning it up once its done

#

the cleanup script has this method


    void Start()
    {
        StartCoroutine(CleanSource());
    }

    public void Stop()
    {
        isPaused = false;
        currentSource.Stop();
    }

    //Borra un source posicional
    IEnumerator CleanSource()
    {
        while (true)
        {
            if ((!currentSource.isPlaying && !isPaused) || (markedAndReadyToClean))
            {
                CleanSFXManagerArrays?.Invoke(id, monolithicID);
                Destroy(gameObject);
                break;
            }
            yield return new WaitForSeconds(.3f);
        }
    }

#

so yeah, not the entire code because we have a lot of game specific code that I cannot really explain here haha

#

but thats the gist of it

#

public Dictionary<string, GameObject> references = new Dictionary<string, GameObject>();
public Dictionary<string, string> monolithicReferences = new Dictionary<string, string>();

#

the manager has this 2 dictionaries

#

one for the SFX instance and for for the monolithic sounds

#

whenever a normal sfx is played, a UID is created for it and added to the references dictionary

#

if you know the guid you can retrieve it and do stuff with it

#

the monolithic references dictionary just creates a second mapping, monolithicID -> GUID

#

so knowing the monolithic ID is also a way to retrieve sounds

#

usage would be trivial, something along the lines of


GlobalSFXManager.Instance.PlayMonolithicSFXWithLocation("Custom ID to be able to retrieve the object from anywhere", "SFX ID defined in the Scriptable Object", gameObjectToAttachTo);

#

nowadays I used this same base but with FMOD instead

#

removes a lot of the boilerplate code ๐Ÿ˜„

green roost
#

I'd love some opinions on the way I'm about to use Graphics.DrawMesh in comparison to the way Unity's Tiledmap renderer works. My goal is not to "beat" Tiledmap for performance, it's just that I want my own custom tiled map implementation suited for my game, and I'm checking my approach isn't hugely inefficient;

Using my own data structure for my tiled map (not Unity's), after working out which square area of tiles are currently visible on the camera this frame, I would draw each visible tile with an individual Graphics.DrawMesh call. Hopefully this gets batched in the one draw call, if I use the same material.

ocean raptor
#

Weird question: looking at ways to get around Unity's 32-bit transforms for precision's sake. Am I understanding octree structures correctly if I say they can be used for large-scale spatial data? Or are they meant for something else entirely?

glass anvil
#
   [Flags]
    private enum BitField
    {
        CELL_PATH_N = 0x01,
        CELL_PATH_E = 0x02,
        CELL_PATH_S = 0x04,
        CELL_PATH_W = 0x08,
        CELL_VISITED = 0x10
    }

I'm converting a project from C++ sorry if this doesn't belong here I'm curious,
how might this;
if ( someIntArray[offset(0, -1)] & BitField.CELL_VISITED) == 0 )
or
someIntArray[offset(-1, 0)] |= BitField.CELL_VISITED | BitField.CELL_PATH_E

..work in unity? I've set the flags attribute already and named the enum.. not sure exactly could anyone point me in the right direction or these two lines equivalent?

I've tried casting to an int which doesn't yield me the results I'm looking for, any suggestions?

orchid marsh
glass anvil
#

I'm using unity yes

junior kelp
#

i believe you are looking for bitwise-shift operations

#

or <<

glass anvil
hexed aspen
#

@rocky mica wow thanks so much!

covert rain
#

Can someone explain to me what a generic method is? Ive watched the unity video, but didnt really understand what it meant

undone coral
glass anvil
undone coral
glass anvil
#

Fair- It's all working now so I'm not too bothered, will keep in mind for future ref

silk trench
#

How can I make a CharacterController be pushed around by Rigidbodies?

regal olive
#

You can only make a CC push rigid bodies

Make a collider on top of the CC
And add a rigidbody

This isnโ€™t a good way though

silk trench
regal olive
#

What assets

silk trench
#

Most FP/TP character controller assets

regal olive
#

Which ones exactly

silk trench
#

Are you implying that they're just using a Rigidbody instead?

#

Let me find some examples

#

This is a good example

regal olive
#

Thereโ€™s more complicated stuff going on there, but there might be a way, or you can but I just forgot you can

undone coral
# silk trench How can I make a CharacterController be pushed around by Rigidbodies?

you can reconcile the physics forces with the position of the character controller a few ways. one is using a separate rigidbody and interpolating / extrapolating the positions. another is to use a collider and interpret the collisions creatively. another still is to implement a different physics approach suitable for character control.

silk trench
somber tendon
somber tendon
silk trench
#

Yeah they say it in the description

silk trench
somber tendon
#

well since this is code-advanced , I wont give you a full code, just a hint on how it (might) work
When a rigidbody hit/touch a charactercontroller, it transfer it's momentum to the charactercontroller, so the transferred push velocity depends on the RB's weight and CC's predefined weight.
Once you got the transferred velocity, you can 'push' the CC by the velocity and decrease the velocity over time by a predefined drag.

silk trench
#

How would I actually get the "transferred momentum" in the first place?

#

I've seen assets where they call CharacterController.Move() 12 times

#

For example, if the first direction is Up, then we call .Move(0, 1, 0) then again: .Move(0, -1, 0)

#

So that it detects collisions in that direction and therefore displaces itself to conform with the collider it's colliding with

#

but Unity recommends that we should only call Move once per frame, and I trust that

main pawn
#

Hi guys im making a game like city builders. The user can rotate the camera and move the camera around. When the camera isnt rotated the camera moves forward and sideways perfectly(X and Z axis) but when I rotate the camera then the movement is reversed. Now forward changes the Z axis and sideways changes the X axis

somber tendon
silk trench
#

Or just not a rigidbody at all?

somber tendon
#

kinematic means it has infinite mass, which means that the receiving (in this case CC's) mass will be ignored

#

yeah, I know CC has no mass, that's why I said predefined mass for the CC

silk trench
#

Kinematic rigidbodies don't store velocity

somber tendon
#

And how do you move your kinematic rigidbody?
You still can get the velocity by comparing current position and last position btw

silk trench
#

right but how do I get the previous position

#

you're being very vague lol

hardy sentinel
#

hi, was wondering.. what's the math to do a pixel perfect camera?

#

is it that camera should only be offset by 1f/Screen.width units on the x axis and 1f/Screen.height units on the y axis?

somber tendon
hardy sentinel
silk trench
silk trench
#

since character controllers only check for collisions in the direction they are headed

somber tendon
#

Wait, I though you're asking on ๐Ÿ˜•

How can I make a CharacterController be pushed around by Rigidbodies?

silk trench
#

Yes

#

Sorry

#

I should be more clear

#

Kinematic rigidbodies

hardy sentinel
#

are you aware of that CC callback.. how's that called

#

OnCharacterControllerCollision(...) or smth

#

should be what you're looking for.. you can make your CC 'move' based on incoming hits

#

BUT.. for moving platforms there's the easy way of just moving the CC along with their direction (not physics based)

somber tendon
#

The easy way would be parenting the CC to the platform when it's touching it and unparent when untouch, at least that what I did in the past

silk trench
#

The problem with that is that I don't retain my velocity

hardy sentinel
silk trench
#

so if I jump off, I just kinda stop dead in my tracks

hardy sentinel
#

yeah, working with kinematic CCs requires you to implement all that stuff ๐Ÿ˜„

#

you basically lifted the middle finger to all game physics except collisions when you added the CC component

silk trench
#

Man I was really hoping that I didn't have to have a different script for environment objects

hardy sentinel
#

most people would argue that CC is not even worth it if you're going kinematic

silk trench
#

I said every swear word and slur in the book

hardy sentinel
#

it's like.. a semi simple script

silk trench
#

Mine so far is 1k lines

hardy sentinel
#

if you create it from scratch you'll pick up some stuff in the meantime

#

oh it's a custom CC?

#

ah, thought u were referring to unity's CharacterController component

silk trench
#

I am

#

lmao

hardy sentinel
#

๐Ÿ˜

silk trench
#

Don't worry, most of the lines of code are just comments and settings

#

Let me ask this, is it bad practice in any way to parent the player to a moving platform?

hardy sentinel
#

not if you know what you're doing

#

nothing is bad practice as long as you know what you're doing and are aware of the consequences

silk trench
#

Then I'll just hope that I know what I'm doing ๐Ÿ˜ฌ

#

Thank you for your help

hardy sentinel
#

alright np

inner dome
#

Heyhey, sorry for asking twice in different places but I figured I could get an answer faster here:
Without code changes, how much can I change in addressable prefabs? For example if I have a command pattern implemented, or some RequestHandlers or whatevs as scriptableobjects AND all of the assets used are marked as addressable
Do I have to only rebuild my addressables or the player itself if I just swap a few references out in the inspector?

#

Aka wanna build for mobile and test my project there, and rebuilding/uploading addressables (only where "pluggable" parts make sense) would be a lot quicker than patching/reinstalling the whole apk

buoyant vine
hushed plume
#

can you get the length of an AppendStructuredBuffer in a compute shader?

stuck onyx
#

is anybody familiar with iap validation? i implemented the local validation example that comes with iap purchasing package last version but im still getting fraudulent IAP's

#

i implemented the localReceiptValidation btw

inner dome
buoyant vine
quartz stratus
#

That's kinda the point of them

regal olive
#

is it normal that NavMesh agents collide with normal colliders with "isTrigger" checked?

regal olive
#

How can I solve this?

untold moth
regal olive
untold moth
undone coral
undone coral
rocky mica
#

if it works it works

#

๐Ÿ˜„

undone coral
#

personally i would use an asset store asset and move on with life

#

i don't author any platformers though

rocky mica
#

If you are using a character controller by default you dont wanna use unity physics tho

#

whats the use case here?

#

If you really want to you could check the velocity of the rigid body and apply that to the CC directly, thats the less "hacky" way

#

the point of CC is to use your custom physics system

stray plinth
#

Hey ๐Ÿ‘‹
In our automated build pipeline we set defines, then in the preprocessbuild/onprocessscene/postprocessbuild we check against those defines, and execute certains actions.
However the issue with setting defines prior to the build means, that the code will not get recompiled, we could request recompilation, however that is async and therefore quite clumsy or we could check the defines set in the project settings directly, which also feels a bit weird.
Did anyone solve this a different way?

undone coral
silk trench
silk trench
#

I found a solution though

#

whenever I'm on an object with the Platform layer, I'll parent the player to it, all while always keeping track of my "world space velocity"

#

so that when I become airborne, I can just add that world space velocity to the player

rocky mica
#

Yeah parenting is a solution

undone coral
undone coral
#

i wouldn't do this.

silk trench
#

I'm actually almost finished

#

all I have to do is being pushed by platforms and one other thing

silk trench
wispy bronze
#

Hey guys, I need help. I'm working on implementing game center for iOS into my game and I'm having some issues with the daily leaderboard. Keep in mind everytime I win a game, I call the saved win number and that's what I report as the score. So I won 1 game after the daily leaderboard reset for the new day and then it said I had 8 wins today. Do you have any idea why?

naive ore
#

Are space-filling curves useful for spatial partitioning of rectangles that must never overlap?
I read somewhere that using space-filling curves on spatial structures, such as a quadtree, is more efficient. Could this be used for a city builder?

undone coral
wispy bronze
#

No it, reset this is happening twice now.

undone coral
#

the idea is maybe that it is a good choice of what adjacent tiles to visit first in a quadtree

#

such that for typical rectangular shapes in video games, most of the time you will visit 1 neighbor instead of e.g. 4

#

does that make sense?

#

most games stick to grids because it's more fun that way

naive ore
#

I don't know how it's used. I ask because using a simple grid is fine, but I also need to know the nearest neighbor to a position, hence why I am considering using a space-filling curve but I don't know if it works for a placement system

fallow dune
#

Hey! So I want to make a system where if the player runs toward a wall the character puts his back against the wall and sticks. (Metal gear solid) My thought process is that I have a box collider extend a littler further off the wall and if the player capsule is in the wall collider area and the player is pushing the horizontal/vertical input button the character will hug the wall with his back.. Is there a better way going about extruding the wall colliders a little ?

coral blade
#

@fallow dune put your scene walls/floors on a specific layer. then raycast for only that layer a small distance ahead of you to check if a wall is there. then with more raycasts you can get the correct way to orient against the wall

undone coral
#

whatever the optimization a space filling curve gives you, it's ahead of where you are

fallow dune
#

@coral blade do you have any links I can use to read up about

coral blade
fallow dune
#

Thank you.

coral blade
#

this is where i got the idea for that actually now that i think about it

#

np

#

you just use that but use transform.forward instead

fallow dune
#

My approach would have been super dirty .. Thinking about all the extra colliders in the game just made me want to cry

coral blade
#

oh yea screw that. i wondered the same thing if developers did that

#

but luckily it was always just collision checks

fallow dune
#

So I use ray cast to just get the nearest opbject back I am facing and perhaps just check the tag of the GameObject

#

IF a wall then play the animation

coral blade
#

well the thing is. if you use layer instead of tag the raycast takes way less things into account

#

since searching by tag will be colliding with everything instead of only one layer

#
Physics.Raycast(transform.position, orientation.forward, 1f, whatIsWall)```
#

whatIsWall is going to be a LayerMask variable

#

you just set that to the layer in the inspector

fallow dune
#

I see. So I can see layer o 1 ,2 ,4 and 5 are in use already

#

So I can just pick one

coral blade
#

make sure you make a new one

fallow dune
#

Sweet

#

Thanks man

#

this makes me super happy

coral blade
#

your welcome

#

yea i had a blast making a free running system with that

fallow dune
#

I still have a lot to learn so this is a nudge in the right direction

#

If I may stary off topic, where can I get solid Animations? I have no will or desire to make my own

coral blade
#

making your own animations is extremely easy and takes a short time. but otherwise you can just buy on them on the asset store or look up free ones

#

you really need a motion capture suit to make pro animations

fallow dune
#

XD I 3D model for games on a daily.. Animations for me is super dificult

coral blade
#

are you using a decent inverse kinematics rig?

#

i only do very simple animations anyways

fallow dune
#

Nope.. I took the keyframe route

coral blade
#

oh yea that is aids trying to do it that way

#

i use uMotion personally but blender rigify if really similar and free

fallow dune
#

๐Ÿ˜‚

rocky mica
#

yeah tags are not really the way to do any kind of complex systems

#

as you develop a game you will notice how many triggers on different layer you will be using and how that is not really compatible with tags lol

fallow dune
#

I have no idea what layers are at this point but I am super keen

coral blade
#

look in the inspector on the top right when you click a gameobject

fallow dune
#

oh

#

easy peasy

thin mesa
fallow dune
#

Thanks @thin mesa

#

having a read now

thin mesa
fallow dune
#

I tried sending you @thin mesa and @coral blade a gif but apparently I am not allowed any fun

coral blade
#

yea i thought you could drop gifs in here

plucky hound
#

is it possible to have a foldout from the bottom of the screen that folds... up? I have a "active tool" button. when user clicks it i want to unfold the set of all tools so they can choose another.

quartz stratus
plucky hound
#

immediate foldout.

#

I'm looking at the UI Builder and it's not immediately obvious that it will fold up.

quartz stratus
#

Oh cool. Not experienced with UI Builder so I won't be any help but gl

plucky hound
#

heh.

#

The fold is full of tools. I guess I'm going to have to add them all and SetActive(false) to most of them at start. At least this way I'll know they all fit on screen together....

undone coral
#

is it possible to render multiple cameras in parallel?

#

i.e. multiple render textures render in true parallel on the GPU

#

in any of the SRP modes?

#

no right?

#

based on what i see the closest thing is single pass stereo rendering

compact ingot
#

i'd say its technically possible but not "supported" in the commonly used pipelines

meager kite
#

is it possible to disable parts of a scriptable object based on prior variables?

#

eg i have a boolean, if its true, it unlocks more fields, otherwise those fields are not there

regal olive
#

Hey Guys, I wanted to know whether we can check if a World Coordinate is inside a certain radius of the Player or any Game Object for that matter... is it possible for me to do a check like that?

regal olive
#

Ok, Thank You!!

#

I will come back if I am unable to do that :).

strong rapids
#

it takes in a vector3 and float radius

#

vector3 being the position

#

of whatever u want to check around

regal olive
#

will that work for 2D?

strong rapids
#

is ur game 2d or 3d

regal olive
#

2D

strong rapids
#

im not sure for 2d

#

might want to have a look at it

#

just lookup Physics.CheckSphere 2d

regal olive
#

Ok

#

I don't think there is a method to do so

#

for 2D

thin mesa
#

Physics2D.OverlapCircle

regal olive
#

for that I need to spawn a object then check with that right?

thin mesa
#

no, it's a physics query just like Physics.CheckSphere. also this is not really an advanced topic

regal olive
undone coral
regal olive
#

Oh right, That will work

#

I couldn't think of that for some reason... Thank You!!!

thin mesa
# regal olive Oh right, That will work

note that will only work if you want to only check the distance between a specific point and the player. if you want to check if any objects are within range of that point you'd want a physics query

regal olive
#

Yea, I want to only check the distance between a point

#

I generate that point Randomly and check if it is near the player, If yes... I would like to re-generate it

#

That is kind of what I am going for... Thank You anyways!!!

thin mesa
#

okay yeah, if you're just checking distance from player that will definitely work. what you originally implied with your question was you wanted to check if it was in range of player or any object

regal olive
#

is there a way I can check if the green waypoint transform , which doesnt have a rb and collider, is inside the tilemap collider?

maiden turtle
#

Is there a built-in way to do this? If not, can someone share a script. I kind of get how it works, but not enough to code that from scratch

#

Another question

#

Is there a way to animate a collection of separate game objects working as a single mesh, rather than the mesh itself?

#

My use case by the way is fracturing an object while it's being animated. So at a certain point while the animation is going I need to swap it out with a set of fragments, having deformed the fragments according to the current state of the animation

maiden turtle
#

Found this thread

regal olive
#

Hello guys, I just imported a new project and opened it with the right version of unity and i'm getting this errors. Any idea why?

flint sage
#

Open the package manager and import the input system

hardy jacinth
#

after I use UnityObjectToClipPos on a vertex in vertex shader - how does it look?

#

is it in NDC or some other cube?

#

(-w, -w, -w) : (w, w, w) ?

#

how perspective divide works between vertex and fragment shader?

odd moth
#

Hello, I am trying to convert httpWebRequest usage to UnityWebRequest . The first one works to upload files to amazon, the second one gets a forbidden error. Do you know what might be the issue?

#

Why can't I paste code here

hardy jacinth
#

put code in the fenced code block:
```cs
code
```

odd moth
#

oh, sorry

#
    {
        WebRequest requestS3 = (HttpWebRequest)WebRequest.Create(URL3);

        requestS3.Headers.Add("Authorization", aws3Header);
        requestS3.Headers.Add("x-amz-date", currentAWS3Date);

        byte[] fileRawBytes = File.ReadAllBytes(FilePath);
        requestS3.ContentLength = fileRawBytes.Length;
        requestS3.Method = "PUT";

        Stream S3Stream = requestS3.GetRequestStream();
        S3Stream.Write(fileRawBytes, 0, fileRawBytes.Length);

        Debug.Log("Sent bytes: " + requestS3.ContentLength + ", for file: " + FileName);

        S3Stream.Close();

        Debug.Log("S3Stream close");
    }

    private IEnumerator sendUnityWebRequest(string FileName, string FilePath, string currentAWS3Date, string aws3Header, string URL3)
    {
        byte[] fileRawBytes = File.ReadAllBytes(FilePath);

        UnityWebRequest www = UnityWebRequest.Put(URL3, fileRawBytes);
        www.SetRequestHeader("Authorization", aws3Header);
        www.SetRequestHeader("x-amz-date", currentAWS3Date);

        yield return www.SendWebRequest();

        if (www.error != null)
        {
            Debug.LogError("www error: " + www.error);
        }
        else
        {
            Debug.Log("Form upload complete! -> www.downloadHandler.text: " + www.downloadHandler.text);
        }
    }```
buoyant vine
#

( just for your interest )

odd moth
#

I agree, I just used method extract to test this.

odd moth
#

I think the problem is with the URL . Does it fail if the URI have the file extension?

hardy jacinth
#

you can try to inspect the HTTP stream in some debugger and compare headers and requests directly

#

you can use some proxy (e.g. ncat/socat) or wireshark and follow http stream or something else

viscid flame
#

How to download pdfs without freezing UIs in unity?

odd moth
hardy jacinth
#

do you really need to download pdf? (i.e. maybe only displaying it with some kind of webview would suffice)

odd moth
viscid flame
viscid flame
odd moth
viscid flame
#

Don't have that because client gave only database url๐Ÿ˜…

#

He may have used admin panel to upload or May be website

undone coral
#

was this ever working in any form?

viscid flame
undone coral
viscid flame
#

Yes i am using it... And it is causing freeze

shadow seal
#

In a coroutine?

viscid flame
#

Yup

shadow seal
#

Youโ€™d best show your code then

shadow seal
#

No, your code

#

Unityโ€™s works

#

This is advanced code, you should expect to post your own code

viscid flame
#

I am not at work... I will share then

shadow seal
#

Why ask the bloody question thenโ€ฆ

viscid flame
#

Well if i offended you by any chance ๐Ÿ˜…

shadow seal
#

You asked a question about your broken code, and canโ€™t even supply it, Iโ€™m not offended I just think itโ€™s silly

odd moth
#

the thing is how should it differ from the UnityWebRequest version to work

shadow seal
odd moth
#

Are you 12?

undone coral
#

i have a feeling you are not doing the AWS signing correctly

#

also, there's a possibility the version with HTTP request doesn't work, and you are misinterpreting something

odd moth
#

Sorry, I am trying not to use that, the error I get is

#

HTTP/1.1 403 Forbidden

hardy jacinth
#

maybe you can't call an http endpoint - only https?

errant plinth
#

I would use tools such as wireshark/fiddler to figure how the requests differ

inland delta
#

Charles Web Proxy is also a good tool for that use case

placid robin
#

Did anyone else notice the .Runtime directory in packages like Burst? I can't seem to find anything in the docs regarding its purpose but I suppose it helps with resolving conflicting dependencies?

odd moth
misty walrus
#

Hi, I'm trying to implement zenject to my projects workflow but I'm failing on some accounts. I have a Factory and the created component creates a pure c# class. Injections on this class seem to be not working.

#

Anyone has experience with a DI that can help me?

misty glade
undone coral
#

is there really no way to get unity to log to standard out on windows

#

is this a joke

misty glade
#

hm.. i think i had a solution for that a while ago

#

lemme dig

#

haha nope other way around - capturing console.out and redirecting it into unity

undone coral
#

yeah

#

right now i am doing something insane, which is running a unity binary with nssm and tailing the log, then catching sigterm, sigint and sighup and sending it to both unity and tail

#

this is crazy

#

i just need it to do the logs correctly

misty glade
#

sounds ducttapey ๐Ÿ™‚

undone coral
#

i might have to make a little golang poop

#

i might need to use job objects

#

i hate job objects

misty glade
#

do unity binaries emit those signals? i didn't know that

undone coral
#

i hate that i have to hate job objects

misty glade
#

out of curiosity what in the world are you using unity as a service for..?

#

some sort of testing?

undone coral
#

WM_CLOSE i guess is the real thing that is sent

craggy linden
#

How do you convert List<SomeRandomClass> to List<object> and back again?

undone coral
#

it's my unity streaming thing

#

so it's nice to be able to gracefully close processes better

#

as though they were conventional console applications

misty glade
#
List<object> myListOfO = new();
List<T> my2ndListOfT = new();
foreach (T t in myListOfT) myListOfO = (object)t;
foreach (object o in myListOfO) myListOfT.Add((T)o);
#

Not sure why you'd want to do that though...

undone coral
#

i don't know why it's saying forbidden

#

403 is forbidden

#

why aren't you using the unity SDK?

#

@odd moth are you trying to do this in webgl?

#

"yes"

#

it's making a CORS request, which is a HEAD

#

so it's going to return 404

#

you won't be able to interact with the S3 API, or indeed any AWS service, from the browser with this approach

#

if you want to use S3 from the browser you have to... look up a tutorial on that or use a dedicated library, then expose the functionality via a .jslib

craggy linden
undone coral
#

it is a bad one

#

anyway i guess you'll figure it out

junior glade
#

Does anyone know of a good way through unity to get screen grabs without killing performance? Context: I want to stream what the user sees in VR to a web app but functions like read pixels are very slow processes. Any ideas? Thanks in advanced!

weary dagger
#

Hi, do you know how to playetest game via Steam without uploading a build to Steamworks?
I'm having issues with the app_id.txt in the game - when I change this to my playtest app id it doesn't work. Is there a magical button somewhere on steamworks where I can enable testing using my app id?

odd moth
misty walrus
undone coral
#

people are difficult today huh

undone coral
#

if you want to distribute the game via steam

#

you have to upload to steamworks

#

use your private release channel

#

when you say you're having issues with app_id.txt, what do you mean?

misty glade
#

I mean, you're asking for a commitment from one person to walk through your problem with you. What you need to do is describe your problem (completely), paste code, show what you've tried, why it didn't work, and go through the problem completely so someone could answer. People in discord (maybe especially so in this channel) aren't going to commit to a socratic interaction with you. https://dontasktoask.com/

undone coral
#

but maybe what is the actual issue you are experiencing?

misty glade
# misty walrus Hi, I'm trying to implement zenject to my projects workflow but I'm failing on s...

I'm trying to implement zenject to my projects workflow but I'm failing on some accounts. I have a Factory and the created component creates a pure c# class. Injections on this class seem to be not working.

This hasn't actually given us any information that someone could offer guidance on. "I'm failing on some accounts" -> What accounts? How is it failing? What are the error messages? Where's the code? etc..

weary dagger
#

well I have the sub-item in steamworks called "playtest" which gave me a new app_id for my game

undone coral
misty glade
weary dagger
#

so I tried to change 480 app_id of Spacewars in my folder where Unity project is to that playetets id and it doesn't work

#

I thought I can leverage my own app_id to test the game

undone coral
weary dagger
#

either from Unity or adding non-steam game to steam when trying buiid from local PC

misty walrus
misty glade
#

I'm just cranky beecause I logged into VS feedback hub for the first time in a few days and most of my issues are closed. ๐Ÿ˜›

undone coral
#

lol

weary dagger
#

Steamworks APP_ID Issue thread here >>>

undone coral
#

yeah there was a directive at M$ recently, "close as many externally visible bug counts as possible"

undone coral
#

is spacewars your game?

#

are you trying to mod it?

misty glade
junior glade
misty glade
#

^ didn't work, easily reproduced issue, still closed for not enough info

undone coral
compact ingot
#

The VS team is legendary for ignoring tickets

undone coral
#

i wouldn't sweat it

misty glade
#

it's like.. ๐Ÿคทโ€โ™‚๏ธ how much work should I do for you for free to improve your product

undone coral
#

just stop using visual studio

#

jetbrains has responded to and fixed all the bugs i file

#

it's over

#

this is how they want to do now

misty glade
#

someday i'll change but for now i'm too vested in the tooling, there are a lot of really great aspects of it, and others......... well......

compact ingot
undone coral
#

what is the gameplay objective?

misty glade
undone coral
misty glade
#

like how much more info do you need...

undone coral
#

the PMs are trying to repro issues now

#

since the time that visible issue counts are in their metrics

#

they just do nothing and close it

#

they have no idea what your'e talking about, they don't program

misty glade
#

yeah, i mean.. it's Enterprise Software

undone coral
#

whoever has the misfortune of being assigned your problem

#

well they used to have SDETs doing this all day

junior glade
misty glade
#

the flip side is I see tremendous wasteage and effort put into things that ... really don't need it. I opened a ticket with Azure support a while ago for help with a firewall issue.. (turns out Azure App Services can only open 80/443 so I had to migrate my app to Azure Container Instances to use a custom port.. no big deal, took me 15 minutes to do after I learned this tidbit of configuration minutae) and yet... they emailed me FIVE TIMES asking for feedback on the call.. i responded to the 5th request by saying "stop asking for feedback i don't have time for this, I already pay $/month for it"

undone coral
compact ingot
# misty glade the flip side is I see tremendous wasteage and effort put into things that ... r...

The first - and probably last - time I will seriously respond to an arrogant, dismissive Twitter post on-stream. I felt it was worth doing at least once.

Esoterica: You'll notice that when I talk about how bad the Visual Studio watch window speed is, I say "default install", and I also explain part of the reason for the slowness (intentional de...

โ–ถ Play video
undone coral
#

how many long, verbose, meaningless emails they sent

misty walrus
# misty glade > I'm trying to implement zenject to my projects workflow but I'm failing on som...
    public class FooComponent : MonoBehaviour
    {
        private FooClass _fooClass;
        private void Start()
        {
            _fooClass = new FooClass();
        }

        public class Factory : PlaceholderFactory<FooComponent>
        {
            
        }
    }

    public class FooClass
    {
        [Inject] private FooInject _fooInject;
    }

    public class FooInject
    {
        
    }

What accounts > Getting FooInject class injected.
How is it failing > _fooInject is null.
What are the error messages > None
Where's the code > Here

misty glade
#

i've watched this guy's stream a little bit before (handmade hero)

#

not sure i have 30 minutes to watch this video atm

compact ingot
sly grove
#

that's how every DI framework i've worked with works.

undone coral
sly grove
#

(never used Zenject though)

misty glade
#

you know, what, I actually do have time for it lately because I'm in the compile-build-deploy-wait12minutesforit-install-test cycle now

#

i'll watch 12 minutes at a time ๐Ÿ™‚

#

(usually i play a game of blitz โ™Ÿ๏ธ )

misty walrus
undone coral
#

is this meant to run on the quest?

junior glade
undone coral
#

okay

#

i think your best bet by far is to use the built in platform streaming solutions, like game mode in windows or the quest mirror view

#

for the purposes of developing a concept

#

and then build the web experience separately

#

if you need it to be in a browser for the purposes of your proof of concept, use an embedded twitch window

junior glade
# undone coral okay

Yea we've done that and the game play experience was fun so this is like Gen 2 of our minimum viable product that's holding us back from committing to more

undone coral
#

there will be latency on the order of 4s

#

hmm

#

well i develop a unity streaming solution and you are venturing into something profoundly challenging

#

it is going to exceed the entire scope of your game

#

you haven't yet told me the platform straight

#

which is worrying

#

are you developing for the quest or PC?

junior glade
misty glade
#

I'm migrating my unity project from Mono to IL2CPP. Does anyone know which C++ compilers are used?

#

Should I just grab the latest? or is there any reason to specifically use older ones

misty glade
#

kk

undone coral
#

as long as it's msvc

#

they're all bad

misty glade
#

no doubt

junior glade
# undone coral it is going to exceed the entire scope of your game

I appreciate the insight, we definitely know it could be a lot but we're just interested in seeing what possible for the future and knew this would be a wall at some point we might not be able to cross. Doesn't hurt to allocate some time in the the background to try and generate options

misty glade
#

Like - any/all of these..?

#

(I'll be building to ARM64)

#

fuck it, this is so unwieldy.. I'll just grab a latest compiler for every single platform i guess

odd moth
#

in the www.result I get protocol error

undone coral
# misty glade fuck it, this is so unwieldy.. I'll just grab a latest compiler for every single...

you need something like this

  curl -sL https://aka.ms/vs/16/release/vs_buildtools.exe -o vs_buildtools.exe
  ./vs_buildtools.exe --quiet --wait --norestart --nocache \
    --add Microsoft.VisualStudio.Component.Roslyn.Compiler \
    --add Microsoft.Component.MSBuild \
    --add Microsoft.VisualStudio.Component.CoreBuildTools \
    --add Microsoft.VisualStudio.Workload.MSBuildTools \
    --add Microsoft.VisualStudio.Component.Windows10SDK \
    --add Microsoft.VisualStudio.Component.VC.CoreBuildTools \
    --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \
    --add Microsoft.VisualStudio.Component.VC.Redist.14.Latest \
    --add Microsoft.VisualStudio.Component.Windows10SDK.19041 \
    --add Microsoft.VisualStudio.Component.VC.CMake.Project \
    --add Microsoft.VisualStudio.Component.TestTools.BuildTools \
    --add Microsoft.VisualStudio.Component.VC.ASAN \
    --add Microsoft.VisualStudio.Component.TextTemplating \
    --add Microsoft.VisualStudio.Component.VC.CoreIde \
    --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core \
    --add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset \
    --add Microsoft.VisualStudio.Component.VC.Llvm.Clang \
    --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 \
    --add Microsoft.Component.VC.Runtime.UCRTSDK \
    --add Microsoft.VisualStudio.Component.VC.140 \
    --add Microsoft.VisualStudio.Workload.VCTools

and you can guess to change x86 x64 to arm64

misty glade
#

I just grabbed everything lol

#

12GB ๐Ÿคทโ€โ™‚๏ธ

undone coral
#

okay well that's the stuff out of my CI

misty glade
#

gives me time to watch the handmade hero rant @compact ingot posted

undone coral
misty glade
#

the funny part about this all is I just need to compile this android AAB a handful of times so I can ensure the pipeline/app works, then i'll go back to the CI/CD

undone coral
#

@odd moth is this in an android simulator?

#

or a real android device?

undone coral
odd moth
#

real device

undone coral
#

i can only help you so much

odd moth
undone coral
#

you aren't going to succeed in signing the requests correctly

#

it's not viable

#

why are you trying to upload directly to s3 from a device? are you familiar with STS?

odd moth
#

I am not

odd moth
undone coral
undone coral
junior glade
#

Definitely!

plucky hound
#

I have GameObject GameController with component Map B and Planner C. C wants a reference to a Map. I give it GameController and it says GameController (Map). Debug.Log also says GameController (Map). Is it correctly referencing the component inside GameController? the display is ambiguous to me.

misty glade
#

@compact ingot This is an ... interesting video. I mean, he makes good points but holy hell is his attitude bad.

thin mesa
plucky hound
#

yeah, wrong channel. thanks!

buoyant vine
#

its not like that there are 1000 other editors around for c++

undone coral
#

i use CLion for C++

misty glade
#

I mean... Criticisms about software, product prioritization, performance etc - those are all valid.. but the hubris to think that there aren't smart people working at MS or that these are difficult problems to solve is just sort of off-putting and reduces the quality of the claim. I get it - he had a shitty experience trying to give feedback, and he's not wrong about that, but the antagonistic and confrontational and insulting approach is just unnecessary IMHO. I enjoy making software, I enjoy the ecosystem, I enjoy talking with other people, solving problems, OSS, etc - no reason to make that lifestyle awful for yourself and everyone around you by acting like a jerk...

fossil prairie
#

Why would I do the first line, if I can just do the second? I would still have to use an interface for multiple different objects but I don't see the benefit of using the unity eventsystem here?

buoyant vine
fossil prairie
#

I dont understand what you are trying to say with that

buoyant vine
#

its too low amount of code to guess what you try to do

#

and you posted image

#

which is not usable at all for explaining

misty glade
fossil prairie
#

ah, so it's something like a message bus to handle more complicated or complex messaging. thanks

odd moth
odd moth
#

is that posssible with regular webRequest?

urban warren
#

What is a good way to handle cases where you need to set a value only when nested if statements fail.

private GameObject _target;

// In Update...

if (Physics.Raycast(.., out RaycastHit hitInfo))
{
  if (hitInfo.transform.gameObject.tag == "something")
  {
    if (hitInfo.transform.gameObject == _traget)
      return;

    _target = hitInfo.transform.gameObject;
    TargetChangedEvent();
  }
  else
  {
    _target = null; // Here...
  }
}
else
{
  _target = null; // And here...
}
#

I have run in to this sort of thing a couple of times and I never seem to come up with a clean looking solution. I feel like a nice way is right there and I am just not looking at it the right way.

fallen magnet
urban warren
long ivy
#

hide the complexity in a method instead when there is a lot of nesting

urban warren
#

As it looks ugly, introduces more spots to fail, and is harder to refactor.

long ivy
#

and why is moving your nested if logic into a different method bad?

#

I don't mean put the whole mess into a method, I mean extract out that nested if condition

urban warren
#

It isn't bad, but doesn't really solve the problem?

#

Like, one option is to use a goto (ew), another is to use a bool that is only true when the target is set, and if it is false then _target = null

#

But neither look that clean imo.

zenith ginkgo
#

Anyone here used Dotween, i cant find this information on the documentation, does anyone know if Sequence.Kill() also sets the cached sequence to null?

 cachedSequence = DOTween.Sequence()```
undone coral
fallen magnet
#

You could store the result of each if clause in variables to remove nesting and repetition

private GameObject _target;

// In Update...

bool rayCastDidHit = Physics.Raycast(.., out RaycastHit hitInfo));
if (!rayCastDidHit || hitInfo.transform.gameObject == _traget)
      return;
bool hitSomething = hitInfo.transform.gameObject.tag == "something";
_target = hitSomething ? hitInfo.transform.gameObject : null;
TargetChangedEvent();
zenith ginkgo
#

Thank you

undone coral
#

i think there's a "killed" property or something

long ivy
# urban warren It isn't bad, but doesn't really solve the problem?

just for reference, to compare it to these other solutions in terms of clarity, I'd do it like this:

private void Update() {
    if (HasHitATarget(out var newTarget) {
        if (_target != newTarget)
        {
            _target = newTarget;
            TargetChangedEvent();
        }
    }
    else _target = null;
}

private bool HasHitATarget(out GameObject newTarget) {
    newTarget = null;

    if (Physics.Raycast(new Ray(), out var hitInfo) && hitInfo.transform.CompareTag("something"))
        newTarget = hitInfo.transform.gameObject;

    return newTarget != null;
}
#

whoops had a bug, fixed

urban warren
misty glade
#

Anyone know if the in-editor player uses mono or IL2CPP? Or something else? I have some code that shouldn't work because it uses some JIT code generation, but it's working fine in the editor (even though the windows build target uses IL2CPP)

misty glade
#

hm.. crap, aight.

urban hull
#

hello everyone

#

i want to implement a custom input system and i would like to take a peek on the code that defines the unity api Input class

#

because im using linux i dont have access to visual studio to use the go to implementation command

#

i tried to implement the go to implementation plugin in my editor and i didnt work either

#

do anybody knows how can i do this?

urban hull
#

does this repository also contains the definition for other classes?

#

just in case i need to check other classes as well

#

oh never mind i just found here

#

thanks a lot @urban warren

urban warren
neat panther
#

Hi everyone
I've been trying to implement a character creation system similar to elden ring/skyrim, but with a low-poly character model and not necessarily humanoid.
Players can tweak a slider to decide on certain attribute of their player model, height, body width, leg length, etc
There are a few options I considered but I have no idea which one is better.

  1. Use blendshape to blend between several pre-made model
    Pros: Easy and fast
    Cons: Not flexible enough for details unless I breakdown the model into hundreds of pieces, which defies the purpose of fast implementation

  2. Color code each vertex and grab vertices by color in unity to scale
    Pros: Relatively easy to code
    Cons: Each model (Male/Female/different race) will have to be manually color coded, increasing the workload by a lot

  3. Create a scriptableObject to contain ruleset for entity creation, stored in string, which an Entity Generator can parse and turn a list of attribute into vertices/triangles/bones
    Pros: Turning all vertices into clear formula that can be tweaked easily, can allow for model generations for all entities, not only humanoid, have potential for procedural entity generation
    Cons: This is basically writing half a compiler/interpreter for a custom language. Heavy code. Could be slow on runtime.

  4. Create an abstract base class for MeshGeneration and have an inherited class for each race/entity/species I want to generate
    Pros: Lighter code than 3 but still retain the flexibility to assign each vertex with formula
    Cons: Hardcode, a lot of hardcode. Also cannot be automated later to create new species.

I have grinded for days and still couldn't decide between 3 and 4. What's everyone's take on this problem? Or are there a fifth options I'm not seeing?

undone coral
undone coral
#

are you one of them so called, coding primitivists?

undone coral
misty glade
#

The best feeling in the world is deleting 18 debug statements, closing 30 browser tabs, and publishing your build without testing because that fucking feature is finally vanquished. Who knew it would be so hard to migrate from Mono to IL2CPP.

#

It was going to poorly I was printing stack traces to a TextMeshProUGUI object on the screen

maiden turtle
#

How can I find out where a vertex inside the mesh that's not on the original mesh lands when I apply an animation's transformation and drformation? I'm thinking I could approximate it via some sort of approximate triangulation via the neighboring vertices. Is there a name for this concept? I don't know how to google this.

#

I need to somehow decide at runtime either which bones it depends on and what their weights are, or somehow approximate it from the neighboring vertices

heady bane
#

what does it mean when unity is throwing a TLS ALLOCATOR ALLOC_TEMP_TLS ERROR after building to iOS?

#

I know its stopping a build from happening since the xcode version of the project is never updated from a unity build

#

but unity does not report the build has failed, just that it has encountered that error above

heady bane
#

would anyone know why unity is not creating new builds for xcode?

#

I keep doing new builds, but none of the changes are coming through

#

like im not sure how to get a new build working, its like unity keeps building an older version.

raw path
#

Hi there
does anyone know a way how to render a material into a RenderTexture through code?

heady bane
#

render a material into a render texture?

raw path
#

yes, I want to create a heightMap through a shader/graph and get a preview inside the inspector
basically draw the result of the graph into a texture that I can use later on

heady bane
#

ah okay

#

that should be possible, Ive done something similar before but I cant remember atm what it was

hardy jacinth
#

How do I convert clip space point to world space properly in shader?

raw path
hardy jacinth
#

Then multiply by inverse view projection matrix in the fragment

#

But it doesn't seem to work

hardy sentinel
#

say I have an arbitrary shape that encloses an area.. how can I find a position for which I can be sure is inside that area?

#

Shape e.g.:

obsidian glade
hardy sentinel
#

sounds good.. but.....

#

wait you changed that twice ๐Ÿ˜›

undone coral
#

lol

hardy sentinel
#

anyway as you see this doesn't work ๐Ÿ˜›

somber swift
#

that does indeed work (except some rare edge cases like the line being tangent of the shape edge at some point)

obsidian glade
#

just changed horizontal to straight since it doesn't actually matter what direction it is - just a point to the edge/infinity

hardy sentinel
#

this line has many points outside the shape

undone coral
#

but i think they're migrating to microsoft's AOT implementation

obsidian glade
undone coral
#

what's your gameplay objective @hardy sentinel ?

hardy sentinel
#

I want to fill a shape with pixels -- and I only have the outline

obsidian glade
#

it doesn't sound like this really answers your goal though

hardy sentinel
#

oh I can fill a shape, no problem.. as long as I have a point that's inside it

#

just trying to comprehend the logic behind this one in the meanwhile lol

somber swift
#

@hardy sentinel (I haven't read this paper myself so no idea whether it's good or not) you can take a look at font rasterization which uses that intersection method (the shape is usually defined by cubic bezier curves) https://infoscience.epfl.ch/record/99768/files/frsa

somber swift
#

oh, that's great, missed that one

hardy sentinel
#

thanks everyone! I'm really happy coz I asked without any expectations especially while being so vague lol ๐Ÿ˜„

#

where could I learn more about SVG graphics and general algorithms/practices regarding that? (anything math/shapes related actually.. I'm VERY curious on that subject)

undone coral
#

you can look at some of the stuff in that

sly grove
hardy sentinel
hardy sentinel
hushed sparrow
#

hey, im trying to figure out how to do super mario galaxy esque movement on cubes, i think ive got the gravity down but im struggling to think of how to make the movement work at different rotations with a character controller, whats a good way of doing this?

gray pulsar
hushed sparrow
#

im working on implementing jumping and gravity rn but this is how i currently have it set up

gray pulsar
hushed sparrow
#

does transform.right/forward translate with rotation?

gray pulsar
#

you wouldn't be using your own transform, you would be using some other transform that is unique to the face of the cube

sly grove
hushed sparrow
#

i see

#

well that makes things much easier, ty

misty glade
#

I'm attempting to stand up CI/CD for android app deployment to google store, and this is my first encounter with gemfiles. How do I go about vetting the huge number of dependencies that a tool I'd like to use (fastlane) rely on? As "CTO" for my little indie studio - do I need to? There's 200-some packages in the gemfile.. ๐Ÿ˜

maiden turtle
#

How do I copy a component, ideally without using GameObject.Instantiate on the source and without runtime reflection?

#

An internal method is ok though

#

at runtime

#

basically, Add component -> copy values

#

another piece of info: I don't own the component that will be copied, so I can't make a copy method that would vopy the relevat properties

buoyant vine
#

for mass instantiation

undone coral
#

fastlane comes packaged with ruby right?

maiden turtle
misty glade
#

No, I had to install ruby and the ruby gem bundler

#

I then ran bundler on a fastfile in the root of my project to generate the dependencies into a gemfile.. which is here (sec, I'll pastebin):

maiden turtle
#

only whole game objects

misty glade
buoyant vine
misty glade
#

A lot of it looks "enterprise" (aws, google, faraday, etc) but there's a ton of stuff in here I've never heard of since I don't really know this ecosystem

maiden turtle
#

And once again, I don't care about pooling

odd moth
#

Is there a way to make this with a coroutine, or in such a way that the app doesn't freeze and progress can be shown?

#
S3Stream.Write(fileRawBytes, 0, fileRawBytes.Length);```
agile grove
#

hey how can i check what Class is T?

sly grove
thin mesa
#

you probably want to put a contraint on T so that you can guarantee it is a type you want. For example if you wanted it to be a class derived from State you can do where T : State

agile grove
#

im doing state machine and want to change state using class inherit from statemachine

sly grove
#

Can't they just be public abstract void Enter(StateMachine stateMachine);?

#

Oh i see

thin mesa
#

yeah looks like a cast is gonna be required for this whether it is generic or not

#

so you can use a switch block and cast to different classes that way (or use multiple if statements)

agile grove
#

can you give me example of syntax? I was trying to use typeof but cant write it right

thin mesa
#

for example:

switch(stateMachine)
{
  case EnemyStateMachine enemy:
      stateMachine.SwitchState(enemy.enemyChaseState);
      break;
  case OtherTypeOfStateMachine otherType:  
      //do things here
      break;
  default:
      //do other things here
      break;
}

of course there are generally better ways to handle it, but with your current setup this would work

undone coral
misty glade
#

Especially because I'm granting fastlane keys to deploy to google play directly

undone coral
#

the only thing you need is

#

you should only do this

#

are you asking why your Gemfile is is so big?

#

it's fine

misty glade
#

Yeah, I did the above

undone coral
#

okay

#

if you know this is just a builder

#

you can do sudo gem install fastlane like it says

misty glade
#

I mean, it's all working, and.. I'm testing out the build for the first time now (I think I have other issues with the build) but I was able to test a connection locally using fastlane to google play with the json key file and it seems all good

undone coral
#

provided ubuntu / aws linux automatically add the gem bin path

#

okay my memory of it is it's

#

very involved

misty glade
#

Yeah, it did (auto add the path)

undone coral
#

you will have a much easier time building from the android gradle project

#

fastlane can interact with it

misty glade
#

perhaps but I don't have android tooling atm.. have just been building directly from unity for manual testing, and using GameCI for CI/CD building & deployment

undone coral
#

it's going to suck to do that

misty glade
#

not opposed to setting up local tooling eventually for when I have bugs I need to debug but.. so far, no bugs ๐Ÿ™‚

undone coral
#

because fastlane can bump versions for you and set up the keys correctly

#

when it's in the gradle project

#

that's just because you haven't really finished yet lol

#

it's not going to work with the apk

misty glade
#

No it's because I'm an excellent developer ๐Ÿ˜‰

undone coral
#

lol

#

another consideration is github actions is the only thing the fastlane userbase really uses

#

so it's the only thing that's 100% supported

misty glade
#

yeah, that's what i'm using as well

undone coral
#

if you can set it up there you're golden

misty glade
#

so far so good

undone coral
#

well there's unity game-ci

misty glade
#

but that yellow icon is just terrifying to watch :p

undone coral
#

but that won't work without a license

misty glade
undone coral
#

that's what i meant

misty glade
#

works fine with a personal license

undone coral
#

well but then you have to see a splash screen

#

๐Ÿฅบ

misty glade
#

heh, yeah, but we'll buy the license prior to us launching.. $1800 or whatever is a lot to pay prior to that

undone coral
#

another consideration is to not bother at all

misty glade
#

unity ๐Ÿ’ธ

undone coral
#

because with ios it will break every month, and your release cycle will be possibly longer than that

misty glade
#

I haven't gotten around to iOS yet - what will break every month? the CI/CD pipeline?

undone coral
#

uploading to apple

#

a token will expire, something will become incompatible with the version of fastlane you install, or there will be a new checkbox you have to check before you can update apps again

misty glade
#

oof

urban warren
#

Is there really no good sparse dynamic matrix (2D array)...?

#

There is of course the dictionary option, but that is going to be pretty slow when accessing repeatedly.

weak dome
#

I've found that I've had to wait for next frame in some particular cases due to some MonoBehaviours' Start method not being completed but somehow feels wrong to do it that way.
I did this most recently with a Tittle Screen where I've set a bool to avoid the Title Screen when testing. Something like this:

private IEnumerator FadeInTitleScreen()
{
    if (!_shouldShowTitleScreen)
    {
        yield return null;
        OnTitleScreenConfirmed?.Invoke();
    }
...
}

No questions really, just wanted to see if anyone had any thoughts or tips on this.

drifting galleon
#

the start method will always be completed

agile grove
sly grove
#

seems like an antipattern though

agile grove
weak dome
drifting galleon
#

i don't think that's the issue

sly grove
weak dome
sly grove
flint geyser
#

Is there a way for a lambda expression or an anonymous method to get its parameters signature automatically adjusted when the delegate the lambda/method is assigned to changes its signature?

flint geyser
drifting galleon
flint geyser
#

Why

drifting galleon
#

because either:
1 - you use the parameters, then you want to know what you get or
2 - you don't use them, then you don't need them

flint geyser
drifting galleon
weak dome
flint geyser
drifting galleon
sly grove
flint geyser
drifting galleon
sly grove
#

Why not - when you change a method signature, it's only natural to have to change all of the call sites for that method

drifting galleon
#

because that sounds like bad code to me anyway

sly grove
#

That's bog standard stuff when you code

flint geyser
drifting galleon
flint geyser
drifting galleon
#

then change your code design

flint geyser
#

You are offering me to change my code design

#

Nice

sly grove
drifting galleon
#

exactly

flint geyser
#

What about a simple case when there is a global event which is listened to by many objects?

drifting galleon
drifting galleon
flint geyser
drifting galleon
flint geyser
#

Would be nice to be able to add to delegates methods with unmatching signatures in that case tho

drifting galleon
#

no it wouldn't

#

if you persist on this idea. then add a fricking List or object or dynamic to your event where you just cram anything in that may or may not be needed

flint geyser
#

Mmm dynamic

#

Nice

#

Thx

drifting galleon
#

well, that's a way to solve your 'problem'

urban warren
#

You could also use multiple events.

#

I am going to have to go with the others though, it sounds like you are trying to fit a square peg in to a watermelon.

drifting galleon
#

+1 ๐Ÿ˜‚

#

that is indeed a very good mataphor

urban warren
#

Why thank you

#

I shall now use this opportunity to ask if you know of any dynamic sparse matrix implementations?

flint geyser
#

I do not think dynamic keyword can help me in the case tho

#

And throwing multiple events sounds like bad code to me

#

Not sure bout it tho

drifting galleon
plucky hound
#

When I say new List<Foo>()... what is the concrete implementation? Array? Queue? Linked List?

urban warren
urban warren
#

Stack, queue, dictionary hashset, are all arrays

#

internally

drifting galleon
#

you've been answered that before i think

plucky hound
#

thanks! I'm used to Java where it's List<Foo> name = ArrayList<Foo>()... eg you see the concrete implementation only at creation.

drifting galleon
#

everything is an array. except a linkedlist

plucky hound
#

I didn't see the previous answer, sorry

drifting galleon
plucky hound
misty glade
drifting galleon
#

^^like i said. you'd have to change your code design

misty glade
#

In fact the more I think about it, the more that model makes sense because it means your published event is going to have a relatively fixed signature - whereas as your game or whtaever develops and you get more and more information that your subscribers need, they can just ask for whatever.

A while ago I used this model that had a player object, and I had a bunch of events like:

public static event Action<int> OnPlayerHealthUpdated;
public static event Action<int> OnPlayerLevelUpdated;

then it started getting bloated..

public static event Action<int, int> OnPlayerHealthUpdated; // from, to
public static event Action<int, int> OnPlayerLevelUpdated; // from, to

and pretty soon it was out of control...

public static event Action<int, int, int, int, int> OnPlayerHealthUpdated;

so you can just change it to either more granular events that never have a parameter list, but instead have an event ID that you can store for as long as you need - AND you only ever need one action:

public static event Action<Guid> OnPlayerUpdated;
struct PlayerHealthUpdated
{
  Guid id;
  Guid PlayerId;
  int HealthBefore;
  int HealthAfter;
  int HowMuchDamage;
  DamageTypeEnum DamageType;
}

...
public Dictionary<Guid, PlayerHealthUpdate> playerHealthUpdateEvents;

{
  Guid eventGuid = Guid.NewGuid(); 
  PlayerHealthUpdate hit = new()
  {
    id = eventGuid,
    PlayerId = playerGuid,
    HealthBefore = player.Health,
    HowMuchDamage = damage, 
    // .. etc ...
  }
  playerHealthUpdateEvents[eventGuid] = hit;
  OnPlayerUpdated?.Invoke(eventGuid);
}


... elsewhere ...
PlayerManager.OnPlayerUpdated += OnPlayerHealthUpdatedHandler;
public void OnPlayerHealthUpdatedHandler(Guid eventGuid)
{
  PlayerHealthUpdate hit = PlayerManager.playerHealthUpdateEvents[eventGuid];
  ... do stuff with hit ...
}
#

that's sort of hacked together (yay for developing in discord) but hopefully that gives you the idea.. I don't know if that pattern has a name (Lazyload pub/sub?) but that'll allow you to emit the fewest possible events, allow for future growth, etc

#

@undone coral these build times are brutal

plucky hound
#

I'm looking for advice from anyone that's build a system of tasks that npcs carry out. for example I might give build orders that go in a queue and then the first available worker starts on the first available build. I'd like please to talk a bit about pitfalls that I can't see from here, having never written this before. I'm concerned that over time all activities from all npcs will be tasks from this queue and I'd to not shoot myself in the foot with a bad design.

#

IDK if I'm ever going to have to return items to the main queue, if NPCs should have a local queue (like they go on break so now the stack has a new task "take a pee"), if a task over there should be two sub-tasks (walk, then work), ... lots of unknowns

#

think Prison Architect or RimWorld type behaviors

undone coral
#

to make it faster

#

cloud compute instances are just slow

plucky hound
#

@misty glade does your github instance cache anything between builds? I have a java project that caches all the downloaded dependencies, really speeds things up.

misty glade
#

I'm currently caching, yeah, but .. for some reason the builds still seem to take a while. DrP: I've considered local github runner, these build times are pretty awful, so I might have to consider it more strongly. 3-4 minutes locally, 30 minutes remotely.. ๐Ÿคฎ

misty glade
#

I think a Queue<NPC.NPCTask> and NPC.Reprioritize() should be a good API surface to try to get started with though.. it'll naturally get more complex ๐Ÿ™‚

#

dammit another 30 minutes down the tubes

#

Additionally, if you want to create draft releases (which will be necessary until you've manually pushed at least one build through the manual submission process), you will want to switch release_status from completed to draft.

Gah. I hate when something really stinkin important is buried in one sentence in documentation like this

dense remnant
#

Question, I wanted to simplify my code for my stats by making a smaller, reusable class, how do I request my 3 stats in Unity script panel:

Ref. code:

public class CharStats : MonoBehaviour
{
    public BaseStatInt maxHp;

    void Start(){
        maxHp.setStartingValue();
    }
}


public class BaseStatInt {
    public int currentValue;
    public int startingValue;
    public int finalValue;

    public void setStartingValue()
    {
        currentValue = startingValue;
    }
    public void LevelStat(int maxLevel)
    {
        currentValue += (finalValue - startingValue) / (maxLevel - 1);
    }
}

result in unity:

obsidian glade
#

best bet is probably just to jump in and start seeing how it works though as Sharping said

misty glade
#

(make the BaseStatInt [Serializable] and give it a [CustomPropertyDrawer] with details about how to render everything inside it)

rocky mica
#

for that kind of stuff I would put that data in an scriptable object tbf

dense remnant
#

the result I was hoping was to add some decorator to my BaseStatInt class so that in the editor i could force to see:

MaxHP CurrentValue
MaxHP startingValue
maxHp finalvalue

misty glade
#

Yeah, property drawer attributes

dense remnant
#

I look into that thank you!

#

Yep that was exactly what I needed! This reduced my code length and complexity a lot!

I like the view in the editor as well, keeps it more clean and together!

Thanks a lot

urban warren
plucky hound
hardy sentinel
#

I suppose I can use a fixed direction for my 'line', then calculate all points on the outline that have adjacent points on that direction and prevent them from adding to the 'edgesHit' counter

#

.. but that sounds kind of like a pain ๐Ÿ˜… (I'll actually go ahead and do that for now.. not like I have any other ways to go with it atm :p)

severe grove
#

I'm not fully understanding how to get interfaces and overrides to work in editor. I am stumbling at the last part, having the ability to drag and drop a derived script into a field in editor. Here is what I tried: I have a skill scriptable object. It has a variable called public ISkill effect; I want this to be a variable I can select different custom functions in editor from based on skill. I.E. Fireball, Lesser Heal, ect. The ISkill class is like this public class ISkill { public virtual void Execute(Character source, Character target, bool isRemove) { return; } } and the AetherManipulation class looks like this public class AetherManipulation : ISkill { public override void Execute(Character source, Character target, bool isRemove) { if (isRemove) { target.hasAether = false; } else { target.hasAether = true; } } }

severe grove
inland delta
severe grove
sinful fossil
#

Hi, I need help with Graphics.Blit method. I am using it to create a texture atlas. However, when I use it to paste a source texture onto the destination texture, the source texture gets repeated over the whole destination texture.

This happens with all the wrap modes on the textures import settings!!!!!

Anyone know how I can solve this problem or use some other method to paste images onto a single image with scaling and offsetting?

Perhaps a mask somehow?

#

As you can see, the texture repeats 9 times, I only want the texture to be on one of those 9 spots since other textures are going to be in each slot!

#

currently this green texture is supposed to go to the bottom middle of the texture which happens to be the farthest texture in the left middle on the top face of the cube (I should have used a plane for this so ignore the textures on the other sides of the cube except for the top)

sinful fossil
#

OMG WAIT Graphics.DrawTexture seems to be what I was looking for. So unless I respond, I found my solution!

rapid flume
#

Hello guys I have created(or maybe copied from github) this move script and I wanted to add sprinting(for who is living under a rock sprinting means running but for some reason its called sprinting in games dont ask me why) when shift is hold with W, how can I add it?

loud basin
#

you bump your movement speed up when the shift key is pressed. e.g. is shift down && w down

rapid flume
loud basin
#

you can use an else or get button up and save the original speed value to another variable

loud basin
devout hare
#

It's the same server. You don't gain anything by asking on the wrong channel, you'll just annoy people. Be patient and ask again later (wait longer than 5 minutes) if no-one answers.

devout hare
#

no

buoyant vine
rapid flume
merry hill
#

im running this piece of code on Start() on a script attached to the main camera
by just adding the if statement i got my unity to refuse to run playmode, anyone know why this might be?

        Attribute[] attributes = Attribute.GetCustomAttributes(typeof(TestScript).Assembly);
        foreach(Attribute attribute in attributes) {
            if(attribute is TestAttribute) {
                Debug.Log(attribute.ToString());
            }
        }```
severe grove
#

Hey all. This is a performance question. I am making a turn based game. At the moment, every character in the scene will run this update function every round. This has quickly inflated to doing multiple thousands of math operations per combat round. Do I need to start getting worried about performance? How would you recommend streamlining? ```
public void UpdateCharacter()
{
SetupDefaults();
ProcessAttributePoints();

    // process traits
    // process passive skills
    // process equipment

    CalculateBaseStats();
    
    // process Active Effects

    // process Sustained Skills

    CalculateFinalStats();
    ClampResourcePools();
    
    if (isEnemy)
    {
        Events.EnemyChanged.Invoke(ID);
    }
    else
    {
        Events.CharacterChanged.Invoke(ID);
    }
}```
#

here is a snippet from my CalculateBaseStats function. ```
stats[StatType.baseACU] = // Acuity
stats[StatType.flatACU] *
(stats[StatType.incACU] / 100 + 1) *
(stats[StatType.multiACU] / 100 + 1);

    stats[StatType.baseCON] =           // Conditioning
        stats[StatType.flatCON] *     
        (stats[StatType.incCON] / 100 + 1) *
        (stats[StatType.multiCON] / 100 + 1);
    
    stats[StatType.baseINT] =           // Intelligence
        stats[StatType.flatINT] *     
        (stats[StatType.incINT] / 100 + 1) *
        (stats[StatType.multiINT] / 100 + 1);```
devout hare
#

A modern computer does billions of math operations per second

#

If you calculate these once per turn, I wouldn't worry about it

#

Once per frame would be a different story

rapid flume
#

Yo guys I am working with a enum(this is the code)

    {
        //Mode - Sprinting
        if (isGrounded && Input.GetKey(sprintKey))
        {
            state = MovementState.sprinting;
            moveSpeed = sprintSpeed;
        }

        //Move - Walking
        else if (isGrounded && ) 
        {
            state = MovementState.walking;
            moveSpeed = walkSpeed;
        }

        //Mode - Idle
        else if (isGrounded)
        {
            state = MovementState.idle;
            moveSpeed = walkSpeed;
        }

        //Mode - Air
        else
        {
            state = MovementState.air;
        }
    }``` to update my movement state, how can I check for walking?
severe grove
devout hare
#

Whatever is the most suitable data type, performance is not a priority here

severe grove
#

Awesome

real talon
rapid flume
mystic terrace
#
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            print("Esacpe key was pressed");

        ```} 
how can I make this code function for the leaderboard as it only prints it to console.
severe grove
#

Making it a switch would clean it up too.

quartz stratus
rapid flume
real talon
#

The question is rather vague

#

Anyhow:
First you check input at all, if no input then idle.
If input and sprint, then sprint,
If input, then walk,
Else falling

rapid flume
rapid flume
#

already

quartz stratus
#

Okay, this is good context to provide with questions. We canโ€™t assume we know what โ€œwalkingโ€ means for your project.

#

Sounds like a want to check if you have any WASD input at all

rapid flume
quartz stratus
#

Okay so your conditional expands. Any WASD input AND not sprinting.

rapid flume
quartz stratus
quartz stratus
#

But yes along those lines

real talon
#

This way you can still press sprint without WASD

quartz stratus
#

Check out Mathf.Abs

rapid flume
rapid flume
real talon
#

It is working, this is just not the implementation he ment

quartz stratus
#

โ€œNot workingโ€ is a nonstarter for getting to the bottom of an issue with code. What is happening now and what are you expecting to happen?

rapid flume
real talon
#

There is no need for vc, the code speaks for itself why it does not work.

#

I gave you pseudo code how you could implement it

quartz stratus
stray sleet
devout hare
#
gempos = Random.Range(0, 1);

^ this is always 0

hollow garden
#

yep, Random.Range(int, int) is min inclusive, max exclusive meaning if you were to do Random.Range(0, 10) it would go from 0 to 9 instead of 0 to 10 and so on

#

so Random.Range(0, 1) is 0 to 0 which is just always 0

stray sleet
#

ty btw

hollow garden
#

ye

#

it's like that because it's most common use case is to pick a random array element/index

#

so you can do Random.Range(0, array.Length) instead of Random.Range(0, array.Length - 1)

hot gale
#

anyone know how I can fix my NavMechAgents becoming stuck on one another?

real talon
#

Read up on Local Avoidance

hot gale
#

Yeah I have. Nothing is working.

#

Changing the object priority is the only solution that works, and even then the plan is to have more ants than the Priority system would allow (0-99)

robust drift
#

I'm currently creating a game where I've got a data class with serialized values that I use to read and write to a binary file as my method of saving and loading game.

The game is going to require a sort of list of various events/flags that will happen throughout the game, and I need to store a list of some sort of which events have happened or not into the save file. So each event needs an ID and a bool. I'm currently thinking of a good and organized way to store this data, but I'm having a hard time picking one. I have some ideas, but they all seem to have some massive drawbacks. Does anyone have any good design patterns or general ideas for achieving something like this? Anything goes as long as it's manageable, scalable and the data is serializable.

buoyant vine
#

what does interface segregation help me whne i combine then afterwards anyway eg i got that for example

  public interface IEffect : IFieldAdder, ICallBackReceiver
  {
    public bool FitsRequirement(Field field);
    public bool FitsCondition();
  }
signal osprey
#

I am trying to make a game of squash in unity, and the way I want hitting the ball to work is as follows:
When mouse1/fire etc. is clicked, the racket animation is played, but the racket itself has no colliders. instead, an invisible "sphere" (this is just how i am imagining it, i'm not sure if there would be an equivalent for unity) expands outward from the centre of the racket. if the ball is at any point of this sphere while it exists, it will inherit the direction of the point of the sphere that it touches.

Is there any way to simulate something like this in unity? will elaborate if needed

real talon
signal osprey
#

this looks pretty promising actually, thanks for finding this! although the link you posted says this at the top

real talon
#

Read a bit further ๐Ÿ˜›

signal osprey
#

is it still worth using or should i use getcontacts?

real talon
#

The alternatives are there, should still be the same

signal osprey
#

i see

#

is the usage the same but i just use the other version of it?

real talon
#

Should be the same, just different implementation

#

Contact point still has a normal

#

So something like collision.GetContact(0).normal and draw your ray there

signal osprey
#

i'm having trouble getting my head around what exactly this does, as well as how i would go about doing these two things:
how would i spawn contact lines going away from a point
how would i give the ball velocity equal to how far it is from that point + the direction of that line being translated to the direction the ball moves

real talon
#

It draws a line from the contact point to the normal, is that the part?

signal osprey
#

i'm not sure exactly what it's doing, e.g i've placed the code in the pic on my player controller, but the "drawray" isn't helping me out much

#

where is the normal? above the player character? or is it the normal to the contact point?

real talon
#

Do you know what a normal is?

signal osprey
#

90 deg to the line or whatever ?

real talon
#

In the geometry of computer graphics, a vertex normal at a vertex of a polyhedron is a directional vector associated with a vertex, intended as a replacement to the true geometric normal of the surface. Commonly, it is computed as the normalized average of the surface normals of the faces that contain that vertex. The average can be weighted for...

signal osprey
#

so the contact ray is just a line perpendicular to where the contact is happening?

real talon
#

It's a point of the vertex of the model that points outward.

#

Your renderer uses this to see which faces it needs to render

#

So a vertex has a normal, but a face (the triangles) also have a normal

#

Understand that part?

signal osprey
#

ok, makes sense

real talon
#

So your contact point has a normal, those are the red lines in this example

#

When you collide you know which vertex here has a collision, or multiple in some cases

#

So your piece of code will probably show those normal lines for 1 frame if you don't use pause in your code

signal osprey
#

ok, i get what it's doing now and i think i have an idea for why you chose this, so here's my next question

if i made a sphere appear, and the ball was on the inside of the sphere, would it still have a contact point?

#

essentially i want it so that when the player swings the racket, the "sphere" appears, and if the ball is at the edge of the sphere, it has lower velocity, but the closer to the centre of the sphere it is, the higher the velocity. is there a way to model that?

#

would i have to spawn a new sphere frame by frame with different sizes to get this effect? or spawn multiple spheres?

real talon
real talon
signal osprey
#

yes!

#

ideally the normal/direction the ball goes in has a different magnitude depending on where inside the sphere the ball is upon spawning

real talon
#

My question would be, why the sphere?

signal osprey
#

i feel like it's a decent way to model essentially how the racket in wii sports tennis works

#

so depending where the ball goes would depend on both your timing and placement, and not necessarily how the ball interacts with the collision of the racket (i felt like using the racket as an actual collider wouldnt be best for this)

real talon
#

Hmm, well yeah you could do it that way, but I think that might cause some problems. I do not see the benefit of the sphere to be honest. You can just use the racket normals which are nice and flat instead of the sphere, where you hit it on the edge of the racket your normals would be facing sideways from your racket. But I might be misunderstanding what you mean here

#

You can also calculate the distance from the middle of your racket to the impact points

signal osprey
#

no, it seems like you've understood it correctly, cuz that's essentially what i would want to happen

real talon
#

So middle means lots of velocity and edge means low velocity

#

Just calculate from that center to the impact point

#

Anyhow, the specifics are up to you ๐Ÿ™‚

#

You can do it both ways, you can also count the distance from the middle of the sphere and shoot of from his normal

signal osprey
#

well, thank you very much :D seems like this is exactly what i need, now i just need to figure out how to use it

real talon
#

My pseudocode would be for the sphere-variant:
Ball hits Racket
OnCollision Racket asks Sphere to calculate impact normals and distance from center
Racket manipulates Ball velocity and rotation

And the sphere is a child object of your racket, always on, trigger Collider
That's how I would do it

signal osprey
#

that's super helpful, thank you. also as just an added clarification (so you dont think im totally crazy), the sphere is meant to be spawned (or at least activated) when the player presses the "hit" button, not on collision with the racket

real talon
#

No problem, good luck ๐Ÿ‘

ancient talon
#

Does Unity offers JWT package to encode and decode JWT?

devout hare
#

I don't think there's any common surface there that they would need to

tribal helm
#

Hey guys, i have been struggling to figure out my issue with mesh deformation on collision for hours now and I don't get it. I have two rigid body spheres dropping on cars, i move each vertex on the cars in the direction of the collision normal within a certain radius. Looks great on the red car I found on the asset store but the other car that an acquaintance I'm doing a project with just look messed up. I believe this has something to do with that the red car has scale 1 and the black car has lots of different scales on th different parts. But I can't really figure out how to handle this correctly. I would really appreciate if someone with better understanding of how to handle this could help me figure this out.

Here is a link to a minimal project demonstrating the issue:
https://github.com/endasil/car-colision-comparsion

the script in question https://github.com/endasil/car-colision-comparsion/blob/main/Assets/Scripts/ImpulseMeshDeformer.cs

GitHub

Contribute to endasil/car-colision-comparsion development by creating an account on GitHub.

GitHub

Contribute to endasil/car-colision-comparsion development by creating an account on GitHub.

dark oracle
#

Hello guys, How can I rotate(Lerp) my player to have the same rotation as the ground under him and distance? my first thought was raycast, but I didn't know how to approach this.

real talon
#

RayCastHit gives you a normal pointing from the ground, you can use that to rotate your player

silver pendant
#

It is a bit complicated, because there are some specific cases like when you are hovering over a corner, which might not result in the expected behaviour.

real talon
#

Yeah that's fair, the bottom right one is difficult because how does he start rotating at corner there. Maybe it has a raycast in front that he is seeing that it's going to collide with the wall and rotate by itself. The other 3 are easily done with raycasthit normals.

dark oracle
#

I understand how that can be complicated but ill give it a try and see what happens, thank you guys for the pointers

real talon
tribal helm
#

Also the issue that the guy who made the car doesn't know how to make it scale 1,1,1 without remaking the car and he does not have time to do so right now.

#

Sadly I have no idea how to use 3D modeler programs so I can't do it iether.

real talon
#

This is with 5, 5, 5, but the children need to be scale 1, 1, 1

tribal helm
#

Yeah I wish I knew how to do that.

real talon
dark oracle
buoyant vine
real talon
#

Looks cool and a little janky still, but the premise is there ๐Ÿ˜›

buoyant vine
#

still just a showcase ... which belongs to works in progress