#💻┃code-beginner

1 messages · Page 17 of 1

mossy arrow
#

What does float mean?

rancid wave
#

Well it didn't i have to be doing somthing Worng.

wary sable
#

this is to help answer questions that people have about code at a beginner level yes, but the assumption is that people attempt to research their questions before asking them. Nothing personal, there are just some questions that can be easily answered with one google search, others need some more boutique explanation. That is what this is for

cosmic dagger
#

yes, but you should always search your question first, especially, smth as simple as this with results and immediate answers. if you trouble using or understanding it, you can always return with examples or code you have problems with . . .

mossy arrow
wary sable
#

your box collider is set to a very small size, make sure to have gizmos on so you can see the hit box and make sure its big enough

cosmic dagger
mossy arrow
#

I don’t get why u can’t say what a float does

cosmic dagger
mossy arrow
#

Containing one or more decimal

eternal needle
#

0 is a decimal

cosmic dagger
mossy arrow
cosmic dagger
mossy arrow
#

What does it mean

cosmic dagger
#

they are two fields of the type float . . .

eternal needle
# mossy arrow I don’t get why u can’t say what a float does

you should really take some basics of c# course first, whether online or through some paid course/tutoring. theres many many free resources online. this is a unity server so people generally dont want to teach the very basics. Like a rocket scientist wouldnt probably enjoy teaching you how to use a bike

cosmic dagger
cosmic dagger
mossy arrow
#

I wanna known both

cosmic dagger
# mossy arrow Both

both what? that's a yes or no question. if you do not, then you should really follow a beginner c# or intro to c# video tutorial. we can't go through the entire basics of a what a type, variable, field, etc., are in the chat . . .

#

you have to read/watch to learn the basics of c# as a pre-requisite to coding . . .

mossy arrow
#

Bro what do u not get where I said what is a float

wary sable
#

this is the very fundamentals of coding, these things are used by basically every coding language... if you do not understand what is happening in that image you are not going to understand much beyond that until you take the time to learn the very basics. It doesnt take very long and you will be much better off in the long run.

cosmic dagger
mossy arrow
#

So it like 0.3f?

wary sable
#

yes that is a __float__ing point number

cosmic dagger
#

if you don't know what a fraction or decimal is, i would look that up to learn. i'm not sure what you mean beyond that . . .

mossy arrow
#

How much floats is there

cosmic dagger
#

also, you can google or search examples of a float in c# . . .

mossy arrow
cosmic dagger
#

what? a floating point number is any value with one or more decimals. that can be never-ending . . .

mossy arrow
#

Ok but how much floats is there

#

Is there different meanings

wary sable
#

are you asking if there are different types of floats?

mossy arrow
#

Yes

cosmic dagger
wary sable
mossy arrow
#

@wary sable

#

What if

#

The float was used like this

cosmic dagger
#

that's just a regular float . . .

mossy arrow
#

Where is the number

#

I only see sped

#

Speed

wary sable
#

there is no number

cosmic dagger
#

if there is no number, it's given a default value . . .

wary sable
#

you are just telling the program that the variables distance and speed can hold numbers (that can have decimals)

mossy arrow
#

Oh

#

Now I get it

cosmic dagger
#

this is called a declaration. you are declaring a field named distance of type float that is private . . .

mossy arrow
#

What is the different between vector and vector2?

wary sable
solar tide
#

Question.
I'm making a card game and I've came across two ways I can continue developing.
Either make a game object prefab for every single card and put the prefabs inside an array list in the inspector.
But two tutorials I watched said that this method is not clean and instead you should only have 1 prefab and use structures and list to store all the info for different cards and apply the data to the card prefab at awake.
Which method is better or rather, what are the upsides and downsides for each method?
Making a prefab for every card definitely feels easier to do but I can see that it may create a lot of space(although each prefab is just 200KB at most. The card images themselves actually reach 800K so if anything the png pictures are too big) but I am not sure what exactly is the problem with this method other than people saying it's "not clean."

eternal needle
# solar tide Question. I'm making a card game and I've came across two ways I can continue d...

regardless of it not being clean, its a way bigger hassle. Whats the difference between cards? just a value and a visual (and possibly the affect associated with it, depending on the game). everything else about cards are the exact same. If you make a bunch of prefabs, then for example decide later that you want the cards to actually be slightly bigger, you gotta go through each prefab and change that

#

so its not even quicker or easier

last igloo
#

hey does anyone know how to get intellesense to work on visual studio code?

swift sedge
last igloo
#

i think i deleted that bc i couldn’t get the debugger to work

#

ima just try that again

#

ig

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

swift sedge
#

Did you install the game dev with unity package?

eternal needle
#

tho i recommend VS cause debugger

swift sedge
#

I managed to get VS Code to work, but it recently stopped working for some reason

#

So is started using VS

last igloo
#

that exactly happened to me

#

it just started being weird

#

and now it officially doesn’t wanna cooperate

swift sedge
#

If your imports (using) are pink instead of blue, then it's not working

last igloo
#

i fixed all that stuff i’m just trying to get the unity thing to work, like the red underline when something is wrong

#

and the suggestions

swift sedge
#

Pink means VS Code is trying to look for the namespace

last igloo
#

auto suggestions things

swift sedge
#

Just use Visual Studio

#

You have a debugger aswell

#

VS Code is a glorified text editor

last igloo
#

community ?

weak talon
#

When ever i export my game as WebGL there is a lot of bugs in the game and it doesnt work the same as in the unity editor
anyone know a fix?

keen dew
#

You'll have to be more specific. Nobody knows a fix to just "a lot of bugs"

weak talon
timber tide
#

You can debug your webgl build in the browser by opening the dev tools

#

usually f12

keen dew
weak talon
#

and in the unity editor it works fine

timber tide
#

Are you using coroutines

weak talon
#

yeah

timber tide
#

change them to general time scripts

weak talon
timber tide
#

just don't use coroutines and use basic timer functions to delay your attacks

weak talon
#

but why was it working every other upload except this one

timber tide
#

something to search the forums for cause they break in my builds too and I've no exact answer

#

even methods of async are screwy too but that's somethign I can understand

#

you should just make sure nothing else isbreaking in your build first using the dev tools

last igloo
#

@swift sedge IT WORKSSSSS thank you for the advice

timber tide
#

and I don't want you go about changing your code even though I have a grudge with coroutines :)

weak talon
timber tide
#

Honestly, you should always build to a desktop platform or mobile before building on webgl

#

webgl builds are a headache to debug usually and doing it something on a desktop build is just easier

rancid wave
#

How do i make a UI of the speed of my player. cant find anything on Google

fringe pollen
rancid wave
#

Yes my bad

#

Of the player

violet rose
#

