#💻┃code-beginner

1 messages · Page 232 of 1

whole idol
#

Oh.. good (way)point ! ( pun intented )

polar acorn
#

But you don't actually know what piece is so log the values of it

#

Stop assuming

#

check

queen adder
#

i know vim is good and all but i REAAALLY need that code parsing to tell me what errors i have

#

hence why i stopped using code

summer stump
noble forum
queen adder
#

oh wow pretty based text editor tbh

#

see though vs code's syntax error parsing is broken when you connect it to unity

#

some people here actually told me i had to make the switch or else they would deny me help

#

since they didnt want to help me every 3 seconds about something i couldve easily fixed with the error parsing fixed

summer stump
#

Huh, must be a linux thing? Because it definitely has it for me

#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

summer stump
#

Make sure this has been followed 🤷‍♂️

slender nymph
summer stump
#

👆 and that goes for rider, VS, and VSCode.
Any of them can be unconfigured

#

But tbh, vscode usually breaks the most.

queen adder
#

yeah i was advised to not use vscode because it has broken configuration

summer stump
#

Welp, you were given the options.
VS, VSCode, and Rider are the main choices. Check out which work for you.
Good luck!

queen adder
#

i guess i'll see if rider works

uneven oriole
#

I'm having an issue with some variables and the way that theyre showing up. I'm making a game where a ball (tag: CashTrigger) bounces off a platform (also tag: CashTrigger) to give you cash to buy upgrades. I have setup the debug log for detecting collisions and it sais they work just fine. here is the code: https://hastebin.com/share/idutegeboc.csharp I hope someone can help me out

polar acorn
uneven oriole
polar acorn
uneven oriole
uneven oriole
polar acorn
#

The code and the result

uneven oriole
#

this is the code:

private void OnCollisionEnter2D(Collision2D collision)
{
    // Check if both colliding objects have the tag "CashTrigger"
    if (gameObject.CompareTag("CashTrigger") && collision.gameObject.CompareTag("CashTrigger"))
    {
        Debug.Log("CashPerBounce = " + CashPerBounce);
        // Increase CashAmount by CashPerBounce whenever a collision occurs
        CashAmount += CashPerBounce;
        Debug.Log("Collision detected!");

        // Update the text component with the new CashAmount
        UpdateText();

        // Convert CashAmount to a string and update the text component
        text.text = CashAmount.ToString();
    }
}
#

CashPerBounce = 10

uneven oriole
polar acorn
#

That'll give you a lot more information

uneven oriole
#

ill test it

nocturne wedge
#

Im looking for a good free C# course, does anyone have any suggestions ?

uneven oriole
#

yea so now im getting this: Collision between Platform and Circle(Clone), CashAmount is 20, per bounce is 10

polar acorn
uneven oriole
#

yes CashAmount goes up

polar acorn
uneven oriole
#

that just stays on 0

#

but thats fine i guess

polar acorn
#

and that you're not setting it to 0 somewhere else

uneven oriole
polar acorn
uneven oriole
#

thank u very much

sly wasp
#

Hi I'm using face.material.SetTextureOffset
This works great for an instance, but how would I get the second material of the face instead of the first one? The face is a renderer object

slender nymph
arctic ibex
#

So, about that second bit, what do you mean a physically compatible way?

#

Nvm sorry i figgured it out

quick kelp
#

making text printing script was following along with a tut cause im good at coding ui yet.
the last half of the code was cut off and im pretty much trying to fill in the blanks

slender nymph
eternal falconBOT
whole idol
#

Do you have to set up and configure Unity and Vsc everytime ? Because I did configure it but it gets undone again everytime somehow

summer stump
swift crag
#

what gets "undone"?

sly wasp
#

I'm using face.material.SetTextureOffset
This works great for an instance, how would I make the face."material" part a reference to something like public Material myMaterial ?

swift crag
#

what is face?

sly wasp
#

Face is a renderer object
Forgot to mention that

swift crag
#

The material property of a Renderer creates an instance of the material that's unique to the renderer

#

sharedMaterial doesn't do this

#

Note that, if the material is an asset, you'll be modifying the asset

#

which creates annoying version control churn and means you're messing with project files every time you run the game

#

What you can do is assign myMaterial to all of the renderers that you want that material to be used by

sly wasp
#

So how would I target which material to make an instance of?

swift crag
#

here's how I'd do it:

#
[SerializeField] List<Renderer> renderers;
[SerializeField] Material templateMaterial;
[SerializeField] Material instanceMaterial;

void Awake() {
  instanceMaterial = Instantiate(templateMaterial);

  foreach (var renderer in renderers)
    renderer.material = instanceMaterial;
}

void OnDestroy() {
  Destroy(instanceMaterial);
}
#

then mess with instanceMaterial

sly wasp
#

Ohh ok

#

I’ll try that

swift crag
#

One thing I'm now less sure about is whether assigning to material will wind up creating new instances of the material

#

If changing instanceMaterial doesn't do anything to the renderers, then you probably just need to assign to sharedMaterial instead of material

#

This function automatically instantiates the materials and makes them unique to this renderer. It is your responsibility to destroy the materials when the game object is being destroyed.

#

oops

#

i've been very bad about that

vale karma
#

hello my noble tutors

sly wasp
#

huh

vale karma
#

if i wanted to paste multiple scripts on one link is there a better way than copy pasting every script?

#

i finished my heirarchical movement state machine and wanted some feedback on if it could be optimized any better

sly wasp
#

I think it was a mistake with the materials

#

I think it was a mistake with the materials

slender nymph
teal viper
vale karma
#

like under eachother, instead of like tabs

slender nymph
#

you can use multiple links or a site that allows multiple tabs

vale karma
#

i can confirm that there is absolutely no need for optimization XD

#

I literally just have movement set up and a full blown state machine error free haha

teal viper
vale karma
#

ill try, its allot tho

slender nymph
#

all as one single paste document though is usually a bad idea because it makes it an absolute pain to read

#

there are plenty of sites that allow you to paste multiple documents in the same link though, i personally use paste.mod.gg

vale karma
#

ooo i like this one

#

thats a nice site, ill use that now, i like the tab feature

teal viper
#

Somehow it fails to work properly on mobile

queen adder
#

@vale karma You just want optimization tips?

teal viper
#
// Player Movement Script
    private ReadInput input;
    private CameraPOV playerCamera;
    public CapsuleCollider capsule;
    public LayerMask groundedLayers;
    public Collider[] groundedResults = new Collider[10];
    public Rigidbody rb;
    [SerializeField] Transform orientation;
    public Transform groundCheckSphere;

    protected Vector3 direction;
    protected Quaternion playerRotation;

    // Input System Script
    public Vector2 MoveAction { get; private set; }
    public bool IsMovePressed { get; private set; }
    public bool JumpAction { get; private set; }
    public bool CrouchAction { get; private set; }
    public bool SprintAction { get; private set; }
    public bool EnableAction { get; private set; }
#

All of this stuff, the state machine itself shouldn't be dealing with or have access to

vale karma
#

Im not sure, i followed iheartgamedev and his stuff, i didnt like how he put all if it in a statemachine script too

#

I had it factored into their own scripts, but to make it more simple to follow i put it all in one

teal viper
#

Bad tutorial 🤷‍♂️

vale karma
#

i agree, but its the only "well made" tutorial about it

#

he has 4 tutorials each going over his bandaids in the last one

teal viper
#

I mean, if it works for you and you don't want to rewrite it, what's the point of asking for feedback?

#

Because looking at it now, it's gonna be a lot of refactoring if you want to make it right.

mystic star
#

does the addressable got abandoned?
trying to chat there but there seems to be no reply

vale karma
#

