#💻┃code-beginner

1 messages · Page 538 of 1

swift crag
#

you might just make a list of all valid sentence arrangements

rancid tinsel
#

im starting to think im overengineering it a bit since ill probably have 3 "parts" max to a sentence

swift crag
#

in that case, make an enum for each sentence part

rancid tinsel
#

but ill give it a proper think after resting

rancid tinsel
swift crag
#

why don't you think the blend tree is changing?

swift crag
#

I guess you could just hard-code it in the script, too

rancid tinsel
#

i see what you mean

spiral narwhal
swift crag
swift crag
rancid tinsel
#

that way i can easily identify what kind of "part" it is and just check the order

spiral narwhal
#

The idle tree's x and y never change

swift crag
#

The sliders have nothing to do with the default parameter values

#

(or the current parameter values, if you're in play mode and have an animator selected in the scene)

#

You can ignore them

rancid tinsel
#

aight im off for tonight thank you very much for the help!

swift crag
#

no prob (:

spiral narwhal
swift crag
#

I use SerializeReference quite a bit for making things like "filters" and "scoreres"

spiral narwhal
#

I can record a gif if it helps

swift crag
#

That's probably not helping

spiral narwhal
swift crag
#

Okay, that looks fine

#

Are you not seeing the animations playing at runtime?

#

I did just go and check on a VRChat avatar -- changing the sliders while live-linked to an animator in the scene does, indeed, affect parameter values

#

i was thinking of the behavior when outside of play mode, where the sliders have nothing to do with the actual parameter values

#

(for me, they're often things like "3.06e-10" or "NaN")

spiral narwhal
#

Hm, do I have to expose the parameter somehow? I remember this is kinda the case in the audio mixer

swift crag
#

No, you don't

spiral narwhal
#

Like, how does Unity know these are all the same

swift crag
#

Oh

#

You're talking about the position of each motion on the blend tree

#

The names are coincidentally similar

spiral narwhal
#

Perhaps me naming them "x" and "y" was not very helpful..

#

It basically describes the player's input axis

swift crag
#

This blend tree has four motions in it

#

They're at these positions:

[0, 0]
[1, 0]
[-1, 0]
[0, 1]

#

I randomly picked two parameters from my avatar. I wound up with "Constant/One" and "Voice"

#

unsurprisingly, the first one is always 1

spiral narwhal
#

Ah, for me this is empty

swift crag
#

did you make x and y ints

spiral narwhal
#

How did you get "Constant/One"

swift crag
#

Oh yeah you used integers

#

that's why

#

I glossed over that entirely

#

blend trees use floats

spiral narwhal
#

I made them as parameters of the animator

swift crag
#

Delete them and re-create them as floats

spiral narwhal
#

Ohh

#

No way it's something this dull haha

swift crag
#

I wonder if x and y are just the default names it plunks in there

supple wasp
#

Hi, I don't know if you can help me with this code. This code is supposed to make the YXZ axes appear when an object appears but it doesn't move it with the axes.

swift crag
#

the funny thing is that, under the hood, they're all floats anyway

#

Please use a paste site for large amounts of code

#

!code

eternal falconBOT
supple wasp
#

is that code

spiral narwhal
supple wasp
#

public class GizmoHandler : MonoBehaviour
{
    public enum Axis { X, Y, Z }
    public Axis axis;

    private Plane dragPlane;
    private Vector3 dragStartWorldPos;
    private bool isDragging;

    public void StartDragging(Vector3 hitPoint, Transform parentPiece)
    {
        // Crear el plano de arrastre basado en el eje seleccionado
        switch (axis)
        {
            case Axis.X:
                dragPlane = new Plane(Vector3.up, parentPiece.position);
                break;
            case Axis.Y:
                dragPlane = new Plane(Vector3.right, parentPiece.position);
                break;
            case Axis.Z:
                dragPlane = new Plane(Vector3.forward, parentPiece.position);
                break;
        }

        dragStartWorldPos = hitPoint;
        isDragging = true;
    }

    public void HandleDrag(Vector3 hitPoint, GameObject parentPiece)
    {
        if (!isDragging) return;

        Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
        if (dragPlane.Raycast(ray, out float enter))
        {
            Vector3 dragCurrentWorldPos = ray.GetPoint(enter);
            Vector3 dragDelta = dragCurrentWorldPos - dragStartWorldPos;

            // Mover la pieza y el gizmo
            switch (axis)
            {
                case Axis.X:
                    parentPiece.transform.position += new Vector3(dragDelta.x, 0, 0);
                    break;
                case Axis.Y:
                    parentPiece.transform.position += new Vector3(0, dragDelta.y, 0);
                    break;
                case Axis.Z:
                    parentPiece.transform.position += new Vector3(0, 0, dragDelta.z);
                    break;
            }

            dragStartWorldPos = dragCurrentWorldPos; // Actualizar el punto inicial para el siguiente frame
        }
    }

    public void StopDragging()
    {
        isDragging = false;
    }
}
fleet surge
#

Help triggering a beginner simple collision

supple wasp
#

If you can help me with the code

naive pawn
swift crag
#

This is abused heavily for advanced VRChat nonsense

#

Almost every parameter on my avatar is a float so that it can be used in gigantic direct blend trees, but they're treated as bools by VRChat

naive pawn
#

wait how does that work for ints

#

theyr'e exposed as int32s, right?

#

but float32 doesn't work for higher values of int32

#

float32:max_safe_int is lower than int32:max_value

swift crag
naive pawn
#

in the scripting api

swift crag
#

you mean how you can get an animator parameter as an int?

naive pawn
#

both getting and setting

upper yoke
#

Hey, I made a build of a game and send it to someone and got these errors in Player.log

The referenced script (Eggflation.Manager.MenuManager) on this Behaviour is missing!
The referenced script (Katsis.Manager.OptionManager) on this Behaviour is missing!
The referenced script (Eggflation.Menu.AchievementButton) on this Behaviour is missing!
The referenced script (Eggflation.Menu.AchievementButton) on this Behaviour is missing!
The referenced script (Eggflation.Menu.AchievementButton) on this Behaviour is missing!
The referenced script (Eggflation.Menu.AchievementButton) on this Behaviour is missing!
The referenced script (Eggflation.Menu.AchievementButton) on this Behaviour is missing!
The referenced script (Eggflation.Menu.AchievementButton) on this Behaviour is missing!
The referenced script (Eggflation.Menu.AchievementButton) on this Behaviour is missing!
The referenced script (Eggflation.Menu.AchievementButton) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object 'MenuManager') is missing!
A scripted object (probably Eggflation.Manager.MenuManager?) has a different serialization layout when loading. (Read 32 bytes but expected 92 bytes)
Did you #if UNITY_EDITOR a section of your serialized properties in any of your scripts?
The referenced script on this Behaviour (Game Object 'MenuManager') is missing!
A scripted object (probably Katsis.Manager.OptionManager?) has a different serialization layout when loading. (Read 32 bytes but expected 364 bytes)
Did you #if UNITY_EDITOR a section of your serialized properties in any of your scripts?
The referenced script on this Behaviour (Game Object 'AchievementButton') is missing!

However I can't reproduce these errors on my machine, either inside Unity nor with the build, would anyone know what they could be related to?
(There are some UNITY_EDITOR things but it's related to an external library (Live2D) and I don't really have controls over that)

pliant abyss
#

What are the values inside an empty array element?

queen adder
#

Alright guys I haven't touched Unity in 5 years but I did learn C++, I got a 2D platform, and IDK how to use something like blender, how can I make a little sprite guy with some movement to get a game started?

any programs for making sprites?
how do I access game data like sprites in C#?

teal viper
queen adder
teal viper
mental palm
#
{
    rb.velocity = Vector2.zero;
    position *= speedMult;
    rb.velocity += position;
} ```

i have this impulse script that is supposed to toss a ball towards the mouse position.

```mousePos = Input.mousePosition;
mousePos = Camera.main.ScreenToWorldPoint(mousePos);
position = (mousePos - transform.position);```

all pretty basic stuff, but theres one thing i dont understand, if i put the mouse in a relaively far position above the ball, the ball will be tossed up to about 90% of the way to the mouse... if i put the mouse closer above the ball it will only travel about 30% of the distance to the mouse... shouldnt the relative distance traveled always be the same? since i just calculate a vector?
#

this feels like a mathbook question lol

#

Also if thats just the default, is there a way to make the ball be tossed a fixed relative distance? like always 70 percent of the distance to the mouse?

fleet surge
#

if anyone gets the chance, please look over my "Help triggering a beginner simple collision" thread Awkward_Smile

teal viper
fleet surge
teal viper
#

Oh, that las message was 30 min ago...

fleet surge
#

you answered me and it worked :D I was using wrong cosole.log instead of debug.log

teal viper
#

Ok, at least make it clear that the issue is solved

#

because it felt like you're gaslighting me

fleet surge
#

what xD

#

sorry not my intention

#

how should I better "mark as resolved" future threads instead of closing them?

teal viper
#

Donno. But you could just keep it open and replied that it's solved or something.

fleet surge
#

thanks for helping anyway!

teal viper
#

Anyways, glad that solved it

thorn kiln
#

Watching Brackeys tutorials to learn Unity, obviously they are quite old, so when he's talking about character movement, I hover over the code in VS Studio and it says "Interface into the **Legacy **Input system."

teal viper
thorn kiln
#

Not really, just interesting that it's legacy, you know, because the tutorial is from 6 years ago

teal viper
#

Yeah. Things change fast in tech.

spark sinew
#

hi y'all, very basic question, I need to get the time but with millisecond accuracy to run some loops. How can I access this ?

spark sinew
#

Thanks. Do I need to add some libraries on top like "with something" ?

#

I am not sure how the things with the with field are called

#

sorry the "using"

fleet surge
#

no it's a unity built in thing

spark sinew
#

ok thanks

teal viper
fleet surge
# spark sinew ok thanks

Unless you deleted it, this should be default in all ur scripts im pretty sure, and it includes Time

spark sinew
#

ok thanks

#

thanks, and now for all linear algebra operations like matrix rotation, multiplication, inverse, singular value decomposition etc is there a library that we can use ?

teal viper
#

Depends on what exactly you need and trying to achieve.

#

There's a Mathf class in unity that implements some math operations.

spark sinew
#

thanks! I am trying to estimate a rotation matrix M from data, and I need to do decompose it into U Sigma V (svd) so I can get thet the U*V that I need ( to ensure that the result is a rotation matrix). I will check in Mathf

teal viper
#

But maybe there's a simpler way. Can you not explain what you need it for?

spark sinew
#

right, but I cannot do this here, it is in order to use an external frame of reference (from a Optitrack system), so I need to compare the points generated by that system and the coordinates of the headset so they can agree on a common system of coordinates

#

the issue being that the X and Z axes of the headset are arbitrary, and the origins are not the same for both frame. It is a relatively simple least squares problem so I just need matrix multiplication, inverse, and in order for the estimated matrix to be unitary I need to do svd on it, it could work without but I think it will be more accurate with that

#

the rotation matrix is between these two frames of reference

#

I know how to do it on python or matlab but this is the first time I use C# and unity

teal viper
#

If you can do it in math, you can probably code it from scratch in any language.

#

Basic math operations are part of the basics.

spark sinew
#

right. I will try this

#

it is just that python and matlab have build in functions for svd, but if we can do multiplication and transpose already I think it is a good step

surreal zephyr
#

Im new to using c# and I was wondering how to I make a game object kinda leap forward at the start and just keep going after that?

teal viper
spark sinew
#

I was looking at the documentation, it seems that in the Unity.Mathematics/src/Unity.Mathematics

/svd.cs there is one thing that should work: [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static quaternion svdRotation(float3x3 a)
{
singularValuesDecomposition(a, out var u, out var v);
return math.mul(u, math.conjugate(v));
}
}

#

so to access it I guess I should type Mathematics.svd.svdRotation(Matrix) ?

#

scratch that it's not what I need. I will keep trying

echo sand
#
public static class TimerManager : MonoBehaviour
{
    List<Timer> Timers = new List<Timer>();
    void Update()
    {
        foreach (Timer Timer in Timers) 
        {
            Timer.Update();
        }
    }
    public Timer NewTimer(float Duration,bool Repeating)
    {
        Timer Timer = new Timer(Duration,Repeating);
        Timers.Add(Timer);
        return Timer;
    }
}
```is this a bad way to handle timers
#

or should i make a monobehavior Timer, without using a TimerManager

eternal needle
# echo sand or should i make a monobehavior Timer, without using a TimerManager

each timer definitely shouldnt be its own monobehaviour, but i also am not sure that TimerManager needs to be one either.
if this suits your use case then its not a bad way. i just dont exactly see what you'll be doing with these timers. i assume when the timer is returned you're subscribing to some delegate to be notified of when its done.

eternal needle
echo sand
naive pawn
#

i know about pointer casting, i just didn't think it'd turn up here, i thought it was just converted normally
thanks for the answers

eternal needle
#

yes if its null and you try to call a function on it, it will give an error

echo sand
#

cant i avoid that tho, ngl feels very tedious if i want to destroy some item class with a timer attached

eternal needle
echo sand
#

oh nvm ur right

royal lodge
#

hello?

teal viper
#

Is it me you're looking for?
There is fire in your eyes...

slate haven
#

Facing this weird error in Unity 6 while using new input system. Never faced this in earlier versions of unity. Please help. Following is my script:
https://hastebin.com/share/obukacecop.csharp


public class Movement : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created

    private PlayerControls playerControls;


    private void Awake()
    {
        PlayerControls playerControls = new PlayerControls();
        playerControls.PlayerActions.Move.performed += Move_performed;
        
    }

    private void Move_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        Debug.Log("MOVING");
    }

  
    public Vector2 GetMovementVectorNormalized()
    {
        Vector2 inputVector = playerControls.PlayerActions.Move.ReadValue<Vector2>();
        inputVector = inputVector.normalized;
        return inputVector;
    }

    private void OnEnable()
    {
        playerControls.PlayerActions.Enable();
    }


    private void OnDestroy()
    {
      
        playerControls.PlayerActions.Disable();
        
    }
}
keen dew
#

