#💻┃code-beginner

1 messages · Page 768 of 1

eager stratus
#

With a castLength of 0 where the character is standing

wintry quarry
#

what's the goal here exactly?

eager stratus
wintry quarry
#

What's with the SKIN thing though

eager stratus
wintry quarry
#

I'm having trouble visualizing this honestly, and not sure I understand the purpose of SKIN or this Approximately check

#

by definition a raycast won't detect things further than the max distance you use in the raycast call

eager stratus
wintry quarry
#

why not?

#

where is the RB position? Where's the pivot of the object in relation to its colliders?

eager stratus
wintry quarry
#

if (Physics.Raycast(rb.position + Vector3.up * SKIN, Vector3.down, out RaycastHit metaHit, groundingMask)
In fact I'm pretty sure you plugged your layermassk into the maxDistance parameter here

#

which is a common error

eager stratus
wintry quarry
#

yes

#

You can check by hovering over it in your IDE

eager stratus
wintry quarry
#

What is this for, a grounded check?

eager stratus
verbal dome
#

I'd visualize the ray/hit with Debug.DrawRay/DrawLine

wintry quarry
#

Yeah ^ you should definitely do this

verbal dome
#

(Or physics debugger)

wintry quarry
#

and double check your layermasks etc, since we know now you had it in the wrong parameter spot

eager stratus
wintry quarry
#

it would be nice to see screenshots of the game/scene view alongside the actual code here

eager stratus
#

It's touching the ground. It just spawned at this point. That's why castLength is zero

#

I'm casting from a spot that is intended to be Vector3.up * 0.01f higher than that point and casting it straight down

#

Then seeing if that length minus 0.01f is approximately equal to the castLength which is zero

wintry quarry
#

That's definitely a problem

eager stratus
#

It's just something to compare hit.distance to

#

Or rather metaHit.distance

wintry quarry
#

The best thing to do would be just to do a raycast from the center of his body down slightly longer than half his height

#

so if he's 2 units tall, do the cast from the center down 1.01 units or something like that

#

There's no need to be doing this distance comparison stuff

eager stratus
#

This is the code once again


if (Physics.Raycast(rb.position + Vector3.up * SKIN, Vector3.down, out RaycastHit metaHit, groundingMask) && Mathf.Approximately(metaHit.distance - SKIN, castLength))

{ grounded = true; }

else { grounded = false; }

if (!grounded) { print((metaHit.distance).ToString() + ", " + castLength + ", " + Mathf.Approximately(metaHit.distance - SKIN, castLength)); }```
wintry quarry
#

you still have groundingMask in the maxDistance slot

#

It's also not clear what hit.point is infloat castLength = hit.point.y - rb.position.y;

#

the result of some other raycast?

eager stratus
# wintry quarry you still have groundingMask in the maxDistance slot

Ok


if (Physics.Raycast(rb.position + Vector3.up * SKIN, Vector3.down, out RaycastHit metaHit, 10, groundingMask) && Mathf.Approximately(metaHit.distance - SKIN, castLength))

{ grounded = true; }

else { grounded = false; }

if (!grounded) { print((metaHit.distance).ToString() + ", " + castLength + ", " + Mathf.Approximately(metaHit.distance - SKIN, castLength)); }```

It's still giving me the exact same result
wintry quarry
#

Well yeah it's not going to change the distance at which the raycast hits

#

The issue is this whole Mathf.Approximately(metaHit.distance - SKIN, castLength)) business in the first place

#

just get rid of that

sour fulcrum
wintry quarry
#

and use maxDistance as intended

eager stratus
verbal dome
#

Either you are overthinking it or we aren't getting it

wintry quarry
#
grounded = Physics.Raycast(rb.position + Vector3.up * halfPlayerHeight, Vector3.down, out RaycastHit metaHit, halfPlayerHeight + 0.01f, groundingMask);```
#

this is assuming the player's pivot is actually at his feet^

eager stratus
wintry quarry
#

if it's in the center of his body it would be:

grounded = Physics.Raycast(rb.position, Vector3.down, out RaycastHit metaHit, halfPlayerHeight + 0.01f, groundingMask);```
dry anchor
#

Hello, I'm new to unity and programming in general. I have completed a few courses that utilized the old input system, but now I'm trying to use the new input system now since I've heard its better. But I'm struggling a bit, specifically with code arrangement and optimization. I'm wondering if there is something that I'm doing severely wrong in my project thats causing a major bottleneck (project is compiling signifantly slower than usual). All I have in the scene right now besides the standard objects unity provides (main camera, directional light, and global volume), is a plane object acting as my ground and a cube for my player. And I only have one script as of right now for my player. Any help would be greatly appreciated. Here is my code: https://paste.mod.gg/lfcbhvwcznvo/0

ivory bobcat
#

It really depends on what's the actual limiting factor.

dry anchor
#

Because tbh I'm not entirely sure what I'm doing with it yet still lol

ivory bobcat
#

How much slower is it and what's actually loading? You ought to get that loading pop-up that would state what's actually being processed atm

dry anchor
#

I think I may have used the wrong term. I'm not talking about the code compilation time, but the scene compilation time when you press the play button. Which I think the code is impacting

#

Went from like 5 seconds max to like 15 seconds

twin pivot
#

15 seconds isnt that bad

dry anchor
#

It is when you're project is basically empty

#

I guess I can try to close out of some other programs and hope that helps unity run faster. Doesn't sound like its bad code or anything

teal viper
#

You could use the profiler to see what takes most of the time. Maybe the logs have info on that too.

#

!logs

radiant voidBOT
# teal viper !logs
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

slender nymph
dry anchor
slender nymph
#

provided you read that information and understand what it means, you can. otherwise you just have to deal with it

teal viper
#

Domain reload timings are logged in the logs. Could maybe have a look to see what takes most time.

tender mirage
#

I believe there was a Mathf function that checked if a variable was really close to a number?

midnight plover
#

Approximately

tender mirage
#

You can use that function and combine that with Mathf.Round to avoid annoying numbers

onyx geyser
#

!code

radiant voidBOT
onyx geyser
#

coming back to this, trying to figure out why I can press W and D and move in those directions, but can't move in A or S

 if (Input.GetAxisRaw("Vertical") == 1)
 {
     rigidBody.AddForce(transform.TransformDirection(0, 0, force * Time.deltaTime));
     Mathf.Clamp01(force);
 }
 else
 {
     rigidBody.linearVelocity = Vector3.zero;
 }   
 
 if (Input.GetAxisRaw("Horizontal")  == 1)
 {
     rigidBody.AddForce(transform.TransformDirection(force * Time.deltaTime, 0, 0));
     Mathf.Clamp01(force);
 }
 else
 {
     rigidBody.linearVelocity = Vector3.zero;
 }
#

I tried this before, and got to it work, but it turned into 4 seperate if else lines

#

and i had to use GetKey

#

and use the corrosponding key

#

But i want to be able to use controller, so i'm trying to figure out how to use the axis

#

my theory is that it's because it's not going in -force when using negative buttons

midnight plover
onyx geyser
#
public class Movement : MonoBehaviour
{
    public int force = 1000;

    /*[Range (0f, 100f)]
    public float tSpeed = 50;*/
    Rigidbody rigidBody;



    