i still have the original scripts in tact. I will look into refactoring it back to what it was. and no this was helpful. I was seeing it so much i didnt notice the elephant there anymore

teal viper
mystic star
teal viper
#

Ah, well, how is it related to "being abandoned"?

#

It just means that not many people sit in that channel. Anything else is a guess and speculation.

vernal plume
#

im trying out photon based on a tutorial and when i connect and load into a room that puts me onto a scene, all my shadows are super dark, is there a reason for this?

teal viper
vernal plume
teal viper
#

Then share the code

mystic star
teal viper
vale karma
#

i did just run into an issue trying to make the player collider hieght get divided by 2 when he crouches, I got it working but if you jump and crouch it now moves the collider down permanently

teal viper
teal viper
# mystic star hmm okay thanks anyway

The last few questions in the addressables channel are very specific and unless someone was dealing with a similar issue recently, they probably wouldn't get a reply. Your best bet is to google and research the topic yourself.

faint sluice
mystic star
unreal imp
#

Guys, how do I always stop using the ammo and not the clip when the player tries to reload? The ammunition is only spent reloading the clip and the clip is only spent shooting, here is an example of the error``` private void Update()
{
if (gameObject)
{
if (currentAmmo > 0 && currentClipAmmo <= 0)
{
StartCoroutine(Reload());
}
if (currentAmmo > 0 && gunAnimator.GetBool("OutOfAmmo"))
{
StartCoroutine(UnFreezeAnim());
}
if (currentClipAmmo > 0 && gunAnimator.GetBool("OutOfAmmo"))
{
gunAnimator.SetBool("OutOfAmmo", false);
}
if (Input.GetMouseButtonDown(0) && currentClipAmmo > 0 && !isCooldown && !gunAnimator.GetBool("OutOfAmmo"))
{
StartCoroutine(Shoot());
StartCoroutine(BulletCartridgeEffect());
}
if (currentClipAmmo <= 0 && !gunAnimator.GetBool("OutOfAmmo"))
{
// gunAnimator.SetBool("IsReloading", true);
gunAnimator.SetBool("OutOfAmmo", true);
}
if (Input.GetKeyDown(KeyCode.R))
{
StartCoroutine(Reload());
}
}
}
public IEnumerator Reload()
{

    //gunAnimator.SetTrigger("Reloading");
    //isCooldown = true;
    yield return new WaitForSeconds(0.8f);
        int reloadAmount = maxClipAmmo - currentClipAmmo;
        reloadAmount = (currentAmmo - reloadAmount) >= 0 ? reloadAmount : currentAmmo;
        currentClipAmmo += reloadAmount;
        currentAmmo -= reloadAmount;
        ammoText.text = currentAmmo.ToString();
        ammoClipText.text = currentClipAmmo.ToString();
    /*isCooldown = true;
    if (currentClipAmmo == maxClipAmmo)
    {
        isCooldown = false;
    }*/
    //isCooldown = false;
}```
#

the ammo is the small number and the big one the clip

teal viper
mystic star
vale karma
#

im having trouble getting the player to not be able to jump until you let go of the jump key and press it again. atm its just jumping continuously once it is grounded. I tried using WasPressedThisFrame but it shows red underline under it

#

JumpAction is currently read as a button

queen adder
#

Please share code @vale karma

vale karma
#

i keep deleting it lol

queen adder
#

!code

eternal falconBOT
queen adder
#

Don't copy and paste it please

#

Share the entire class as well

vale karma
#