Use a bin site that shows line numbers. !code

eternal falconBOT
ivory bobcat
tough tartan
#

Someone help me i cant fix my code

naive pawn
ivory bobcat
fickle plume
#

!unmute 433502248828665857 Don't spam the same link multiple times next time.

eternal falconBOT
#

dynoSuccess iota777 was unmuted.

slate haven
slate haven
naive pawn
ivory bobcat
slate haven
#

what do i do instead?

ivory bobcat
#

You've never initialized it

naive pawn
#

PlayerControls playerControls = new PlayerControls();
this is a variable declaration. you're doing PlayerControls playerControls twice. you have 2 separate variables. you only initialized one, the local variable that the rest of the script doesn't see

#

instead of creating that extra variable, assign to the existing field

ivory bobcat
#

What you're looking at in Awake isn't the same as the class' member

naive pawn
#

remove the PlayerControls in the declaration in Awake to turn it from a declaration into an assignment.

slate haven
#

I removed the Awake

ivory bobcat
slate haven
naive pawn
slate haven
naive pawn
slate haven
#

2 times I was initializing it

tough tartan
# tough tartan

Can u guys help me out with this i need for a level project

naive pawn
ivory bobcat
#

You've declared it once as a class variable and another time in Awake - two completely different variables.

slate haven
#

Also any good tutorial or document where I can know about Cinemachine 3.1? They have changed all of it

naive pawn
#

!code

eternal falconBOT
tough tartan
#

Alright

#

Im using a school pc so its kinda hard to rn

#

How would i put the errors in just type?

#

as a comment?

naive pawn
#

no, screenshot the error, but actually focus on it

tough tartan
#

Okok

ivory bobcat
# tough tartan

We'd need to see line 10 where you're trying to use some member named useEvent - the code shown doesn't seem to represent the error.

tough tartan
#

and its the only code which features that useEveny

ivory bobcat
#

Maybe you've changed the code or that's an old error

tough tartan
naive pawn
tough tartan
#

im getting it up

#

hold on

ivory bobcat
#

You've changed some lines of code and have not saved/compiled the script.

tough tartan
#

Heres the code

#

nevermind

naive pawn
#

anyways, have you at least read the error
are you missing a using directive?

tough tartan
#

first error says

#

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

ivory bobcat
#

Your error line is here and not where you've suggested

tough tartan
#

The type or namespace name 'InteractableEvent' could not be found (are you missing a using directive or an assembly reference?)

tough tartan
#

my c# skills r terrible rn

naive pawn
ivory bobcat
#

Either make sure interactable has that member or don't use that member. You may be referring to a different interactable if you believe it does have said member.

tough tartan
#

What foes this mean

naive pawn
#

or is Interactable your own class?

ivory bobcat
#

It means you didn't write/design your code and need to show or explain where/how you got it.

tough tartan
#

In this video We're going to expand our interaction system to include the use of Events!
This is a really powerful way for us to quickly prototype and design our interactions!
Health Bar Tutorial
https://youtu.be/CFASjEuhyf4

00:00 Introduction
00:30 Unity Events Example
01:15 Interaction Event Script
01:53 Interactable Extras #1
02:25 Intera...

▶ Play video
#

around 4mins

naive pawn
#

alright, you need to define your own InteractionEvent class

#

you have not done so

tough tartan
#

And how would i do that

naive pawn
#

uh, watch the tutorial?

tough tartan
#

Did i miss something in the vid or no

naive pawn
#

yes

#

you did

tough tartan
#

oh crap

naive pawn
#

useEvents is also defined around 2mins in

#

InteractionEvent is defined around 1min

#

if you're following a tutorial and something doesn't work, the first step should be to go back through the tutorial to see what you missed

vast stirrup
#

does Unity Learn support Firefox? I want to do the quiz for Prototype 1 and it sends me to this. I dont know where to really ask this question I didnt find a Unity Learn channel. do I need to put !bug in? I think I do...

eternal falconBOT
#

🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.

📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!

💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.

For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting

fickle plume
#

@vast stirrup How does this relate to this channel? Also don't cross-post.

vast stirrup
#

oh ok sorry, im new. I do not know where this really belongs I just wanted some help or an answer.🙂

humble forum
#

fogsight can you help me with some code?

rocky canyon
#

just ask.. you'll have better luck

humble forum
#

basically i am trying to place a building based on what the placer clicks in the ui

verbal heron
patent grail
#

can someone tell me why this won't work?

#

this issue started after i moved them into functions

#

the debug's are fired

#

but not the movement

rocky canyon
timber tide
rocky canyon
#

ya, ^

umbral bough
#

Hi, I have this so:

namespace Scenes.Snowstorm
{
    [CreateAssetMenu(fileName = "SnowstormConfigData", menuName = "Config/SnowstormConfigData")]
    public class SnowstormConfigData : ConfigData {}
}

How can I create an instance of it in the editor via c#?
I tried doing this:

//sceneName is set to Snowstorm when executing the thing
var className = $"Scenes.{sceneName}.{sceneName}ConfigData";
var classType = Type.GetType(className);
var so = CreateInstance(classType);
var soPath = Path.Combine(sceneDir, $"{sceneName}ConfigData.asset");
AssetDatabase.CreateAsset(so, soPath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

Also tried this var so = CreateInstance($"Scenes.{sceneName}.{sceneName}ConfigData"); and this var so = CreateInstance($"{sceneName}ConfigData"); and not a single approach worked.
I would really appreciate someone's help cuz I'm lost :/

#

Forgot to mention in the original message, ConfigData class inherits from so and this does appear in the create menu and works fine when manually created.

rocky canyon
# patent grail yoo
   if (horizontalInput != 0)
        {
            rb.velocity = new Vector2(horizontalInput * characterSpeed, rb.velocity.y);
            Debug.Log($"Moving {(horizontalInput > 0 ? "Right" : "Left")}");
        }
        else
        {
            Idle();
        }```
one improvement I can suggest is just using a single variable for ur Horizontal movement..
#

no need for soo many if/else statements.. esp since one of em basically just cancels each other out..
if u use horizontalInput with Input.GetAxisRaw("Horizontal"); <-- then
horizontalInput is either gonna be -1, 0, or 1
then u can just multiply that by ur speed..

#

it'll automatically go left.. and go right

humble forum
#

public class PlaceBuildChecker : MonoBehaviour
{
    [SerializeField] private TileBase expected;
    private TileBase test;
    [SerializeField] private Tilemap tilemap;
    [SerializeField] private BuyScreen BuyScreen;

    
    public void SetExpectedTile(TileBase newTile)
    {
        expected = newTile;
        Debug.Log("Nieuwe verwachte tegel ingesteld!");
        
    }

    private Vector3Int PointedCell
    {
        get
        {
            Vector2 screenPos = Input.mousePosition;
            Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);
            worldPos.z = 0;
            return tilemap.WorldToCell(worldPos);
        }
    }

    public bool IsValid(Vector3 mouseWorld)
    {
        Vector3Int cell = tilemap.WorldToCell(mouseWorld);
        TileBase tile = tilemap.GetTile(cell);
        return tile == expected;
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector3Int clickedCell = PointedCell;
            TileBase tile = tilemap.GetTile(clickedCell);

            if (tile == expected)
            {
                Debug.Log("Je hebt op een verwachte tegel geklikt!");

                if (BuyScreen != null)
                {
                    BuyScreen.ShowPanel();
                }
            }
        }
    }
#
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Tilemaps;

public class TileSelector : MonoBehaviour
{
    [SerializeField] private PlaceBuildChecker placeBuildChecker;
    [SerializeField] private TileBase tileToSet; 
    [SerializeField] private Button setTileButton;

    void Start()
    {
        if (setTileButton != null)
        {
            setTileButton.onClick.AddListener(OnSetTileButtonClicked);
        }
    }
    
    private void OnSetTileButtonClicked()
    {
        if (placeBuildChecker != null && tileToSet != null)
        {
            placeBuildChecker.SetExpectedTile(tileToSet);
        }
    }
}
patent grail
#

thanks for the help

rocky canyon
#

or where are u stuck..

humble forum
#

tile selector basically needs to do it needs to copy the position and bind to the button so it can replace the tile

patent grail
#

wierd tho worked fine when i didn't move them into functions maybe i forgot to save ;/

humble forum
rocky canyon
#

if u put a physics2d material on ur collider w/ zero or low friction u can get by with using smaller values

humble forum
#

so if i press one of these i want the too spawn on the wood i touched

rocky canyon
#

can u already select the tile and its position and everything?

#

is it finding out and assigning what "type" of house is where ur having trouble?

humble forum
rocky canyon
#

ahh okay 👍 just trying to figure out the exact issue

humble forum
rocky canyon
#

yea, i was just confirming the specific problem as at first the question was a bit broad

#

the easiest way imo would be to have an array of prefabs..
[SerializeField] private GameObject[] housePrefabs; // Array of house prefabs to spawn
^ could have (1) prefab for each house type..

then to spawn it or select it it'd just be
housePrefabs[0], [1], or [2] for example..

#

for determining which house u select i guess a ScriptableObject could work

#
public class TileData : ScriptableObject
{
    public TileBase tile;
    public GameObject housePrefab; // Associated house prefab
}``` like this..
#

if u did Scriptable objects u wouldnt even need a list.. (u'd just have a different prefab for each house)

humble forum
#

because i already know the location

rocky canyon
#

i suck at tilemaps.. im reading some stuff myself to figure out what the best approach would be

verbal heron
#

i have a parkour game but my character keeps flying into the celing

using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour
{
public float moveSpeed = 5f; // Speed of player movement
public float jumpForce = 5f; // Force applied when jumping

private Rigidbody rb;

void Start()
{
    rb = GetComponent<Rigidbody>();
    rb.useGravity = true; // Ensure Unity's gravity is applied
}

void Update()
{
    Move();

    if (Input.GetKeyDown(KeyCode.Space) && IsGrounded())
    {
        Jump();
    }
}

void Move()
{
    float moveX = Input.GetAxis("Horizontal");
    float moveZ = Input.GetAxis("Vertical");

    Vector3 moveDirection = new Vector3(moveX, 0, moveZ).normalized;

    Vector3 moveVelocity = moveDirection * moveSpeed;
    rb.linearVelocity = new Vector3(moveVelocity.x, rb.linearVelocity.y, moveVelocity.z);
}

void Jump()
{
    rb.linearVelocity = new Vector3(rb.linearVelocity.x, jumpForce, rb.linearVelocity.z);
}

bool IsGrounded()
{
    // Check for grounding to prevent floating or upward dragging
    return Physics.Raycast(transform.position, Vector3.down, 1.1f);
}

void FixedUpdate()
{
    // Extra safeguard to force Rigidbody's velocity in case of erratic behavior
    if (rb.linearVelocity.y > 0 && !Input.GetKey(KeyCode.Space))
    {
        rb.linearVelocity = new Vector3(rb.linearVelocity.x, 0, rb.linearVelocity.z);
    }
}

}

tough python
verbal heron
#

dont think so

#

i cant change it

tough python
#

in rigid body?

#

not 0 like 1 or something

verbal heron
#

the mas?

#

i dont see gravity

tough python
#

for my game its a top down game so i used 0 gravity scale. the mass changes the speed of the character for me

verbal heron
tough python
verbal heron
#

it removes the infinite jumps

tough python
#

i think whats happening is the script doesn't know what exactly is ground and what is not

#

so you might have to make a method to make sure its grounded

verbal heron
#

it does know i added stuff

umbral bough
pliant abyss
#

Why does Unity assume that when I specify a color, I want the alpha to be zero? That is so counterintuitive there must be a good reason for it.

swift crag
#

Color is a struct, so you can't have field initializers (in the version of C# Unity is using, at least)

polar acorn
#

Because 0 is the default value for a float

pliant abyss
swift crag
#

Color.blue does not give you a color with an alpha of zero

pliant abyss
#

Or does that only modify the RGB?

swift crag
verbal heron
#

i have a parkour game but my character keeps flying into the celing

using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour
{
public float moveSpeed = 5f; // Speed of player movement
public float jumpForce = 5f; // Force applied when jumping

private Rigidbody rb;

void Start()
{
    rb = GetComponent<Rigidbody>();
    rb.useGravity = true; // Ensure Unity's gravity is applied
}

void Update()
{
    Move();

    if (Input.GetKeyDown(KeyCode.Space) && IsGrounded())
    {
        Jump();
    }
}

void Move()
{
    float moveX = Input.GetAxis("Horizontal");
    float moveZ = Input.GetAxis("Vertical");

    Vector3 moveDirection = new Vector3(moveX, 0, moveZ).normalized;

    Vector3 moveVelocity = moveDirection * moveSpeed;
    rb.linearVelocity = new Vector3(moveVelocity.x, rb.linearVelocity.y, moveVelocity.z);
}

void Jump()
{
    rb.linearVelocity = new Vector3(rb.linearVelocity.x, jumpForce, rb.linearVelocity.z);
}

bool IsGrounded()
{
    // Check for grounding to prevent floating or upward dragging
    return Physics.Raycast(transform.position, Vector3.down, 1.1f);
}

void FixedUpdate()
{
    // Extra safeguard to force Rigidbody's velocity in case of erratic behavior
    if (rb.linearVelocity.y > 0 && !Input.GetKey(KeyCode.Space))
    {
        rb.linearVelocity = new Vector3(rb.linearVelocity.x, 0, rb.linearVelocity.z);
    }
}

}

pliant abyss
verbal heron
#

how do i do that? srry im new

fickle plume
#

!code

eternal falconBOT
pliant abyss
#

```csharp
[your code here]


remove the slash
fickle plume
#

@verbal heron Use paste site in the bot message

swift crag
#

That's too long to put inline

#

yes, use a paste site

pliant abyss
rocky canyon
#

gists seem more permanent.. hate to add one just to share it and then have to go and delete it.. all the others are more temporary.. dont have to deal w/ accounts either

pliant abyss
swift crag
#

i etch my code onto a stone tablet and hurl it through your window

#

fix it

rocky canyon
verbal heron
#

idk how to use it

rocky canyon
#

just use one of those paste bin websites..

#

u paste u code.. hit the 💾 save icon and the URL will refresh

#

copy and paste that here

swift crag
#

gdl.space broke

#

so use one of the other site in that bot message

rocky canyon
#

no suprise flash-bangs, oh and can post multiple code snips on a single page.. (good for systems)

verbal heron
#

i not working

rocky canyon
#
//like this. make sure theres a line-break

#

but ur code block is a bit long.. sooo if u could use one of the links on the embed u got sent earlier.. that everyone keeps telling u to use

#

that'd be great.. ☕

#

lol.. ` <-- gotta use three back-ticks

#

at the top and the bottom

swift crag
rocky canyon
#

discord code formatting

verbal heron
#

alr

#
cs using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour
{
    public float moveSpeed = 5f;    // Speed of player movement
    public float jumpForce = 5f;   // Force applied when jumping

    private Rigidbody rb;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.useGravity = true; // Ensure Unity's gravity is applied
    }

    void Update()
    {
        Move();

        if (Input.GetKeyDown(KeyCode.Space) && IsGrounded())
        {
            Jump();
        }
    }

    void Move()
    {
        float moveX = Input.GetAxis("Horizontal");
        float moveZ = Input.GetAxis("Vertical");

        Vector3 moveDirection = new Vector3(moveX, 0, moveZ).normalized;

        Vector3 moveVelocity = moveDirection * moveSpeed;
        rb.linearVelocity = new Vector3(moveVelocity.x, rb.linearVelocity.y, moveVelocity.z);
    }

    void Jump()
    {
        rb.linearVelocity = new Vector3(rb.linearVelocity.x, jumpForce, rb.linearVelocity.z);
    }

    bool IsGrounded()
    {
        // Check for grounding to prevent floating or upward dragging
        return Physics.Raycast(transform.position, Vector3.down, 1.1f);
    }

    void FixedUpdate()
    {
        // Extra safeguard to force Rigidbody's velocity in case of erratic behavior
        if (rb.linearVelocity.y > 0 && !Input.GetKey(KeyCode.Space))
        {
            rb.linearVelocity = new Vector3(rb.linearVelocity.x, 0, rb.linearVelocity.z);
        }
    }
}  
fickle plume
#

@verbal heron No space before cs

#

Also still use paste site like directed

verbal heron
#

i did

rocky canyon
#

i have a parkour game but my character keeps flying into the celing

  • Ridd1er
    (OG question buried ^)
fickle plume
#

@verbal heron Pick one of the links (except first one) and post code there. !code

eternal falconBOT
verbal heron
#

i did

rocky canyon
#

hit the save button, and paste the URL it gives u here then..

fickle plume
#

@verbal heron You might need to tab out from the Fortnite you are playing to comprehend this.

rocky canyon
#

lol.. but he's almost Top 5 😅

verbal heron
#

its creative

rocky canyon
#

neither here nor there.. once u paste a good link to your code we'll be able to help..

fickle plume
#

@verbal heron Why are you doing the same thing again and again?

fickle plume
verbal heron
#

yeah

fickle plume
#

click them

verbal heron
#

i use myst

fickle plume
#

paste your code there, click generate link and post the link

verbal heron
rich adder
verbal heron
#

i spawn and i start flying even with jumpforce 0

rich adder
#

what is this supposed to do rb.linearVelocity = new Vector3(rb.linearVelocity.x, 0, rb.linearVelocity.z);

#

why 0

rocky canyon
#

i just noticed two of em

rich adder
#

Extra safeguard to force Rigidbody's velocity in case of erratic behavior
huh?

rocky canyon
#

1 in update and 1 in fixed

verbal heron
#

it removes vertical movement

rocky canyon
#

have u debugged ur velocity value and watched it?

#

its ur Y velocity variable wherest lies the problem

verbal heron
#

yeah but chatgpt added that after i asked him.....

rocky canyon
#

and how ur managing ur rb.velocity directly

verbal heron
#

can you fix it maby?

#

if you know how

rocky canyon
#

i could.. but that doesn't help you at all

rich adder
rocky canyon
#

first advice would be to stop trusting chatgpt

verbal heron
#

yeah.....

rocky canyon
#

i wont be all anal and say Dont use it..

#

but dont trust it

verbal heron
#

ok

rich adder
#

at very least you should know what the hell you're copying and why. Its still wont help you fix it if its broken

rocky canyon
#

it gets confused very simply when encountering someone thats learning

verbal heron
#

yeah

rocky canyon
#
  • its a yes, man.. it'll str8 up change its response just b/c u asked it too.. (even if by accident)
#

soo.. why do u have two rigidbody functions?

verbal heron
#

he added that aswell...

rich adder
#

anyway the y velocity would only be set to 0 before doing a jump, so if anything it should go in the Jump function

rocky canyon
#

and u know u shouldnt typically messs w/ rigidbodies in the Update() loop

#

u know the difference in the two right? the Update vs the FixedUpdate

verbal heron
#

not acutaly

#

i asked fix and he add stuff

rocky canyon
#

yea, he's too far gone already

rich adder
#

why are you here if GPT can fix it for you

verbal heron
#

he cant

rocky canyon
#

time to scratch that conversation.. (and this is why ai == bad)

rich adder
#

then stop using it

verbal heron
#

i am

rocky canyon
#

all that time wasted

verbal heron
#

yessir

rocky canyon
#

do u know what ur code is doing?

verbal heron
#

a lil bit

rocky canyon
#

i suggest if u want the fast and easy way... thats marginally better than chatgpt.. is start working from a good video tutorial

verbal heron
#

it conrtolss the players movement, jumping and the speed and jump hight

rocky canyon
#

most ppl will say stop what ur doing, start !learn Unity Learn material, do not pass go, do not collect 200 dollars

eternal falconBOT
#

:teacher: Unity Learn ↗

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

verbal heron
#

i lowkey challanged my self to make a game just with ai

rocky canyon
#

challenge successfully failed i guess

rich adder
verbal heron
#

yessir

pliant abyss
#

I don't care for it myself.

rich adder
#

what a joke

coarse shore
#

should i download vs or vs code?

rocky canyon
#

whats the point?

rich adder
pliant abyss
coarse shore
rocky canyon
#

why even make a game if ur just letting the ai do it for u.. lol

#

i bet u get ur art from midjourney too

pliant abyss
rich adder
coarse shore
#

these?

#

or do i need more

#

idk if i need to somehow activate them

rich adder
#

the steps are here

#

!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

rich adder
#

follow the thoroughly

coarse shore
#

alr ill check it

#

ty

pliant abyss
pliant abyss
rocky canyon
#

@verbal heron the rb already has gravity..

#

the velocity code u have conflicts w/ that.. + u do it again in fixedupdate

pliant abyss
# coarse shore

I highly recommend learning how to create a profile in VSCode specifically for Unity.

flat sphinx
#

two questions
first, how do i do global scope

rocky canyon
#

Update -> every frame
FixedUpdate -> every X frames (locked for physics)

wintry quarry
flat sphinx
pliant abyss
flat sphinx
#

and assigning courses by the hole is clunky

wintry quarry
coarse shore
rich adder
flat sphinx
wintry quarry
#

Basically look up "Unity DDOL singleton"

flat sphinx
wintry quarry
rocky canyon
# verbal heron ``` cs using UnityEngine; [RequireComponent(typeof(Rigidbody))] public class Pl...

Update is for Input and logic, and Fixed is for physics.. u can assign the velocity every update and fixedupdate will use whichever value it has when it runs.. but u shouldn't do this more than necessary.. and a lot of the times you can use functions like rb.AddForce() to let Unity do its own thing w/ the velocities.. but if ur gonna modify them yourself i would do it as little as possible.. and know when and how to.. b/c if for example you add force and then call rb.velocity = blabla.. ur gonna overwrite it immediately..

rocky canyon
#

rb.velocity = new Vector3(moveDirection.x, rb.velocity.y, moveDirection.z); doing something like this can be paired w/ AddForce if ur Force is on the Y b/c if u notice the new Vector3... ur changing the x, and the z

#

but we pass in the rigidbodies own velocity into the y

#
    void Update()
    {
        Move();

        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
            Jump();
    }

    void Move()
    {
        float moveX = Input.GetAxis("Horizontal");
        float moveZ = Input.GetAxis("Vertical");

        Vector3 moveDirection = new Vector3(moveX, 0, moveZ).normalized * moveSpeed;
        rb.velocity = new Vector3(moveDirection.x, rb.velocity.y, moveDirection.z);
    }

    void Jump()
    {
        rb.velocity = new Vector3(rb.velocity.x, jumpForce, rb.velocity.z);
    }```
i wonder what this would do in ur project 🥄
rich adder
#

split the inputs to their own method like Input() keep it in update, move Move() to FixedUpdate

rocky canyon
#

for jump ud probably still wanna cancel gravity as mentioned cs void Jump() { rb.velocity = new Vector3(rb.velocity.x, 0, rb.velocity.z); rb.velocity += Vector3.up * jumpForce; }

verbal heron
#

alr

rocky canyon
#

+= just means this = this + that

verbal heron
#

ik

rocky canyon
#

well wasn't sure if chatgpt had lied to ya or not..

verbal heron
#

same

coarse shore
#

guys what thing is this dropdown on for u guys?

#

yk where it says "unity"

#

what is it for u guys

#

bc i got the suggested keywords like (Input) and Keycode

#

but i dont got GetObject

#

unless i have to attach the script

#

to the item first

flat sphinx
rich adder
#

also please ease with the vertical messages

coarse shore
coarse shore
flat sphinx
#

anyways second question
is there some means to subtype off a gameobject

rich adder
verbal heron
#

Assets\Scripts\PlayerMovement.cs(39,10): error CS0111: Type 'PlayerController' already defines a member called 'Move' with the same parameter types
coarse shore
coarse shore
rich adder
coarse shore
rich adder
flat sphinx
#

word salad but i mean like
i have a gameobj with children for a board, obstacles, spawn point n such
and i want to access these through a shared interface

rich adder
coarse shore
#

as a suggestion

coarse shore
#

ohhh

rich adder
#

you declare types not methods for variable

flat sphinx
#

*be able to

coarse shore
#

im trynna code what i remember; i shouldve js watched the video again

#

ty navarone

rich adder
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

these are people who made the program ^

coarse shore
rich adder
#

do Essentials -> Junior Prog, and go from there

coarse shore
#

i js dont wanna waste my time learning things i already have

coarse shore
rich adder
#

most of the essentials like configure editor you did already so no worry, just check out where eevrything is in the editor

rich adder
#

there are ways to programmatically access the children but its not very precise / inefficient

flat sphinx
#

pain

#

public class StupidBoardHolder it is then

rich adder
#

if you have components its easy to store them in arrays

#

Gameobject / Transform works too but its pretty useless most of the time

rich adder
flat sphinx
#

why the access modifiers

swift crag
flat sphinx
#

and.. i guess why is it inheriting from monobehaviour

swift crag
#

this sounds more like what you do in Unreal

flat sphinx
swift crag
#

in Unity, you don't subclass GameObject or otherwise create more "specific" kinds of game objects

rich adder
swift crag
#

you just attach components to game objects

coarse shore
#

yk how if u press space or enter, the suggested keyword would replace the word ur typing, how do u avoid that?

swift crag
flat sphinx
#

i mean i was just gonna shove it into a StupidGlobalsClass.all_boards

#

and leave it as

rich adder
#

or turn off the setting (i forgot where it is on VSCode)

flat sphinx
#

anyways third question, is there a way to make/get "model groups" from a blender model
stupid wording but what i mean is, i want to make my game map in blender instead of playing lego with cube objects

swift crag
#

you can import a model that contains many small objects in it

coarse shore
flat sphinx
#

but in said map i need to f.e treat borders differently than the floor

flat sphinx
#

so how/can do i do that without just importing multiple models and stitching them together

rich adder
#

why not proto with ProBuilder, its similiar to blender for basic needs like grayboxing

#

i know 0 of blender sorry blushie

flat sphinx
#

can try

#

i only knew of blender so yknow

#

lol

swift crag
#

Building the entire level directly in Blender sounds awkward for a couple of reasons

flat sphinx
#

ama check rq if it runs on manjaro

swift crag
#

If you use the same floor piece 1,000 times, you'll get 1,000 copies of that mesh when you import it into Unity

#

Probuilder is part of Unity.

flat sphinx
#

oh

#

neat

swift crag
#

in Unity, you can make a prefab that has a model and some components to give it functionality

#

then scatter that prefab around your level as needed

flat sphinx
swift crag
#

You'd need to either manually attach components to all of these Blender-imported objects, or write editor code to automatically do this

flat sphinx
#

main appeal was actual control over the model

swift crag
#

i mean, you can still make models in Blender

#

you just don't want to build the entire level into one giant FBX

flat sphinx
#

cuz again, stitching cubes is a mental pain

#

oh yeah btw am i just unable to access consts from outside the class

swift crag
#

const-ness has nothing to do with accessibility

flat sphinx
#

you say that but if i remove the const modifier from my public const int AIM_LOCK_AIMING = (1<<0) it just works

swift crag
#

show the relevant code

flat sphinx
#

yeah hol lon lemme boot discord on the thing

swift crag
#

ooh, right -- I forgot about that behavior of const

flat sphinx
#

lemme check if throwing static at it will fix it

swift crag
#

it also makes the member static

flat sphinx
#

nop

#

it didnt

swift crag
#

as the error suggests, access it from the type itself

#

not from an instance of the type

languid spire
#

read the message. Use the type name

flat sphinx
#

oh yeah

#

so much for no-sleep coding

#

also sucky behaviour but k

languid spire
#

standard C. const belongs to the class not an instance of it

flat sphinx
swift crag
#

there is no point to accessing it from an instance, yes

pastel dome
#

say you set a layer mask to one layer for a raycast. that is the layer it is meant to collide with? will it be blocked by things in other layers?

languid spire
#

no

rich adder
hasty tundra
#

I have 2 objects in unity that are clickable with the OnMouseDown() function in unity, and one of the objects apears on top of the other. However, the hitbox for the first object covers over the one for the second, making it unclickable, this isnt helped by the fact that object 2 is a child of object 1, but im trying to figure out a way to make them both clickable at once

flat sphinx
#

how do i animate an object without giving it full on physics
am trying to do a cool "yeet the map offscreen on finish" animation and giving the floor rigidbody feels wrong

#

specifically i want it to accelerate along the y axis

#

asking here since i assume there's already an inbuilt for this

rich adder
#

tweening or something like that

rich adder
rich adder
#

you need Physics Raycaster on camera for event system to work on colliders *

swift crag
#

adding an increasing amount to your Y position every frame would do the trick

flat sphinx
#

or hell even transform a to transform b

swift crag
#

libraries like DOTween will let you do this easily

languid spire
#

yep, as mentioned Tweening

flat sphinx
#

aig ama look that up

#

worst case scenario ill bootleg some custom interpolation shit

pastel dome
#

im pretty sure in vfx you just lerp along a curve

#

but i dont know what tweening is

rich adder
#

tweening just uses interpolation

languid spire
swift crag
#

non-linear lerp 🤭

hybrid finch
#

i have two scripts, Player health and Enemy Controller, in Player Health i have a method that takes away damage every 5 seconds and in enemy controller the enemy follows the player and if its 5 or under away it stops and im trying to get the Player Health method to work inside the stopping if statement. Can anyone tell me what i did wrong/ didnt include?

rich adder
#

good way to get help..

fickle kelp
#

I just downloaded unity and have absolutely no clue what I’m doing. How should I start? Should I start by learning C++ or smth?

rich adder
hybrid finch
#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using static UnityEngine.GraphicsBuffer;

public class PlayerHealth : MonoBehaviour
{
public int playerHealth = 100;
public int damage = 25;
public Transform enemy;
public float timee = 3.0f;
[SerializeField] private TMP_Text HealthDisplay;

private void Update()
{/*
    if (enemy != null)
    {
        enemy = GameObject.Find("Enemy(Clone)").transform;
    }*/
    if (playerHealth <= 0)
    {
        Destroy(this.gameObject);
    }

    HealthDisplay.text = playerHealth.ToString() + "%";
   /* if (enemy != null)
    {
        if (Vector3.Distance(transform.position, enemy.transform.position) < 6)
        {

           // EnemyTakeDamage();
        }

    }*/
}

public void PlayerTakeDamage()
{

    timee -= Time.deltaTime;

    if (timee <= 0f)
    {
        playerHealth -= damage;
        timee = 5f;
    }

}

}

#

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

public class EnemyController : MonoBehaviour
{
public Transform target;
private NavMeshAgent agent;
public bool isStopped;
private PlayerHealth health;
// public PlayerHealth playerhealth;

void Start()
{
    agent = GetComponent<NavMeshAgent>();
    

    target = GameObject.Find("PlayerBody").transform;
    health = GetComponent<PlayerHealth>();
}

void Update()
{

    if (Vector3.Distance(transform.position, target.transform.position) > 5)
    {
        agent.destination = target.transform.position;
        agent.isStopped = false;
    }


    else
    {
        agent.isStopped = true;
        health.PlayerTakeDamage();
    }
}

}

#

@rich adder

rich adder
rich adder
#

no you just plopped the code here as a message instead of sending the links

#

paste each script on the site, save , send link of each

civic cradle
#

hey mates, sorry, I'm ashamed to ask, but how do I get the ref to a script?
case: I have a playercontroller, which has an action (basically doDamage())

if(Input.GetKeyDown(KeyCode.Space)) {
  Attack();
  GameObject enemy = GameObject.Find("Enemy").GetComponent(typeof(EnemyController));
}

My Enemy GameObject has a public field "health". All i really wanna do is set health -= 1
I tried accessing with via GetComponent<EnemyController>() but that also didn't work.

#

(Using unity 6.0)

silver basin
#

I have a navmesh agent and an array of objects, how do I make the navmesh agent choose the closest one?

rich adder
silver basin
silver basin
swift crag
#

you can query for a path and then check how long it is

languid spire
swift crag
#

You'll have to get the list of corners from the path and then compute the distance between each pair

languid spire
#

if you have many objects you probably dont want to do all of that in one frame

swift crag
#

You could make the process more efficient by sorting the objects by distance and then giving up once your best path is shorter than any of the remaining distances.

fickle kelp
# rich adder https://learn.unity.com/pathways

I started the tutorial and I’m at a part where it says to use the arrow keys to move forward, backwards, left, and right but when I press the up and down arrows on my keyboard I move up and down not forwards and backwards. Do you know how I would fix this?

rich adder
mortal jewel
#

how can i make it so it picks at random which one of the 2 backgrounds its going to pick?

rich adder
flat sphinx
#

*cshart .

rich adder
flat sphinx
#

shitlang lol

rich adder
flat sphinx
#

some engine-specific langs do cool stuff

rich adder
#

engine specific language isn't usually useful in the real world

#

so the language is bad because there is no Pick() method?

flat sphinx
#

yep

marble hemlock
#

thinking of organizing an objective system and im just like

#

what if i used a really big else if statement

#

im making the quests, that's fine. but im just like how do i organize this mess

rich adder
#

or just a switch

languid spire
rich adder
#

but usually there is a better way like SOs and arrays

flat sphinx
#

yeah p much

marble hemlock
#

this sucks :(

flat sphinx
#

i personally am used to abusing prototype subtypes

#

because i can do f.e var/quest_type = pick(subtypeof(/quest/generic_guard))

#

tho obviously thats not a thing in cshart

#

moethink will have to figure out if theres some analog

marble hemlock
#

i am at a point where i read that and it completely goes over my head i am cooked

#

did not think the inventory system was the easy part

rich adder
#

who ever said inventories are easy?

#

they can be basic or get very complex, not usually easy though if you're a beginner

flat sphinx
rocky canyon
#

exponentially slower to get there but yes

rich adder
flat sphinx
#
if(equipping_to == SLOT_NECK) neck = item
else if (equipping_to == SLOT_HELMET) helmet = item
else if (equipping_to == SLOT_BOOTS) boots = item
else if (equipping_to == SLOT_GLOVES) gloves = item
flat sphinx
#

am myself refactoring inventory from that (or well was gonna, and then gave up half way) to a type-based system

rich adder
untold shore
#

Hey! So having a quick issue. I haven't worked a lot with Vectors, and one of my issues right now is when I hover over my game object, it just...floats until I get off it. What I want it to do is move the X coordinate up 10, then when my mouse goes off it returns (I have a method for that which Ill add.)
Currently heres the code:

    public void HandleHoverState()
    {
        glowEffect.SetActive(true);
        rectTransform.localScale = originalScale * selectScale;
        rectTransform.localPosition = Vector3.up + rectTransform.localPosition;
        Debug.Log($"HandleHoverState");
    }

Any ideas?

flat sphinx
wintry quarry
flat sphinx
#

i think theres a proc for "on hover start" but if not just have a is_elevated var or such

wintry quarry
#

If it's every frame it will move every frame

untold shore
wintry quarry
final trellis
#

how do i generate a random number between -10 and 10, but have it be weighted like a bell curve

swift crag
#

Sounds like you want a Gaussian distribution!

#

(with a bit of truncation)

#

It'll need a little adjustment to clamp the number between -10 and 10

#

This gives a 98.7% chance of picking a random number between -10 and 10

#

mean is 0, standard deviation is 4

swift crag
#

0 would be infinitely far left, and 1 would be infinitely far right

#

0.5 is the center of the curve

#

so in this case, I think you'd just need to do this!

float prob = 0.9876; // got that from the website
float margin = (1 - prob) / 2;
float sample = Random.Range(margin, 1 - margin);
return PeterAcklamInverseCDF.NormInv(sample, 0, 4);

It'll pick a random number that's not too close to 0 or 1 -- so that we stay in bounds -- and then computes the resulting value from the normal distribution

final trellis
#

thats a lot more code than i thought jeez

#

thank youu i was NOT gonna figure that out myself 😭

swift crag
#

I've also used libraries for random sampling

#

The name escapes me at the moment..

swift crag
#

The mean is the center of the curve, and the standard deviation is how wide it is

#

the default values of 0 and 1 would've given you numbers much closer to zero

mortal jewel
#

can someone tell me why its behind the main menu?

#

i changed the layer but it still would go behind

wintry quarry
mortal jewel
wintry quarry
#

Overlay canvas?

tulip geyser
#

why am i colliding with the tilemap building here?

wintry quarry
#

Layers don't really matter with UI

wintry quarry
#

you have a tilemap collider on it, no?

swift crag
tulip geyser
#

because the green outline is the collider and theres space

swift crag
#

These are unrelated to UI rendering

#

An overlay canvas gets drawn on top of everything else after the rest of the scene renders

tulip geyser
mortal jewel
tulip geyser
#

for reference, this is my player collider

bright sequoia
#

hey guys :) So I have a working system where when my player get close to an interactable object, a white line is applied around it
https://paste.ofcode.org/5mAXkP3MEfuu8LNQDKxzKY (<--- the script for that)

Now, I'm trying to add a system that will display unique dialogue depending on which object is interacted with (upon it being highlighted and pressing E)

I have an IInteractable script that simply reads

{
    void Interact(); 
}```

and an "InteractableObject" script that reads
```public class InteractableObject : MonoBehaviour, IInteractable
{
    public void Interact()
    {
        Debug.Log($"Interacted with {gameObject.name}");
    }
}```


I have the "InteractableObject" script applied to every interactable, and upon entering within range, it plays the debug log without any input. 
Could anyone advise me the way I could Implement this "E to read a script" idea? I'm pretty knew and had help with the InteractableHighlighter :)
#

Ive tried watching video tutorials for this, but since my game is 2d and I already have a way to detect the closest object, I end up having to modify their code and it doesnt work anymore pensive

alpine fjord
#

For example, use vector2 instead of vector3.

bright sequoia
#

I'll try this one, thank you : )

alpine fjord
#

And collider2d instead of collider.

#

I implemented the same system in a 2d game. So I can confirm the video does work.

jaunty junco
#

How to make a smooth jump in 3D
(Sorry for my bad english its not my first language)

Hi im currently making a 3D platformer. Im working on the player jump but I just dont get a smooth jump. I tried looking for tutorials on youtube but every video is ether for 2D or for the CharacterController. But I need to use a Rigidbody for my use case. I want to make something like a mario jump.

For my jump im currently using:

rigidbody.AddForce(new Vector3(0f, jumpForce, 0f), ForceMode.Impulse); 

But this is to snappy. It looks more like the player is teleported to the top and then glides down.

timber tide
jaunty junco
#

Like this? @timber tide

#

I tried that but now my player doesent jump at all.

#

jumpForce is set to 130f

ripe shard
steep rose
#

Addforce works fine for jumping, just makes sure nothing is overriding your Rigidbody's Y velocity

jaunty junco
#

Yeah but I want the jump to be more like a curve. With AddForce its more like the player is teleported

ripe shard
jaunty junco
ripe shard
#

your drag is way too high

steep rose
#

default drag value is 1, so best keep it like that

jaunty junco
#

I set it to 0 but the player still doesent move

ripe shard
#

well, then something you aren't showing is overriding what you do to the rigidbody

jaunty junco
#

My jump function:

private void Jump(InputAction.CallbackContext ctx)
{
    Debug.Log("JUMP - Ground Check");
    if (!IsGrounded()) return;

    Debug.Log("JUMP");
    //this._rigidbody.AddForce(new Vector3(0f, this._jumpForce, 0f), ForceMode.Impulse);
    Vector3 velocity = this._rigidbody.linearVelocity;
    velocity.y += this._jumpForce;
    this._rigidbody.linearVelocity.Set(velocity.x, velocity.y, velocity.z);
}
ripe shard
#

you should probably share all the code that acts on the player object

#

and stick to AddForce for now

jaunty junco
#

My playerController.cs file

using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    [Header("Values")]
    [SerializeField] private float _moveSpeed = 2.5f;
    [SerializeField] private float _crouchSpeed = 1.0f;
    [SerializeField] private float _jumpForce = 1.0f;
    [SerializeField] private float _isGroundedDistance = 1.0f;

    [Header("Connected Components")]
    [SerializeField] private Rigidbody _rigidbody;
    [SerializeField] private Collider _collider;
    
    // Private
    private InputController _inputController;
    private Vector3 _currentMovement;
    private Vector3 _currentGravity;

    private void Awake()
    {

        _inputController = new InputController();
        _inputController.PlayerGameplay.Enable();
        _inputController.PlayerGameplay.Movement_Jump.performed += Jump;

    }

    private void OnDestroy()
    {
        _inputController.PlayerGameplay.Movement_Jump.performed -= Jump;
        _inputController.PlayerGameplay.Disable();
    }


    private void FixedUpdate()
    {

        SideMovement(this._inputController.PlayerGameplay.Movement_Sides.ReadValue<float>());
        this._rigidbody.linearVelocity = this._currentMovement;

        //Gravity();
    }

    /// <summary>
    /// IsGrounded confirms that the player is grounded, by checking if it hits a collider in range set by _isGroundedDistance.
    /// </summary>
    /// <returns>  bool If the player is grounded it returns true if not then false. </returns>
    private bool IsGrounded()
    {
        return Physics.Raycast(transform.position, -Vector3.up, _isGroundedDistance);
    }

    /// <summary>
    /// SideMovement moves the player to the sides on the X axis. If the crouch button is pressed it moves the player with the crouch speed.
    /// </summary>
    /// <param name="ctx">The CallbackContext from the input action.</param>
    private void SideMovement(float inputValue)
    {
        if (!this._inputController.PlayerGameplay.Movement_Crouch.IsPressed())
        {
            this._currentMovement = new Vector3(-(inputValue) * this._moveSpeed, this._currentMovement.y, 0f);
        } else
        {
            this._currentMovement = new Vector3(-(inputValue) * this._crouchSpeed, this._currentMovement.y, 0f);
        }
    }

    private void Jump(InputAction.CallbackContext ctx)
    {
        Debug.Log("JUMP - Ground Check");
        if (!IsGrounded()) return;

        Debug.Log("JUMP");
        //this._rigidbody.AddForce(new Vector3(0f, this._jumpForce, 0f), ForceMode.Impulse);
        Vector3 velocity = this._rigidbody.linearVelocity;
        velocity.y += this._jumpForce;
        this._rigidbody.linearVelocity.Set(velocity.x, velocity.y, velocity.z);
    }

    private void Gravity()
    {
 
    }
}