    void Start()
    {
        rigidBody = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    private void Update()
    {
        Mathf.Clamp01(force);
        var horiz = Input.GetAxisRaw("Horizontal");
        var vert = Input.GetAxisRaw("Vertical");
        Debug.Log($"horiz {horiz}");
        Debug.Log($"Vert {vert}"); 

    }

    private void FixedUpdate()
    {

        

        

        if (Input.GetAxisRaw("Vertical") == 1)
        {
            rigidBody.AddForce(transform.TransformDirection(0, 0, force * Time.deltaTime));
            Mathf.Clamp01(force);
        }
        else
        {
            rigidBody.linearVelocity = Vector3.zero;
        }   
        
        if (Input.GetAxisRaw("Horizontal")  == 1)
        {
            rigidBody.AddForce(transform.TransformDirection(force * Time.deltaTime, 0, 0));
            Mathf.Clamp01(force);
        }
        else
        {
            rigidBody.linearVelocity = Vector3.zero;
        }

    }
}

#

full code

#

I am debugging it, it does respond to me pressing S and A

#

but it simply will not go in those directions

#

don't worry about that mysterious clamp at the top, i have yet ot remove it because i'm still figuring this one out

#

i'm still fairly new

midnight plover
#

Just read your code carefully. Describe what it does to your velocity. Just because your horizontal value is changing the force, what does your vertical one do?

#

if you do not hit a button/key

onyx geyser
#

if I don't hit W or D, it won't move (vertical and horizontal reacts the same)

midnight plover
#

right, what does your code do when you do not hit w or d?

onyx geyser
#

now that you point it out, is it just that because the force is not meant to be negative, it automatically uses the else scenario even when I use A and S?

#

because if i'm not pressing W or D, it stops

midnight plover
#

you are setting your velocity hardcoded to 0,0,0

onyx geyser
#

linearvelocity right?

midnight plover
#

So if you hit horizontal input, your vertical one is still killing the movement in the next fixed update frame

onyx geyser
#

and because it's killing input, it's pretending like it's not being pressed?

midnight plover
#

no, its stopping your rigidbody

onyx geyser
#

might have to go a little deeper, not sure i'm getting it.

#

because would A and S be -1?

midnight plover
#

you tell me. Thats why I said, debug your getaxisraw

onyx geyser
#

well, it is -1

#

in the debugger

#

it's being pressed

midnight plover
#

so == 1 wont work

onyx geyser
#

that's the part??

#

i thought it was something entirely different

midnight plover
#

thats ONE part that might stop your code from working

onyx geyser
#

ok so I pulled that while search of a way to make a float do a bools job, uhh..

would you be willing to help me understand what that was?

midnight plover
#

firstly, you want to be sure, that both inputs are being accepted. so you can have either a check for 1 and -1 or you could transform the getaxisraw to be always positive, so == 1 works for both scenarios

onyx geyser
#

well, i know both inputs are being accepted, so if i set it to 0, wouldn't it stop moving?

#

do i need to get 2 more if else commands in order to make this work

#

with -1

ivory bobcat
midnight plover
#

I mean that your if statement accepts both 1 and -1. so you either can write

if(MyInputValue == 1 || MyInputValue == -1)

or you could write

if(Mathf.Abs(MyInputValue) == 1)
or even better
if(Mathf.Approximately(Mathf.Abs(MyInputValue)) == 1)

Just written here in chat, so check the syntax 😄

ivory bobcat
#

Horizontal being checked after vertical would be able to recover it's added force but vertical velocity would always be zero if horizontal is false

midnight plover
#

and even if it works for the fixed time rate, it still wont have the result you would expect from adding force, when resetting it in the next frame

#

But as a follow up on my suggestion, you might end up in another code anyway as soon as you want your input value to be considered as direction for your force

ivory bobcat
onyx geyser
#

wait, maybe i'm dumb, but using Keys WASD would have the same affect as Updownleftright? right?

midnight plover
#

You might want to store the linearVelocity after adding the force and then only control the axis you want to control to 0 when not pressing any button for either one of the directions

ivory bobcat
#

It might be better to cache your input and do a single check later to see if any input was pressed at all before setting velocity to zero:```cs
int vert = Input.GetAxisRaw("Vertical");
int hori = Input.GetAxisRaw("Horizontal");
if (vert > 0)
{
rigidBody.AddForce(transform.TransformDirection(0, 0, force * Time.deltaTime));
}
else if (vert < 0)
{
rigidBody.AddForce(transform.TransformDirection(0, 0, -force * Time.deltaTime));
}
if (hori > 0)
{
rigidBody.AddForce(transform.TransformDirection( force * Time.deltaTime, 0, 0));
}
else if (hori < 0)
{
rigidBody.AddForce(transform.TransformDirection(-force * Time.deltaTime, 0, 0));
}
if (vert == hori == 0)
{
rigidBody.linearVelocity = Vector3.zero;
}
else
rigidBody.linearVelocity = Vector3.ClampMagnitude(rigidBody.linearVelocity, force);

onyx geyser
#

I feel like i'm understanding more than I did before because of the my lessons, but I think i'm still confunes on a fair bit of things

midnight plover
#

But you want both buttons to work? W/S and A/D ? or did I get this wrong?

onyx geyser
#

yes I want to use both WS and AD, but am only capable of using W and D

midnight plover
#

yes, so you need to transform your negative axis value to positive to not need to check for two values. Thats what I wrote up there

#

I am sure dalphat can adapt the code to use mathf.abs quickly here 🙂

onyx geyser
#

would that just be a seperate if statement before the getaxis statements

#

careful dalphat, I may ask you how it all works for clarification if you do

midnight plover
#

its just the bool lines changing the

Input.GetAxisRaw("Vertical")

to

Mathf.Abs(Input.GetAxisRaw("Vertical"))

and same for horizontal

#

Mathf.Abs will turn your values into absolute numbers, always positive

onyx geyser
#

so they'll always be 1 and 1? not -1 and 1?

#

which, don't I want -1 and 1?

#

since negative utilizes -1

midnight plover
#

the bool check will check for 1 and 1, but the input value is of course -1 and 1. You just transform it in that line to avoid two if statements

onyx geyser
#

so it'd be something like if (Mathf.Abs(Input.GetAxisRaw("Vertical") == 1)
{

#

like that?

#

still a little confused on.. how that'd work

midnight plover
#

you are missing == 1 in your example

onyx geyser
#

cannot convert from bool to float

midnight plover
#

basically this line

if(Mathf.Abs(Input.GetAxisRaw("Vertical")) == 1)

says. If the absolute value (the always positive one) of your input axis (which can be between -1 and 1) is 1, the condition is met.

onyx geyser
#

ohh ok I see, so what's the == 1 for in this case if it's already checking for an absolute value, still got the issue of cannot convert bool to float

midnight plover
#

bool to float? where?

onyx geyser
#

I am big dumb dumb, Parenthesis was in wrong spot

midnight plover
#

😄

onyx geyser
#

time to see if it works as intended.

#
if (Mathf.Abs(Input.GetAxisRaw("Vertical")) == 1)
        {
            rigidBody.AddForce(transform.TransformDirection(0, 0, force * Time.deltaTime));
            Mathf.Clamp01(force);
        }
        if (Mathf.Abs(Input.GetAxisRaw("Horizontal")) == 1)
        {
            rigidBody.AddForce(transform.TransformDirection(force * Time.deltaTime, 0, 0));
            Mathf.Clamp01(force);
        }
        else
        {
            rigidBody.linearVelocity = Vector3.ClampMagnitude(rigidBody.linearVelocity, force);
        }
#

well,

#

A and S work, just not in the right direction

#

so that's at least a step in the right direction

midnight plover
#

Please use code tags 😄

onyx geyser
#

will try to

hexed terrace
#

!code

radiant voidBOT
onyx geyser
#

so changing both negatives into positives just makes them go in the positive direction right?

#

because that seems to be what it's doing

midnight plover
onyx geyser
#

..alright, so, how would I go about assigning direction, would I just copy and paste the if and make to more if's

#

and set the 1 to -1?

#

lemme see

midnight plover
#

store your if statement into a bool, as dalphat suggested. and store your input correct values (not absolute) into two floats you can reuse then

onyx geyser
#

i feel like at this point my original code probably worked the same and just needed to be cleaned up

#
public class MOVEFORWARD : MonoBehaviour
{

    Rigidbody Rigidbody;
    [Range(15000f, 50000f)]
    public int force;

 


    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        Rigidbody = GetComponent<Rigidbody>();
    }

    public void FixedUpdate()
    {
        

        
    }
    // Update is called once per frame
    void Update()
    {

        Mathf.Clamp01(force);
        Rigidbody.linearVelocity = new Vector3(0, 0, force);
        if (Input.GetKey("w"))
        {
            Rigidbody.AddForce(transform.TransformDirection(0, 0, force * Time.deltaTime));
        }
        else
        {
            Rigidbody.linearVelocity = Vector3.zero;
        }
        
        if (Input.GetKey("s"))
        {
            Rigidbody.AddForce(transform.TransformDirection(0, 0, -force * Time.deltaTime));
        }
        else
        {
            Rigidbody.linearVelocity = Vector3.zero;
        }

        if (Input.GetKey("a"))
        {
            Rigidbody.AddForce(transform.TransformDirection(-force * Time.deltaTime, 0, 0));
        }
        else
        {
            Rigidbody.linearVelocity = Vector3.zero;
        }

        if (Input.GetKey("d"))
        {
            Rigidbody.AddForce(transform.TransformDirection(force * Time.deltaTime, 0, 0));
        }
        else
        {
            Rigidbody.linearVelocity = Vector3.zero;
        }



    }
}
#

a lot of clean up

#

i can get rid of probably all of those vector3.zero's

#

except for the final one

onyx geyser
midnight plover
#

add force in update() for example is not something you should do.

onyx geyser
#

yeah, realized that while I was looking back over it

#

can't readd it to the character now though, for some reason it has decided it no longer works even though I just used it

midnight plover
#

Your console will most likely fire an error

onyx geyser
#

you'd think

#

it was an error with a completely different script

real thunder
#

is there something to clear console through code?
Debug.ClearDeveloperConsole(); don't do it at least for regular logs

honest ermine
#

can someone DM me and help with adapting a GI script to VR? the onyl problem is renderTextures not beign set up right and me being dumb
been trying to fix this for 7hrs now

midnight plover
#

a quick google search will tell you what to do

midnight plover
real thunder
grand snow
#

Not everything in editor is exposed for us to use

sour fulcrum
#

because they are corwards

midnight plover
#

Also wondering why you would want your console log to be cleared in the middle of script execution

real thunder
#

in short I don't want to care about proper logging yet

#

so I shoved a bunch of debug logs inside a long method I want to check but it getting executed pretty frequently

midnight plover
#

Well, then clearing the log is not the issue 😄

rocky wyvern
#

the actual solution takes less effort that trying to clear the logs all the time

real thunder
#

are you sure about that
because I just copypasted random code (which may cause mild memory leak by creating objects each time used? but whatever) and it works

nimble apex
#

is there a constant that is hooked onto assets? i need something that are shared among all kinds of assets(e.g meshes/animations/images/textures/materials)

real thunder
#

yeah I doubt that making logging out properly would take more time than doing what I did but I would have to go get distracted out of what I do right now and learn something else

timber tide
#

what's the use case

rocky wyvern
#

might be edge cases but they probably all inherit from Object

nimble apex
#

im migrating SO data into cloud save, but multiplayer side coding isnt the problems here, my question is, i need a reference, or a constant that can refer back to the exact asset in the project

#

because no way i will throw the exact model/material inside the backend right?

real thunder
#

addressables something something?

timber tide
#

generate your own GUID, or during editor serialize the asset ID via on validate

rocky wyvern
#

it's always unique

sour fulcrum
#

not in the longterm

#

you'd need some guid like mao said

rocky wyvern
#

why not

sour fulcrum
#

you'd have to look at how this is used on full but boss room sample implements that kind of idea https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Infrastructure/NetworkGuid.cs

GitHub

A small-scale cooperative game sample built on the new, Unity networking framework to teach developers about creating a similar multiplayer game. - Unity-Technologies/com.unity.multiplayer.samples....

rocky wyvern
#

if i understand correctly he will keep all assets in the project

sour fulcrum
rocky wyvern
#

shame

real thunder
#

I wish I could comprehand what's the issue is, I can't help but curious

#

I know that SO is a scriptable object, what is the issie of putting it onto cloud save?

nimble apex
#

but , what if the texture is huge? or any other highly complicated datatypes

sour fulcrum
#

how to generate a unique value that you can "permanently" associate with an object so if i say like "FSEFR4TR4FGFGSD" that will always* mean say Crop_Ice_Harvest.png

nimble apex
#

and thats the guid were talking about

#

a constant that needs to be immutable in any situation

#

so when i grabbed the data, i can use that constant to find the asset in my project

real thunder
#

so this is how to use cloud properly

sour fulcrum
#

the concept of it is a part of it yes

#

generally in networking a lot of stuff is too big to send over the network, so you need to find a way to send smaller info that communicates the same thing

#

eg. instead of an object in a list you just send the index

timber tide
#

networking is a good way to learn how to make an actual save system that's for sure

#

optimized at that

real thunder
#

yeah I was just getting away with small size assets and no thinking

real thunder
nimble apex
real thunder
#

I guess

nimble apex
#

but if ur game got something that is larger than 10mb, i dont think its suitable for u to stuff the whole thing into backend

real thunder
#

since I only did small things...

#

I just convert all save data in a single long string lol

#

almost as optimized as a JSON (I mean better but it's just a string)

#

which means it's bad but fine for small things

#

to take my chance I ll ask here what things are better

#

for saves I mean

#

like if u got lists of inventories and some transforms to save

grand snow
#

json is not "optimised", binary serialisation formats are better

#

protobuf and bebop are examples

nimble apex
#

i think json is more universial/common and compatible to most of the designs?

#

thats why its popular

grand snow
#

to save data for your own program, compatibility isnt a concern

grand snow
#

to store data you expect to be used elsewhere, then it matters

real thunder
#

I was using string at one project and JSON at another because well it's a web game so

grand snow
#

some games even use sqlite for save data due to its efficency and speed

real thunder
#

just saying

grand snow
#

Ofc for web we are restricted but you can serialize to a binary blob, convert it to a "string" and store it in local storage/elsewhere.

real thunder
#

makes sense tho I can't figure out what to use to do that convertion

real thunder
#

I suppose a string is a binary blob internally right

grand snow
#

most common way is to a base64 string

real thunder
#

interesting

nimble apex
#

i think my way to create GUID is using sha256 to hash the asset name

grand snow
#

anyway as a beginner dont go trying all this if it confuses you too much

grand snow
nimble apex
grand snow
#

you would generate a new guid and use that... thats it

sour fulcrum
grand snow
#

^ yes use this

real thunder
real thunder
#

tho I guess they keep it simple for modders

nimble apex
#

ty i will check on it 👍

desert shard
#

Hey everyone! I’m Aaryash, pretty new to Unity and currently working on developing educational games for the Meta Quest 3s. I’m here to learn, explore, and hopefully get some guidance or insights from you all to help me with my research and project development. Would really appreciate any tips, resources, or experiences you can share!

midnight plover
# desert shard Hey everyone! I’m Aaryash, pretty new to Unity and currently working on developi...

Sorry to say, but this server does not work that way. You can come here with a question related to the channel you are asking in (in this case, paste your code and ask where you are stuck for example). And then you wait for answers to come in 🙂 A lot of people here are employed devs and hanging out on discord meanwhile, so we all pick our time share quite carefully. Welcome and feel free to ask anything, if its related to code in here or search for other channels. If you dont know exactly where to ask, just ask in #💻┃unity-talk and someone might tell you a direction where to go or answer your question there 🙂

heady token
#

Hey guys, I'm creating a movement controller that'll apply force to the character in WASD directions. The difference from regular solutions is that I need it to work reliably with different shapes. For example walking around sphere, I expect the character to be pulled down to vector -y (towards the ground), that's easy. But determining the right and left reliably seems more of a challenge.
It should work something like in Super Mario Galaxy, but character is ball (the physical model)

Or for example, walking on the sphere from inside out, on the walls. If the camera looks down on the character from atop, W should mean go up, if I look forward from the character, W should mean forward.

Can you guide me in direction of what methods I should implement to get this going?

#

I could add a raycast, for example, for forward and down, but then the ball is going to rotate, so that might not be it.
A collision normal sounds like the solution, but it only gives me vector Y, so I can't reliably get X or Z direction.

#

I'd really appreciate help on this one

#

Basically, my game is going to be a game where you're a droplet moving accross the inner sides of bottle. Camera will be top down view.
But also, there may be situations where you're on bottom of the bottle, or on some other surface

midnight plover
#

I am still trying to understand, what exactly you trying to achieve. This sounds like 5 different movement controls in one

real thunder
#

what is your point of reference anyway
if it's camera use camera oritentation
if it's character use it's oritentation

heady token
#

Hmm.
Super Mario Galaxy is the closest

midnight plover
#

It sounds a bit like a sticky ball, that should be rolling on everything in the world

wintry quarry
heady token
#

That easily?

midnight plover
heady token
wintry quarry
midnight plover
#

So lets imagine a huge pipe and you can run from ground into a looping movement, your issue is, that for example going right will eventually turn into going left, because force is still going right relative to the characte rbut your camera view shows the ball rolling left on the top of the pipe

heady token
#

I've previously tried implementing a similar solution for my other prototype, and there were some issues, like the ball rotating in to the right (torque) when pressing D and looking down on it.
That may be a specific issue that needs fixing, but it seems to me, maybe there's more robust solution

wintry quarry
midnight plover
#

Do you want your ball to stick to a ceiling too, for example?

heady token
#

But that's gravity, -y 9.8 for example.

midnight plover
#

the question is, do you need gravity?

heady token
#

No-no. Let me explain to you.
So on the wall, for example, I expect the ball to start rolling to the right relative to the wall. But it starts rolling to the right relative to the ground, because the Right from camera is pushing 90 degree right, while the wall may be outwards.
Or pressing W will push the ball INTO the wall, do you get me?

heady token
midnight plover
#

I am just thinking, if you could just add force into the direction you are moving your direction vector.

#

But I guess your issue, you want to go up but also want to go forward

heady token
#

My issue is that, I'd say, when looking at the character, I may not be looking perfectly forward from it's pov, but I still may want it go up "forward" relative to itself
So the W may mean forward, but it may also mean Up. It sounds like camera movement may be what I need, but in my experience it has introduced quite a few issues. Let me show you if I can catch one.

midnight plover
#

I guess you have no other option, if you dont want to use two joysticks to move 😄 But just looked at mario galaxy and from what I see, its mostly spherical gravity or hard coded rotated gravity. So if you jump over a ledge, it turns and moves gravity to another direction

heady token
#

How do they handle the direction of the charcater in Mario, what do you think?

midnight plover
#

Relative to the camera

#

Projected on the ground he is on

heady token
#

Here is one of the issues introduced by it.
So, when I go W or S, it works nice. It goes up or down. (Also in this example gravity is always downwards, since it's my other prototype).
But when I go D, it doesn't rotate the ball relative to the wall. It starts rotating the ball relative to ground

#

This is how it does now

#

And this is how it should be doing

midnight plover
heady token
#

So you think that's more of a bug than fundamental issue with the projection?

timber tide
#

pretty sure direction is always relative tot he camera in 3d mario games

midnight plover
#

If you look at mario again, the character is rotated, right? It always orients its down vector to the plane he is on. Your ball is not I assume

heady token
#

Hm, interesting.

midnight plover
#

thats why rotation on D will rotate like the ball is in global space

#

so you gotta subtract/add the orientation of the plane the ball is on from the calculation to rotate the character

heady token
#

This is how my code looks like in regards to this


        Vector3 cameraForward = assignedCamera.transform.forward;
        Vector3 cameraBack = -assignedCamera.transform.forward;

        Vector3 cameraRight = assignedCamera.transform.right;
        Vector3 cameraLeft = -assignedCamera.transform.right;

        // Project the force onto the plane perpendicular to the ball's up vector
        Vector3 projectedForceForward = Vector3.ProjectOnPlane(cameraForward, Vector3.up).normalized;
        Vector3 projectedForceRight = Vector3.ProjectOnPlane(cameraRight, Vector3.up).normalized;
        Vector3 projectedForceLeft = Vector3.ProjectOnPlane(cameraLeft, Vector3.up).normalized;
        Vector3 projectedForceBack = Vector3.ProjectOnPlane(cameraBack, Vector3.up).normalized;
        #endregion```
#

But I guess it might not tell you everything?

midnight plover
#

How are you moving your ball? With forces?

midnight plover
heady token
#

Both

midnight plover
heady token
#

Interesting

#

But the projection is correct?

timber tide
#

My experience with parenting and applying relative forces never been that positive really.

#

Kinematic Character Controller has a lot of this behaviour btw. You can probably go download it and rip it apart to get a better idea if you're curious

sour fulcrum
heady token
#

Looking at my code, one thing that concerns me, it feels like I'm never actually projecting the up or down?

#

Like, here ```Vector3 cameraForward = assignedCamera.transform.forward;
Vector3 cameraBack = -assignedCamera.transform.forward;

Vector3 cameraRight = assignedCamera.transform.right;
Vector3 cameraLeft = -assignedCamera.transform.right;```

#

So I never use Y basically?

#

Would that cause the issue I'm having?

#

At the time when creating the ball controller the resources were pretty scarce

#

Anyways, thanks for the help guys. I'm still open to suggestions of how it could work in a more complete way, but I'll go try something I guess

final sluice
#

I'm trying to make a 2d RTS top down game, Can someone give me some pointers to what I should research and learn to make them ?

rich adder
#

I believe even codemonkey 🙄 has a bunch of rts 2d stuff you can learn about

final sluice
#

thank you

tender mirage
#

i think there's something wrong with my visual studio.

rich adder
#

is that 2026?

keen dew
#

If you look closely the first i has an accent (´) on top of it (í)

grand snow
#

wow good spot

rich adder
#

ow foreign keyboard moment

grand snow
#

unicode was a mistake, ascii only

sour fulcrum
#

not beginner code

scenic perch
#

Why is it when I extract a method from my code (2nd image) it changes into the first image's code rather than just simply saying "HandleShoot();" ?

#

Following a course and theirs ends up different from mine when I extract my method, pretty sure it still works, I just want to know why it does that

rich adder
naive pawn
#

probably just to handle the return "correctly"

scenic perch
#

Alright

rich adder
#

btw ?. doesn't work proper on UnityEngine.Object / Components

#

use the == null check
or better yet , TryGetComponent

naive pawn
#

(in general you shouldn't rely on those kinds of tools to be exactly what you expect - they're there to save time, not to replace work. oftentimes you will have to tweak various suggestions to get exactly what you want)

naive pawn
#

(in "technically works" terms, not saying ?. should be used)

tender mirage
#

and annoying

#

i miss having the 2022 version

naive pawn
#

you could just get the 2022 version if you want

tender mirage
#

It's support ended just recently right tho?

#

i kept having popups

#

and couldn't use it anymore

tender mirage
naive pawn
rich adder
# naive pawn considering the specific usage here, it would "work" for the possible situations...

I guess its more of a edge case maybe ? not sure
the docs just says

The null-conditional operator (?.) and the null-coalescing operator (??) are not supported with Unity Objects because they can't be overridden to treat detached objects objects the same as null. It's only safe to use those operators if the checked objects are guaranteed to never be in a detached state.
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Object.html

#

idk what detached state means tbh lol

eternal needle
rich adder
#

ah ok

teal viper
rich adder
#

anyway I'd rather use TryGetComponent when the component is on this object / not a parent / child

tender mirage
naive pawn
#

so i think it'd technically work fine. probably still not good practice though

eternal needle
# rich adder ah ok

if you cache the result, destroy the object, then check with ?. thats when it will give errors. so you can use it safely but theres just no point in mixing it between using that and checking for null properly

rich adder
#

gotcha

teal viper
tender mirage
sour fulcrum
naive pawn
naive pawn
tender mirage
teal viper
#

I mean, we still have projects that use vs 2017 at work. Even if it's out of support, it's not a big deal.

slender nymph
naive pawn
#

yeah there's this notice

Older versions require an active Visual Studio Subscription.
but 2022 isn't included in the following list

slender nymph
#

I wouldn't expect 2022 to go out of support for at least another year. it's supposed to get 5 years of regular support, then 5 years of extended support (which i think only enterprise gets access to?)

teal viper
tender mirage
slender nymph
#

i mean, that's what the insiders program is basically for, to find all those bugs and squash them. make sure to report the ones you do fine

teal viper
tender mirage
tender mirage
#

as well as the one most probably have experienced, when you create a new script it just doesn't automatically show up

#

in vs

grand snow
#

if created in your ide it should work, otherwise unity has to update the ide project to include it

balmy vortex
keen dew
#

IsClient is false

rough granite
rough granite
acoustic arch
#

for beginning work on my 2D top downs procedural generation what would be the best approach. It works by generating 1 - 10 different areas that the player will progress through and the entire thing is called a “Loop”. Should I use noise maps? Or by pre defined map parts

timber tide
#

is this code related

rough granite
#

!collab

radiant voidBOT
# rough granite !collab

:loudspeaker: Collaborating and Job Posting

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

mild citrus
#

I am not getting any errors but the object is not becoming inactive, I checked "is trigger" please help

forest wolf
#

you have a typo, it should be OnTriggerEnter, not OnTriggerEmter

polar acorn
mild citrus
forest wolf
#

Ok, do the colliding objects have rigidbodies with the 'isKinematic' unchecked?

mild citrus
#

the invisible box holds up other boxes then the trigger makes them drop

forest wolf
#

So, I believe you need to enable some settings now. If the bodies do not have rigidbody, then they will not interact by default. You need to go to:

#

Edit -> Project Settings, then select tab Settings under the Physics

#

then in the game object tab change the contact pairs to all contact pairs:

still ingot
#

How do I rotate the Z angle of a 2D game object to the surface of another object?

keen dew
compact sandal
#

where do i ask scene related questions? (dont see a channel for it)

acoustic arch
thick tusk
#

I am having a bit of trouble understanding the state machine are there any videos someone could recommend to make me understand how I could scale, transition, between states and how root states are defined, etc...?

thick tusk
wintry quarry
#

Just conceptually? Or are you referring to some specific library or framework?

thick tusk
wintry quarry
#

I'm not exactly sure what you meant by "scale" in your original question

thick tusk
#

when you are adding new states say attack or parry I don't get how people expand the scale of the hsm.

wintry quarry
#

Just by adding states aren't you expanding the scale of the state machine?

thick tusk
wintry quarry
#

It can be complicated and it might not always fit into a clean hierarchy. But basically if you can do a thing while doing other things, that points to probably a child state.

For example "shooting" might be something you can do while walking, jumping, or crouching

thick tusk
hollow zenith
#

A lot of my ScriptableObjects have Name and Description field.
What is a common way of reusing that piece of code for all SOs that need these fields?

Should I just create ScriptableObjectNameAndDescription : ScriptableObject class?
Or maybe a struct/regular class that can be attached to it(but then you have to go through extra layer to get name/description.

wintry quarry
#

or a struct or class that you add as a field to them all

#

I will say that name exists on ScriptableObject itself already

#

(actually it comes from UnityEngine.Object)

hollow zenith
#

I use uppercase Name field so I can name my weapons, enemies, spells etc

#

lowercase name is for asset file name afaik(or object name in case of monobehaviors I think)

warm gull
#

hey folks. I have a player gameobject, I have chunk prefabs, and I have a chunk manager that I want to contain the scripts for spawning the next (adjacent) chunks as my player moves into them. I've followed these instructions (with debug.log to make sure that a triggering part works successfully, it does) but I'm unable to get the chunk prefab linked to the chunk manager in the inspector. I suspect it's a matter of trying to reference a gameobject on a prefab. I encountered this issue before but i can't remember how i made it work and im struggling to understand the fixes that google is suggesting. I'll send the screenshots of the instructions google ai gave me

#

it's the second point in step #4 that is the issue, dragging the ChunkManager gameobject into the Chunk Manager field in the inspector doesn't work because the chunk is a prefab

forest wolf
#

You should be able to drag prefab to a game object field

eternal needle
#

If youre trying to reference the prefab from the in scene object, that works fine. It sounds like youre trying to do the opposite though

forest wolf
#

Wait a second, but where is scene in that? Chunk Manager seem to be a script on the game object in the scene and the chunk is a prefab, right? Or what am I not understanding?

warm gull
#

i'll grab screenshots of my actual code

forest wolf
eternal needle
radiant voidBOT
warm gull
#

okay so, I have 3 objects

eternal needle
#

Follow the bot command linked above

warm gull
#

player, chunk manager, and then the chunks themselves which are prefabs

#

the chunk itself is whats looking for the trigger event

#

and i want that to communicate to the chunk manager object which handles spawning new chunks

#

im able to instantiate the first chunk just fine, because that happens at game start

#

the issue is getting the next ones to spawn as i go

forest wolf
#

but the reference you sent a photo of is not of type game object

#

it is on script ChunkBoundary and requires Chunk Manager

warm gull
#

yeah thats where im getting confused. in screenshot 2 you'll see where that field is made. google told me to do "public ChunkManager chunkManager" instead of "public GameObject chunkManager". so I changed it to GameObject, but then it said that gameobject doesn't have the method spawnNewChunk

#

so i have no idea what to do

forest wolf
#

Oh, you will have hard time making a game because it looks like you are missign fundamental knowledge.

#

you need to get a component from game object by doing chunkManager.GetComponent<ChunkManager>();

eternal needle
#

Don't focus on what AI is telling you. All you need is a reference to chunk manager. It seems like chunk manager is already spawning the individual chunks.. so just pass the reference. Don't reference it by type GameObject, use ChunkBoundary

eternal needle
#

Otherwise he could just directly reference the component

forest wolf
#

yeah, you are right

#

ohhhhhh wait, so I understand now. You are having a prefab that has a field and you want to drag an object you have in scene to that prefab?

warm gull
#

yes

#

and i understand that that

#

isn't how it should be done, google is telling me to reference it at runtime

#

but im confused as to how to do this

forest wolf
#

Ok, you won't be able to do that. Instead of reference, if you want to do it dirty but quick, instead of using reference do FindFirstObjectOfType

eternal needle
forest wolf
#

@eternal needle, what's wrong with my answer?

eternal needle
#

Its just unnecessary

#

Theres no world where you need to use the find functions here

forest wolf
#

I am an idiot haha, I just realized there is even simpler way, you are right

#

Can't you just set the reference in the script when you instantiate the prefab?

#

So your spawnNewChunk would have
var chunkObject = Instantiate(...);
chunkObject.GetComponent<ChunkBoundary>().chunkManager = this;

eternal needle
#

That is exactly what my suggestion is

forest wolf
eternal needle
#

Except you dont need to get component if you reference it as type ChunkBoundary, which is what I said above

forest wolf
#

oh instantiate will return you a specific script? I didn't know that, I thought it always returns game object!

#

I just learnt something interesting than, thanks! :)

warm gull
#

ill try that

eternal needle
#

You just need to make sure that all chunks are spawned using this chunk manager, so the chunk manager can always provide the reference

languid pagoda
#

is there a way to get a pointer to a unity.object?

warm gull
#

hmm, still not working. Sorry if this is frustrating.

wintry quarry
languid pagoda
wintry quarry
#

What's the end goal?

languid pagoda
#

Its a long story that is outside of the scope of this channel, is it possible?

#

To summarize it would prevent me from having to track gameobjects via something like an ID in my end user scripting language.

wintry quarry
#

Can you just use the instance id?

languid pagoda
#

so if I go from GameObject -> instance id can I go back?

#

only in the editor as far as I am aware

eternal needle
wintry quarry
#

If it's for an in game scripting engine I would just keep a Dictionary<int, GameObject> internally

#

IDK if it's stable or safe

languid pagoda
#

It will be stable and safe as long as you dont attempt to access memory that is no longer allocated.

wintry quarry
#

I'm not even sure then - what if the garbage collector moves objects around in memory

languid pagoda
#

Unitys GC doesn't move items

#

its non compacting

#

wouldn't references go stale if items moved around after a gc sweep?

wintry quarry
#

not if the references are also updated by the GC

#

these seem like GC implementation details

#

hence why I wouldn't personally mess with this stuff if I didn't need to

#

Seems like a Dictionary would be a much better/safer bet to me

languid pagoda
warm gull
# eternal needle Again, youd need to show the actual setup. This doesnt give us any indication as...

i got it working by passing the reference at runtime like google suggested because i couldn't figure out how to apply your solution in my use case. I've been trying to learn by doing, as back when I learned C++ i made very little progress by reading and only made progress when i decided to just jump in and fix problems as they came up. Most problems in unity and C# I have been able to learn from so far, but this solution still puzzles me so i'm going to go ahead and hit up the unity learn courses like you suggest before I continue on this game. I appreciate the help.

eternal needle
#

!learn

radiant voidBOT
eternal needle
#

thats the learn site though

unreal imp
#

fellas how can i do that if my bool like CanBeDestroyed is Checked it does shows a lot of options and configuration vars, but in case of CanBeDestroyed is false it doesnt show nothing like unable it

timber tide
#

Is this some serialized bool

timber tide
#

If you can't be too bothered with plugins, just make some serialized class and stick the bool at the top of it.

#

Making a serialized class will collapse the rest of the params

timber tide
#

Another idea is use a scriptable object and instead of checking the bool you can just check if the variable that contains the SO is null or not

somber temple
#

I am having a lot of issues with my code if anyone is willing to help please let me know 😭

radiant voidBOT
# eternal needle !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

eternal needle
#

particularly the last point, don't ask to ask

somber temple
#

oh sorry, thank you!

#

So, one of my university projects is to reimagine an existing 2d game so i chose undertale, but I'm having this issue where the paper bullet here is supposed to follow the soul whenever it moves, but it doesn't. It instead only follows the soul's spawn position, not the soul itself. I've tried to fix this for days and can't figure it out

#

this code snippet is like 1 of 10 i tried, all to no avail 😭

timber tide
#

props for using quaternions in 2D ;p

somber temple
#

WAIT DOES THAT NOT WORK??? 😭 every single thing i looked up used it for this

timber tide
#

I'd debug the position of this target to make sure it's actually moving, otherwise perhaps what you're targeting is not what you're expecting

slender nymph
#

yeah make sure your target is the actual scene object and not a prefab

somber temple
somber temple
slender nymph
somber temple
slender nymph
#

you need to be referencing the object that is in the scene, not the prefab. but because prefabs cannot reference scene objects, you cannot assign the scene object to your projectile prefab. so you simply need to pass the reference to the projectile from whatever spawns it

somber temple
timber tide
#

what you have there looks fine? Usually people just use eulers (which is fine for 2D)

somber temple
somber temple
#

oh wait

#

im dumb

#

disregard!

timber tide
#

you can also use Quaternion.LookRotation and ditch atan2 if you wanted too I believe

slender nymph
#

nah, that points the Z axis at the target which is not ideal in 2d

timber tide
#

if you specify up as vector3.forward, wouldnt that work, no?

slender nymph
#

seems like FromToRotation may be the better option here

timber tide
#

I do recall getting angle axis to work like this before and it worked out

somber temple
#

at least i think i followed it

slender nymph
#

show your actual code

#

!code

radiant voidBOT
somber temple
slender nymph
#

yes

timber tide
#

Ah, ok yeah you're right. LookRotation does only look at the z, I thought here was some additional params to change the forward but seems stictly to point towards the z

somber temple
#
 public BulletPathing gradePaperPrefab;
 public Transform _target;