JumpAction.WasPressedThisFrame doesnt work basically. Atm i have public void OnJump(InputAction.CallbackContext context) { JumpAction = context.ReadValueAsButton();

#

any way that i try to add waspressedthisframe gives me an error. I forgot how ive called it before... idk what im doing wrong here

queen adder
#

What function controls jumping?

#

What's the error say

vale karma
#

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

queen adder
#

I need to see the Basestate class again

#

Idk the type of Ctx

cosmic dagger
#

You don't have a parameter variable named that in the method signature . . .

vale karma
#

long story short its apart of the tutorial to refer to the other scripts ig

cosmic dagger
#

That's doesn't make sense . . .

vale karma
#

i half heartedly know what this stuff does haha, i know how to use it but not exactly what each part does

cosmic dagger
#

The code links don't work for me . . .

#

We kinda need to see the variable declaration to understand what type Ctx is . . .

queen adder
#

We need the Basestate and the substate (jump) classss

frigid sequoia
#

Can I... just not use Lists in a Editor tool?

teal viper
cosmic dagger
#

What does the error say? It should explain the problem . . .

frigid sequoia
#

It is in spanish... so if anyone is wondering is something like "non-generic List type cannot be used with arguments of type "

frigid sequoia
cosmic dagger
#

As dlich stated, it looks like you are missing a using statement . . .

#

You're missing the generic using . . .

teal viper
frigid sequoia
teal viper
#

Though, where does the List come from then?

#

I thought they had the visual scripting namespace, since they had List too

cosmic dagger
#

You should be able to click the light bulb on that line for quick fixes . . .

frigid sequoia
#

I though List where just from System.Collections

cosmic dagger
frigid sequoia
#

Ok, it was just missing this for some reason...

cosmic dagger
#

I know, that's what I said. The generic using statement . . .

frigid sequoia
#

I really don't undertand this stuff, doesn't System.Collections already include System.Collection.Generic?

noble forum
cosmic dagger
noble forum
#

so it is what happends with working code

teal viper
frigid sequoia
queen adder
#

They contain different stuff

teal viper
#

To put it simple: to keep things ordered and organized.

frigid sequoia
#

Well okay, thxs

noble forum
#

here i put the codes

#

without debug.log

#
{
    TakePiece(piece);
    Queen.SetActive(true);
    Bishop.SetActive(true);
    Knight.SetActive(true);
    Rook.SetActive(true);
    Debug.Log(piece.occupiedSquare);
    Debug.Log(piece.team);
    if (QueenPromote)
    {
        chessController.CreatePieceAndInitialize(piece.occupiedSquare, piece.team, typeof(Queen));
        QueenPromote = false;
        Bishop.SetActive(false);
        Queen.SetActive(false);
        Rook.SetActive(false);
        Knight.SetActive(false);
    }
    else if (RookPromote)
    {
        chessController.CreatePieceAndInitialize(piece.occupiedSquare, piece.team, typeof(Rook));
        RookPromote = false;
        Bishop.SetActive(false);
        Queen.SetActive(false);
        Rook.SetActive(false);
        Knight.SetActive(false);
    }
    else if (BishopPromote)
    {
        chessController.CreatePieceAndInitialize(piece.occupiedSquare, piece.team, typeof(Bishop));
        BishopPromote = false;
        Bishop.SetActive(false);
        Queen.SetActive(false);
        Rook.SetActive(false);
        Knight.SetActive(false);
    }
    else if (KnightPromote)
    {
        chessController.CreatePieceAndInitialize(piece.occupiedSquare, piece.team, typeof(Knight));
        KnightPromote = false;
        Bishop.SetActive(false);
        Queen.SetActive(false);
        Rook.SetActive(false);
        Knight.SetActive(false);
    }
    Debug.Log(piece.occupiedSquare);
    Debug.Log(piece.team);
}``` i have this function currently
#

Queen, bishop, knight and rook at start are buttons

#

this code doesnt work, it doesnt read the position

#

yet this one works public void PromotePiece(Piece piece) { TakePiece(piece); chessController.CreatePieceAndInitialize(piece.occupiedSquare, piece.team, typeof(Queen)); }

frigid sequoia
#

Well shit, why is the List not appearing in the inspector now? xd

noble forum
vale karma
#

okay i got to where i can use WasPressedThisFrame, but i think im wrong about what its used for. It makes my character jump indefinitely after pressing it once, not just when i press the key down

frigid sequoia
teal viper
noble forum
frigid sequoia
frigid sequoia
teal viper
frigid sequoia
#

It doesn't seem to work with arrays anyways though

teal viper
frigid sequoia
#

I guess I will have to create several mat parameters and pass make them into a List later

#

Which, is kinda weird but ok

teal viper
#

You could get them from a scriptable object or something.

#

Or load with resources or asset database.

frigid sequoia
#

I think I could. But all this is meant to do is to let me push a button to call all this and setup all the components of the objects automatically to save them as a prefab without the need of having to it manually for each manually and not having to assing it on start. For all I know scripteable objetcs are more meant to be for runtime stuff?

#

Read about them, but never used one yet

teal viper
#

They're just a way to have an instance of an object as an asset.

frigid sequoia
oblique lotus
#

ummmm can someone explain to me why its not printing in order...

#

it justs goes out of order starting index 2...

#

and fixes itself after index 5

teal viper
#

You can define all the references needed in that SO. Not just the list.

frigid sequoia
teal viper
frigid sequoia
teal viper
oblique lotus
frigid sequoia
teal viper
eternal falconBOT
oblique lotus
arctic ibex
#

quick question, is there a way to disable/enable the sprite renderer of an objects child without directly referenceing the child object? (Just straight up disabling the whole gameobject is also fine, because it only has a spriterenderer component)

dark laurel
#

in code? or in the editor

arctic ibex
#

code

dark laurel
#

do you already have a reference to it?

arctic ibex
#

I have a reference to the parent

arctic ibex
dark laurel
#

you'll have to iterate the children, find the sprite renderer, then setActive(false) it

dark laurel
#

yes, if you set the parent inactive, all of its children are inactive

dark laurel
#

iterate = "loop over"

teal viper
dark laurel
#
foreach (Person p in discord.AllPeople) p.Ping(); // this is what @channel would do
#

that's called iterating

arctic ibex
#

What does it do?

#

oh wait nevermind I think I get it

#

It's basically saying "for everything in this set, do this once" right?

queen adder
#

Right

#

Foreach thing in this collection of data do something

hot wave
#

I am trying unity 3d for the first time UnityChanThink but dont know how to put a character (moving camera for now) and platform

eternal falconBOT
#

:teacher: Unity Learn ↗

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

frigid sequoia
#

I am noticing that even though when using the editor tool to assign the components they do assign correctly, once I enter play mode they lose the reference for some reason, even though I am pretty sure nothing is messing with those parameters at all. It does work eventually, but most of the time is just doesn't

#

Any idea why this could be?

north kiln
frigid sequoia
#

So... it is not meant to work unless I specifically tell it too?

#

Cause it has indeed persisted like 1/10 times for some reason

#

Without me specifying anything

frigid sequoia
hot wave
#

how do I add planes that looks like it is tiled?

#

for placeholders

#

like this

pearl lodge
#

Right when you enter your loop, try to print out moves[i].base.name to the terminal.

timber tide
#

some of the unity templates come with some gridbox textures too

hot wave
#

how do I tile/repeat the image, the options doesnt have the tile, I am confused

#

Is it a different unity version?

rocky canyon
#

its in the material

hot wave
#

this is the material

rocky canyon
#

u have debug mode turned on

#

turn that off

#

or wait.. why is ur so different?

#

create a new material and use the textures from the pack

hot wave
#

im so confused UnityChanSorry

rocky canyon
#

can u try creating a new material yourself..

hot wave
#

okok, I will try

rocky canyon
#

right click the project window, create new material

hot wave
#

ah wait, it is in debug mode UnityChanOkay

rocky canyon
#

and then you can click next to Base.. and that will let u pick one of those grids from that pack as the texture

#

i knew it!

#

lol

hot wave
#

I was so confused xD

rocky canyon
#

me too b/c when u click the three dots on the material inspector u cant turn off debug from there

#

u have to do it on some other component first

#

😅

hot wave
#

thank you spawn UnityChanCelebrate

rocky canyon
#

NORMAL keep it NORMAL

#

lol, why u have it on debug mode anyway?

hot wave
#

I was checking gravity

rocky canyon
#

ohh cool cool 👍 carry on

#

but yea, debug mode exposes alot of new info.. but it also hides abunch of stuff

hot wave
#

why does my screen get seams/ screen tearing when looking at tiles? (might not be just tiles)

#

can it be fixed?

timber tide
#

adjust your near clipping on the scene camera

hot wave
#

what is the comfortable clipping distance?

#

it is 0.3 atm

#

I tried 1, I think it looks better

#

I still see some tears, but is it only inside the editor?

teal viper
queen adder
#

sooo I'm a beginner UnityChanThumbsUp

hot wave
#

screenshot cant get the seams

queen adder
hot wave
#

but it looks like this from what I see (edited in paint)

teal viper
hot wave
#

I will try, but I only notice the seaming when moving

north kiln
hot wave
#

ah, where can I find vsync?

north kiln
#

I would have to google the documentation for you

#

and I think you can do that yourself

teal viper
#

If it's in the scene view, then the scene view camera settings.

#

Go over the unity ui in the manual

hot wave
#

ah I found it UnityChanOkay

#

thank you vert, dlich

#

sorry for all the questions, I dont know most of the terms in unity, I hope it isnt too much trouble

teal viper
#

Make sure to go through the !manual and unity !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

teal viper
#

!manual

#

!docs

eternal falconBOT
nimble apex
#

just consider this scope, without other scripts, will both behaves the same?

  public int m_columnNum { get; private set; }

  private void Awake()
  {
    m_columnNum = 8;
  }```

```cs
  public int m_columnNum
  {
    get { return 8; }
    private set { m_columnNum = value; }
  }
#

i simply dont want to make another awake functions

north kiln
#

The bottom one contains an infinite loop

nimble apex
#

ok i will go for first one then

#

ty

north kiln
#

and also makes no sense

pallid nymph
#

you can do public int ColumnNum { get; private set; } = 8; 🤔

languid spire
#

why have a set at all when you always return 8

nimble apex
#

whhhhhat?

#

damn didnt know that tho lol

nimble apex
#

it seems that the

public int ColumnNum { get; private set; } = 8;``` its a good way to go👍
zinc warren
#
    private Texture2D Render3DObjectToTexture(GameObject objPrefab)
    {
        RenderTexture renderTexture = new(256, 256, 24);
        int LayerIndex = LayerMask.NameToLayer("UiItems");

        GameObject cameraObject = new("RenderCamera");
        Camera renderCamera = cameraObject.AddComponent<Camera>();
        renderCamera.targetTexture = renderTexture;
        renderCamera.enabled = false;
        renderCamera.clearFlags = CameraClearFlags.SolidColor;
        renderCamera.backgroundColor = new Color(0, 0, 0, 0);
        renderCamera.cullingMask = 1 << LayerIndex;

        GameObject obj = Instantiate(objPrefab);
        obj.transform.position = renderCamera.transform.position + renderCamera.transform.forward * 4f;
        obj.transform.LookAt(renderCamera.transform);
        obj.layer = LayerIndex;

        renderCamera.Render();

        Texture2D texture = new(renderTexture.width, renderTexture.height, TextureFormat.RGB24, false);
        RenderTexture.active = renderTexture;
        texture.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);
        texture.Apply();

        RenderTexture.active = null;
        Destroy(cameraObject);
        Destroy(obj);

        return texture;
    }

why is the background of the texture black even though i set the camera's clearflag to solid color?

rocky canyon
#

did u chose black as the solid color its using?