ripe shard
#

you are overriding rigidbody veloctiy in each update (_currentMovement) and jump does not write to that variable

#

you need to add your jump to _currentMovement like you do in SideMovement

jaunty junco
#

Updated Jump function:

private void Jump(InputAction.CallbackContext ctx)
{
    Debug.Log("JUMP - Ground Check");
    if (!IsGrounded()) return;

    Debug.Log("JUMP");
    //this._rigidbody.AddForce(new Vector3(0f, this._jumpForce, 0f), ForceMode.Impulse);
    this._currentMovement.y = this._rigidbody.linearVelocity.y + this._jumpForce;
}
#

Now the player jumps but just keeps going up.

steep rose
#

well yes, you are setting the Rigidbody's Y velocity to linearvelocity + jumpforce which will set its Y velocity to whatever you set it to, you should probably stick to Addforce and not overwrite your rigidbody's Y velocity

jaunty junco
#

But how would I get a jump that is smoothe. With addforce the only thing I get is more like a teleport.

steep rose
#

do not overwrite it's Y velocity and put that drag variable on the RB itself to 1

jaunty junco
#

Ok but now its like a teleport

#

Or what type of Forcemode should I use?

#

Right now im using Impulse

steep rose
#

Impulse is fine, show me your new !code using one of the paste sites