 public float xMin = -7;
 public float xMax = 7;
 public float yMin = -4;
 public float yMax = 4;

 void OnEnable()
 {
     Vector2 spawnPos = GetRandomOutsidePosition();

     Vector2 soulSpawnPos = new Vector2(0, -3);

     BulletPathing instance = Instantiate(gradePaperPrefab, spawnPos, Quaternion.identity);

     instance.Initialise(_target);
 }
#

this is my spawner

#

hold on lemme get the other my computer is screwed up rn

#

also ignore "OnEnable" we were trying something and it technically works but we'll change it

#
 public Transform _target;
 public float rotationSpeed;

 void Update()
 {
     switch (attackType)
     {
         case AttackType.GradePaper:
             if (_target != null)
             {
                 Vector2 dir = (Vector2)_target.transform.position - (Vector2)transform.position;
                 dir.Normalize();
                 float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90;
                 Quaternion targetRotation = Quaternion.AngleAxis(angle, Vector3.forward);
                 transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
                 Debug.Log("Target position:" + _target.transform.position);
             }
             break;
     }
 }

public void Initialise(Transform target)
{
    _target = target;
}

#

that SHOULD be everything relevant to this attack's behaviour (the paper)

slender nymph
#

so provided your spawner object is referencing the in-scene target in its _target variable that should work

somber temple
#

it works now

#

thank you so much!

#

bookmarking that website that's actually so clutch

timber tide
#
Vector3 direction = target.position - transform.position;
Quaternion targetRotation = Quaternion.FromToRotation(Vector3.right, direction.normalized); //Or is it transform.right?
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);```
Think that should be fine? Need to do a 2D project again one of these days
somber temple
#

yeah now that i found out what the issue is im gonna tweak that part of the code to be much more simplistic cause there are simpler ways i was just spiraling LMAO

timber tide
#

Like I said what you are doing looks fine. I'm just seeing what else works besides abusing eulers ;p

somber temple
#

i'll go back to my og one which was just a few lines lmao

mild citrus
#

I purposely typed a code wrong to check if it's working at all on an object and there were no errors. It is ignoring all my scripts, please help

#

code say "please open a folder with a solution to debug" if that helps

naive pawn
mild citrus
#

one script is showing errors the other isn't at all

sour fulcrum
#

what errors

mild citrus
# sour fulcrum what errors

sorry I mean one is working because it's showing errors the other is not showing any errors in console. My problem is the one not showing any errors because that means it's not working at all

sour fulcrum
#

thats not necessarily true

#

what errors

mild citrus
#

Never mind it's working I don't know what I even did but now both are showing

#

I just kept messing with ui

vocal frigate
#

Hey im following a tutorial for 3d movement and i seem to have got some weird error, the error says i cant do this with a bool, however the video im following those the exact same operation
video with time stamp:https://youtu.be/PIFQbxMgT0c?t=979

In part 2 of this series, we go through animations for running, sprinting and idling states. Additionally, we make a basic enum state machine to keep track of our player's movement state.

In this series, I'll be going over beginner through advanced topics for building a complete player controller, both for 1st and 3rd person. We'll covers topi...

▶ Play video
#

can anyone help me with this?

sour fulcrum
#

you are not following the exact same operation

#

compare their line with yours

winter stratus
#

11-11 16:57:04.852 12351 19014 E Unity : DllNotFoundException: Unable to load DLL 'native-googlesignin'. Tried the load the following dynamic libraries: Unable to load dynamic library 'native-googlesignin' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "native-googlesignin" not found 11-11 16:57:04.852 12351 19014 E Unity : at Google.Impl.GoogleSignInImpl.GoogleSignIn_Create (System.IntPtr data) [0x00000] in <00000000000000000000000000000000>:0 11-11 16:57:04.852 12351 19014 E Unity : at Google.Impl.GoogleSignInImpl.. why I am getting this error in unity 6000.2.6f2 version , before it my google signing work fine

sour fulcrum
#

something is different

winter stratus
vocal frigate
cosmic dagger
vocal frigate
naive pawn
#

the syntax highlighting makes it pretty obvious imo

vocal frigate
#

i mustve missed a capital letter

naive pawn
#

you missed the () on the method call

vocal frigate
#

ah i see

sour fulcrum
#

i blame the tutorial tbh

#

its meant to be the bool

naive pawn
#

but yeah, a variable the same name as the method...

cosmic dagger
#

I was just pointing out, it's best to send the actual error message. That way, we can deduce what happened more clearly . . .

balmy vortex
#

does anyone maybe know why the for loop in enableInGameUI() doesn't actually loop through and disable the children in my slider?

keen dew
#

Well what do you have in that list?

onyx geyser
#

So i found out why My movement system wasn't responding to Horizontal and Vertical the right way

#

I think so at least

#

Active input handling was set to the new one

#

should I be using the new input handler? as someone who's new, there's a lot more for the old style by the looks of it

#

and it just seems confusing

hexed terrace
#

you can currently use either

onyx geyser
#

is the new one worth learning..?

hexed terrace
#

the new is enabled by default now, and is "better"... but I think for beginners learning adds an extra layer of complextity

#

Yes, the new one is well worth learning.. at some point

onyx geyser
#

maybe AFTER I get the old one down?

#

or at least when i'm more experienced

naive pawn
#

you don't need to learn the entirety of the old one

#

but if you have like, other stuff working (movement and physics etc), you could try looking into this, for example

#

it's more flexibility at the cost of more complexity

#

but it's definitely worth it

onyx geyser
#

because it was breaking a lot of my code to try and use, Like, I couldn't make a super simple movement system the way I thought I could, had to do a weird round about way

#

so.. pick it up once I have the basics down then?

#

"basics"

#

whatever that entails on my end

naive pawn
#

i mean, whenever you feel you want to

#

that's kinda up to you

onyx geyser
#

ok well, can I ask for an example of how the new system works and what it's purpose is? what is the flexibility?

naive pawn
#

the old system just had axes and buttons, retreived by name, right? (idk i didn't really get into it)

the new system focuses more on actions as the primary structure, and each action can have bindings (which can be changed at runtime) along with interactions or processors to modify the input or detect certain patterns

#

it's a lot more done by reference and using assets

onyx geyser
#

i'm not sure my newbie brain fully comprehends that

#

I've heard it has more complexity, but is that complexity there to shorten the process overall?

#

while the old system may use something simple, this might be able to make something a bit more complex with the same amount of lines kinda deal?

naive pawn
#

there's a default asset that has some basic bindings though

#

i don't think an amount of lines is a good comparison

onyx geyser
#

ok, maybe control then?

naive pawn
#

there's a part of it that exists outside code

#

i guess there's a part where setup is less in code and more in references/assets

sour fulcrum
#

There’s also some parts of configuration you just outright can’t do via code in the old one

onyx geyser
#

maybe i'll get it more when my projects start getting a little more technically complex

#

I don't see much reason to use it currently, as it was screwing up how I was looking at the documentation, as well as just general tutorials, and I don't quite get how useful it is currently because it sounds like it's a step above the old system in terms of neediness?

#

I may have that all wrong

#

tiny brain doesn't get it

hexed terrace
#

I got distracted and haven't read up a bit.. the old system is good for throwing in quick input.. I think the new will always take longer because it requires a bit more setup/ code. So it's worth knowing the old just for quickness in prototyping... and new for fully fledged projects

onyx geyser
#

maybe I don't have it wrong then, because the way it's described there is for a more precise correction of system management.
while the old one has a simple movement system you can utilize, you lack some of the varying control that lets you fine tune it completely
the new one lets you fine tune it far more than before as well as iron out and tighten the code up.

rope versus metal wire kinda deal?

#

takes longer to make but is stronger and useful for heavier projects?

hexed terrace
#

Input systems are nothing to do with movement, per se. They give you an input and then you take that info and do whatever you want with it.

#

The new input system has, I dunno the term.. different 'setups'? that allow you to swap quickly and easily between controls.

EG: if you were making something like battlefield, one input set would be for on foot, and you'd swap to a different input set when you get in a tank, or another different one for a helicopter.

With the old system that would be a ball ache to code

onyx geyser
#

ahh, I think I get it, it makes the process smoother to some extent, things like switching weapon, switching camera types, switching out controls?

#

i heard somewhere it lets you select something by name specifically?

#

probably class?

#

it's still lightly confusing

hexed terrace
#

that makes no sense to me

onyx geyser
#

guess i'll cross that bridge when i get to it

#

which may be soon

#

one of my goals with this first project is to have a terrain switch, since the idea is to "travel between past and present"

#

or maybe that'll actually be super simple

onyx geyser
#

i'm just.. kinda repeating back what I think I hear

naive pawn
#

i can't really comment, i never used the old system much

#

i don't really like magic strings

hexed terrace
#

the old didn't have to use strings

#

Input.GeyKey(KeyCode.W)

#

but then you're hard coding instead

naive pawn
hexed terrace
#

yes, 'tis why it's not very good and things like InControl/ ReWired exist

naive pawn
#

ive heard rebinding is something the new system does easily while the old system you'd have to make yourself?

hexed terrace
#

yup

hexed terrace
#

I believe it's sort of similar to ReWired

naive pawn
#

oh shoot, there is a thing called "scheme" in the new system but it's not what i was referring to

#

at least, i don't think so.. i was thinking of like, switching action maps

hexed terrace
#

yeah, that sounds right. I can see clearly in my head the code ActionMap

naive pawn
#

out of curiosity - how would you go about rebinding in the old system, briefly?
would it just be checking every keycode individually and binding them to, essentially, your own inputactions?

hexed terrace
#

I dunno how you'd do it and allow the player to rebind freely.

But brainstorming the BF example above with set controls (needing to rebind between inf/veh) I think one of the better ways to do it would be to have a class per input type. InfentryInput TankInput HelicopterInput and swap between the active one .. maybe

naive pawn
hexed terrace
#

infentry /vehicle

#

BF being Battlefield

naive pawn
#

ah

onyx geyser
#

I am trying to teach myself some gravity stuff and accidentally made an autobounce

#

not the intended goal, but, I am not displeased

#

so it turns out, bouncing WAS infact the right direction, I just needed to do -transform.up

#

instead of standard transform.up

fluid ether
gusty forge
#

hey guys quick question, how do I make it so a rigid body is easily moved by an object it's connected to (using a joint) like it's nothing?

naive pawn
#

not the right channel

gusty forge
#

supposed to work if it has 0 mass but it's not possible to set rigid bodies' masses to 0 sadly

gusty forge
#

where do I ask

naive pawn
#

this is why you don't crosspost..

gusty forge
#

thank you

gusty forge
naive pawn
#

exactly, don't crosspost please

onyx geyser
#

got a question regarding falling.
so, I got falling to work as intended, but now i'm running into the issue where the player can "glide" off a ledge, and I'd like to have a separate animation for falling that's noticable.
i'm kinda hoping (since i'm using an if else to check if the player isGrounded, and both if and else are returning the correct statements.) that I can use Else to stop player speed entirely until they qualify for "grounded", is that possible or do I have to learn how to use Raycast to figure this out?

naive pawn
#

what are you using to move?

onyx geyser
#

character controller

#

need to see my code?

naive pawn
#

that I can use Else to stop player speed entirely until they qualify for "grounded"
wouldn't this prevent air movement as well? or do you want to prevent that too?

onyx geyser
#

well, the way I was hoping to use it was to actually just stop the player speed rather than their controls

#

and when the grounded is checked for true, they'd get their speed back

#

so no, it doesn't affect any of that, kind of a weird way to loop back without touching Horizontal and Vertical

#

the issue I'm running into is, I can't give the players speed back upon landing on ground

naive pawn
#

well, are you saving it?

onyx geyser
#

yeah

#

wel

#

oh you meant the speed itself

#

kinda just now realized I was setting the speed permenantly

#

is there a way to only set speed temporarily?

#

that's a dumb question actually i think, i can just use floats to change the speed

naive pawn
#

you've lost me

#

im not psychic, i don't know the context of your code lol

#

you can send it if you're going to refer to it, sure

#

but mostly i don't really get what you're going for exactly

onyx geyser
#

!code

radiant voidBOT
naive pawn
onyx geyser
#
public class ThirdPersonMovement : MonoBehaviour
{
    //movescript
    public CharacterController controller;
    public Transform cam;

    public float speed;
    public float originalSpeed = 6f;
    public float fallSpeed = 0f;

    public float turnSmoothTime = 0.1f;
    float turnSmoothVelocity;

    public float DashSpeed = 0.5f;

    //gravity script
    public float gravity = -1;
    float velocityY;
    


    private void Start()
    {
        //cursor
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }
    void Update()
    {

        //movescript
        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");
        Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;

        
        if(direction.magnitude >= 0.1f)
        {
            float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
            float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
            transform.rotation = Quaternion.Euler(0f, angle, 0f);

            Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
            controller.Move(moveDir.normalized * speed * Time.deltaTime);
            if (Input.GetKey(KeyCode.LeftShift))
                {
                controller.Move(moveDir * speed * DashSpeed * Time.deltaTime);
                }
        }

        //dash script


        //gravityscript
        velocityY += Time.deltaTime * gravity;
        Vector3 velocity = -transform.up * gravity + Vector3.down * velocityY;
        controller.Move(velocity * Time.deltaTime);

        if (controller.isGrounded)
        {
            Debug.Log("grounded");
            velocityY = 0f;
            

        }
        else Debug.Log("NotGrounded"); //want to stop speed and then reset it once isGrounded is true.


       
            
    }
   
}
naive pawn
#

use the large code blocks section please

onyx geyser
#

?

hexed terrace
#

!code

radiant voidBOT
naive pawn
#

...you summoned the bot just to get backticks?

onyx geyser
# radiant void

so.. would I just paste the Link it makes for me, in here?

naive pawn
onyx geyser
#

...while i'm falling, I want Speed (the players speed upon an input being pressed), to be reduced to 0, then when I am grounded, for that Speed to return back to it's original value, so the player does not move while falling, and can move while grounded.

#

i actually managed to figure it out

#

a bit proud of myself, a bit more simple than using raycast I think

naive pawn
#

btw, you shouldn't have multiple Move calls in the same frame

onyx geyser
#

oh?

#

is there a particular technical reason for it?

naive pawn
#

CC expects 1 move per frame/update

onyx geyser
#

so for gravity, what should I use instead?

#

or, well, better question is, what would you change?

#

because it seems to work fine at the moment

#

but i'm always open to finding a way to make this easier

naive pawn
polar acorn
# onyx geyser is there a particular technical reason for it?

Character Controller determines its collisions based on what it hits on the last Move call, which includes setting isGrounded. If you call Move multiple times, the first one's collisions are effectively ignored, since nothing will have the time to actually read that collision before it's overwritten.

#

The usual symptom of this is either never having isGrounded set at all, or having it rapidly oscillate between grounded and not every frame

onyx geyser
#

huh

#

well, I haven't run into an issue with isGrounded yet

#

in fact, it works exactly as I intended it to, which for now, with my current skill level, is probably good enough

#

spending all night to try and figure something simple out is a lil exhausting, but at least this way i'll improve my general skill

marble hemlock
#

For a status effect system would it be strange for the SO for each status effect to not actually have any methods but instead have a big script that manually checks for what the last added effect (SO) was, and then goes through a list of if statements to check what to do?

#

Ex.
if list[-1] == a, do this
if list[-1] == b, do this

And then just continuing. It feels highly inefficient but its all I can think of. Just one master script to handle all status effects

timber tide
#

you can have methods on SOs if you want, sure.

#

Usually I just like to do a singleton for status effects as you'll usually be running coroutines which SOs cant do

#

It's usually a choice of a manager running those coroutines or if you like keeping it all independent then sticking those coroutines on those independent gameobjects

#

But if you do want to do like a single script for all effects, which is fine honestly, just make sure you map everything to some enum/dictionary so you can just do a 0(1) lookup to what's applied

golden junco
#

Hey, what tools or systems do you currently use for procedural generation and or NPCs, and what’s the hardest part about making them feel intentional instead of random?

mild citrus
#

How do i fix this error

naive pawn
radiant voidBOT
eternal needle
mild citrus
#

How can the script not be found

rough granite
polar acorn
rough granite
#

But should make sure that previous error has been fixed befofr you make another class

polar acorn
rough granite
rough granite
mild citrus
polar acorn
tender mirage
#

my Dictionary's key is a string. Isn't there a way to loop through it with a for loop?
Or do i have to make a brand new seperate list?


public void SellAllOres()
{
    
    for (int i = playerInventory.oreInventory.Count; i > 0; i--)
    {

        

    }


    //Update inventoryListText
    UpdateInventoryListText();

}
polar acorn
polar acorn
#

Also if you're going to post code in-line at least remove all the egregious empty space

tender mirage
#

Thanks alot.

tender mirage
mild citrus
tender mirage
#

although without literating knowledge it was impossible xD

polar acorn
#

Which you could see underlined in red if you configured your IDE

#

!ide

radiant voidBOT
mild citrus
polar acorn
polar acorn
mild citrus
polar acorn
#

are those underlined

rough granite
mild citrus
rough granite
rough granite
polar acorn
mild citrus
#

no

polar acorn
#

then configure your IDE

#

so you can actually see the errors in the code

#

and not just guess blindly at a solution for your spelling mistakes

mild citrus
#

which option of the 4 am i supposed to click I updated the app that did nothing, isn't it already installed

tender mirage
# polar acorn https://code-maze.com/csharp-iterate-through-dictionary/

That was very insightful.

How did you find the exact topic i was looking for?


public void RemoveAllItems()
{

    print(oreInventory.Keys.Count);

    //Loop through inventory length
    for (int i = oreInventory.Keys.Count - 1; i >= 0; i--)
    {

        //Gets the index of certain key
        KeyValuePair<string, int> item = oreInventory.ElementAt(i);


        print("ItemName: " + item.Key + "ItemAmount: " + item.Value);

    }
}
#

It works exactly as i wanted it to be.

eternal needle
#

its easy to find the topics with google. "loop through dictionary c#"

#

compare that to the initial question you asked, all i did was cherry pick words out of it to use in a google search. plus adding c#

tender mirage
tender mirage
icy wigeon
#

Yo I need some help with my unity project if anyone got time please @ me

fickle plume
#

!ask @icy wigeon

radiant voidBOT
# fickle plume !ask <@240256995104391171>

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

celest jay
#

How to put a string here via code?

fickle plume
kindred dome
#

anybody know why visual studio code keeps autocompleting stuff when i dont want it to?

#

like im trying to type Time.deltaTime and it keeps autocompleting to TimeOnly whenever i type the .

somber temple
#

My health bar stopped updating in game view, when i take damage it doesnt update, but it does update AFTER i stop play mode. Any ideas?


public Transform _target;

Rigidbody2D rb;

public float cinnamoSpeed;
public float gradeSpeed;
public float rotationSpeed;
private Vector2 direction;
public AttackType attackType;
public bool isCollided;
public float maxRotationSpeed;
public float rotationAcceleration;
public float followDuration = 2f;
public float destroyBoundary = 12f;
public float rotationModifier;

public bool blueAttack;
public bool orangeAttack;
public bool isFollowing;

private void OnTriggerEnter2D(Collider2D collision)
{
    if (collision.CompareTag("Player"))
    {
        Player player = collision.GetComponent<Player>();
        if (player != null)
        {
            player.TakeDamage(15);
            Debug.Log("Damage taken");
        }

        Debug.Log("Bullet has hit the player.");
        Destroy(gameObject);
        isCollided = true;
    }
}

using UnityEngine;
using UnityEngine.UI;

public class HealthBehaviour : MonoBehaviour
{
    public Slider slider;

    public void SetMaxHealth(int health)
    {
        slider.maxValue = health;
        slider.value = health;
    }

    public void SetHealth(int health)
    {
        slider.value = health;
    }

    void Start()
    {

    }


    void Update()
    {

    }
}

fickle plume
#

Also make sure IDE is actually configured for Unity correctly.

somber temple
#

current health is assigned in script

kindred dome
#

sometimes

#

ive seen it do it before

#

but its not doing it right now

brave robin
somber temple
# brave robin Problem would be in `player` in `TakeDamage`, presumably. That's the only spot t...

using UnityEngine;

public class Player : MonoBehaviour
{
    public int maxHealth = 5;
    public int currentHealth;

    public HealthBehaviour healthBehaviour;

    void Start()
    {
        currentHealth = maxHealth;
        healthBehaviour.SetMaxHealth(maxHealth);
    }

    public void TakeDamage(int damage)
    {
        currentHealth -= damage;
        healthBehaviour.SetHealth(currentHealth);
        Debug.Log($"Player took {damage} damage! Current health: {currentHealth}");

        if (currentHealth <= 0)
        {
            Debug.Log("Player is dead");
        }
    }
}

this is the code it's referencing

polar acorn
somber temple
#

can i ask what you mean?

polar acorn
#

I mean what have you assigned the variable healthBehaviour to

somber temple
polar acorn
#

Yeah, what did you drag in there

somber temple
#

oh

polar acorn
#

Something in the scene? Or a prefab?

somber temple
polar acorn
somber temple
#

but in this case it could be? it is a prefab i had to pull in there

#

cause it wouldn't let me pull a scene object in it

polar acorn
somber temple
#

OH I FIXED IT

#

exactly the issue

#

i feel a bit dumb

#

thank you lmao

sand glen
#

I have an asset on the asset store, script asset.
I have built it on 2021, then 2022, now 6.2
What would be pipeline to export the project for each version?
Opening project in each version and then building and uploading is really a hassle
Is there a smarter way? or just pick one version and go with it?

Problem is, if its latest version of Unity, older versions cant import it into the project, if its older version of the package i dont know if newer can import it but they cant if there is higher already online

dont really know where to ask because there is only showcase for the asset store, info online is really limited

muted plume
#

anyone can help me making fps movement with character controller i nearly try every tutorial i can find but it doesnt work what should i do?

polar acorn
#

You'll need to be more specific about what "doesn't work"

ornate yew
#

Yo can anyone send me a code for egg hatching?

polar acorn
ornate yew
#

Srry didnt see that I apologize

muted plume
dusty nest
#

good evening folks

rich adder
radiant voidBOT
icy wigeon
#

I'm trying to implement steam lobbies in my game

But I'm getting these error messages

This is the code

using UnityEngine;
using Mirror;
using Steamworks;

public class SteamLobby : MonoBehaviour
{

public GameObject hostButton = null;  // Reference to Host Button
// Reference to Networkmanger Script


private NetworkManager networkManager;

protected CallBack<LobbyCreated_t> lobbyCreated;
protected CallBack<GameLobbyJoinRequested_t> gameLobbyJoinRequested;
protected CallBack<LobbyEnter_t> lobbyEntered;
private const string HostAddressKey = "HostAddress";

private void Start()
{
    networkManager = GetComponent<networkManager>();

    if (!SteamManager.Initialized)
    {
        Debug.LogError("Steam is not initialized.");
        return;
    }

    lobbyCreated = CallBack<LobbyCreated_t>.Create(OnLobbyCreated);
    gameLobbyJoinRequested = CallBack<GameLobbyJoinRequested_t>.Create(OnGameLobbyJoinRequested);
    lobbyEntered = CallBack<LobbyEnter_t>.Create(OnLobbyEntered);

}

//Host Lobby
public void HostLobby()
{
    hostButton.SetActive(false);
    SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypePublic, networkManager.maxConnections);
    
}

//OnLobbyCreated
private void OnLobbyCreated(LobbyCreated_t callback)
{
    if (callback.m_eResult != EResult.k_EResultOK)
    {
       hostButton.SetActive(true);
        return;
    }
    networkManager.StartHost();

    SteamMatchmaking.SetLobbyData(new CSteamID(callback.m_ulSteamIDLobby), HostAddressKey, SteamUser.GetSteamID().ToString());
}


//Lobby Join Request
private void OnGameLobbyJoinRequested(GameLobbyJoinRequested_t callback)
{
    SteamMatchmaking.JoinLobby(callback.m_steamIDLobby);
}

//Lobby Entered
private void OnLobbyEntered(LobbyEnter_t callback)
{
   if (NetworkServer.active)
    {
        return;
    }
    string hostAddress = SteamMatchmaking.GetLobbyData(new CSteamID(callback.m_ulSteamIDLobby), HostAddressKey);
    networkManager.networkAddress = hostAddress;
    networkManager.StartClient();
    hostButton.SetActive(false);
}

}

sour fulcrum
icy wigeon
#

Soz

rich adder
#

nobody likes a giant wall of text

wintry quarry
autumn dew
#

Thanks!

onyx geyser
#

Out of some minor curiousity, as a newbie, how hard would it be to learn inverse kinematics?

wintry quarry
onyx geyser
#

Hmm, might be worth learning the long way?

dark laurel
#

Anyone know any nifty ways to get off-main-thread stack traces to log to unity logs? I had an exception happening (I subscribed to an ad completion event while the app was backgrounded, which updated some text, which blew up textmeshpro) and never knew about it until.. way too late.

#

(I'm already doing Console.SetOut() to a text writer of my own making..)

kindred dome
#

so i have a simple script for moving an object smoothly

    public Transform target;
    public float speed = 10;

    void Update()
    {
        float step = speed * Time.deltaTime;
        transform.position = Vector3.MoveTowards(transform.position, target.position, step);
    }```is there something equivalent for rotating stuff?