zinc warren
north kiln
#

renderCamera.backgroundColor = new Color(0, 0, 0, 0);
Why are you expecting anything but black?

zinc warren
north kiln
#

But what color would the actual background be

zinc warren
north kiln
#

But what do you think the background color would be? What sets the background if not that?

zinc warren
north kiln
#

It clears it with the background color, as it says

zinc warren
north kiln
#

What do you want the background color to be

zinc warren
timber tide
#

why not make it alpha and clip it

north kiln
#

There is no such thing as "Clear"

#

You cannot make transparency so your game is see-through

#

(Without hooking into complex OS-specific functionality)

zinc warren
#

say i want the ui behind the rawimage to be rendered instead of the solidColor

timber tide
#

cant you render the texture, make black as alpha, then render it onto a quad with a transparent shader

#

or alpha clip the black

north kiln
zinc warren
slender cargo
#

So I'm attempting to save an objects data set to json, But for some reason I can't get all the game objects with the tags added to the array?

north kiln
#

also .ConvertTo<String>(); should just be .ToString()

slender cargo
#

Thats what I assumed, how would I go around this?

slender cargo
slender cargo
north kiln
#

Add them to a list, and use that in your loop; or make a method that you call multiple times with each array, making sure to correctly increase the identifier between each one

#

Or, I wonder why you're using tags at all and not just getting all the FwogControllers?

slender cargo
#

so I create a loop that adds them seperately to the array?

slender cargo
north kiln
#

var controllers = FindObjectsOfType<FwogController>();

slender cargo
#

Says I can't convert it to game object

north kiln
#

It's not a GameObject, it's an array of FwogController

slender cargo
#

ohhhh Im being silly ofc

#

I'd still need to create a loop to add them to the array though?

north kiln
#

No

slender cargo
#

Awesome

north kiln
#

You seem to be using 2023, which has FindObjectsByType instead.

slender cargo
#

Also Am I doing the saving of each Frwog's data wrong. Currently Im creating a new json file for each one

#

as surely if I tried to do it to the same file, it would overwrite each other?

#

Then im loading them like:

north kiln
#

Not if you serialized an array or list of the data (which JsonUtility would need inside another object because it's ick)

slender cargo
#

Heres the data... Do I want to reference this GameData from the FrwogController's and store their data here instead?

north kiln
#

I mean you need to serialize a wrapper containing a list of your data if you want to save it all in one file using JsonUtility

[Serializable]
public class GameDataGroup
{
     public List<GameData> Data = new();
}
slender cargo
#

oo

#

So How do I use this? Do I create a new script which just collects all the gamedata into a list?

#

then I can then save that using the json Utility

slender cargo
north kiln
#

You just create a new one of those, Add each of your things to the list, and then serialize that object

slender cargo
#

but how do I add the data to the list sorry?

queen adder
#

!code

eternal falconBOT
queen adder
#

even tho I use it

#

how can I fix this

north kiln
slender cargo
hot wave
#

I tried making character movement in 3d, but I do not like transform as movement because there is no momentum, how do I make one with momentum? UnityChanThink

north kiln
hot wave
queen adder
#

is there something wrong with the script

#

ifs

opal portal
#

Hello there, is there any way to automatically assign via scripts an scriptableobject event to the GameObject with that script?

queen adder
#

no lying I copy pasted from this guys tutorial

#

everythings the same yet my jump doesnt work

#

and layers are set correct

hexed terrace
#

If you're following a tutorial, and it works in theirs but not yours.. you did something wrong or missed something

timber comet
# queen adder

Did you forget to set something in the player inspector?

north kiln
#

everythings the same
@polar acorn get in here

queen adder
#

Ground is set its layer is set

#

groundcheck set

#

let me clarify that

#

it works

#

except for jumping

slender cargo
#

Then I can then save the Data list to json

timber comet
slender cargo
#

But how would I then loop through this data retreiving each data from the list? Would that be going through the index of the list?

slender cargo
north kiln
slender cargo
#

Right, so I would add them in the save script

north kiln
#

Where you had it before was totally fine, you just needed to do what I said, create a new group object—without changing what I wrote to something else, add to its list, and serialize that object

slender cargo
#

Then reference the gamedatagroup for when im saving it

hot wave
north kiln
#

I can't see what datalist is, and also note that you really don't need to declare these variables outside of the function if you're not using them elsewhere

autumn tusk
#

i dont know whats causing this issue

#

i think i messed up a file or class name somewhere

north kiln
north kiln
#

It would be best if you linked to both sets of !code

eternal falconBOT
slender cargo
autumn tusk
#

here we are

#

second script starts from line 791

#

im currently using astar pathfinding project

north kiln
#

Are you seeing this issue in the Unity console?

north kiln
autumn tusk
#

had to lanch my project in safe mode bc of it

slender cargo
autumn tusk
slender cargo
#

and do the index?

rocky canyon
#

its in the Pathfinding namespace

north kiln
rocky canyon
#

do u have that using statement in ur script?

#

or Pathfinding.

slender cargo
north kiln
#

They're both in the code posted, both in the same namespace

slender cargo
#

Or am I being silly

north kiln
#

You need to deserialize the same type you're serializing though, which is now GameDataGroup not GameData

slender cargo
#

ohhhhh

#

I feel silly now

#

How did I miss that 😂

north kiln
# autumn tusk

If both of these scripts are within the Astar project and unmodified by you then it seems like something else has gone awry

autumn tusk
#

i copied one of these scripts directly yesterday

north kiln
#

What do you mean?

autumn tusk
#

i deleted it after it caused significant issues, but

#

broke this getcomponent function

autumn tusk
north kiln
#

What, and moved it somewhere else?

rocky canyon
#

is this a clue?

buoyant knot
#

i think so, batman

autumn tusk
#

renamed it, renamed the class that sorta thing for the copied version

north kiln
#

The script was originally in a location under an assembly definition, if you moved it out from that assembly then the other scripts won't be referencing it

autumn tusk
#

ok i fixed it

#

placed the file back in its original location

#

fixed itself

rocky canyon
#

wouldn't the namespace Pathfinding line be enough? im asking for myself.. not sure..
i thought no matter where the file was located if u specifically wrapped the class in the namespace everything would still be okay

north kiln
#

No

languid spire
slender cargo
#

Thanks for all the help @north kiln. I understand how to use Json Utility much better!

rocky canyon
#

ohh interesting.. okay. TIL

autumn tusk
#

christ, looks like im gonna have to remake my enemy prefab

rocky canyon
#

oof

autumn tusk
#

its fine since i made a base before applying a* pathing to it

#

but thats gonna be annoying

rocky canyon
#

smart thinksmart

#

things like that happen.. but its a learning experience

keen sorrel
#

Would anyone be able to help me with my c# script. Its a script that is supposed to rotate a gameobject to face another gameobject. Here is my function at the moment (Sorry if its a bit messy im very new to game dev)

The current error seems to be that it doesnt properly calculate the foodangle, it staying set and then the ant is rotated at the angle of -food angle. Iv tried a couple different ways of doing this and none seem to be working.

    private void MoveTowardsFood()
    {
        if (currentFood != null)
        {
            float step = antTurnSpeed * Time.deltaTime * 10;
            float foodAngle = Vector2.Angle(this.transform.position, currentFood.transform.position);
            Debug.Log("Food angle = " + foodAngle);
            float comparedAngle = this.transform.rotation.z - foodAngle;
            if (comparedAngle> 10f)
            {
                float targetAngle = Mathf.LerpAngle(this.transform.rotation.z, foodAngle, step);
                Debug.Log("Target angle = " + (targetAngle - this.transform.rotation.z));
                this.transform.rotation =  Quaternion.Euler(0, 0, (this.transform.rotation.z - targetAngle));
            }
            else if (comparedAngle < 10f)
            {
                Debug.Log("Snapping on");
                this.transform.rotation = Quaternion.Euler(0, 0, (this.transform.rotation.z - foodAngle*2));
            }
            //This is just a function that moves it in the direction its facing.
            Move();
        }
    }
autumn tusk
#

ok i really need to start backing things up

#

this a* algorithm is messing up my entire project

#

im gonna push this onto git

#

just causing a lot of bugs

keen sorrel
timber tide
#
  float degreesPerSec = 10; //some value
  float step = degreesPerSec * Time.deltaTime;
  Vector3 direction = target.position - transform.position;
  Quaternion targetRotation = Quaternion.LookRotation(direction, Vector3.up);
  transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, step);```
keen sorrel
# timber tide ```cs float degreesPerSec = 10; //some value float step = degreesPerSec * Ti...