eternal falconBOT
jaunty junco
steep rose
#

you are still overwriting the rigidbody's Y velocity this._currentMovement.y instead use _rigidbody.velocity.y

jaunty junco
#

ahh now its smoothe thank you very much ^^

#

o7

steep rose
#

sweet

#

I always forget its RB.linearvelocity on unity 6, I'm a 2022 guy

jaunty junco
#

I think that I get the gravity stuff myself. Thank you for the help.

jaunty junco
untold shore
#

Sorry thats a bad explanation, but I don't know how to word it better.

teal viper
prime goblet
#

why is it a txt......

#

also i run the initialising devices function in void Start

untold shore
#

Maybe because of length, you could use Pasteofcode?

prime goblet
#

next time

teal viper
eternal falconBOT
prime goblet
#

im having trouble with the headset rotation not rotating and the controller positions not changing

hazy ember
#

I've seen lots of people use variables to check grounds, jumping, etc. for platformers, just wondering if using a state machine like this would cause any issue?

#

so far it's going great, but dunno if it's better to do differently

teal viper
#

But maybe worry about it when there's an actual problem.

open vine
#

Hey, I want to make movement like in super mario galaxy where you can run on any surface, but rather than running around planets I want it to be able to walk on any surface, like complex meshes, etc. How should I go about making something like this?