wintry quarry
kindred dome
wintry quarry
#

Quaternion

#

same type transform.rotation is

#

If you want, you can even use the same trick you're using here for position

#

target.rotation

#

^ rotate towards the orientation some target object has

kindred dome
#

but if i wanted to give it a rotation value how would i do that?

wintry quarry
#

with a Quaternion

#

That's what Quaternions are - variables that hold a rotation

naive pawn
kindred dome
#

hey so im wanting to detect when i click on a gameobject

#

and i saw stuff saying to use the function OnMouseDown

#

but that doesnt work but im not seeing how to do it with the new input system

wintry quarry
#

You need:

  • An Event System in the scene (Create -> UI -> Event System)
  • A collider on the object (or a 2D collider)
  • A PhysicsRaycaster on your camera (or the 2D version)
  • Your MonoBehaviour script to implement the IPointerDownHandler interface
kindred dome
#

that seems a lot more complicated

wintry quarry
#

It is a bit more complicated but it's better

#

It will interact properly with the UI

visual linden
#

anyone know why meshes do this

#

i recalculated normals

naive pawn
visual linden
#

this is the function idk if im missing something
void GenerateChunk(int chunkX, int chunkZ)
{
int size = 16;
List<Vector3> vertices = new List<Vector3>();
List<int> triangles = new List<int>();
List<Vector2> uvs = new List<Vector2>();

    float[,,] density = TerrainDensity.GetDensity(size * size, new Vector3(chunkX * ChunkSize, 0, chunkZ * ChunkSize), 0.05f, worldHeight, seed);

    GameObject ChunkObject = new GameObject("Chunk_" + chunkX + "_" + chunkZ);
    ChunkObject.transform.parent = this.transform;
    ChunkObject.transform.position = new Vector3(chunkX * ChunkSize, 0, chunkZ * ChunkSize);
    MeshFilter MF = ChunkObject.AddComponent<MeshFilter>();
    MeshRenderer MR = ChunkObject.AddComponent<MeshRenderer>();

    MR.material = TerrainMat;

    for (int x = 0; x < size; x++)
    {
        for (int y = 0; y < size; y++)
        {
            for (int z = 0; z < size; z++)
            {
                float[] cube = new float[8];
                for (int i = 0; i < 8; i++)
                {
                    Vector3Int corner = MarchingCubes.Corners[i];
                    cube[i] = density[x + corner.x, y + corner.y, z + corner.z];
                }

                MarchCube(new Vector3(x, y, z), cube, vertices, triangles);
            }
        }
    }
    print($"Chunk mesh has {vertices.Count} verts and {triangles.Count/3} triangles");

    Mesh mesh = new Mesh();
    mesh.vertices = vertices.ToArray();
    mesh.triangles = triangles.ToArray();
    mesh.RecalculateNormals();

    MF.mesh = mesh;
    
    ActiveChunks.Add(Vector2Int.RoundToInt(new Vector2(chunkX, chunkZ)));
}
north kiln
#