Alright, it now rotates towards the food but then continues to keep rotating past the item and then starts bugging when it begins to bug when the food leaves the collider snaping in then rotating back out and repeats

I did have to change it to only rotate on the Z axis since its a 2d game but i think i did that fine

Here is the code:

    private void MoveTowardsFood()
    {
        if (currentFood != null)
        {
            float step = antTurnSpeed * Time.deltaTime;
            Vector3 direction = currentFood.transform.position - transform.position;
            Quaternion targetRotation = Quaternion.LookRotation(direction);
            transform.rotation = Quaternion.Euler(0, 0, Quaternion.RotateTowards(transform.rotation, targetRotation, step).eulerAngles.z);
            Move();
        }
    }
timber tide
#

the rotation shouldn't overshoot, but if you don't need to rotate once looking at the target then flag it to stop calling your method

keen sorrel
timber tide
#

yeah you could just compare angles

#

probably worth it to figure out why it's overshooting though for when you continuously want to look at something

keen sorrel
# timber tide probably worth it to figure out why it's overshooting though for when you contin...

it seems to be going to an angle which isnt where the food is which i dont really understand why. I'v attached a picture where it kinda just stays on that degrees while its supposed to be tracking the red dot? (made it so instead of getting caught on the collision boundary it would go past it so i could check where it was trying to rotate too or if it was spinning or what)

Do you have any ideas?

timber tide
#

Ah, you're using 2D so your up axis would be z+

keen sorrel
timber tide
#

vector3.Up is +y

keen sorrel
#

Yeah, i would use vector3.Forward?

timber tide
#

not sure if there's a 2D method for this, but try using Vector3(0, 0, 1)

keen sorrel
#

cause forward is z+ and backwards z- right

timber tide
#

Yeah, or vector3.forward

keen sorrel
#

alright

timber tide
keen sorrel
#

i used vector3.backwards

#

and it worked

#

idk why its backwards instead of forwards

queen adder
#

Some day ago, i saw in one of Unity's documentation that they were using Time.deltaTime in FixedUpdate. We know using Time.fixedDeltaTime is giving almost exactly same value as Fixed TimeStep unless there is a heavy calculation. So my question is, which **deltaTime **to use in FixedUpdate?

teal viper
#

they're basically equal

timber tide
#

I was told it will use the time method relative to what loop it's in

steel smelt
#

Which is an abomination

teal viper
#

No, it makes total sense

queen adder
rocky canyon
queen adder
rocky canyon
#

yup

steel smelt
#

Ah

oblique ginkgo
steel smelt
#

I think there's a misunderstanding @teal viper

You were talking about the fixedDeltaTime being the same value as* the fixed timestep?

rocky canyon
#

since fixed timestep is fixed, it'll always be the same.. (its the time that has transpired since the last fixed update)

steel smelt
#

The abomination I'm talking about is Time.deltaTime returning different values depending on whether it's called during the update or the physics step

frosty hound
rocky canyon
#

how is it an abomination?

oblique ginkgo
#

Its not like it detects where its being called and returns a different value, its just a side effect of the physics simulation being called at a constant interval

rocky canyon
#

^ basically just technicallities

steel smelt
#

Okay, fair.

Because the logic is not visible, and because there is an explicit Time.fixedDeltaTime property, it is prone to misleading the users

#

There is no use in having the Time.deltaTime property handle that logic because Time.fixedDeltaTime exists. My understanding is that they've added this internal handling to simplify the engine for beginners

gaunt ice
#

probably the calculation of dt is current time of this call- that of previous call so it returns fixeddt when you call it in fixed update

#

The interval in seconds from the last frame to the current one

north merlin
#

I'm feeling a bit lazy so I want to know an easier way to write this expression
if (int a == int b || int a == int c)
looking for something easy like
if (int a == int b : int c : int d)

acoustic crow
#

how i can download my game from cloud?

gaunt ice
languid spire
oblique ginkgo
gaunt ice
#

btw if you need to check it against lots of int, use hashset

north merlin
#

What's a hashset

oblique ginkgo
languid spire
#

neither would his previous line and that is what I meant

rocky canyon
#

he's asking if theres something similar where he doesnt have to do each comparison individually

silk night
rocky canyon
#

but nah.. not that i know of.. maybe could write ur own method to do something as such

acoustic crow
burnt vapor
oblique ginkgo
oblique ginkgo
silk night
burnt vapor
gaunt ice
#

oh, first time to know that

tired junco
#

hey! currently im working on a game where the player should overcame various obstacles one of them should be a canon that knows the target position and the distance between the canon and the target with these parameters the canon should align itself so that the projectile hits the player no matter what distance (image) how would you implement that or do you have any ressources you would recommend?

burnt vapor
oblique ginkgo
north merlin
rocky canyon
#

must be some new c# syntax sugar

oblique ginkgo
slender cargo
#

Why is my data list count outputting double than there is in the list?

languid spire
oblique ginkgo
silk night
north merlin
burnt vapor
slender cargo
oblique ginkgo
slender cargo
burnt vapor
rocky canyon
# tired junco hey! currently im working on a game where the player should overcame various obs...

i made a system like this last year.. it was trial and error. I would have the cannon angled up by soo many degree's and add a force... (i would adjust it so it would hit at a certain distance) like zeroing in a scope... once it was hitting i moved the cannon back and just adjusted the angle.. (keeping the force the same) and i did that until it hit.. and then i used those two distances and lerped the angle w/ those.. soo like 10 ft there would be a 15degree angle.. and then at 30 feet they'd be a 45 degree angle.. and then any distance between those.. would just find the middleground..

oblique ginkgo
rocky canyon
#

it worked out prettty good after i did all the zeroing stuff.. (OR u can go math heavy and just use a formula for a parabola and do it)

north merlin
#

Let me rewrite it so it's easier to understand.