teal viper
dreamy lark
#

I am a bit new to Unity and I'm having a few issues with a classlib I built. I first am having trouble finding the main entry point to add some hosted and transient services or and similar for each scene. I also am not finding the window for adding a reference to a NuGet package in my local NuGet feed

#

the nuget option is also greyed out in vs2022

timber tide
#

There's a specific plugin for NuGet if you want to use it with Unity

open vine
# teal viper You'll need to adjust the gravity vector dynamically.

Hey sorry for the late reply, i think i understand that part, but what would you do to solve charp corners or rounded parts? I have my player rotate towards the normal of a down raycast and make the gravity vector the normal, but how do i detect to go around a corner, etc?

signal mango
teal viper
# open vine Hey sorry for the late reply, i think i understand that part, but what would you...

Well, that's a design problem. How do you want it to be handled?
In the first place, do you want it to be possible to change gravity on sharp corners?
If yes, then maybe lerp between the old and the new normal over time.
if you were to do sphere casts(potentially several, both right below and a little bit towards a position in front of the character), you could detect a "wall" in front and get it's normal.

open vine
mortal jewel
#

Can someone pleases tell what is happening?

#

it worked well like an hour ago and now it every time i pass through a tube it stops and give me this error

charred spoke
#

Something on line 18 in that script is null