your shader probably has issues, not your mesh

fringe plover
#

i cant figure out whats wrong with it im gonna crash out

#

i just created an empty Canvas and it happens

naive pawn
fringe plover
#

Alright

light cave
#

how hard is it to make a small multiplayer?

naive pawn
#

quite a subjective measure, but apparently it's relatively harder than.. a lot of other stuff

naive pawn
#

don't need to, the answer's not really gonna change

dry dock
grand snow
dry dock
grand snow
#

Once you start using the IPointer events with event system you wont go back

dry dock
boreal cedar
#

Hello, I'm trying to make a pool game and wanted to try something different than using Unity Physics. I was thinking of using Physics.Simulate and Script mode and have the entire simulation play out in one frame and then interpolate it depending on the cached data.

I want it this way, because I figured if we send the cached data over the network then I wont have to worry about network sync issues that Photon Network sync comes with(like latency).

I just want to know if this actually possible or if someone has done something similar to this?

timber tide
#

doesnt photon have its own physics

boreal cedar
#

it does, but we are facing sync issues on low network devices

#

no wait, you mean PUN2 has its own physics?

timber tide
#

photon fusion has deterministic rigidbodies

boreal cedar
#

We're on PUN2 and are using PhotonRigidbodyView

timber tide
#

Ah, I see. I know they have a discord around somewhere so it's probably better to ask in there