if(numberA == numberB || numberA == numberC){ Debug.Log("it works.");

burnt vapor
languid spire
oblique ginkgo
tired junco
#

thanks

north merlin
#

Ik I just don't like being misunderstood.

languid spire
#

that is not saving data

slender cargo
north merlin
#

It makes me look dumb.

burnt vapor
#

JSONUtility can deserialize into a List? And here I thought it was too basic for that.
Well, doesn't look like a 2d array so nevermind.

oblique ginkgo
#

okay can we have a look at your json file
go to Go to C:\Users\username\AppData\LocalLow\gamecompanyname/FrwogData.json

#

and paste the contents somewhere.

teal viper
languid spire
#

he's deserializing multiple times and not clearing the List first

slender cargo
north merlin
oblique ginkgo
slender cargo
oblique ginkgo
#

appdata is a hidden folder

slender cargo
#

For some reason file exporer on the pc won't open 😂

oblique ginkgo
#

check hidden items

slender cargo
#

This is great

rocky canyon
#

thats kinda important

slender cargo
#

ayy finally got it to open

#

Well its empty 😂

rocky canyon
#

no json to be found

#

👀

oblique ginkgo
#

did you... save the file?

#

how is it deserializing nothing

slender cargo
#

Its writing to this path

#

any idea where that is?

rocky canyon
#

ur lookin at it

north merlin
#

U can't json parse a vector 3.

slender cargo
#

Thats odd, its definetly saving information

burnt vapor
slender cargo
#

alright

burnt vapor
#

Perhaps it's not this folder at all

north merlin
#

Put in into a list<int>{int, int,int}

rocky canyon
#

thats a possibility

burnt vapor
oblique ginkgo
slender cargo
rocky canyon
#

ya vector3's end up lookin like this

burnt vapor
north merlin
#

Did he add anything before the fwog folder cuz that data path looking a bit too short.

slender cargo
rocky canyon
#

nah, but guy said u cant json a vector3

#

thats not true

burnt vapor
#

That's a transform, not a vector3

slender cargo
rocky canyon
#

nah i use POsition

#

transform.position

#

thats a vector3

oblique ginkgo
#

which are both serialized here.

#

ergo, you can serialize a vector3

rocky canyon
#

facts

burnt vapor
#

Last I checked a Vector3 does not keep track of a rotation

rocky canyon
#

well the first one is a vector3

oblique ginkgo
#

oh yeah, rotation is a quaternion

#

not a vector3

north merlin
#

You will run into bugs because unity doesnt deserialize it well.

rocky canyon
#

the rotation is a quaternion

oblique ginkgo
#

but pos and scale are both vector3s

burnt vapor
#

Right, I was just pointing out the object as a whole was not a Vector3...

oblique ginkgo
slender cargo
#

Should I try writing the json path some place else?

#

for a test?

oblique ginkgo
#

did the guy we were meant to be helping dip
why are we yapping about this

rocky canyon
#

ur right

#

here let me fix that for ya

#

jeeez

oblique ginkgo
burnt vapor
rocky canyon
#

lol

rocky canyon
# slender cargo

debug ur persistentDataPath and see if it is indeed that folder ur lookin at

burnt vapor
slender cargo
oblique ginkgo
#

wait

rocky canyon
#

this method never gets called

#

so how does it write?

slender cargo
oblique ginkgo
rocky canyon
#

why is it faded?

oblique ginkgo
#

its just visual studio being ass

rocky canyon
#

ohhh ok

oblique ginkgo
#

it doesnt detect unity functions

#

wait

rocky canyon
#

🤔

burnt vapor
# slender cargo uhh yeah

Okay, and are you aware this method only exists for the editor and not actually if you were to play a build?

oblique ginkgo
#

holup

#

how does path.combine

#

go from /FrwogData.json

#

to /FrwogData

burnt vapor
#

Can we stop spamming this chat? Send a single message and stop writing a few words

burnt vapor
rocky canyon
burnt vapor
#

... or is it? I might actually be wrong now that I think of it. Sorry

burnt vapor
#

Actually, the method is probably called regardless. Please place a Debug.Log in the code and see if the message is logged on quit

slender cargo
#

But the path here is right?

rocky canyon
burnt vapor
#

Regardless the method should not indicate it's unused. Unity methods are hardcoded to not do that

oblique ginkgo
rocky canyon
#

yea thats what threw me off.. plz debug like fused mentioned

#

for ease of mind

shell sorrel
burnt vapor
oblique ginkgo
rocky canyon
#

mines UN-Faded

shell sorrel
#

differences could be the ide used

slender cargo
rocky canyon
slender cargo
oblique ginkgo
rocky canyon
#

what IDE are u using? im curious

oblique ginkgo
#

Try removing Path.Combine and just using a +

#

Just for now

burnt vapor
languid spire
oblique ginkgo
#

Oh yeah lose the / before you try mine.

rocky canyon
#

ohh yea you dont need the / if ur using Combine

slender cargo
#

I removed the slash and it works now

rocky canyon
#

🍿 im here for this..

rocky canyon
slender cargo
#

I wonder whether it was my college pc file stuff causing the issues?

oblique ginkgo
#

This session has just been comedy
try saving it, post the json thing

shell sorrel
#

whole point of Combine is it does the slashes for you, with the correct ones for said platform

oblique ginkgo
slender cargo
#

anyways lets try fix my original bug

rocky canyon
#

so it was probably trying to save it to ProjectName//Frwog...

#

and wigged out the system

slender cargo
#

It seems to be doubling the count of how much I am saving

oblique ginkgo
#

yeah that wouldnt change
but can you post your json file

rocky canyon
#

where do u call the method that saves it? debug it and see how many show up

slender cargo
#

So it saves the correct amount, but loads double

rocky canyon
#

where do u call the method that loads it? debug it and see how many show up

shell sorrel
#

datalist exists outside of that method

slender cargo
#

Am I using the correct term to see how many data sets is in the json file?

oblique ginkgo
#

which should now show up in the expected folder

shell sorrel
#

might want to clear it first

slender cargo
slender cargo
oblique ginkgo
#

yeah run dataList.Clear(); at the top of your function

slender cargo
#

thanks

#

didn't realise that I had to clear it before writing in it

#

I thought it just overwrite it

rocky canyon
#

i did too..

languid spire
slender cargo
#

Thanks for the help guys!

vast vessel
#

So you know how in the unity event system, you can select a geme object, then choose a function from one of the components on that game object? How do i get something like that on my own scripts? is there a class for it or smth? Im trying to make my own thing that is like the unity even system but also takes in a delay.

oblique ginkgo
#

It's under UnityEngine.Events

vast vessel
#

I just want the dropdown field in the inspector that has all the accessible methods on a gameobject

oblique ginkgo
eager fulcrum
#

does anyone know any discord server for robotics

oblique ginkgo
frigid flume
#

hello, i've recently built my app's apk but the camera is very far away from the content... i don't know how to do it, i don't understand how the main camera is working in the editor, it ain't displaying anything

#

this is what it looks like

keen sorrel
flint rock
#

I am a tiny bit confused.
I have this collision detector:

private void OnCollisionEnter(Collision collision)
{
    GameObject enemyObject = collision.gameObject;
  //  UnitCombat unitStats = enemyObject.GetComponent<UnitCombat>();
    bool disableDamage = false;
    print(gameObject);
}

Why does print(gameObject) return the name of the OTHER object that this is colliding with, as opposed to returning the parent?
When I do print(collision.gameObject) it returns the object that is running this line of code. I'm trying to work out if this is a bug so really I'm just looking for people to validate this as intended functionality.

It confuses me because if I do print(gameObject) outside of OnCollisionEnter it'll print the object that is running the code, whereas if I do it in a OnCollisionEnter it'll print the object that it's colliding with, not the object running the code. It completely inverses it...

frigid flume
frigid flume
oblique ginkgo
flint rock
frigid flume
#

i don't understand

keen sorrel
frigid flume
#

there are images, buttons, text

keen sorrel
keen sorrel
frigid flume
#

yes but only on items like buttons and images

#

not on camera

keen sorrel
frigid flume
#

but how do i do ? ^^

keen sorrel
buoyant knot
#

wait, is your camera a child of your canvas?

flint rock
# keen sorrel So what this does is when it collides with something, it returns information on ...

It's not printing the gameObject the script is on, when I print gameObject it's printing the object it collides with instead of the object the script is on.

Let's say we have an object called "MainObj" and MainOBJ has the script with print (gameObject) in it in the scope of OnCollisionEnter, and it's colliding with a gameObject called "Wall" which has no scripts at all and is completely devoid of anything apart from the components necessary to make it render, and a BoxCollider
Now, when MainObj hits "Wall" you would think MainObj would print its own name, but instead it prints the name of the wall.

The code inside of MainObj?

    private void OnCollisionEnter(Collision collision)
{
print(gameObject.name)
}```
See how there isn't any code for print(collision.gameObject.name) but it's printing out the name of the object it collided with instead of its own?
buoyant knot
#

camera should not be in screen space, so it should not have a recttransform

#

camera should be in world space

buoyant knot
#

UI elements are supposed to be in canvas-space (screen space). Right now, you have it in world space

#

which is very very wrong

frigid flume
#

it is overlay

#

Screen-Space (overlay)

keen sorrel
buoyant knot
#

so your UI elements all have recttransform, and are all children of an object with a canvas component?

frigid flume
buoyant knot
frigid flume
buoyant knot
#

canvas children? is there not one gameobject in the root that has a canvas?

#

one main canvas for everything

frigid flume
buoyant knot
#

ok, so only Canvas has a canvas component

#

that is right

flint rock
buoyant knot
#

check canvas settings

frigid flume
buoyant knot
#

idk how this works exactly in 3D, since I only do this in 2D

#

but the canvas should display normally regardless of wtf is going on with the camera

#

it is a canvas. it exists in screen space, not in world space.

#

it effectively plasters the canvas onto your screen with the camera view behind it

frigid flume
#

yes i can move the camera in the scene and the game window still displays it perfectly

summer stump
frigid flume
#

sorry i tought this was the wrong channel at first

buoyant knot
#

so the menu isn’t a problem right now, just the camera positioning?

frigid flume
#

and someone responded before i deleted it ^^'

buoyant knot
#

which means the solution is to move the camera or change the camera settings

summer stump
frigid flume
frigid flume
buoyant knot
#

is there anything in the scene to look at? because it looks like no

spring quail
#

Hey ! I'm trying to make my code cleaner by making some headers, but for some reason, the one you can see on the screenshot is not showing in the inspector, any ideas ?

buoyant knot
#

your controller isn’t serialized

buoyant knot
#

Header is an attribute that targets the next thing

buoyant knot
frigid flume
#

so camera is useless right ?

buoyant knot
#

camera lives in world space, and sees things in world space

#

if there is nothing in worldspace to see, it will not show anything

frigid flume
#

so why when i launch the game on my phone i see the UI but very very small ?

buoyant knot
frigid flume
#

it should be completely on my screen

rocky canyon
#

the UI should be Overlayed..

#

maybe ur resolution/dimensions aren't correct on the canvas

buoyant knot
#

canvas should autoscale to your screen resolution

#

this is not a default setting for some terrible reason

frigid flume
#

i can't even edit them

fair thorn
#

Is their any github project out their with basic Android platformer controls

rocky canyon
buoyant knot
polar acorn
rocky canyon
#

its controlled here in teh canvas scaler component

spring quail
frigid flume
buoyant knot
rocky canyon
# frigid flume

the canvas component above.. is it set to screen space / overlay/

frigid flume
#

it is

rocky canyon
#

ohh see here

#

thats why its small..

frigid flume
#

seems fine

rocky canyon
#

ur elements arent even fullsize

#

they should fill up that entire square

buoyant knot
#

public float walkSpeed;
should be
[field: SerializeField] public float walkSpeed {get; private set; }
so you can’t randomly edit it from other classes.

rocky canyon
#

thats ur screen size

buoyant knot
#

i do warn since you are now serializing a different variable, you need to use [FormerlySerializedAs…] to keep the old variables

frigid flume
rocky canyon
#

u can resize the scroll object to Stretch

#

all the objects that are children should fit

buoyant knot
rocky canyon
#

this one on the bottom right.. will make it all fit within ur canvas

quick summit
#

hello

frigid flume
spring quail
rocky canyon
hot wave
#

is rigid body better than character controller? UnityChanThink

frigid flume
#

neither works

rocky canyon
hot wave
#

hmm, it is difficult, they both have nice features

rocky canyon
#

as a beginner i would suggest CC

spring quail
#

Same, rigidbody can become a mess at first

rocky canyon
#

CC comes with ground checks, can walk up stairs, and can work with Trigger Colliders

#

Rigidbody comes with gravity, but thats it

#

ur coding the rest urself

buoyant knot
# spring quail Oh I see, a part of my code was like this at first because I followed a tutorial...

public => anything can read or write. We really do not want just anything to write because that introduces a lot of problems.

public int x {get; private set; }
this defines an autoproperty for x that allows anything to read x, but only the inspector or class that owns it can write to x.
That works, but is not serialized.

[field:SerializedField] public int x {get; private set; }
x is a property with an automatically defined backing field, and we want to serialize the backing field. So we can’t just use [SerializeField]. We need to use [field:SerializeField] for that attribute to specifically target the backing field, which we can serialize.

#

make sense?

frigid flume
#

thanks for your help, i'll try later

buoyant knot
#

in general, public fields are like public toilets. Everything is fine until someone shits in it.

hot wave
#

I do feel like CC lacks a lot of things compared to rigid, would like to try rigid body as well UnityChanThink

spring quail
buoyant knot
#

dynamic rigidbody does a lot of things automatically that are annoying af.

kinematic rb struggles to handle collisions unless you have a custom kinematic solver.

rocky canyon
buoyant knot
hot wave
#

is combined? UnityChanOkay

buoyant knot
rocky canyon
#

ya, this controller is a Kinematic controller..

buoyant knot
#

one which is not shit for moving a player

rocky canyon
#

its the best of the rigidbody world

buoyant knot
#

my custom physics engine is inspired by KCC

hot wave
#

can I use KCC, if ok

buoyant knot
#

yeah, it’s free

spring quail
buoyant knot
#

one last random thing that might help you:
in visual studio, press ///, and it will autocomplete ///<summary> </summary>

#

write a comment between the two summary blocks. it is now a comment tied to the tooltip of the next class/struct/field/property/method

#

so if you mouseover the variable/method/class…, the tooltip will display that information

rocky canyon
#

i love summaries

#

use em all the time now.. so i get less confused when typin my functions

spring quail
#

Oh nice to know! thanks

buoyant knot
#

Example:
///<summary>This is the height of a jump. </summary>
[field:SerializeField] public float jumpHeight {get; private set;}

tender stag
#

the first one has a 20 in the z and it works because it sets the camera holder rotation to 20 on the z axis
cameraHolder.transform.localRotation = Quaternion.Euler(xRotation, yRotation, 20);

#

but here i use cameraPosition.localRotation.z and it barely sets the rotation
cameraHolder.transform.localRotation = Quaternion.Euler(xRotation, yRotation, cameraPosition.localRotation.z);

#

lets say i rotate the cameraPosition like 20 it only rotates the cameraHolder 0.1

polar acorn
wintry quarry
tender stag
#

how would i do it?

polar acorn
#

It's a normalized four-dimensional vector

tender stag
#

like this?

polar acorn
#

Basically never deal with individual components of Quaternions unless you're a savant at complex number theory

wintry quarry
# tender stag how would i do it?

What are you trying to do? generally try to avoid euler angles. You can't generally isolate a single euler angle, they come as a set of three and are not independent of each other.

tender stag
wintry quarry
buoyant knot
#

localRotation.z is like looking at one of the parts of a complex number, which is not the Z angle you want

#

changing between euler angle and quaternions is not a one-to-one transformation

keen sorrel
buoyant knot
#

the best way to handle quaternions is to never ever touch/read/write the internal values of a quaternion

polar acorn
keen sorrel
buoyant knot
#

you want to almost exclusively create new quaternions via the various quaternion methods, and multiply quaternions together (which is like applying a rotation to a rotation)

polar acorn
buoyant knot
#

particles are really bad at getting turned off individually by code

polar acorn
#

Assuming your script is on the thing getting hit by a particle, and not on the particle system itself looking for collisions with other objects

keen sorrel
keen sorrel
polar acorn
#

As the documentation says, it's of type GameObject because it behaves differently depending on whether this is on the particle system or the thing getting hit by the particles

keen sorrel
#

oh i see

buoyant knot
#

particles are really bad at being modified or read by the rest of your game

polar acorn
#

Yeah they're not really meant to ever be taken individually

buoyant knot
#

also, game behaviour should not be affected by graphics, ever

#

game logic changes world state, and you then render a graphical representation

#

i was working with a guy who made all the game logic for his game depend on animations. When the animation hit a certain thing, new things would happen etc… Very buggy

rocky canyon
#

thats a bit better tho.. atleast animation events are a thing.. not sure theres a particle event 🙂

#

possibly in VFX graph

#

i could see that..

buoyant knot
#

imagine if you skip to the next turn, and different gamelogic happens because the animations aren’t done

tender stag
#

why is this happening when i lean right if(Input.GetKey(KeyCode.E)) ```cs
float angle = isCrouching ? crouchLeanAngle : isCrawling ? crawlLeanAngle : walkLeanAngle;
float distance = isCrouching ? crouchLeanDistance : isCrawling ? crawlLeanDistance : walkLeanDistance;

if(canLean)
{
if(Input.GetKey(KeyCode.E))
{
if(!Input.GetKey(KeyCode.Q))
{
targetLeanAngle = -angle;
targetLeanDistance = distance;
}
}
else if(Input.GetKey(KeyCode.Q))
{
if(!Input.GetKey(KeyCode.E))
{
targetLeanAngle = angle;
targetLeanDistance = -distance;
}
}
else
{
targetLeanAngle = 0;
targetLeanDistance = 0;
}
}
else
{
targetLeanAngle = 0;
targetLeanDistance = 0;
}

float smoothAngle = Mathf.Lerp(cameraPosition.eulerAngles.z, targetLeanAngle, leanDuration * Time.deltaTime);
float smoothDistance = Mathf.Lerp(cameraPosition.localPosition.x, targetLeanDistance, leanDuration * Time.deltaTime);

cameraPosition.eulerAngles = new Vector3(cameraPosition.eulerAngles.x, cameraPosition.eulerAngles.y, smoothAngle);
cameraPosition.localPosition = new Vector3(smoothDistance, cameraPosition.localPosition.y, cameraPosition.localPosition.z);```

#

it only works when i lean left

wintry quarry
#

rule #1 of euler angles is friends don't let friends use euler angles

#

use quaternions and you won't have this issue

timber tide
#

xyz quaternion rotation

wintry quarry
#

Something like Mathf.Lerp with euler angles will lerp from -10 to 370 degrees by doing a full circle because it doesn't realize angles are cyclical and -10 and 370 are only 20 degrees apart

tender stag
#

so im lost

#

what should i do

wintry quarry
#

Use quaternions

thick jetty
#

i am having some issues with getting a unit to walk, been trying to figure it out and watched videos nothing is helping. not quite sure what to do, my next thought was scrap and start over again. but i wanted some input first i created terrain and a unit as a capsul i also created a new layer called ground and i baked a navmesh surface into the terrain so that the unit can walk from my knowledge the code is correct i have double checked it and even re wrote it and that is doing nothing

tender stag
#

so like this?

timber tide
#

technically with quaternions your goal is to rotate in a orderly way forever, so ideally in a fps you stick to x -> y -> z rotations

thick jetty
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class UnitMovment : MonoBehaviour
{
Camera camera;
NavMeshAgent agent;
public LayerMask ground;
// Start is called before the first frame update
void Start()
{
camera = Camera.main;
agent = GetComponent<NavMeshAgent>();
}

// Update is called once per frame
void Update()
{
    if(Input.GetMouseButtonDown(1)) 
    {
        RaycastHit hit;
        Ray ray = camera.ScreenPointToRay(Input.mousePosition);

        if(Physics.Raycast(ray, out hit, Mathf.Infinity, ground)) 
        { 
            agent.SetDestination(hit.point);
        }
    }
}

}

#

that is the code

eternal falconBOT
buoyant knot
#

euler angles are of limitted use unless you are in 2D

timber tide
#

eulers is fine for single dimensional rotations

thick jetty
#

/// using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class UnitMovment : MonoBehaviour
{
Camera camera;
NavMeshAgent agent;
public LayerMask ground;
// Start is called before the first frame update
void Start()
{
camera = Camera.main;
agent = GetComponent<NavMeshAgent>();
}

// Update is called once per frame
void Update()
{
    if(Input.GetMouseButtonDown(1)) 
    {
        RaycastHit hit;
        Ray ray = camera.ScreenPointToRay(Input.mousePosition);

        if(Physics.Raycast(ray, out hit, Mathf.Infinity, ground)) 
        { 
            agent.SetDestination(hit.point);
        }
    }
}

}

timber tide
#

but once you add that second rotation axis does eulers create gimbal

buoyant knot
#

the issues with angles is that they don’t commute

tender stag
#

i've got this but it doesnt work```cs
float smoothAngle = Mathf.Lerp(cameraPosition.localRotation.z, targetLeanAngle, leanDuration * Time.deltaTime);
float smoothDistance = Mathf.Lerp(cameraPosition.localPosition.x, targetLeanDistance, leanDuration * Time.deltaTime);

cameraPosition.localRotation = Quaternion.Euler(cameraPosition.localRotation.x, cameraPosition.localRotation.y, smoothAngle);
cameraPosition.localPosition = new Vector3(smoothDistance, cameraPosition.localPosition.y, cameraPosition.localPosition.z);```

thick jetty
#

""" cs using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class UnitMovment : MonoBehaviour
{
Camera camera;
NavMeshAgent agent;
public LayerMask ground;
// Start is called before the first frame update
void Start()
{
camera = Camera.main;
agent = GetComponent<NavMeshAgent>();
}

// Update is called once per frame
void Update()
{
    if(Input.GetMouseButtonDown(1)) 
    {
        RaycastHit hit;
        Ray ray = camera.ScreenPointToRay(Input.mousePosition);

        if(Physics.Raycast(ray, out hit, Mathf.Infinity, ground)) 
        { 
            agent.SetDestination(hit.point);
        }
    }
}

}

tender stag
thick jetty
#

those instructions are terrible

tender stag
#

and it only rotates like 0.1

eternal falconBOT
polar acorn
buoyant knot
#

you are fucking with the contents of a quaternion

thick jetty
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class UnitMovment : MonoBehaviour
{
Camera camera;
NavMeshAgent agent;
public LayerMask ground;
// Start is called before the first frame update
void Start()
{
camera = Camera.main;
agent = GetComponent<NavMeshAgent>();
}

// Update is called once per frame
void Update()
{
    if(Input.GetMouseButtonDown(1)) 
    {
        RaycastHit hit;
        Ray ray = camera.ScreenPointToRay(Input.mousePosition);

        if(Physics.Raycast(ray, out hit, Mathf.Infinity, ground)) 
        { 
            agent.SetDestination(hit.point);
        }
    }
}

}

eternal falconBOT
buoyant knot
#

if you fuck with a quaternion’s guts, the quaternion fucks with you

thick jetty
#

what is a back quote

timber tide
#

yo can I stop scrolling down every two seconds

buoyant knot
#

guys, stop with the giant code blocks