mortal jewel
#

theres nothing null in line 18

charred spoke
#

Well I would wager that instance of your Score singleton is null

#

Perhaps its not in the scene anymore

mortal jewel
#

NEVERMIND I FOUND IT

#

Thank you tho i was so stressed i didnt see that it was line 18

echo sand
#

is there a way i can assign multiple "owner types" to my inventory class? its being used by my character class and my item class, but i can only assign 1 data type

charred spoke
#

The way to do that would be with polymorphism but I do not see what a charaacter and item have in common. Perhaps a IInventoryOwner interface would work better here.

echo sand
#

Ty, i will try that

odd edge
serene timber
# odd edge

try making a JointMotor2D variable which stores slider.motor, then you should be able to modify motorSpeed of that variable

pure fractal
#

How can i fix this error ?

odd edge
serene timber
odd edge
#

what does serializable mean

odd edge
#

why does this not work

languid spire
odd edge
#

how do i connect it then

languid spire
#

if you post your !code correctly I will show you

eternal falconBOT
odd edge
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class platformscript : MonoBehaviour
{
    public SliderJoint2D slider;
    public float speed;
    public float distance;
    private float DistanceMoved;
    private float rotation;
    public JointMotor2D Motor;


    // Start is called before the first frame update
    void Start()
    {
        Motor = slider.motor;
    }

    // Update is called once per frame
    void Update()
    {
        Motor.motorSpeed = speed;
        DistanceMoved =+ Time.deltaTime * speed;
        if (DistanceMoved > distance)
        {
            DistanceMoved = distance;
            speed = -speed;
        }
        if (DistanceMoved < 0)
        {
            DistanceMoved = 0;
            speed = -speed;
        }
    }
}
languid spire
#
void Start()
    {
        Motor = slider.motor; // Make a COPY of motor
    }

    // Update is called once per frame
    void Update()
    {
        Motor.motorSpeed = speed; // Change the LOCAL COPY
        slider.motor = Motor; // set the COPY back to the ORIGINAL
#

this is the same workflow for ALL structs as properties

burnt vapor
# odd edge why does this not work

It is not possible to update a struct directly. You must either make a copy of the struct, change that, and replace the existing struct, or you use existing methods in the struct so it modifies itself, if applicable.

#

Unlike classes which can be modified directly

#

Something something value types and them being copies

queen adder
marble hemlock
#

the inventory took me like a week of actually trying to understand. it was hard, but i did reach a point where I went ohh and it started to piece together

#

this, however, i just don't know

i feel like a bunch of if statements would work but that might be overcomplicating it, but i cant think of a way that can be more dynamic

#

i mean if i made it so quests couldn't be failed or skipped, or something, then that would work but i want it scalable so that i could include changes like that

willow shoal
#

i need 2 lines of code

languid spire
#

How often do you need to be told?
use a !code paste site

eternal falconBOT
willow shoal
#

i did somethink wrong? send again?

#

; /

languid spire
#

yes, remove and use a paste site as per the bot message and that you have been told on many occasions

willow shoal
#

okey

languid spire
#

what about 'use a paste site' did you not understand?

willow shoal
#

sry i just check how i it work

#

okey now is okey

#

right?

marble hemlock
#

paste code in box

#

click save

#

and then put that link here

willow shoal
#

okey

marble hemlock
#

after you save, it should show a screen like this (i don't have any actual code there, so i just wrote "Type here"), and then click copy url

#

the blue one i mean

willow shoal
#

thanks

marble hemlock
#

ye

#

going to go cry as i can't figure this objective system out

#

good night

#

i need to make a new system for this its so over

pure fractal
river helm
#

says Player profile for '' not found! and Opponent 1 profile for '' not found.

#

!code ```cs
private void HandleCampaign()
{
Debug.Log($"Campaign cost text: {campaignCostText.text}");
if (int.TryParse(campaignCostText.text.Replace("M", "").Trim(), out int campaignCost))
{
if (userBalance >= campaignCost)
{
userBalance -= campaignCost;
UpdateBalances();
Debug.Log($"Campaign started for {stateNameText.text}. Cost: {campaignCost}M");
UpdateCampaign(stateNameText.text, selectedPlayerCharacter, PlayerProfileImage);
CharacterProfile selectedProfile = CharacterProfiles.Find(p => p.CharacterName == selectedPlayerCharacter);

            if (selectedProfile != null)
            {
                Button clickedButton = GetButtonByStateName(stateNameText.text);
                UpdateStateColor(stateNameText.text, null, null, selectedPlayerCharacter);
            }
        }
        else
        {
            Debug.LogWarning("Insufficient balance for campaign!");
        }
    }
    else
    {
        Debug.LogError("Invalid campaign cost!");
    }
}```
eternal falconBOT
burnt vapor
pure fractal
#

i think no

burnt vapor
river helm
#
  private void HandleCampaign()
    {
        Debug.Log($"Campaign cost text: {campaignCostText.text}");
        if (int.TryParse(campaignCostText.text.Replace("M", "").Trim(), out int campaignCost))
        {
            if (userBalance >= campaignCost)
            {
                userBalance -= campaignCost;
                UpdateBalances();
                Debug.Log($"Campaign started for {stateNameText.text}. Cost: {campaignCost}M");
                UpdateCampaign(stateNameText.text, selectedPlayerCharacter, PlayerProfileImage);
                CharacterProfile selectedProfile = CharacterProfiles.Find(p => p.CharacterName == selectedPlayerCharacter);

                if (selectedProfile != null)
                {
                    Button clickedButton = GetButtonByStateName(stateNameText.text);
                    UpdateStateColor(stateNameText.text, null, null, selectedPlayerCharacter);
                }
            }
            else
            {
                Debug.LogWarning("Insufficient balance for campaign!");
            }
        }
        else
        {
            Debug.LogError("Invalid campaign cost!");
        }
    }```
it is passing Null sometimes
#

can I know how to fix

burnt vapor
river helm
burnt vapor
eternal falconBOT
river helm
burnt vapor
#

Log a message, see if it's truly null, then come back

#

Note that the player prefs has a default value of "", so if it truly returns null then that means that something has explicitly set SelectedCharacter to be null and so it does not use the default value

#

However, once again I don't see any code that sets this value so I would not know what it does

sharp bloom
#

Trying to make some sort of bouncing ray, as you can see it works here, but when I move the blocks slightly, it goes in the wrong direction

for (int i = 0; i < 360; i+=10)
        {
            var _x = Mathf.Cos(i * Mathf.Deg2Rad);
            var _y = Mathf.Sin(i * Mathf.Deg2Rad);
            var pos = new Vector2(_x, _y);
            var hit = Physics2D.Raycast(transform.position, pos, 10);
            Debug.DrawRay(transform.position, 

pos*10f, Color.green);

            if (hit)
            {
                var hitPos = hit.point;
                var newDirection = Vector2.Reflect(pos, hit.normal);
                var hit2 = Physics2D.Raycast(hitPos, newDirection, 8);
                Debug.DrawRay(hitPos, newDirection * 8f, Color.blue);

                if (hit2)
                {
                    var hitPos2 = hit2.point;
                    var newDirection2 = Vector2.Reflect(newDirection, hit2.normal);
                    var hit3 = Physics2D.Raycast(hitPos2, newDirection2, 6);
                    Debug.DrawRay(hitPos2, newDirection2 * 6f, Color.red);

                    if (hit3)
                    {
                        var hitPos3 = hit3.point;
                        var newDirection3 = Vector2.Reflect(newDirection2, hit3.normal);
                        var hit4 = Physics2D.Raycast(hitPos3, newDirection3, 5);
                        Debug.DrawRay(hitPos3, newDirection3 * 5f, Color.cyan);
                    }

                }
#

I'm sure my code is super bad but I can't figure out why this happens'

swift crag
#

I wonder if the red line is starting from inside of the block and then instantly hitting it

#

The Debug.DrawRay lines you're drawing do not depend on how far the raycast actually traveled

#

Also, to reduce code duplication, consider doing something like this!

sharp bloom
#

I want the lines to be visible in play mode after all

swift crag
#

Nah, you just need to change how you use it (or use DrawLine!)

#
var _x = Mathf.Cos(i * Mathf.Deg2Rad);
var _y = Mathf.Sin(i * Mathf.Deg2Rad);
Vector3 pos = transform.position;
Vector3 dir = new Vector2(_x, _y);
float rayLength = 10;

for (int try = 0; try < 10; ++try) {
  float hue = try / 10f;
  Color color = Color.HSVToRGB(hue, 1, 1);

  var hit = Physics2D.Raycast(pos, dir, rayLength);

  if (hit) {
    Debug.DrawLine(pos, hit.point, 3f, color);
    pos = hit.point;
    dir = Vector2.Reflect(dir, hit.normal);
  } else {
    Debug.DrawRay(pos, dir * rayLength, 3f, color);
    break;
  }
}
#

Something like that

#

I renamed "pos" to "dir" because that's what it actually represents

sharp bloom
#

Yea that's much cleaner xd

swift crag
#

HSVToRGB is useful for creating a range of colors

swift crag
sharp bloom
#

This is for a demo thingy that is supposed to visualize sound

swift crag
#
Physics2D.Raycast(pos + dir * 0.01f, dir, rayLength);
#

e.g.

sharp bloom
#

I know it

#

it's a simplification

#

Since sound actually doesn't reflect speculary

#

Unless it's a extremely smooth surface

swift crag
#

i wonder if it winds up being a BSDF

#

just like light

#

bad thought! bad thought! bad thought!

sharp bloom
#

Yea my professor talked about that

#

He specializes in video game audio actually

swift crag
#

Neat!

#

I've been fussing around with implementing my own spatial audio system (Steam Audio doesn't work on ARM hardware...)

#

I've only really done occlusion (in straight lines) and using a nav mesh to figure out the ratio between:

  • the straight line distance
  • the shortest path to the listener
#

I need a 3D navmesh system for this notlikethis

sharp bloom
#

Haaugh

swift crag
#

this is closer than I thought

verbal dome
sharp bloom
#

Thanks

swift crag
#

Oops, I got the arguments backwards

#

start, end, color, duration

verbal dome
#

I'll probably implement portal based occlusion since my interiors are procedural so I already have portals and simple wall geometry

#

For exteriors I need to think of something else 🤔

swift crag
#

I was watching a GDC talk about 3D pathfinding in Warframe

#

It's mildly terrifying

verbal dome
swift crag
#

i am also struggling to find it

verbal dome
#

Cheers

swift crag
#

In theory it's not that bad, and I don't need to bother with things like obstacle avoidance

#

but it still sounds scary

charred spoke
swift crag
#

i wonder if there's a maximally wrong way to order the nodes

#

a morton anticode

stuck palm
#

does anyone know how to deal with scenes? I know basic stuff such as scenemanager.setactive or whatever but i want to minimize loading time. I'm using quantum, which uses additive scene loading.

swift crag
#

that's a bit vague :p

stuck palm
#

i see a lot of unity made games with super quick scene loading, for my game genre (fighter) at least

#

do they load it all at the start or something?

swift crag
#

You can use LoadSceneAsync to read the data from disk in the background, but scene activation will still have a cost

stuck palm
#

will that become very costly?

#

if theyre deactiveated

verbal dome
#

I havent used addressables yet but those can probably be used to manage what is loaded and when

swift crag
#

SetActiveScene is not used to "turn a scene on"

runic lance
#

yes, most likely lazy loading is the answer here

#

not loading at all once

swift crag
#

A better name might be "main scene"

#

It's the scene that new objects go into, where lighting settings come from, etc.

stuck palm
swift crag
#

But this will not reduce the hitch caused by creating all of the objects

verbal dome
runic lance
#

depens on how far you want to go with addressables really, if you just want to load stuff it shouldn't be too much additional work besides changing some parts of the code to be async

verbal dome
#

I dislike how it adds the Addressable toggle on every asset though... Waste of screen space

runic lance
#

then later you can deal with sorting things into proper groups, reducing asset duplication, loading things remotely

swift crag
#

I haven't really used Addressables yet. I played with using it to easily load every asset of a certain type (without having to dig around in a Resources folder for them), but that was a bad idea

#

since I had no Addressables scenes and I wasn't using any addressable asset references, the objects I got from Addressables had nothing to do with the objects I was referencing from my scenes

#

(This only becomes apparent in the built game. In the editor, loading an Addressable asset just grabs it from the AssetDatabase)

runic lance
#

yeah, resources folder is also an option for lazy loading

#

although less robust than addressables

swift crag
#

I wound up making "catalog" objects that reference every object of a relevant type

#

I have not yet automated putting things in the catalogs. I should...do that...

stuck palm
swift crag
#

increasing the what now

swift crag
#

This will allow the game's framerate to dip in exchange for faster reading of the scene data

#

Note that this won't do anything to the hitch that you get when a scene activates

#

That does look useful, though. I might switch that to "High" when the player hits Start

stuck palm
swift crag
#

At that point you could just load the scene synchronously

floral viper
#

Could any of you help with this error?

rich adder
rich adder
#

looks like you manually linked the exe and its causing issues now. Go to External Tools and fix it

stuck palm
rich adder
#

@floral viper also don't crosspost

floral viper
#

mb

#

sry

#

thx for the help

coarse shore
#

guys why do i have to close unity then open it again just for the script to load

swift crag
#

well, it's happening to them right now :p

coarse shore
#

like whenever i do smth in vs code and i save it, for the changes to be implimented onto unity, i have to close unity

swift crag
#

You might have Unity set to only reload manually

#

Try hitting ctrl + R

coarse shore
steep rose
coarse shore
#

tysm

#

for helping me

#

is there a way to set space to the hand?

#

like how in photoshop and illustartor, if u hold space bar, u can use the grab

#

to mvoe around the screen

#

nvm i think i found it

steep rose
#

middle mouse click I believe

coarse shore
#

oh em gee

swift crag
#

You can also press Q to switch to the "View Tool"

coarse shore
#

tanks so much ❤️

coarse shore
#

i js found the shortcuts section

#

i shouldve looked for it myself b4 asking mb guys

spark sinew
#

hi y'all quick question how do I add two vectors? I get an error that + cannot be used between a Vector3 and something like (0,1,0)

#

if I have v as a Vector3, how do I do v+(0,1,0) ?

rich adder
#

you can certainly add 2 vectors, you just cant multiply them

languid spire
#

(0,1,0) is not a Vector3 it is a tuple.
new Vector3(0,1,1) is a vector3

rich adder
#

var tuple = (1,3,4)
var vector = new Vector3(1,3,4)

swift crag
#

A tuple is, essentially, several values glued together. They're useful...but irrelevant here

rich adder
#

lazymans struct

frosty field
#

https://hastebin.com/share/cikiweheca.csharp
so i have this script that is supposed to scale my bullets while they travel but it doesnt really work

#

removing the Time.deltaTime is making it work but its scalling too much, and it just becomes huge instead of stopping at certain size

wintry quarry
#

you know this entire for loop is going to run instantly right

#

The code after it will run after the entire loop

#

and you are doing all of this every single frame

frosty field
#

well...

wintry quarry
#

I don't see the point of the loop at all

#

If you want it to scale a little bit each frame, that's what Update is for