boreal cedar
#

Ow, so the Physics.Simulate and script mode cant be used to simulate everything in one frame?

marble hemlock
#

i know the code has a very obvious problem of "that's a game object, not an int" but does anyone understand what im trying to do?

how would i go about finding the index of menu, and then going back 1

#

it feels like it should be simple and fairly obvious but im just running a blank

timber tide
naive pawn
#

there's not really a concept of "the thing before" with foreachs

#

you could keep the thing before as a variable if you want

#

also consider what should happen when it's the first element

rugged beacon
#

if that a list there is .indexof(menu)

timber tide
#

But yes, I would expect you to advance to simulation yourself as the host then transmit the new positional data to the clients

rocky canyon
# marble hemlock it feels like it should be simple and fairly obvious but im just running a blank

if ur using a list to represent its index.. you can do what stalin mentioned.. just get the index of the element and use that to load the pref scene..

int currentIndex = menuManager.MenuList.IndexOf(menuManager.currentMenuSelected);
int targetIndex = currentIndex - 1;```
else i would ask *what* is a menu? does it even know what sceneIndex it is?
menu.index or menu.id -> w/e as long as its an integer
```cs
public class Menu : MonoBehaviour
{
    public int id; // could also represent Scene build index
}

// could even auto-cache it in awake or something
id = SceneManager.GetActiveScene().buildIndex;
int prev = menuManager.currentMenuSelected.id - 1;
SceneManager.LoadScene(prev);```
marble hemlock
#

i think im getting a grasp on how to do this but im probably going to be testing for a while
turns out this was harder than i expected it to be

but .indexof seems to be what i needed

#

i will do my best to break it

rocky canyon
tight fossil
#

[Package Manager Window] Error adding package: https://github.com/lexonegit/Unity-Twitch-Chat.git?path=/Unity-Twitch-Chat/Assets/Package.
Unable to add package [https://github.com/lexonegit/Unity-Twitch-Chat.git?path=/Unity-Twitch-Chat/Assets/Package]:
No 'git' executable was found. Please install Git on your system then restart Unity and Unity Hub
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

Is there a github app i have to install for me to add this package or is there a way to circumvent this? and if I do need the app would this still work if I build the project and send it to a user without the app?

strong wren
strong wren
strong wren
tight fossil
#

kk thanks :)

grand snow
#

git included with clients like sourcetree arent because they dont usually add to PATH

naive pawn
dusk jay
#

I got a code issue, my objects are kinda falling even when i make them static, and i dont understand cuz im new in unity

keen dew
#

Show the code

dusk jay
#

ok

#

but i dont have any code i just have basic movement and i was trying to make my player hit a wall and stop but the wall moves and then it starts falling

keen dew
#

Then how is it a code issue

dusk jay
#

cuz i thought i might need code

#

my bad

#

il ask in unity talk

timber tide
#

Misconception that even though you do a lot of this in code. If it's specific to values done on the editor, yeah you'll want to take it to #💻┃unity-talk

hybrid cobalt
#

I'm recently changing to Unity and have been confused with how inheritance works there.

Say I make a Vehicle class with a name and a Honk() method.

If I want to make a Car, Bike, or Boat, what is the common approach in Unity?

a) Just make like a VehicleComponent and slap it onto an Empty GameObject

b) Actually inherit it by doing "public class Car : Vehicle"

c) Make the vehicle a prefab or scene.. and inherit that?

Still trying to wrap my head around Unity's best practices. I come from Godot btw.

eternal needle
timber tide
#

It's very similar to godot. The only big difference here is usually godot native classes do require you to inherit from their component class if you do want to modify them, and even though you can extend similarly in Unity, it's not a requirement. Well, it's a mix of only having one script per node as well compared to how you can stick multiple different scripts per gameobject in Unity. Example of a problem, having a scene object that can have either a static body or a character body -> you need to have a wrapper node as the root

polar acorn
iron wind
hybrid cobalt
iron wind
#

exactly

hybrid cobalt
#

Awesome, I'll look into prefabs and components to figure out how to use them now, thanks :)

timber tide
#

You can pretty much stick everything onto one gameobject if you wanted, but I like godot's idea of forcing you to branch out your hierarchy

#

much more clarity when you can see the components on the scene viewport

#

one large problem with that idea in unity is you do incur a cost of a transform even if you don't need one

naive pawn
hybrid cobalt
timber tide
#

gameobjects always have a transform

dusk jay
#

Hi, my sprint variable does not change when i press shift, i was using gitHub copilot to help me out, this is my code for it to change, and this is my input system

slender nymph
#
  1. have you confirmed that code is running
  2. how have you actually verified that the variable is not changing?
dusk jay
#

1: yes as i got more on the code and i can walk and activate the sprint through the engine, making me run
2: i have the sprint as public to change it, but i can also see if by pressing shift it changes or not

slender nymph
#

you need to verify with code, don't use the inspector because if it changes but then something else is changing it back you might not see that in the inspector. so add some logs to that method to actually verify that it's being called

polar acorn
#

Also are you actually using OnSprint anywhere? Is it actually being called by the input system?

#

There's quite a few ways to assign that action as a callback to that button, which one are you using?

dusk jay
#

thats actually the part where i think i did it wrong as i dont know how to properly work with the input system so well

polar acorn
dusk jay
#

yes

#

the OnMove and the OnMouseLook

polar acorn
# dusk jay yes

So, see how those are assigned, and try to replicate that with OnSprint

#

Check this script, and any other components on the object

dusk jay
#

i think i cant actually cuz they are vectors and i think shift being a button kinda changes the way it should work

#

here

slender nymph
#

can you try printing something actually useful instead of a blank string

polar acorn
slender nymph
#

also your ide seems unconfigured 👇

#

!ide

radiant voidBOT
dusk jay
dusk jay
slender nymph
#

including for Unity types? and error underlines? because i can see in that screenshot neither of those are happening

dusk jay
#

maybe not, what is completing is the github copilot and its preety usefull

#

let me show you

#

wait i think i know how to fix it

slender nymph
#

having a configured IDE is a requirement to get help with your code here. so stop whatever you are doing and go get that configured

dusk jay
#

im about to tweak ou everything dissapeared

naive pawn
#

did you close the file

dusk jay
#

no more nothing

naive pawn
#

there are errors

#

have you checked them