For one thing, don't compare pig to null every frame, it's costly (assuming you're concerned about performance optimization at this stage). Just set it once in Awake or Start, or serialize it in the Inspector. In terms of cleaning the rest of the code, there's likely some kind of abstraction you could explore around these order buttons, but it's hard to tell how much could be possible without seeing the PigOrders and PigBehaviour scripts as well.

wooden minnow
#

im just learning Mathf.Clamp()
can someone tell me if this does what i think it will

                Quaternion rotationAddon = rightHandRotation * Quaternion.Inverse(prevRightHandRotation);
                stick_BottomRotationAnchor.transform.Rotate(rotationAddon.eulerAngles);
                float fixedX = Mathf.Clamp(stick_BottomRotationAnchor.transform.rotation.x, stickRotation.x-30, stickRotation.x+30);
                float fixedY = Mathf.Clamp(stick_BottomRotationAnchor.transform.rotation.y, stickRotation.y-30, stickRotation.y+30);
                float fixedZ = Mathf.Clamp(stick_BottomRotationAnchor.transform.rotation.z, stickRotation.z-30, stickRotation.z+30);
                stick_BottomRotationAnchor.transform.rotation = Quaternion.Euler(fixedX, fixedY, fixedZ);``` what im trying to do is limit stick_BottomRotationAnchor's rotation to 30 degrees in every direction from stickRotation
violet rose
# rancid wave Of the player

"of the player" doesn't give folks a clearer picture of what you're looking to accomplish, those exact words were in both options Hanneseses inquired about

delicate portal
round arch
#

I'm Working on a Project, where I need to create geometry In-Game. I have the basic mesh creating working, but I get this weird Half shaded rendering. Anyone know, what could cause this? As far as I can tell, all the vertex- and face normals are pointing in the correct direction.

#

The pink and orange lines show the vertex and face normals. (Using a script I found Online)

tiny terrace
#

hello, is there a way to see what the current PlayerPrefs in a machine contains using code?

#

like what attributes does it have and other stuff like that?

wooden minnow
#

how would i take an object's current rotation at 1 moment, and then stopping it from going under -30 or over 30 degrees in every direction from that saved rotation

#

ive been trying for 4 hours and NOTHING WORKS

burnt vapor
frail hawk
#

you can browse the registry tho : HKEY_CURRENT_USER\SOFTWARE\Unity\UnityEditor\CompanyName\ProjectName'

burnt vapor
#

Users are not going to appreciate you looking through the registry keys.

wooden minnow
#

i have no idea what to do

frail hawk
#

you have to clamp the rotation Elmishh

wooden minnow
#

thats what ive been trying to do for 4 hours

frail hawk
#

show what you have so far

burnt vapor
eternal falconBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

wooden minnow
#

every time ive tried it either used Quaternion.Identity as the center rotation or it just didnt decided to not rotate at all and just stay still

wooden minnow
#

anything helps

languid spire
wooden minnow
#

no?

#

wdym tho

frail hawk
#

why would it not be possible tho?

languid spire
#

I will explain
You are trying to do
Quaternion->Vector3->Clamp->Quaternion
This will not work because the Vector3 you will get from the Quaternion is almost certainly not what you are expecting to get

foggy magnet
# wooden minnow ive already just reset my code back so currently i have nothing

One thing you can do, that might be a simple solution, is to make an empty GameObject which saves the orientation you are interested in.

Then in code, you can parent your object to this dummy object, and then the transform.localEulerAngles will now be the deviations from the saved orientation.

So something like this

public Transform myObject;
public Transform theDummyObject;

public void SaveTheOrientation() {
Transform currentParent = theDummyObject.parent;
theDummyObject.SetParent( myObject );
theDummyObject.position = Vector3.zero;
theDummyObject.localEulerAngles = Vector3.zero;
theDummyObject.SetParent( currentParent );
}

void ClampToNumberOfDegrees( float maxDegrees ) {
Transform currentParent = myObject.parent;
myObject.SetParent( theDummyObject );
Vecror3 localEulerAngles = myobject.localEulerAngles;
localEulerAngles.x = Mathf.Clamp( localEulerAngles.x, -maxDegrees, maxDegrees );
localEulerAngles.y = Mathf.Clamp( localEulerAngles.y, -maxDegrees, maxDegrees );
localEulerAngles.z = Mathf.Clamp( localEulerAngles.z, -maxDegrees, maxDegrees );
myObject.localEulerAngles = localEulerAngles;
myObject.SetParent( currentParent );
}

Now there are some extra nuances to this, such as what if there is a 30 degree rotation around both x AND y, does that mean the overall angle is now over 30, or is that acceptable, etc..

wooden minnow
#

currently im subtracting a quaternion from a quaternion to create a quaternion and then im putting it in transform.Rotate
so quaternion-quaternion->quaternion->vector3

foggy magnet
#

( I just typed that straight into discord, so may well have errors 🙂 )

wooden minnow
#

currently what i do is

                rotationAddon = rightHandRotation * Quaternion.Inverse(prevRightHandRotation);
                stick_BottomRotationAnchor.transform.Rotate(-rotationAddon.eulerAngles.x, rotationAddon.eulerAngles.y, -rotationAddon.eulerAngles.z);``` to rotate my object, whenever i try clamp something goes wrong 100% of the time
foggy magnet
#

So, do you know how euler angles are different from quaternion representations of orientation?

Things like gimble lock, but also , having multiple sets of euler angles that will define the same orientation?

wooden minnow
#
                rotationAddon = rightHandRotation * Quaternion.Inverse(prevRightHandRotation);
                stick_BottomRotationAnchor.transform.Rotate(-rotationAddon.eulerAngles.x, rotationAddon.eulerAngles.y, -rotationAddon.eulerAngles.z);
                float fixedX = Mathf.Clamp(stick_BottomRotationAnchor.transform.rotation.x, -30, 30);
                float fixedY = Mathf.Clamp(stick_BottomRotationAnchor.transform.rotation.y, -30, 30);
                float fixedZ = Math.Clamp(stick_BottomRotationAnchor.transform.rotation.z, -30, 30);
                stick_BottomRotationAnchor.transform.rotation = Quaternion.Euler(fixedX, fixedY, fixedZ);``` whats wrong with this
languid spire
#

you are trying to clamp the quaternion

foggy magnet
#

I don't know the Quaternion math well enough to be able to understand that at first glance.

Can you tell me a bit more about the desired clamping that you need. Is it really a maximum on each of the euler angles?

Or is really just you don't want to be more than 30degrees away from the target orientation?

wooden minnow
wooden minnow
#

what happens now is that it locks at quaternion.identity and doesnt rotate at all

foggy magnet
#

Ok, well did you see the code I posted earlier, that should what you want.

languid spire
#

look

float fixedX = Mathf.Clamp(stick_BottomRotationAnchor.transform.rotation.x, -30, 30);
                float fixedY = Mathf.Clamp(stick_BottomRotationAnchor.transform.rotation.y, -30, 30);
                float fixedZ = Math.Clamp(stick_BottomRotationAnchor.transform.rotation.z, -30, 30);
                stick_BottomRotationAnchor.transform.rotation = Quaternion.Euler(fixedX, fixedY, fixedZ);

transform.rotation is a Quaternion, you try to clamp the internal values as if they were euler angles which they are not so you cannot do
you then use the clamped values as if they were euler angles

wooden minnow
#

i have no idea whats going in the code before

waxen aurora
#

Is it possbile to crate a SpeedTest method to check user speed from Unity?
I've done this simple script:

{
    private string url = "https://link.testfile.org/15MB";

    void Start()
    {
        StartCoroutine(DownloadAndMeasureSpeed(url));
    }

    IEnumerator DownloadAndMeasureSpeed(string url)
    {
        Debug.LogWarning("SpeedTest STARTED");

        UnityWebRequest request = UnityWebRequest.Get(url);

        float startTime = Time.time;
        yield return request.SendWebRequest();

        if (request.result == UnityWebRequest.Result.Success)
        {
            float downloadTime = Time.time - startTime;
            float fileSizeInBytes = request.downloadedBytes;
            float fileSizeInMB = fileSizeInBytes / (1024 * 1024);
            float downloadSpeedMBs = fileSizeInMB / downloadTime;
            float downloadSpeedMbs = downloadSpeedMBs * 8; // Convert from MB/s to Mb/s


            Debug.LogWarning("File size: " + fileSizeInMB + " MB");
            Debug.LogWarning("Download speed: " + downloadSpeedMBs + " MB/s");
            Debug.LogWarning("Download speed: " + downloadSpeedMbs + " Mb/s");
        }
        else
        {
            Debug.LogError("Error downloading file: " + request.error);
        }
    }
}```
the problem is that there is a significant discrepacy between this output (15Mb/s) and a google speedtest (50Mb/s)
does exists some better ways to do it? and could it be reliable in the first place?
wooden minnow
#

its been like 4 or 5 hours of me failing to clamp a single object im not in mood for the most cryptic, unhelpful responses i barely know how quaternions work to rotate an object, let alone know the big difference between Quaternion() and Quaternion.Euler()

foggy magnet
foggy magnet
wooden minnow
#

i have no idea what is going on in that code

wooden minnow
foggy magnet
wooden minnow
#

why

foggy magnet
#

When you reparent an GameObject in Unity, then Unity makes all the necessary calculations to mainain the world position, and world orientation ( and world Scale ) of that object.

Just like if you were doing in the Editor.

This means, you can use this sideeffect to essentially, copy the orientation of one object to another.
And the useful part for you, is that while the object has been temporailly reparented, the localEulerAngles will NOW show the angles the object is rotated from that parent. Which I think is exactly what you need to perform your clamping.

wooden minnow
#

object.transform.rotation = otherobject.transform.rotation?

foggy magnet
#

( however there are a few caveats, to do with things like gimble lock, and multiple sets eulerAngles defiing the same orienation. Wether or not this is a problem for you, depends on what you are ultimately going to achieve with it )

wooden minnow
#

but overly complex

foggy magnet
wooden minnow
#

what?

foggy magnet
#

Well, think about the eulerAngles. -180,0,60
Is that past your 30degree limit or not?

wooden minnow
#

ok listen i have 2 objects a stick object that i see and an invisible bottom object right at the bottom of the stick that i rotate, the stick is a child of the bottom object so when i rotate the bottom one the stick seems to be rotating around a center point

I want the bottom object to only rotate 30 degrees in each directions (+ and -)

foggy magnet
#

Just to confirm, this is in 3D right? not 2D?

wooden minnow
#

yes

#

you know how flight sticks work?

#

like jet ones

foggy magnet
#

Yes , ok I got you. And what about the rotation of stick around itself. A flight stick can swivel around its own axis normally right?

wooden minnow
#

wdym

#

what im making is a 3d flight stick that once i press the grip button starts copying the rotation of my hand up to 30 and -30 degrees in each axis

#

and when i release the grip it returns to a pre saved rotation

#

now cs rotationAddon = rightHandRotation * Quaternion.Inverse(prevRightHandRotation); stick_BottomRotationAnchor.transform.Rotate(-rotationAddon.eulerAngles.x, rotationAddon.eulerAngles.y, -rotationAddon.eulerAngles.z); this makes it perfect besides the fact that it doesnt stop at 30 degrees in every axis

foggy magnet
#

Ok, so, how about making your hierarchy like

swivelNodeX ( simply clamp the eulerangles to ( -30,30) for x, and 0 for y and z
swivelNodeY. ( similar to above, but 0 for x and z, and (-30,30) for y
yourStickObject. ( nothing to clamp here )

wooden minnow
#

i dont understand

foggy magnet
#

just bear in mind, again, that this would be a square gate on your flightstick. If you really want circular gate then you'd be clamping the sqrt(x^2 + y^2) to 30 ( I think?)

foggy magnet
#

Try it in the editor now. Rather than having that single bottom gameobject, have two , the first one you move only the x euler cooridnate, the next one you move only the y

wooden minnow
#

ok

#

so in total 3 objects not including the stick itself for rotating?

sharp oracle
#

is there a channel to talk about unity problem/question but are not really code related ?

foggy magnet
#

You only need two, because you are really just rotating in two dimensions, forward.back , and left/right

If you did want to swivel the stick around it center axis, then you can do that directly on the YourStickObject

wooden minnow
#

im also rotating on the yaw axis

#

for example like this?

#

actually no i want yaw at the bottom

foggy magnet
#

Ok, so put your object under the Y rotation one.

Now just play around a bit in the editor.

If you set Z rotation to. 0,0,30

Is that what you want?

Now set it back to 0,0,0
And set X rotation to 30,0,0

Is that what you want?

Try a combination of values.

If it all looks good, then your clampin scripts are going to be super easy.

wooden minnow
#

and now i need to clamp each one right

quiet ginkgo
#

I'm trying to control a ball using torque
but the ball is going in random directions

foggy magnet
# wooden minnow

Yes, the claimping should be straightforward, but first play with in the Editor, and convince yourself this will work if you can clamp those angles.

wooden minnow
#

assuming i clamp it corrently but i dont know if i am

foggy magnet
# wooden minnow

something like this

class ClampEuler : MonoBehaviour {
public Vector3 maxAngles;

void Update() {
transform.localEulerAngles = new Vector3(
Mathf.Clamp( transform.localEulerAngles.x, -maxAgnles.x, maxAngles.x ),
Mathf.Clamp( transform.localEulerAngles.y, -maxAgnles.y, maxAngles.y ),
Mathf.Clamp( transform.localEulerAngles.z, -maxAgnles.x, maxAngles.z );
}

Now put tht on each of your Z rotation, X rotation objects

And set the public varabile to ( 30, 0, 0 ) for the X rotation object, and similarly for the y and z

wooden minnow
#

considering everything rotates at a max of 30 i can make MaxAngles an int or a float

foggy magnet
#

keep it as a float, because the Mathf.Clamp will be happier with all the paramaters being floats

wooden minnow
#

but after clamping how do i rotate it?

#

do i need to rotate it?

foggy magnet
#

No need to rotate it.

wooden minnow
#

would what you said work like this?

#

or do i need to do it differently

wooden minnow
#

what is transform.localEulerAngles supposed to be?

#

SmoMo?

wooden minnow
keen dew
#

That would also make it go in random directions, only at different speed

rancid tinsel
#

if you type "yes" in lowercase this should skip the whileloop no?

#

or did I make some mistake

north kiln
#

!cdisc

eternal falconBOT
rancid tinsel
#

thank you

languid spire
rancid tinsel
#

turns out its because i put || instead of &&

final kestrel
#

my in game platform is marked ground too

neon ivy
#

I made a little shader with a bool that I want to control from a script but it says that material.SetBool() isn't a thing, despite it being a field in the shadergraph

fossil drum
final kestrel
#

I tried to make it bigger but it still does not work.

#

.2 mm looks like this

fossil drum
# final kestrel

Well it still doesn't hit the ground?
Anyhow, log Physics.CheckSphere(_groundCheck.position, .002f, _groundLayer); every frame, I want to see if this is the problem or your canJump bool.

final kestrel
#

all right. I will do it. When I start my game the character lands on the ground btw.

#

Wait how do i log that?

#

Okay its false

#

I did change its size. Made it bigger and it still is false.

fossil drum
#

Well, there's your problem.

#

Oh, you use Physics, and not Physics2D

final kestrel
#

This is a 3d game

#

Its ortographic because I wanted to show how my ground check looks

fossil drum
final kestrel
#

Ah okay I did not actually assign the ground layer. Only changed tag to ground. My bad sorry.

#

Thanks for the help.

fossil drum
final kestrel
#
private void Jump()
{   
    {
        _rb.AddForce(transform.up * _jumpForce, ForceMode.Impulse);
    }

}

private void Move()
{
    Vector3 forward = transform.forward;
    float currentYVel = _rb.velocity.y;
    Vector3 newVelocity = transform.forward * _moveSpeed;
    newVelocity.y = currentYVel;
    _rb.velocity = newVelocity;
    //_rb.velocity = transform.forward * _moveSpeed;
}

Am I over doing something here?

#

regarding jumping.

foggy magnet
foggy magnet
#

so something like

private void Move() {
_rb.AddVelocity( transform.forward * _moveSpeed );
}

final kestrel
#

My jump was working all fine till i figured the ground check.

queen adder
foggy magnet
#

What does your ground check look like?

final kestrel
foggy magnet
#

(oh snap 🙂 )

keen dew
#

AddVelocity isn't a thing

final kestrel
#

My character just flies upwards

foggy magnet
#

Oh, ok, I got confused then.

#

Don't you want to set
canJump = false

inside your if

final kestrel
#

I thought IsGrounded's false return would do it already?

#

well its working now that I set it false. Why?

foggy magnet
#

But you are setting it to true, and it is staying true for ever

#

Like, the player presses jump, you set the bool to true

but then you need to set it to false once you perform the jump

#

otherise it will keep happening every frame

#

( Also, remember that for each Update() there may be many calls to FixedUpdate() that happen )

foggy surge
#

What should I be learning I never coded before

queen adder
final kestrel
#

Yes. I did. SmoMo's suggestion worked.

foggy magnet
foggy surge
#

2d

foggy magnet
# foggy surge 2d

2D is good place to start if you are new to making games. What kind of game are you thinking of, platform, RPG, something else?

final kestrel
#

What I thought was that. IsGrounded() would return true only if it touches the ground. When I jump it would return false so I did not have to set the canJump true again

foggy surge
foggy magnet
# final kestrel What I thought was that. IsGrounded() would return true only if it touches the g...

So you could have done this:

if( Input.GetKeydown etc.... && isGrounded() ) {
canJump=true;
} else {
canJump = false;
}

And that is probably closer to what you were initially intending.

But the problem with that, is if lets say, there are 3 FixedUpdate() calls before the next Update(), you would still be applying the impulse 3 times, before the Update() is called again and sets canJump to false.

Best solution is to set it to false in FixedUpdate() right after the Jump()

final kestrel
#

yes I tried to set it on false in update but yes It acted up

#

Thanks.

foggy magnet
foggy magnet
foggy surge
#

Yeah

foggy magnet
# foggy surge Yeah

There is tutorial here, but it is for a 3D Street Fighter style game in Unity : https://www.youtube.com/watch?v=cyJFySbLFVE

It might be useful to watch thouhg, even if you make it 2D in the end you might learn a lot of the same concepts.

In this video, we'll create a Street Fighter "Hadouken" style fireball projectile special attack in unity.

For this, we’ll simply need an animation, some particles, & a 3d mesh for our projectile. We've provided the animations, 3d meshes, textures, as well as the completed prefabs in the link bellow.

🕹️ Free Game Asset Download 🕹️
🆓 FREE ...

▶ Play video
#

This one here, shows you how to organise animations for a 2D fighting game : https://www.youtube.com/watch?v=WYCjmVhiLaM

This is a reworking of my original video which I wasn't entirely happy with, so please enjoy this improved, concise version.

Let's look at some ways to animate a 2D fighting game!

MUSIC USED:

0:02 - Morrigan's Theme - Marvel v Capcom
0:50 - Whiling the Hours Away - Skullgirls
1:29 - A Road in Kyoto - Street Fighter III 3rd Strike
4:31 - Stran...

▶ Play video
tender stag
#

somewhere in the code i need to check if all input cells have no item inside, and that the scrapper is turnedOn

#

is this the best way to do it?

gaunt ice
#

goto

#
int i=0;
for(...){work and if(some thing)goto L1;}
goto L2;
L1:
for(remaining i){work}
TurnOff();
L2:
modest dust
#

won't a break; be enough

#

to get out of the loop

mossy arrow
# mossy arrow

How do i fix this i want it where it does not do what it is doing

violet creek
#

Is it possible to use Character's Slope limit to detect if the floor underneath is too steep and make the player slider along?

swift crag
#

explain your problem

swift crag
#

The normal is a vector pointing straight out of the surface you hit

violet creek
#

Oh, that sounds like what I need, thank you : )

swift crag
#

You can do Vector3.Angle(hit.normal, Vector3.up) to get the angle between the surface and the up-vector

ashen ferry
swift crag
#

you might need to be careful if you call Move more than once per frame

#

you could get multiple messages

violet creek
#

Alright

rancid wave
#

Hey guy's anyone know what i am doing wrong here my Character keep falling down. How would i fix this without Friezing the Z.

rancid wave
# mossy arrow

Look's Like you have the same movement Code on the Gray Square.

swift crag
swift crag
#

freeze X and Z rotation

#

Y rotation can stay unfrozen, so that it can pivot

round arch
#

Anyone know what could cause this half shaded effect?Its a custom Mesh. The Pink and Orange Lines show the vertex and face normals, so that shouldn't be the problem.

rancid wave
zealous oxide
#

https://hastebin.com/share/unubigehot.csharp hey peeps, i've made a camera zoom script for a platformer. any tips to improve it? (i've got a separate camera follow script)

tender stag
#

im so confused

#

its something in HandleFuel

timber tide
round arch
#

@Mao I'm not using a custom shader, It's the standard Opaque shader that comes with the editor.

#

And, yes I believe the normals are right. I added a script (I found on the Internet) to show the normals. (Orange and Pink Rays)

timber tide
#

Oh, I see. How about any other unity shaders, same thing?

round arch
#

I'm not sure what you are refering to but noting special going on with the material/shader

#

Just the Geometry (mesh) is custom. (Computed at Runtime)

timber tide
#

I mean, you've got specular highlights there and reflections tick, is that not a shader?

tender stag
#

Mao do you think you could help me quickly?

timber tide
#

Usually when I did opengl stuff, that stuff was all compute shader, only geometry data/mesh data was just colors/normals/uvs

#

but im rusty

timber tide
tender stag
#

look at the console when i try and turn the furnace on the the item is in the second cell

#
Debug.Log("Now"); is on line 146```
https://hastebin.skyra.pw/puwequgojo.csharp
#

the cells are correctly set up

round arch
#

Yes I'm sure there is a shader connected in the background. But I didn't touch that part. Its all defaults Material of the Unity Editor.

tender stag
timber tide
#

I just know that if you're using reflections, that's some heavy computation

round arch
#

I just tried torning off the specular highlights there and reflections, and it didn't change anything.

summer stump
timber tide
tender stag
#

its starting to

#

but then it gets turned off

#

this gets called

summer stump
#

Oh, I misunderstood the issue i guess lol. Ignore me then

tender stag
#

as soon as i turn the furnace on

#

and i have the item in the second cell

#

where the red is im checking every fuel cell if it has an item

#

and then the logic happens

#

but it doesnt return

#

on the second and so on cell

#

only on the first one

summer stump
#

Where do you decrement fuelTime?
Is see this:
fuelTime = Mathf.Max(fuelTime - Time.deltaTime

But that minus sign doesn't actually reduce the time

tender stag
#

it does

summer stump
#

Oh, duh, yeah, you assign the result. I gotta stop trying to help while getting ready lol

tender stag
timber tide
#

That looks good

#

Im confused lol

tender stag
#

only works for the first slot

#

look what happens when i do it in second

#

this runs

#

because for some reason it doesnt return

timber tide
#

this is one of those things where you need to use vs debug tool

#

and just throw breakpoints all over

tender stag
#

like i grayed this out

#

and this is what happens now

#

the furnace doesnt turn off anymore and the fuelItem is not getting set to null

timber tide
#

I could run through the logic of how I would do it

#

So you've turned it on and it's actively checking both slots, right?

summer stump
timber tide
#

I assume you can have both slots active at once, and when a fuel added is added, you prevent checking of that particular slot until the timer zeroes out.

#

There is no real race conditions or anything, I guess you could create more materials in the end? But that's extra logic (need to dump the materials outside)

#

Could even split it into two independent functions if you want to do that to make it easier.

wary sable
#

is there a way to select serialized scripts from a wrapper class? I am making an inventory system, and currently I have a serialized class Item that has an instance decleared in a mono attached to a game object. Obviously I want to have different types of items all with different stats, animations etc... Would there be a way to choose which serialized class you want to wrap onto the G.O. (choosing between children of the item class), or would I have to make wrappers for each child?

Example of item class:

[Serializeable]
public class Item{
}```
Example of "wrapper"
```using unity;
public class myWrapper : monobehavior{
  public Item item;
}
timber tide
#

Any more examples because I'm thinking generics

swift crag
#

sounds like an application for [SerializeReference]

#

you want to store one of many possible plain-old C# classes

#

i'm using it to build boss attacks. notice how this list contains both SchemeSequenceSteps and SchemeWaitSteps

#

Unity does not provide an inspector GUI for [SerializeReference]

swift crag
#

I'm using one provided by the Animancer package. You probably don't want to buy a $90 animation package for just that :p

#

but

#

I used to use a very very similar implementation

timber tide
#

unity really needs to up their gui tools already

wary sable
# rich adder what like scriptable objects?

sort of, but I want the variables to be dynamic and save between sessions. Since scriptable objects only save to memeory, changes to variables will be lost between sessions

swift crag
#

I think it was...

languid gate
#

does anyone know why i cannot create a pipeline asset (2d render) i have googled it and other people have had this issue but i couldnt find a solution could someone explain i have already installed universal renderer as you can see

swift crag
#

That data is part of the scene.

trail heart
wary sable
swift crag
#

If you want to have persistent data, you will need to serialize and deserialize it yourself. Json.NET is an excellent choice for this.

#

it's like JsonUtility, except that it hasn't been hit with a sledgehammer

slender nymph
timber tide
swift crag
swift crag
#

The general idea is that they let you pick from one of many types to display in the inspector

#

[SerializeReference] lets Unity correctly handle derived types. Normally, it just winds up serializing the static type of the field.

wary sable
round arch
#

@trail heart Yes, that looks exactly like my Issue. So you think the (vertex) normals of the "Side Faces" of the cube are pointing up and down instead of "out"?

swift crag
#

(and it'll definitely die when the game quits)

#

oh wait, I misread you -- you were asking if storing the data in JSON would work

#

Then yes. You'd serialize the inventory data when you save the game, and deserialize it when you load the game

round arch
#

@trail heart Sadly I have to leave now, but thanks alot for this tip👍

swift crag
#

[SerializeReference] just lets you serialize the (possibly polymorphic) field correctly, so that it can be shown in the inspector and stored in the scene.

wary sable
dawn sparrow
#

Hi, I've come across a really confusing issue. I'm trying to subsribe 5 objects - each having this UI scripts attached it it - to the onCharacterSlotItemChange event. For some reason even though all five are calling the subscribe (line 39), when onCharacterSlotItemChange is invoked, only 3 of the 5 are informed

#

I've tried testing a bunch of things, only thing I can guess is happening is somehow two of the five are unsubscribing themselves

swift crag
#

When does onCharacterItemSlotChange get invoked?

timber tide
#

Are they subscribing at all?

swift crag
#

I'm wondering if it's happeng in someone's Start method

timber tide
#

All 5

swift crag
#

or as a result of someone's Start method

dawn sparrow
polar acorn
#

Put a log in Start and OnDestroy, log the object name and which method it is. See if you get exactly five more subscribes than unsubscribes

swift crag
#

you should log when it's called and when the subscriptions are made

timber tide
#

Can use debug tool and stick them on the subscriptions too

dawn sparrow
swift crag
#

how?

#

your code does not demonstrate this; did you use a debugger?

dawn sparrow
#

Right above the subscribe I print something to see if it's being called

#

And all five print

swift crag
#

well, not in this code you don't. show us the code you're actually running right now.

dawn sparrow
#

This is the only difference here

polar acorn
languid gate
#

why doesnt this come up for me? this is my project with all the correct packages installed any ideas on what the issue could be?

dawn sparrow
polar acorn
timber tide
languid gate
#

oh thanks

swift crag
#

The 2D Renderer is relatively new.

dawn sparrow
#

I included a log inside the subscribed event like so:

#

Results in 3 logs

#

2 are missed

swift crag
#

and in what order do these messages appear?

#

show us the console.

#

turn off Collapse.

dawn sparrow
swift crag
#

there is an exception. is that causing it?

#

it's definitely causing it.

#

fix the error

polar acorn
#

that's the problem

#

Woulda been nice to know about it

dawn sparrow
#

The exception occurs at line 72, after the log at line 58 is called

swift crag
#

so what?

#

the exception is thrown up the call stack until someone catches it

dawn sparrow
#

So the log should be called before any error occurs

swift crag
#

your method is gone

dawn sparrow
#

Why would the log be innaccurate ?

final kestrel
#

I learned I cannot Invoke("string", delay) methods with parameters. How can I achieve that in other ways?

swift crag
#

an exception will, as it always does, interrupt this

sacred zenith
#

Hey guys,
For games like farming simulator, in which the terrain texture is altered all the time, is there something I need to know about Unity's terrain system?
Or the basics of the tutorial is enough? I am worried about updating the splatmap all the time

final kestrel
#

Thanks.

swift crag
swift crag
sacred zenith
swift crag
#

Oh, one thing

#

TerrainPaintUtility lets you paint on terrain textures with a material. This is a lot nicer than manually editing the splatmap (and is a lot faster, too)

#

it can also correctly affect multiple terrains at once

#

It took me a fair while to figure out, though

#

I'm still a little rough with painting on textures

sacred zenith
#

Damn, this might be the edge I needed! I noticed some lagging when I coded the splatmap update

swift crag
#

I used it to stamp textures on the ground to make footsteps for a giant enemy

#

as well as to deform the terrain

polar acorn
#

It cannot continue to call other callbacks

sacred zenith
#

Aight, thank you! This will help

timber tide
swift crag
#

it's not that you've experienced a "really bad" exception or a "safe" exception

#

it's an uncaught exception. everything goes bye-bye.

#

Although, I guess it's fair to phrase it that way.

polar acorn
#

The exception is "caught" meaning that the runtime has basically Old Yeller'd that entire function

#

Unity just told that event to close its eyes and think of the rabbits

swift crag
#

every function going all the way back to the point where Unity called your Update method

livid jacinth
#

I'm getting an issue where I can't attach a script to an object because the script class can not be found, and the inspector says no MonoBehaviour scripts are in the file and I'm not sure why? the names are matching exactly and I do have MonoBehaviour in the class, I'm not sure what else to check

swift crag
#

or however else this thing was originally called

swift crag
#

clear the console and look for any errors.

#

Ensure that you haven't filtered them out. Light-gray buttons are enabled. In this case, errors are hidden.

livid jacinth
#

Ooooh okay, let me try that

dawn sparrow
#

Didn't realize that's how it worked

swift crag
#

This is how all of your code works.

#

Exceptions are not to be confused with just calling Debug.LogError. That just prints a message with a red icon to the console

#

if you use gameObject.CompareTag with a bogus tag, you get an error in the console

#

but it doesn't throw an exception

dawn sparrow
#

I just assumed that since the error came after the log, and since they're all seperate scripts, the log was accurate

swift crag
#
foo.DoThing();
bar.DoThing();
baz.DoThing();

if bar.DoThing() throws an exception, baz.DoThing() will never be reached

#

exceptions are not confined to object instances (what you called "scripts")

dawn sparrow
#

Yeah see that's where I had a misconception

swift crag
#

the call stack is the sequence of methods that were called to reach you

#

an exception will unwind the call stack until it's caught

dawn sparrow
#

I knew that code after an error isn't called, but I thought seperate scripts wouldn't affect one another, so I could ignore the error

#

anyhow probably a pretty good rule of thumb to fix red things first before worrying about why your code isn't working lol

#

Thanks for the help

swift crag
#

no prob

#

and yes, that's a good idea: attack the first error

#

you'll often have hundreds of errors: one of type A, and many of type B

#

but the second error is just a consequence of the first error

dawn sparrow
#

Yeah I see that now

#

Thank you

livid jacinth
#

I've been working on something for a little while, I saw a comment on reddit saying I should be able to do this, but maybe they weren't correct. I'm trying to use a GameManager script as kind of like a hub to manage different things like what day it is, currency, etc. So I'm testing it out and my GameManager script looks like this: https://pastebin.com/u3BEjUQJ

My CurrencyManager script looks like this: https://pastebin.com/gkHG0wes

And the third script I'm trying to access it through looks like this: https://pastebin.com/1A1dWJRU

In the third script I'm getting an error that says "An object reference is required for the non-static field, method, or property 'GameManager.currencyManager'". I have the CurrencyManager script assigned in the inspector in Unity and I'm not entirely sure what's missing. I can put currencyManager as static, but that kind of makes having GameManager pointless. Is this even possible to do?

river roost
#

And use it like this:

GameManager.Instance.curencyManager.AddCurrency(30);
swift crag
#

GameManager is a type name. You don't have a specific GameManager.

#

So, you can only access static members from it.

livid jacinth
#

Ooooh ok I haven't looked into instance a whole bunch, I was having it attached to a GameManager object that is on the main screen and I just had DontDestroyOnLoad, I'll look into this some

timber tide
#

singleton everything

livid jacinth
#

Thanks!

swift crag
#

also, singletons are fine. the example in that article makes no sense. the example provided (adding extra options to a 'play sound' method) happens in literally any case where you use the same type in many places.

#

use a singleton when there is a single instance of something that everyone can unambiguously talk to

#

if this is not the case, do not use a singleton

#

that's what's going to cause you problems

#

(moving from a singleton to a non-singleton can be reasonably painless, especially compared to just having a class with lots of static members)

timber tide
#

Any type of pooling is a good example of a singleton

swift crag
#

you just need to replace every instance of SingletonType.Instance with a specific reference

timber tide
#

audio, vfx, enemy templates, item containers

river roost
swift crag
#

what?

#

object pooling has nothing to do with scriptable objects

#

an object pool is a collection of instances you can hand out when needed, instead of instantiating or constructing them on-demand

river roost
#

Yeah

timber tide
#

audio is actually a little tricky, you wanna smart pool it usually

#

bad idea to cache too much of it

river roost
#

If you use singletons, you can't have different pools with the same type, unless you make a new type for every poolable object

swift crag
#

well, yes: you no longer have a singleton anymore

#

so you shouldn't use a singleton

#

I would put multiple pools onto a singleton instance.

#

If I needed to be able to assign a specific pool to each user of pooled objects, then I would not use a singleton at all

timber tide
#

Yeah, if you have a base enemy template, you don't really have much of a type difference if they all derive similarly.

zenith cypress
swift crag
#

you can get very interesting surprise behavior when the SOs are loaded and unloaded

#

(although, using SOs as keys is perfectly reasonable)

#

(in which case you'd be showing the key to a singleton pool manager, of course..)

river roost
timber tide
#

Single enemy type, your SO decides the composition/components

river roost
timber tide
#

advisiable you don't swap too many components then it becomes a question if instantiating is faster

river roost
#

yeah

#

You're gonna have different prefabs for each enemy type

timber tide
#

Depends on how you want to make your game, but swapping out a model and stats could be all you need to do.

river roost
#

if you have a very simple game i guess

swift crag
#

Dictionary<GameObject, ObjectPool<GameObject>>

You'd pass it a prefab reference and get back an instance.

#

It might instantiate a new instance, or it might grab one from the corresponding ObjectPool

#

(i might use a more specific type, like Enemy)

#

This would let you pool any prefab you want

swift crag
livid jacinth
#

Thanks guys, I remember seeing that it can backfire so I'm just trying to keep it as like a hub to be able to manage things like inventory/money management, keep the time of day from one scene to another, etc

#

I appreciate the help

swift crag
#

Just make sure that the singleton really is single!

#

Also, think a little about whether the singleton will always be available

#

(or at least, always be available when it might actually be used)

#

if an enemy makes use of FooSingleton, and it's not reasonable for FooSingleton to always exist when an enemy exists, something is wrong

zenith cypress
#

Yeah ours uses Component so we can just pass in a component-typed prefab

swift crag
#

oh hey, there you go

river roost
#

This is one of the use cases for scriptable objects, instead of a dictionary with ids and stuff held somewhere in a singleton. It's really just personal preference in this case

swift crag
#

I do not see a use-case here.

#

at best you'd just have a singleton by a different name

river roost
#
[CreateGenericAssetMenu]
public class CustomObjectPool<T> : ScriptableObject, IDisposable where T : Component, IPoolable<T> {
    [Header("Object Pool")]
    [SerializeField] T _prefab;
    [SerializeField] bool _collectionCheck = true;
    [SerializeField] int _defaultCapacity = 10;
    [SerializeField] int _maxSize = 10000;
    [SerializeField] bool _clearOnSceneChange = true;

...
}
```This is how my pool looks like (using GenericUnityObjects to create generic instances). There's not much of a difference in practice. I does however allow me inherit from this to create specialized pools, such as a UI pool that efficiently disables and reparents objects to avoid uneccessary dirtying. It also lets me change the settings for any individual pool, but does require slightly more setup since you have to create an instance. I did however make a simple menu item to generate one from a component on a prefab
delicate portal
#

Hello! How can I visualize a capsuleCast? This just doesnt seem to work, the player is colliding with the thin air sometimes when there isnt something in front of it.
float moveDistance = movementSpeed * Time.deltaTime; float playerRadius = 0.05f; float playerHeight = 2f; bool canMove = !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight, playerRadius, moveDir, moveDistance); Debug.Log(canMove);

swift crag
river roost
#

also use three ` to get nicer formatting on the code

swift crag
#

Make sure to enable the appropriate checkboxes

#

You will then see physics queries in the scene view. they'll only last for one frame, mind you

delicate portal
#

Looks like this for me

swift crag
#

That is the wrong tab.

zenith cypress
#

damn they are making my visual physics package obsolete 😠

swift crag
#

Go to the Queries tab.

swift crag
delicate portal
#

There is no other tabs

swift crag
#

But not having scene objects is a plus...

swift crag
zenith cypress
#

Seems before 2022.2

river roost
swift crag
#

If you can't use the physics debugger to visualize the cast, then the next best thing would be to use Debug.DrawRay

swift crag
zenith cypress
swift crag
#

It's a really pleasant-sounding idea

#

It feels like I should like it

nimble laurel
#

Hey all, I’m pretty new at this still and I’m trying to follow different tutorials and the like to make my own multiplayer game using Netcode for GameObjects.
I’m wondering if anyone else has had trouble trying to understand how to implement item inventories like individual inventory, shared chests, and shop inventories.
Just at a basic level, should the inventories only be created/instantiated on the server side or should I be using things like IsOwner and instantiate the players personal inventory on the client and others on the server.
But then I have questions about sending the item data via rpcs and there’s a whole bunch of issues with serializing the stats of the item.
Has anyone seen someone’s project or tutorial that can really help me understand what I should be doing?
Again, super new so really appreciate and guidance and patience over my probably misunderstood ideas.

swift crag
#

I might give that package a crack sometime soon.

river roost
#

I've built my game in a similar way but I just found this couple of days ago

swift crag
#

I was put off of using SOs for mutable data by their unpredictable behavior in-editor vs. in-game

#

in short, they live until you switch scenes or exit the editor

river roost
#

Yeah the lifetimes are weird

#

but the author of the package probably figured all that out

swift crag
#

yeah

zenith cypress
#

I think the only SO in our game that is mutable atm is for our settings. We assign it to places that need it, and when the game is going, they can have direct access to the updated data.

swift crag
#

I got burned by this in the middle of a game jam lol

#

so it made me very upset

zenith cypress
#

It's quite handy

delicate portal
swift crag
#

It seems kinda cool to just slot in an asset reference to provide a setting value

#

My current system is enum-based

wild wolf
swift crag
#

e.g. Prefs.GetPref<Pref.CameraShake>() returns Pref.CameraShake.On or Pref.CameraShake.Limited or Pref.CameraShake.Off

#

it uses the dynamic keyword

#

evil

river roost
#

ew

zenith cypress
river roost
#

ironically i use a singleton for my settings

swift crag
#
        toggle.onValueChanged.AddListener(delegate
        {
            if (toggle.isOn)
            {
                dynamic en = Convert.ChangeType(value, prefType);
                Prefs.SetPref(en);
            }
        });
#

SetPref is generic, so I need to be able to provide it a specific type

#

big scary

river roost
#

that's a bit cursed

swift crag
ember spear
#

Can you change the disabled sprite of a button during runtime, and if so how would that be done?

swift crag
zenith cypress
#

Fen over here writing python types 😔

wild wolf
swift crag
#

do not attempt to ping the entire server

wild wolf
zenith cypress
#

solution: don't tag anyone and wait

swift crag
ember spear
#

I mean you're trying to tag like thousands of people lol

swift crag
#

so far you have not

wild wolf
#

sorry

swift crag
#

explain what, exactly, you want to accomplish, and what you've tried so far

river roost
#

still a bit ugly

swift crag
wild wolf
river roost
swift crag
#

It is. This code is attached to a Toggle used to pick from one of several options for a specific kind of preference

river roost
#

Yeah, so value is int?

swift crag
#

public Object value;

#

i'm going to stop looking at this code now 🫠

river roost
#

me too

swift crag
#

for localization

#

I have to do some hilariously cursed things with attributes to attach that data to the enum types directly

river roost
#

I am proud of being able to do this though

swift crag
#

I auto-generate my entire settings menu

#

_prefTypes ??= AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Preferences").SelectMany(t => t.GetTypes()).Where(t => t.IsEnum && t.Namespace == nameof(Pref)).ToList();

AAAAAAAAAAUGH

river roost
#

What the

swift crag
#

well, if each preference is an enum type

#

then i need to get all the enum types

river roost
#

is it worth it?

swift crag
#

probably not, in hindsight

#

but the system works pretty well

zenith cypress
swift crag
#

I might scrape it out and replace it with something SO-based

river roost
#

if it works it works

ember spear
#

Seems like they use SpriteStates

#

at least for the spriteswap transition type

swift crag
#

yeah -- so you'd need to get the existing SpriteState, set a new disabledSprite, and then put the modified SpriteState back in

#

since it's a struct

river roost
#
public Sprite disabledSprite    { get { return m_DisabledSprite; } set { m_DisabledSprite = value; } }
```This is the stupidest property I've seen
swift crag
#

You often see properties used when you're actaully modifying something on the native-code side

#

not in this case

zenith cypress
#

This is just a field at that point Kappa

slender nymph
swift crag
#

well, it does feel a little bit unnecessary

ember spear
#

🙃

swift crag
#

turning a field access into a method call

river roost
#

this is not decompiled

delicate portal
#

Hello! How can I visualize a capsuleCast? This just doesnt seem to work, the player is colliding with the thin air sometimes when there isnt something in front of it.

        float playerRadius = 0.05f;
        float playerHeight = 2f;
        bool canMove = !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight, playerRadius, moveDir, moveDistance);
        Debug.Log(canMove);```
swift crag
#

i suggested just using Debug.DrawRay

#

did that not work for you?

ember spear
#

Please argue more over this so I may learn

slender nymph
ember spear
#

From the top rope!

ashen ferry
#

what yall tryna show with m_ prefix just googled its a left over from c++ or something but things like cinemachine fields have those prefixes

river roost
swift crag
#

cinemachine got rid of that in Cinemachine 3.0

ashen ferry
#

but its useless

swift crag
#

i mean, names are useless

#

you could name every member member_####

#

with an incrementing number

ashen ferry
#

typing m_ sounds like so much extra work instead of starting lower case or upper case according to scope lol

short hazel
#

C# fields should start with an underscore to differentiate them from local variables, so you're not that far from m_

slender nymph
swift crag
#

In ye olden days, before we had lots of code analysis and good IDEs, it made more sense

#

hungarian notation shudder

river roost
#

There's also this Static fields start with s_.

#

but ive never seen anybody do it

swift crag
#

use C for classes

#

hmmm

#

this also takes about using the I prefix for interfaces

#

i'm not a huge fan of that

#

i don't care if Foo is an interface or not; I just want a Foo

delicate portal
#

How am I getting this error? I don't even have a cabbage variable in the script

swift crag
#

I do it anyway beacuse VSCode tells me to and I haven't bothered to configure it

river roost
#

But what if I(am)Foo

swift crag
#

(make sure you've saved and reloaded the code in unity first)

slender nymph
# swift crag > use `C` for classes

isn't that bit actually about the convention used in the language specification and not actually a recommended naming convention for real code?

short hazel
#

If you don't want to put I before your interface name, go back to Java and send someone more appropriate for programming

swift crag
#

The preceding single-letter names are allowed only in the language reference section.

#

Me read good

swift crag
short hazel
#

Used it 1.5 years, it's enough, so 1000 would be my death

clever jackal
#

Hey can someone help me out plss.
I'm Trying to make the angle adjustment on click and drag shown in video in unity.... tried so hard but were not able to do that.... could someone help me out.. I'm a beginner..

delicate portal
zenith cypress
#

Restart your IDE

delicate portal
#

Wait is it your tool?

zenith cypress
#

Yes

#

(bad timing, but i have to run to an appointment so I won't be around for a bit)

delicate portal
#

Ah sheesh

#

Alright nevermind

#

Wil talk to you if you get back, can you?

zenith cypress
#

Yeah looks like VS. Restart VS and it should be there. If you are using asmdefs, add the package asmdef to it, otherwise it should work fine. Otherwise add the namespace manually. 🫡 If you still have problems I will assist when I get back.

delicate portal
#

Thanks, will try everything

clever jackal
slender nymph
#

you probably want to use line renderers for the lines and just set the first position as the position they connect to the base to and then just change the second position to the position of the sphere

clever jackal
craggy lava
#

How do i change the color of the background color of a camera in C# script?

ember spear
swift crag
#

👍

swift crag
#

You'll see this in a few different places

#

Newer C# has nice syntax for "updating" record classes and record structs, so that you don't have to make that local variable

#

I forget which version that appeared in

#

(and Unity doesn't use them, so w/e)

ember spear
#

I'll take a mental note of that, great tip.

swift crag
#

dies

slender nymph
#

records support with expressions in c# 9 but unity doesn't have full record support anyway. c# 10 introduced support for structs

swift crag
#

yeah

slender nymph
#

with expressions are so convenient though. i've been using them in godot quite a bit

swift crag
#

They remind me of Haskell

#

(non-derogatory)

#

:p

stiff stump
#

GameObject item = Resources.Load<GameObject>("Assets/Resources/Weapons/Pistol");
returns null not sure why i copied path file from the resource but still null

swift crag
#

Read the documentation for Resources.Load.

#

You are not using it correctly.

stiff stump
#

silly me 🤦‍♂️

swift crag
#

no prob, it's easy to do (:

slender nymph
#

yeah pretty common mistake

swift crag
#

Unity mashes all of your Resources folders into one big folder

#

and you address things relative to that

swift crag
hushed hinge
#

uhm, now I got a problem, after I got the screen scaling fixed, and when I test it out and press on the button player 1 for only 1 player to appear, both of the players appears instead. I did got all the help from someone on dms but after the screen scaling help, this happens, I don't get why

fickle knoll
#

i need some help, this is prob like the first lines of code that i have written but it does not work and i dont know why please help me.

public class FollowPlayer : MonoBehaviour
{
public GameObject player;
public float rotation = 36.0f;
private Vector3 offset = new Vector3(0, 11, -12);

void Start()
{

}


void LateUpdate()
{
    transform.position = player.transform.position + offset;
    transform.rotation = rotation;
}

}

eternal falconBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

polar acorn
#

(Didn't fat finger it this time)

fickle knoll
#

can you explan it

#

im dumb

polar acorn
#

First off, share your code formatted properly according to the bot's instructions

#

Second what is the actual problem

slender nymph
#

i'm gonna go with, it's the compile error on the last line

polar acorn
fickle knoll
#

it says "Cannot implicitly convert type 'float' to 'UnityEngine.Quaternion'"

rich adder
polar acorn
fickle knoll
#

then what should i do

slender nymph
fickle knoll
#

nope

slender nymph
#

then configure your !IDE

eternal falconBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

fickle knoll
#

what should i download

rich adder
fickle knoll
#

it dont work

slender nymph
#

what doesn't work?

fickle knoll
#

the red underline

slender nymph
#

did you go through the entire configuration guide for the correct code editor?

fickle knoll
#

yes

slender nymph
#

which one are you using?

fickle knoll
#

the 2022 version

slender nymph
#

screenshot the entire visual studio window with the solution explorer open and visible

fickle knoll
#

what is the solution explorer?

rich adder
slender nymph
fickle knoll
#

im trying to screenshot but it aint working

slender nymph
#

is your snipping tool broken or something?

fickle knoll
#

im pressinmg print screen but nothing happening

slender nymph
#

oh my god

fickle knoll
#

the key on the keyboard

slender nymph
swift sedge
#

ctrl - v

fickle knoll
#

dude i already did that

wintry quarry
swift sedge
#

also use WinKey + Shift + S instead

#

its 10x better

#

allows you to snip certain regions of the screen

fickle knoll
swift sedge
#

the IntelliSense is not working

slender nymph
#

go through the entire guide again because you very clearly missed something

#

and click the Regenerate Project Files button when you see it

ashen ferry
#

using System.Security.Cryptography

#

bro onto something

polar acorn
# fickle knoll

Not configured. You've missed a step somewhere. Did you get the last step where you're supposed to restart VS

slender nymph
fickle knoll
#

it was just there

#

i didnt type it

swift sedge
swift sedge
#

unity only has Collections and Generic

#

and Unity Engine

#

ofc

fickle knoll
#

im doing the unity pathway thingy so in the scripit is was just there

slender nymph
swift crag
#

probably the result of aggressive auto-completion of type names

slender nymph
fickle knoll
#

doing it again

#

rn

slender nymph
#

make sure you do not skip any steps. with the exception of installing Unity and Visual Studio again. you do still need to use the visual studio installer for the unity workload though

dawn sparrow
#

Anyone know if it's possile to use enums as paramaters in the animator?

swift crag
#

No. Animators can only have int, float, bool, and parameters

slender nymph
dawn sparrow
#

That's too bad

slender nymph
#

you can use ints since enums are just ints with nametags anyway

swift crag
#

Of course, you can convert an enum value into an integer. But there will be no relationship between the int and the original enum

dawn sparrow
#

Yeah, just looks way neater to use enums

swift crag
#

you won't be able to see your enum names in the animator, and the animator won't update if you rearrange or change the values of the enum values

dawn sparrow
#

With ints im constantly having to go between my enum list and manually convert that to int

swift sedge
#

an enum is just an array of items with names

swift crag
#

an enum type is a type with zero or more values

#

it's not an "array", for sure

swift crag
swift sedge
#

oh

#

enum = enumeration

dawn sparrow
#

I guess another option is a fully code-based approach

swift sedge
#

(thats what i have)

slender nymph
#

yes

swift sedge
#

so maybe grasshat doesnt have that installed

slender nymph
#

probably, hence my instructions for following all of the steps including that step

slender nymph
#

being ignored implies that people intentionally did not reply to you. however that is clearly not the case since you ignored follow up questions #💻┃code-beginner message

fickle knoll
#

well i have to go i will try to figure it out tommorrow

shadow flame
#

when i start game my main menu pops up and goes into main game scene

#

idk how to fix

slender nymph
#

please see #854851968446365696 for what to include when asking for help. right now, with no context we can really only guess at what the issue might be

shadow flame
#

this pops up for a second then it switches scene to to

slender nymph
#

screenshots of your menu and scene aren't really going to tell us anything

shadow flame
#

what can i do

rich adder
slender nymph
shadow flame
polar acorn
slender nymph
#

well there you go, you're loading the level1 scene in Start

polar acorn
# shadow flame

Okay, so, when this object is created, you go to level1. Is that what you want

shadow flame
#

is that not when i click start

#

?

swift crag
#

why would it be?

polar acorn
shadow flame
swift crag
#

I suppose it is, technically

slender nymph
#

damn beat me to it

swift crag
#

but Start is a unity message.

#

Name it something else.

shadow flame
#

ohh

#

and

#

what is this

swift crag
#

you probably moved the file.

rich adder
#

maybe deleted file

#

or moved

shadow flame
#

ok thatnks

lime leaf
#

Does anyone how I can speed up my unity project load time?

polar acorn
#

And the fact that it's in Miscellaneous Files means you haven't configured your !ide

eternal falconBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

swift crag
#

also, "Miscellaneous Files" being there implies your IDE isn't set up properly. Are you getting error highlighting and completion suggestions?

#

zoop

polar acorn
#

That's really your only option

lime leaf
#

I just made one and it is taking like 30 Minuets to load it

slender nymph
swift crag
#

you will get slow loading if you're using a slow hard drive or have antivirus software trying to scan all of the tiny files unity makes

lime leaf
#

Also this just came uo

shadow flame
#

1 more thing i just dont know how to explain it

polar acorn
#

You can either speed up the machine or make it have to do less

swift crag
#

Unity-5.x is..alarming to see

rich adder
#

packages are downloading

shadow flame
#

is there a way to stop my charecter from spining after going off a corner of a box collider

swift crag
#

freeze rotation on the rigidbody.

rich adder
lime leaf
#

Is this a major issue?

polar acorn
lime leaf
#

2022.3.10f1

slender nymph
#

it's not an issue, you can just reset the layout and it should prevent that warning from happening again

rich adder
#

i had that too not sure wats it about

slender nymph
#

if it is an old project, that is to be expected opening it in a recent editor version

polar acorn
lime leaf
#

It is still there

rich adder
#

clear console

lime leaf
#

Thank you!

bright violet
#

I'm having problems with the raycast hitbox of an UI Image, the hitbox is skewed and I can't get why

wintry quarry
bright violet
bright violet
wintry quarry
#

possibly something else is blocking it

bright violet
rich adder
bright violet
wintry quarry
bright violet
#

it's not a collider

wintry quarry
#

not the move tool

#

though I suspect it will show the same box...

rich adder
#

weird

bright violet
bright violet
rich adder
#

btw always b sure you're working with pivot mode not center

rich adder
bright violet
#

i forgot abt that

#

i still don't get what the problem is

rich adder
#

can you share script

bright violet
#
public void OnPointerClick(PointerEventData eventData)
{
    if (selectable) { 
        if (!selected) {
            selected = true;
            Events.selected.Invoke(eventData.pointerClick.gameObject);
        }
        else
        {
            selected = false;
            Events.unselected.Invoke(eventData.pointerClick.gameObject);
        }
    }
}```
bright violet
rich adder
#

you can try looking at event system inspector in playmode see whats going on there as well

bright violet
ashen ferry
#

wtf is going on with ur scale bro fix that before u gonna need to rescale everything like I had

rich adder
ashen ferry
#

still rescaling btw lmfao I wanted draggable rect and sensitivity was off cause of scale

bright violet
bright violet
rich adder
#

you debug.log and made sure line is running, more details on how you tried to debug would help

ashen ferry
#

what do you mean eventSystem shows same behaviour, when you hover over your button is Name correct or no

bright violet
#

it is fixable by changing meshtype from Tight to FullRect

bright violet
rich adder
#

idk I tried test alphaHitTestMinimumThreshold but never used it.. cs Using alphaHitTestMinimumThreshold greater than 0 on Image whose sprite texture cannot be read. Texture 'aaa' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings. Also make sure to disable sprite packing for this sprite.

bright violet
rich adder
languid spire
rich adder
#

oops

polar acorn
rich adder
#

reading skill issue UnityChanOops

rich adder
bright violet
# rich adder which part? its a long ass thread xD

"Hi again! Found a real solution: pixels won't be shifted IF you change the texture's import properties: MeshType = from Tight to FullRect. According to the Unity help on SpriteMeshType is:

FullRect = Rectangle mesh equal to the user specified sprite size.
Tight = Tight mesh based on pixel alpha values. As many excess pixels are cropped as possible.

That explains our problem: if we use Tight, then alpha=0 pixels on the four edges are cut off, this is why the coordinates get shifted by the alphaHitTestMinimumThreshold bug. That's it :)"

rich adder
#

wow this is some obscureness I just learned about UI 👍

bright violet
#

ikr?

rich adder
#

is working now for you?

#

pretty kewl

bright violet
#

I'm creating a map editor and that was crucial

shadow flame
#

how can i load next scene without the name

#

instead of "level2"

rich adder
bright violet
shadow flame
bright violet
#

well in your build settings you're gonna put all the scenes ur gonna use

#

and they're gonna have an index

#

from 0 to X

shadow flame
#

like that