#💻┃code-beginner

1 messages · Page 100 of 1

worldly jolt
#

im downloading visual studio it takes so long

#

vscode is not good for c#

#

unfortunately

magic linden
#

Really?

worldly jolt
#

no theres lots of extra features in visual studio that arent in vscode

#

and visual studio is build for just .NET and c++ developement wheras vscode is for a lot of languages

static cedar
#

Actually it's whatever people make it for. UnityChanThink

#

So it's close enough I guess.

worldly jolt
#

wdym

#

this gonna take so long

static cedar
#

You generally download packages, made by 3rd parties sometimes. Before using VSC.

#

I'm also fairly certain that the C# package (by Microsoft) is discontinued for VSC. But unity has its own package for unity development specifically but VS is still better supported anyways I think.

magic linden
#

Yeah visual studio's auto-complete functions are amazing

static cedar
#

You also have suggestions.

queen adder
worldly jolt
#

rider is like $1000000 per month

#

289 usd per year for the full ide

#

149 for the min

static cedar
#

Real.

#

The only thing Rider has and VS don't is namespace refactoring in masses.

#

You do have sync namespaces but come on, it will turn your namespaces into MyGame.Assets.Scripts.. I don't like it.

woven arrow
#

Hello guys, I have a question:
I am trying to create a 2D Plattformer and I want to have a isGrounded Variable in my PlayerMovement Script. The Script has to know what's Ground and what's not, so I watched a tutorial in which Layers were used to define what is ground and what not. My Question: What's the difference between Layers and Tags? And when to use which one?

languid spire
woven arrow
#

So in my case tags are the better choice?

languid spire
#

no, Layers are the better choice

woven arrow
#

But my case has nothing to do with RayCasting, or did I understand something wrong?

languid spire
#

it's not just RayCasting, that was just an example, it's also useful for optimizing Collisions and Triggers

woven arrow
#

So when to use tags?

languid spire
#

I never use tags

woven arrow
#

Ok 😄

#

Thank you for the help

queen adder
#

Why is my A* Pathfinding agent returning a desired velocity of 0?

#

While it is still moving towards a target?

#

I've checked that I'm including the library, "using pathfinding;", the prefab has a component called AIPath

#

The AI destination setter gets set

languid spire
queen adder
#

That wonder around the garden area

#

I'm using a state machine to set them to wander around

#

By setting a random target position

slender nymph
#

that wasn't their point. the point was you are checking those values on the prefab not the instance(s) in the scene

#

of course the prefab which is not in the scene will have a desiredVelocity of 0 because it is, notably, not in the scene to even get a path

queen adder
#

this does make sense actually

languid spire
#

yes, oh!

queen adder
#

embarrasing 💀

lean basin
#

Hello, I'm trying to use DOTween to tween Rig's weight property. But it gives an error

public void SetEnabled(bool status){
        rigObject.weight = 1f;
        if (status) {
            DOTween.Kill(uid);
            DOTween.To(rigObject.weight, x => rigObject.weight = x, 1f); // << The error is in this line, in the variable X in second argument.
        }
    }

Error message is : Cannot implicitly convert type 'string' to 'float'
Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists (are you missing a cast?)

I don't know where the string is coming from.

languid spire
#

I think the string is a false positive. Try (float)x

slender nymph
#

isn't the first parameter of DOTween.To supposed to be a delegate? 🤔

rare basin
#

you can just do Tween tween

#

then tween.Kill();

#

and you might want to use DOVirtual.Float

#

if you want to modify float during X seconds

#

(startValue, endValue, duration, delegate)

lean basin
teal viper
# lean basin

I don't think you can parse it into float implicitly.

round moon
#

can someone explain why my virtual came change position after i set follow to object amir(player) but when i see on udemy when virtual camera set follow to player(doggy) thats position virtual camera stay ?

#

"btw sry if my typing english it doesnt good anyway bro🙏 "

wind meteor
#

why

#

when

#

i play the game

#

its dont work

slender nymph
#

jesus christ, finish your thought before pressing enter

wind meteor
slender nymph
#

your camera is likely not where you think it is

wind meteor
round moon
#

ssshh i cant recrod it on udemy just blank @,@

wind meteor
teal viper
round moon
#

Wait ill record via my phone

round moon
round moon
royal ledge
#

Do particles collider force work right of the box or do i have to grab the collider force in a script and write it's behaviour?

#

Solved: Yes it does just work, had to just adjust some settings

cunning rapids
#

Set a raw image's anchor to scale with screen size but the white triangle didn't cover the entire screen?

slender nymph
slender nymph
#

so tell them that, not me

acoustic arch
queen adder
#

Hi all i got a question.
In my game right now i have a panel with a scrollbar that has hundreds of different rewards in it.
Those rewards become active when the player levels up.

So say they reach level 10. Then the 10th reward will be available to claim.

The only problem i have is if the player reaches say level 50, they open the panel scroll to the 50th reward claim it and close the panel.
Then when they level up to level 51. They have to scroll again all the way from the 1st reward through to the 51st.

Is there any way that i can save the scrollbar or something so when the player levels up to say level 51 then when they open the panel it will automatically show the 51st reward and they dont need to scroll from the 1st all the way through to the 51st.

little meteor
#

Hi all i got a question.

azure zenith
#

I am making a main menu, however I would like a background image in my main menu. I want to get the background image of my gameplay. How can I get it?

eager elm
pure sigil
#

Hey everybody 👋 I'm making an old school ddrpg game in unity in the style of eye of the beholder. I'm getting stuck on character movement/rotation. I'm having trouble rotating my character and setting where they are looking as their new look position so that i can move forward in that direction. In this case if I want to move forward (by pressing the W key) they move in the original forward vector and not the new rotation forward vector. Any help is greatly appreciated!

upbeat merlin
#

New to Unity. Does anyone know what Carl(the guy is the unity tutorials) uses as extentions in his visual studio?

#

It would help me a lot having to not remember everything word by word

fossil drum
eternal falconBOT
upbeat merlin
#

Thanks

sand veldt
#

i have an issue with unity animation it was working fine before i created a andoride build but not its not work any reasons

#

they are playing in animator but its not show up

celest flax
#

If you have an if-case like if(a || b, which condition is tested first?

eager elm
#

left to right

upbeat merlin
fossil drum
upbeat merlin
#

The descriptions do appear while hovering over the written formula

#

But dont appear in the selection menu

fossil drum
#

Oh, this is Visual Studio Code...

upbeat merlin
#

It is

upbeat merlin
fossil drum
upbeat merlin
#

Oh

#

My bad OG

fossil drum
#

Visual Studio and Visual Studio Code are 2 different programs

#

What are you looking at from Carl then?

#

Can you show a screenshot of that?

upbeat merlin
fossil drum
wintry quarry
#

yep, definitely not VS Code

upbeat merlin
#

Well then which should I usemad

#

Im confused

wintry quarry
#

That's up to you

#

If you want it like your Youtube guy, use Visual Studio

upbeat merlin
#

I mean code has similar things

#

So I might just stick to it

#

Thanks

upbeat merlin
#

Thanks a lot

boreal tangle
#

Does someone know how I fix this. I just try to put a repository in my unity project but this pops up

timber tide
#

I don't think you need us to read that for you

boreal tangle
#

I know what it says but I can't just remove the file

fossil drum
frosty hound
#

You should be using the unity gitignore so you're not pushing the Library folder

slender nymph
boreal tangle
#

Why

lucid jetty
boreal tangle
#

Ok

frosty hound
#

Library folder is locally generated when you open the project, there's no reason to commit it.

boreal tangle
#

Ok

frosty hound
#

It's also massive, as you're seeing

boreal tangle
#

Yeah

#

Thank you

lucid jetty
#

Hello im making a enemy ai system that kills the player when he got hit by the enemy but the problem is that it doenst work do you ❤️ it would help me a lot if you guys know how to fix this problem here are my two codes:

https://pastebin.com/eh5PprRk Enemy
https://pastebin.com/zEH1p8hN Player script

timber tide
#

Probably clarify what part isn't working and what have you debugged

lucid jetty
#

i debugged when i touch the enemy but i dont see boom so

timber tide
#

well, for one I think you should consider letting the player handle the callbacks for damage when they collide with the enemy

timber tide
#

Do you have colliders on both the player and enemy yeah

#

one of them needs to have a trigger collider is you're using the collision events

#

I don't think it works if both are trigger colliders though, I'm a little rusty on them

boreal tangle
#

When making a git repos, do you know which option is the library I need to ignore

lucid jetty
wintry quarry
boreal tangle
#

Ty

timber tide
#

ah, try adding a kinematic to the enemy

lucid jetty
timber tide
#

I'm assuming you're just using trigger events but not the actual physics

lucid jetty
#

only when i disable the is kinematic in the rigibody then the scene would load but the ai is not chasing the player

timber tide
#

player has a rigidbody too right?

lucid jetty
timber tide
#

Honestly, I would just suggest using spherecast at that point then

lucid jetty
#

istead of the rigibody for the enemy or in the script?

timber tide
#

Each enemy can spherecast (or circlecast for 2D) around themselves, and you just do the collider checking* through that

#

what you're trying to do is possible but it's some combination of kinematic rigidbodies and triggers. Oh, actually im confused, maybe you're just using collisional events when you actually want trigger events

maiden compass
#

Hey guys how you doing ? I have a really simple thing I would like to do,

I have a shadergraph where I have a float property, I would like to change that property accordingly to a timer that I have in a script.

How can I do it ? I'm not familiar with normalize or things like that.

lucid jetty
#

because im trying to fix this problem now for 4 hours straight but i dont have a clue what i need to do

maiden compass
rich adder
maiden compass
#

My property have a range from 0 to 1, and my timer from 0 to 5 ThinkO_O

#

Give me 1 sec

eternal falconBOT
maiden compass
#
    [SerializeField] private Material paleSkinShader;

    [SerializeField] private float timerLenght;

    private bool timerCount;

    private void Update()
    {
        if (timerCount)
            timer();
        else
            return;
    }

    private void timer()
    {
        float timeLeft = timerLenght;

        timeLeft -= Time.deltaTime;

        if (timeLeft !< 0)
            timerCount = false;
    }
#

(I know it's probably trash, it's just to prove a concept so it's okay)

timber tide
buoyant knot
#

learning about new() was a gamechanger. Can't believe I've been here for 6 months, and I just learned it a couple weeks ago

timber tide
#

wat

rich adder
maiden compass
rich adder
#

not at all

maiden compass
#

Yeah..

#

I knew I didn't understand x)

rich adder
#

min and max are the values of your timer

#

if you said 0-5

#

then min is 0 and max is 5

timber tide
rich adder
#

timerValue is your current timer time @maiden compass

#

btw this float timeLeft = timerLenght; should prob not be in update '

#

since you only want it to set to max in start of timer

maiden compass
#

You're right

rich adder
#

alright, after thats fixed should be able to get it working

float minValue = 0;
        float maxValue = 5;
        float timerValue = 2.3f;
        float normalizedValue = (timerValue - minValue) / (maxValue - minValue);
        Debug.Log("Original Timer Value: " + timerValue);
        Debug.Log("Normalized Value: " + normalizedValue);```
as An example, gives
maiden compass
#

Gonna try that ! Thanks !

rich adder
#

! means not

#

so if time left is not smaller than 0 set timer to false

maiden compass
#

Oh, though it meant strictly inferior

#

Didn't script in month, I'm rusty

#

(not that I knew what I was doing before frog_smirk)

rich adder
#

thought you meant you did so much Rust for a second you forgot c# 😏

edgy hearth
#

Would this video tutorial for wall running work if I was using a character controller instead of a rigid body? https://youtu.be/gNt9wBOrQO4?si=CEjm3NCtuuN6ypJG

ADVANCED WALL RUNNING - Unity Tutorial (Remastered)

In this video, I'm finally going to remaster my old wall running tutorial code. This wall running ability feels a lot cleaner!

If this tutorial has helped you in any way, I would really appreciate it if you leave a like in return. And you can also subscribe to this channel if you want to see ...

▶ Play video
timber tide
#

I'm confusing myself now. Does unity really require rigidbodies for OnTriggerEnter? Why does that even make sense

#

It should be be independent to that of the collider component

rich adder
#

its a physics object as well 🙂

timber tide
#

Docs saying you do need a kinematic rigidbody

rich adder
#

cc is very similiar to a kinematic rb

#

its like mix between kinematic and rigidbody or somehing

timber tide
#

Yeah, but you can't use the events with the collider component alone

rich adder
#

it has velocity and simple gravity

#

you def can

slender nymph
rich adder
#

only thing that dont work is OnCollision but CC has its own OnControllerColliderHit

timber tide
#

Ok, so the docs just using kinematic as an example then

#

I don't really use the trigger events anymore. Only the collision if needed, otherwise I stick to casting it through updates

summer stump
rich adder
#

hell yeah its wrong, shits moving it with translate

#

cringe

#

unity doesn't adhere its own advice

edgy hearth
#

So, uh, should I try using the character controller instead?

lucid jetty
#

@timber tide i fixed the problem now its works ❤️ now i need to fix that if i load the new scene the mouse cursor unlocks do you know how to do that?

rich adder
#

for like velocity and drag

edgy hearth
#

Ok thanks, I’ll try to find some other tutorial

maiden compass
maiden compass
#
    [SerializeField] private Material paleSkinShader;

    [SerializeField] [Range(0f, 5f)] private float TimerLenght;
    [SerializeField] private float timerValue;

    private bool timerActive;

    private void Start()
    {
        timerValue = 0;

        timerActive = true;
    }

    private void Update()
    {
        if (timerActive)
            Timer();
        else
            return;

        paleSkinShader.SetFloat("_DiffuseBlending", 0f);
    }

    private void Timer()
    {
        timerValue += Time.deltaTime;

        if (timerValue >= TimerLenght)
            timerActive = false;
    }
#

At the "Setfloat" part

#

I've put 0 so I have no errors, but I can't figure how to put the normalize thing in there. im_vibe_panic

rich adder
maiden compass
#

"normalizedValue = (timerValue - minValue) / (maxValue - minValue);" this part ?

rich adder
#

yeah

#

make a method and put it in the set float

maiden compass
#

Ooooooooh

#

I think I understand but I don't know how to write that

gaunt sandal
#

Thanks, I'm checking that out. I have a lot of objects because I need a big ocean, and the water assets all seem to work about the same way: Lot's of tiles. Small-ish tiles are needed to the wave effects. I'm absolutely open to suggestions on how to reduce the number of objects though.

rich adder
# maiden compass I think I understand but I don't know how to write that
[SerializeField] private Material paleSkinShader;
    
    [SerializeField] private float minValue = 0;
    [SerializeField] private float maxValue = 5;

    private float currentValue;
    private bool timerActive;

    private void Start()
    {
        currentValue = maxValue;

        timerActive = true;
    }

    private float NormalizedValue(float timeValue)
    {
        return (timeValue - minValue) / (maxValue - minValue);
    }
    private void Update()
    {
        if (timerActive)
            Timer();
        else
            return;

        paleSkinShader.SetFloat("_DiffuseBlending", NormalizedValue(currentValue));
    }

    private void Timer()
    {
        currentValue -= Time.deltaTime;

        if (currentValue <= minValue)
            timerActive = false;
    }```
timber tide
maiden compass
#

Really appreciate, have a nice evening Thumbglass

rich adder
#

you too!

spare sparrow
#

Have a bit of a problem where i can use textmeshpro in the editor but whenever i try doing "using TMPro" in my code it isnt recognized by rider. I have the package isntalled under package management so im kinda confused

errant kayak
#

how would one replace the nested runtimeAnimatorController of an AnimatorOverrideController in unity? Im trying to just set the runtimeAnimatorController within my variable but it doesnt seem to be working..

eager elm
spare sparrow
spare sparrow
rich adder
#

It should never do that..

#

but yeah also checking if you're using Assembly Definitions

#

Regen Project Files just regens the csproj files

#

highly doubt it would ever break anything

spare sparrow
#

I do have one assembly definition for my tests

rich adder
#

alr well if your script is in that assembly , did you add reference to TMP ?

summer stump
spare sparrow
primal dirge
#

void OnCollisionEnter(Collision collision) {
If(collision.collider.CompareTag("Player")){
Debug.Log("YEY");

}
}

primal dirge
#

And I said that it is a script problem because I tried adding a collider and rigidbody to the player and nothing

#

Besides it has character controller

rich adder
lucid jetty
bitter oar
#

Hey, i need help. im using unitys new input system, and i want to do that when you move your left stick SIGNIFICANTLY from the position it was last frame, something happens, and if you move it a just a bit from where it was last frame, nothing happens. any help?

eager elm
bitter oar
bitter oar
#

like if it moved A LOT i want to do something

rich adder
bitter oar
#

didn't know that was a thing

#

but what is the max? 1?

summer stump
eager elm
bitter oar
#

oh

#

ok

#

so can i do like if (Vector2.Distance(lastStickInput, currentStickInput) < 1)
{
do something
}

primal dirge
stuck palm
#

why isnt my player spawning on the position of the spawnpoint? it is saying its changing but it doesnt. here is the code that runs when the player is created.

private void Awake()
        {
            DontDestroyOnLoad(gameObject);
            if (FindObjectOfType<SpawnPoint>() != null)
            {
                foreach (SpawnPoint sp in FindObjectsOfType<SpawnPoint>())
                {
                    if (sp.id == id)
                    {
                        Transform spawnTransform = sp.transform;
                        transform.position = spawnTransform.position;
                        print($"setting transform to spawnpoint {sp.id}, {spawnTransform.position}");
                    }
                }
            }
            else
            {
                print("no spawnpoints found! spawning in center");
            }
        }
rich adder
eager elm
# bitter oar oh

ye, but moving that much in one frame could be quite challenging. You might want to use a timer that updates the lastStickInput every 0.2sec or so instead of every frame.

stuck palm
#

its meant to spawn on one of the points.

eager elm
stuck palm
rich adder
#

eg rb.MovePosition(spawnTransform.position);

stuck palm
rich adder
#

it might be waiting for the next Physics frame to move it

#

or cheese it fix and disable the renderer until that frame is hit

stuck palm
primal dirge
rich adder
rich adder
#

oh these are phone photos..oh dear.

primal dirge
primal dirge
rich adder
#

also see one of the colliders is still trigger

spare sparrow
rich adder
spare sparrow
#

this is the only assembly file i have

summer stump
spare sparrow
#

yea this is the error

rich adder
spare sparrow
#

the one just called scripts

rich adder
#

right

#

so did you add TMP in there

#

click it and look at inspector

spare sparrow
#

not sure how they work, just blindly followed a guide for that

rich adder
#

then don't use it

spare sparrow
spare sparrow
#

so im kinda forced to have it

hexed terrace
#

Best read up and follow a guide properly, instead of blindly 😄

rich adder
#

they are useful for compartmentalization but also isolate assemblies

queen adder
#

how do you locate a "NullReferenceException: Object reference not set to an instance of an object" in the hierarchy?

rich adder
#

which is what is happening now

#

all your scripts are isolated from TMP and other assemblies not linked

hexed terrace
spare sparrow
summer stump
timber tide
#

@lucid jetty stick to this channel if you need help. You're more likely to find the help you need. Also, try to clarify your problems out and debug if possible.

rich adder
summer stump
# queen adder graphs

Then it is an internal unith error
You can ignore it.

It is from windows inheriting from Graphs. Like the Animator or ShaderGraph
You can close those windows and restart Unity if you want to get rid of it

spare sparrow
#

Im really not try change anything about the assembly definition, all i want to do is figure out why i cant use textmeshpro

stuck palm
#

how can i make nice and snappy movement with rigidbody? right now its just sliding everywhere

waxen pecan
#

Hey i am facing a problem. I want to change the direction and fov from vr cameras within the meta sdk. Right now i am playing around with render textures but actually id like to avoid that

queen adder
modest dust
#

Simply add the TMP assembly reference to the list

summer stump
hexed terrace
waxen pecan
queen adder
#

solved

#

don't know why it was giving that error

summer stump
queen adder
#

thanks for the help!

rich adder
#

from the screenshot

#

OnCollision doesn't get called on dynamic rigidbody with normal collider in trigger.
only 2 solid collider

stuck palm
rich adder
#

snappy and rigidbody is funny

summer stump
rich adder
#

if you want snappy then make custom forces

#

ie Kinematic rb

rich adder
#

addforce is taking into account your mass btw

#

if you .velocity for example which overrides the mass you notice its more "snappy"

#

also drag amount and physics material matter a lot (with dynamic rb)

stuck palm
#

i did a dirty fix by just making the drag big and increaseing the add force

#

but i'll try velocity

rich adder
#

ah yes found it.

summer stump
# stuck palm

And what about the movement? How do you get input?

stuck palm
#

movement is a vector 3 that is set by an input event

stuck palm
stuck palm
#

using velocity makes the character fall extremely slowly for some reason

rich adder
#

yea because now you're overriding forces each frame

stuck palm
#

ah

rich adder
#

including physics gravity

stuck palm
#

does kinematic work with gravity?

rich adder
#

you make your own MovePosition but you can achieve the same effect

#

i found the code on unity forums once lemme see if I can scoop it

#
var positionOffset = (Physics.gravity * gravityScale) + (direction * speed);
    rb.MovePosition(rb.position + positionOffset * Time.fixedDeltaTime);```

Original
```cs
    var positionOffset = (Physics2D.gravity * rb.gravityScale) + (direction * speed);
    rb.MovePosition(rb.position + positionOffset * Time.fixedDeltaTime);
stuck palm
rich adder
#

it was for 2D but i modded

summer stump
# stuck palm does kinematic work with gravity?

Kinematic means it will not respond to forces, so no, you do it yourself

For velocity responding to gravity, you need to set the y velocity to the rigidbody's current y velocity, then it will work right

stuck palm
rich adder
stuck palm
rich adder
#

hmm try starting it a bit above ground maybe ?

#

last time I tried that code it was working so pretty sure it should

stuck palm
#

yeah still through the floor

#

i might just stick with rigidbodies tbh

#

i mean like

#

kinematic

rich adder
#

are you not using that on kinematic?

stuck palm
#

yes i am

#

sorry i meant dynamic

rich adder
#

maybe MovePosition doesn't care about collisions in 3D

stuck palm
#

i tried the forcemode.velocitychange thinking it was the same as changing velocity, but it made the character so fast

rich adder
#

velocitychange says is time independent so you probably needed fixedDeltaTime in there

stuck palm
rich adder
stuck palm
#

if it doesnt use rigidbodies

rich adder
stuck palm
#

i'll have a play with that than

rich adder
#

you also must make your own gravity

#

unity has an example on .Move

solemn fractal
#

hey guys.. If I have a list, and I use that if: cs if (_enemyList.Count < 30) if I have more than 30 elements inside my list it should not go inside the if right? I created a debug log and even when I have more than 30 it goes inside the if. what I am doing wrong?

stuck palm
#

fully admitting that i asked chatgpt for this... but how can i make my player face where theyre moving? i want it to be smooth which is why i tried slerp, but for some reason it just faces the world origin. with rb i just used moverotation

summer stump
solemn fractal
rich adder
stuck palm
#

nvm i fixed it on my own

rich adder
#

that's def not how you lerp

stuck palm
#

i got rid of the - transformpotiion thing

#

this is my fixed code

rich adder
#

lerp is still wrong

solemn fractal
stuck palm
#

it works the way i want it to

#

wait i just read it

#

i still think its okay enough, like i cant use smoothdamp for my purposes

#

and idk if a tweening library is necessart

muted wadi
#

i have some code that updates this text based on the number stored in another variable, how would I make the variable amount display but also display a certain amount of 0's in front like in old arcade games?

rich adder
stuck palm
#

im happy to change it but

rich adder
stuck palm
#

idk if smoothdamp is good for a constantly changing value?

#

i could be wrong

muted wadi
rich adder
#

should

muted wadi
#

thanks much

stuck palm
# rich adder should

do you know why my jumping is really delayed sometimes?sometimes its instant, which is why i find it weird. the inspector shows the player is grounded at the right times

rich adder
#

its very opinionated when it considers itself grounded xD

stuck palm
wintry quarry
stuck palm
wintry quarry
#

so it's impossible to tell when it's grounded and not grounded

#

especially inside the OnJump call

#

you're not logging it where it counts

#

you're probably logging it somewhere else

stuck palm
#

its like a true every once in a while

wintry quarry
#

Do you know how CharacterController.isGrounded works?

#

It has a very specific, very predictable method of working

#

The last time Move was called is what matters

#

and if that move call pushed it into the ground, it will be true

#

otherwise, false

muted wadi
#

@rich adder i have no idea why this might be happening

rich adder
muted wadi
# rich adder uh show current code
{
    string scoreString = $"{score:000000}";
    string killsString = $"{kills:0000}";
    string stardustString = $"{money:00000}";

    moneyText.text = "Stardust: " + money.ToString(stardustString);
    scoreText.text = "Score: " + score.ToString(scoreString);
    killsText.text = "Kills: " + kills.ToString(killsString);
}```
stuck palm
#

I had one when I used rigid bodies

#

I think it's still in there

wintry quarry
rich adder
muted wadi
wintry quarry
#

you should just be writing scoreString

rich adder
#

ahh yes good catch

muted wadi
#

oh duh

wintry quarry
#

not only that

#

you don't need the concatenation

muted wadi
#

i can just do scoreString?

wintry quarry
#

just do killsText.text = $"Kills: {kills:0000}";

#

for example

#

no need for the extra variable and secondary concatenation stuff

muted wadi
#

oh that makes sense

wintry quarry
#

scoreText.text = $"Score: {score:000000}";

muted wadi
#

thanks a lot

#

ironically i haven't done much practice with strings and stuff at all

rich adder
#
private void GroundedCheck()
{
    // set sphere position, with offset
    Vector3 spherePosition = new Vector3(transform.position.x, transform.position.y - GroundedOffset, transform.position.z);
    Grounded = Physics.CheckSphere(spherePosition, GroundedRadius, GroundLayers, QueryTriggerInteraction.Ignore);

    // update animator if using character
    if (_hasAnimator)
    {
        _animator.SetBool(_animIDGrounded, Grounded);
    }
}```
#

very simple stuff but does major difference in detection

mild mortar
#
public class MovingPlatform : MonoBehaviour
{
    public float speed = 1;
    [SerializeField] GameObject[] waypoints;
    int currentWaypointIndex = 0;
    private Vector3 lastPosition;

    public Vector3 direction => waypoints [currentWaypointIndex].transform.position - transform.position; 

    // Update is called once per frame
    void Update()
    {    
        if (Vector3.Distance(transform.position, waypoints[currentWaypointIndex].transform.position) < .1f)
        {
            currentWaypointIndex ++;
            if (currentWaypointIndex >= waypoints.Length)
            {
                currentWaypointIndex = 0;
            }
        }
        // Move towards
        transform.position = Vector3.MoveTowards(transform.position, waypoints[currentWaypointIndex].transform.position, speed * Time.deltaTime);

        lastPosition = transform.position;

    }
}

Anyone have any idea why this cube of mine just keeps going forever in one direction?

I wanted it to go back and forth between the two waypoints

gaunt ice
#

parent position is affected by its children and the children position are modified by the parent when the parent move
circular dependency

cinder plover
summer stump
cinder plover
#

It doesnt log

#

Idk why tho

#

Like the debug log doesnt activate

summer stump
#

It is not hit or headHit

#

Debug BEFORE the if statements

cinder plover
#

That does work

summer stump
#

Make sure the physics message actually gets triggered

cinder plover
#

It does

#

but in the if

#

both dontć

summer stump
rich adder
#

why are you storing collider anyway lol

#

public Collider hit;
public Collider headhit;

cinder plover
#

to know if it was a body hit or a headshot

rich adder
#

you should at least use tags

summer stump
#

What gameobject is target on?

cinder plover
swift crag
cinder plover
#

Where are the tags

swift crag
#

Although, the logic seems backwards

#

other is the collider that hit you

rich adder
cinder plover
swift crag
#

so other is a bullet

cinder plover
#

shit

swift crag
#

Unfortunately, you can't ask what your collider was in a trigger message.

#

unlike with a collision message.

#

but all is not lost: you just need to use separate game objects

summer stump
swift crag
#

Give each part of the target a separate game object with one or more colliders

#

You'll put a component on each game object that reacts when hit.

cinder plover
#

kk ill try it

swift crag
#

Maybe each one can have a float that says how much damage is caused when it's hit.

rich adder
swift crag
#

that method name is a mouthful

#

i often avoid using it just because it's so annoying to look at

summer stump
#

I told someone to make a bool yesterday, and they named it isLowPriorityDestinationCurrentlySet

rich adder
swift crag
rich adder
#

I wonder what the efficiency of it is , i never benchmarked it

#

I just blindly trusting unity on this one

rich adder
swift crag
#

bool goodLuck

rich adder
#

xD

rich adder
#

oh my. that would be a curse

swift crag
hybrid gust
#

So I'm running into an issue in my scene, where I have an interactable object I can pick up and put down. I'm handling both the 'pick up' and 'put down' functions with raycasts. Only issue is that, because I'm playing the object at RaycastHit.point, my object is always going to clip halfway into wherever I place it. Any tips or ideas? I tried looking online for an answer and all I got was this vdeio https://www.youtube.com/watch?v=BNOAeQqXgg0. Which is ALMOST like the issue I'm haing, except I'm trying to fix this at runtime and not in the editor. But it is a good visual representation of what my issue is.

More often than not, when we're placing objects in our scene we want to place them on the ground. This can be tricky to get exactly right when positioning manually, so in this quick tip we'll look at a feature of Unity that does this for us automatically.

If you prefer written instructions you can find a link to the text version here - https://...

▶ Play video
rich adder
#

must lpdc my lpdcs

bitter oar
#

can anyone explain to me why unity doesn't let me put this in an if statement?

(Vector2.Distance(inputManager.prevDefinedMovementInput, inputManager.movementInput) < 1f || inputManager.previousMovementInput = inputManager.movementInput)

it says:
operator can not be applied to 'bool' and 'vector2'

but what does it matter? im only checking if one of them is true..

swift crag
#

Compare the hit point to the center of the object. Offset the object by the difference.

bitter oar
#

oh my god im so stupid

#

thank you so much

hybrid gust
swift crag
#

specifically, offset it by the differnce after running it through Vector3.Project, kind of like this:

Vector3 placePoint = // do your first raycast to decide where it goes
Vector3 bottomPoint = Vector3.zero;
if (Physics.Raycast(placePoint - Vector3.up * 3, Vector3.up, out var hit, 5f, LayerMask.GetMask("Item"))) {
  bottomPoint = hit.point;
}

Vector3 correction = placePoint - bottomPoint;
placePoint += correction;
swift crag
stuck palm
hybrid gust
#

I kept thinking of my object as a single point and not as a whole thing with bigga^^ collision box. Yeah that makes a ton of sense

swift crag
#

you want to place it at the red X, and you do

#

then you shoot a ray to find the blue X and offset by the difference!

hybrid gust
#

Huge help thank you

#

also what program is that?

swift crag
#

no prob (:

#

The physics should behave properly. You'll move the object (and thus its collider) twice instantly

#

So it won't go flying after clipping into the floor from the first move

cinder plover
swift crag
#

I think you'll want to set the transform directly for the first move

#

Then set the rigidbody position for the second move

hybrid gust
# swift crag

Cause I could using something like this to visualize my problems

swift crag
#

this and hit can't possibly be equal; they're unrelated types

swift crag
hybrid gust
#

nvm I just realized that is an IOS app

swift crag
#

it's Notability, yeah

swift crag
#

Okay, so you should have a "Target" component on both objects, too.

hybrid gust
swift crag
#

Each one will respond to trigger messages caused by its own colliders

#

So Target would only have one damage number prefab (you'd assign a different one for the head target and the body target)

#

Each one would just say "i got hit, so spawn my damage number prefab"

hot niche
#
using UnityEngine;

public class PlayerMouseLook : MonoBehaviour
{
    public float sensitivity = 2f;
    public float verticalLimit = 80f;

    private float rotationX = 0f;

    void Update()
    {
        // Mouse Look
        float mouseX = Input.GetAxis("Mouse X") * sensitivity;
        float mouseY = Input.GetAxis("Mouse Y") * sensitivity;

        // Apply rotation to the player around the Y-axis (horizontal)
        transform.Rotate(Vector3.up * mouseX);

        // Apply rotation to the camera around the X-axis (vertical)
        rotationX -= mouseY;
        rotationX = Mathf.Clamp(rotationX, -verticalLimit, verticalLimit);

        // Apply the rotation to the camera (not the entire player)
        transform.GetChild(0).localRotation = Quaternion.Euler(rotationX, 0f, 0f);
    }
}

My camera is rotating left/right instead of looking Up or Down

rich adder
hot niche
#

the "Player" its just a cylender

#

its doing this instead of looking up

ashen wind
#

I have this third person camera that rotates around the player and moves up and down as you move the cursor:

            pitch = Mathf.Clamp(pitch + -Input.GetAxis("Mouse Y") * sensitivity, minPitch, maxPitch);

            Vector3 pos = Target.position;
            Quaternion rot = Quaternion.Euler(pitch, heading, 0);
            pos += rot * (Vector3.back * distanceToTarget);

            transform.position = Vector3.Lerp(transform.position, pos, Time.deltaTime * smoothing);
            transform.rotation = Quaternion.Slerp(transform.rotation, rot, Time.deltaTime * smoothing);

the problem is I want the camera as a child of the player so it moves with the player, and the way I've coded it resets the camera position every frame, overriding the parent/child positions setting

#

how do I fix this

wintry quarry
ashen wind
#

because when I move the cursor a certain amount up or down, I want the camera to move up or down

#

so that it rotates around the player

wintry quarry
#

to move up or down? Or to rotate?

#

Oh like an orbit camera?

rich adder
wintry quarry
ashen wind
#

yes exactly

wintry quarry
#

so do that

#

transform.localPosition exists

wintry quarry
#

Note that - Vector3 pos = Target.position; will need to be converted to local space too

#

it's unclear what Target is exactly

hot niche
rich adder
hot niche
#

yes

rich adder
#

thats why when you rotate you going sideway

swift crag
#

Red - X - Right
Green - Y - Up
Blue - Z - Forward

rich adder
#

your forward should be Blue

swift crag
#

Those are the three axes.

hot niche
rich adder
#

common issue 😏

swift crag
#

When you have the scene view in "Local" mode, you'll see the handles (e.g. the arrows in your screenshot) lined up with the local axes of the selected object

hot niche
#

the reason why I did that was because the camera icon

#

shows a "window" facing forward

#

see like a TV

swift crag
#

Perhaps your camera is on the wrong side.

hot niche
#

maybe

#

lemee rotate it il brb

swift crag
#

Switch to "Pivot" mode and select the capsule.

#

(from "Center" mode)

rich adder
#

yup, make that camera frustum face the same direction as blue

swift crag
#

The camera should be looking in the direction of the capsule's blue arrow.

#

It should have no rotation around the Y axis, as a result

hot niche
#

il have to unchild the laser gun

#

to do this as its rotating everything

rich adder
#

well having correct gizmos is priceless in time saved later

hot niche
#

TY for the the advice

swift crag
#

Yes, you should get a good grasp of how things are oriented and positioned

#

I rarely have to "guess and check" anymore

hot niche
#

im used to the war thunder CDK gismo being the red line as the front so yeah my bad

rich adder
#

in 2D generally Red is "Forward "

#

(technically right in unity)

#

but topdown you can also make Up your forward

swift crag
#

yeah, Vector3.forward points into the screen if you put your scene view into 2D mode

cinder plover
cinder plover
#

same

swift crag
#

is it overheating and lagging?

hot niche
#

lagging his headset to death

cinder plover
#

when the bullet hits yeah

#

and crashes

#

does it activate multiple times or something

swift crag
#

Show your new code.

rich adder
#

are you recursively doing something?

swift crag
#

I can't guess what you wrote!

cinder plover
hot niche
#

@rich adder it works yayyyy

swift crag
#

Perhaps spawnedNumber has a collider on it?

hot niche
#

TY

cinder plover
rich adder
swift crag
#

You're unconditionally spawning a number every time anything sets off your trigger collider.

ashen wind
# wintry quarry You should just be dealing with _local_ positions, not world positions

it's so close, but there's still a problem when I try to walk. the walking transform.Translates the parent, (which is what Target is) and somehow that makes the whole thing go out of whack.

            pitch = Mathf.Clamp(pitch + -Input.GetAxis("Mouse Y") * sensitivity, minPitch, maxPitch);

            Vector3 pos = Target.localPosition;
            Quaternion rot = Quaternion.Euler(pitch, heading, 0);
            pos += rot * (Vector3.back * distanceToTarget);

            transform.localPosition = Vector3.Lerp(transform.localPosition, pos, Time.deltaTime * smoothing);
            transform.rotation = Quaternion.Slerp(transform.rotation, rot, Time.deltaTime * smoothing);
#

should I be using localrotation too?

wintry quarry
#

what is target? Which object?

#

oh sorry

#

it's the player/parent?

ashen wind
#

and is also the parent of the camera gameobject

wintry quarry
#

that's nonsense anyway

ashen wind
#

oh yeah that makes sense

#

since it's the topmost parent

wintry quarry
#

Vector3 pos = Vector3.zero; would be correct here

#

transform.localPosition is in the coordinates space of its parent

#

so Vector3.zero would be the parent's location in that coordinate space

hot niche
#

How do I rotate the gizmos of an object without rotating the object itself

swift crag
hot niche
swift crag
#

you probably need to parent the object to an empty object

hot niche
#

its causing the rotation of my gun to be wrong

wintry quarry
#

and fix the mesh

#

and re-export it properly

swift crag
#

That would be preferable, yeah.

wintry quarry
#

Or yes, use an empty parent

swift crag
#

But you might need to use an empty parent anyway

ashen wind
swift crag
#

e.g. to adjust the exact position the gun sits at

#

I almost always wind up setting up objects like this:

  • Gun
    • Model
wintry quarry
ashen wind
#

so I think that's why I was doing target.position

swift crag
#

the model is not the root object

hot niche
ashen wind
#

ok just checking that it doesn't need to be localpos

wintry quarry
ashen wind
#

no it's not. got it

hot niche
swift crag
#

non-uniform scale!

#

A parent of that object has a scale with uneven values.

#

This will cause skewing.

ashen wind
#

something is still wrong somehow

#

when I move the camera rotation goes crazy

hot niche
#

whats busted

swift crag
#

Oh wait, I didn't read that properly.

#

I thought it was stretching.

#

It's just rotating around the wrong axis.

#

Are you rotating PlayerCamera, perhaps?

ashen wind
#

            pitch = Mathf.Clamp(pitch + -Input.GetAxis("Mouse Y") * sensitivity, minPitch, maxPitch);

            Vector3 pos = Vector3.zero;
            Quaternion rot = Quaternion.Euler(pitch, heading, 0);
            pos += rot * (Vector3.back * distanceToTarget);

            transform.localPosition = Vector3.Lerp(transform.localPosition, pos, Time.deltaTime * smoothing);
            transform.rotation = Quaternion.Slerp(transform.rotation, rot, Time.deltaTime * smoothing);
#

this calls on the camera script

hot niche
swift crag
#

Look in the scene view as you look around

#

you can grab the game view window and move it to the side

hot niche
#

without the edited gun script, the gun will rotate left and right with the player

#

but il look up and down and it will just stay where its at

ashen wind
#

@wintry quarry do you think the reason it's getting messed up when I move has something to do with the distance calculation that I do in start()

distanceToTarget = Vector3.Distance(transform.localPosition, Target.position);

hot niche
swift crag
hot niche
#

How do I get it to look up and down too

swift crag
#

You could parent it to the camera, or you could separate logic to rotate it up and down

hot niche
#

yayy

wintry quarry
#

.position would be correct

ashen wind
#
private void Start()
    {
        pitch = transform.eulerAngles.x;
        heading = transform.eulerAngles.y;
        distanceToTarget = transform.localPosition.magnitude;
        

    }
    void Update()
    {
            pitch = Mathf.Clamp(pitch + -Input.GetAxis("Mouse Y") * sensitivity, minPitch, maxPitch);

            Vector3 pos = Vector3.zero;
            Quaternion rot = Quaternion.Euler(pitch, heading, 0);
            pos += rot * (Vector3.back * distanceToTarget);

            transform.localPosition = Vector3.Lerp(transform.localPosition, pos, Time.deltaTime * smoothing);
            transform.rotation = Quaternion.Slerp(transform.rotation, rot, Time.deltaTime * smoothing);
ashen wind
#

perhaps it's the pitch and heading calculation?

#

or maybe it's in my player movement code

#
           
            rb.velocity = Vector3.zero;

            Vector3 camEuler = cs.transform.eulerAngles;
            camEuler.x = 0;
            Vector3 moveDir = Quaternion.Euler(camEuler) * new Vector3(direction.x, 0, direction.z).normalized;
            transform.Translate(moveDir * Time.deltaTime * speed);



            float targetAngle = Mathf.Atan2(moveDir.x, moveDir.z) * Mathf.Rad2Deg;
            float angle = Mathf.SmoothDampAngle(player_capsule.transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
            player_capsule.transform.rotation = Quaternion.Euler(0f, angle, 0f);```
#

I think maybe when I change player_capsule.transform.rotation

#

it's messing it up

wintry quarry
ashen wind
#

because when I wrote that code

#

it wasn't parented

wintry quarry
#

Also yes you're mixing up Rigidbody motion with Translate?

#

That's a recipe for disaster

ashen wind
#

oh do those not play nice? i was gonna do translate when grounded and rigidbody when airborn

#

that's why I have rb.velocity = 0

wintry quarry
#

absolutely not

#

Either use physics or don't

#

you can't mix and match

ashen wind
wintry quarry
#

it will

#

subtle, nefarious, weird collision issues, etc.

ashen wind
#

so the rigidbody should be on the parent gameobject?

#

and then I should use rb.move or something

#

for player grounded movement

slender nymph
#

if you're using velocity or force for jumping/air movement then you'll want to do the same for ground movement

ashen wind
#

ok

inner juniper
#

what is this error?

wintry quarry
inner juniper
#

okay i will check

inner juniper
#

wait but at line 109 isnt anything like speedcontroll

slender nymph
#

line 109 should be within the SpeedControl method

languid spire
inner juniper
#

wha...?

wintry quarry
#

that's absolutely inside SpeedControl...

slender nymph
eternal falconBOT
wintry quarry
#

anyway clearly text_speed is null

#

you have to assign it

inner juniper
#

oh i see it now

#

okay

wintry quarry
#

Also yes your IDE is not configured, that's going to make your life quite difficult

inner juniper
#

how do i configure it?

wintry quarry
#

by following the instructions you were just linked

inner juniper
#

and im sorry im bothering im VERY new to c sharp programing

inner juniper
queen adder
#

Hey guys, Im having trouble with Vector3.MoveTowards. This is my code but the gameobject is going somewhere completetly different instead of following the player

wintry quarry
#

Also this code is framerate dependent

#

it will move at different speeds depending on your current framerate

ashen wind
#

@wintry quarry got it working and changed everything to rigidbody. ❤️ appreciate you

queen adder
wintry quarry
#

how did you assign the player reference?

queen adder
#

hello, i am struggling with a problem that is tough to find why it's happening. basically, what i'm trying to do is a fog of war effect where i have a 2D tilemap over top of another tilemap and based on the location of the player, set some tiles to null in the fog of war tilemap that shows in the full screen map.

the problem is my code works fine in the editor, and all the expected tiles are disabled. however, when i run the code in the windows build, it will not work the same. it will disable tiles fine, up until the first time i open up my full screen map window. then it will not disable tiles anymore. the full screen map window has a RawImage that points to a RenderTexture which my Camera is rendering to.

i would appreciate any help to understand where the problem might be.

my code in Update


  Vector3Int playerCellPos = currentGroundTilemap.WorldToCell(playerPos);

  for (int x = -revealRadiusX; x <= revealRadiusX; x++)
  {
      for (int y = -revealRadiusY; y <= revealRadiusY; y++)
      {
          Vector3Int tilePos = new Vector3Int(playerCellPos.x, playerCellPos.y, 0) + new Vector3Int(x, y, 0);

          var tile = currentFogOfWarTilemap.GetTile<Tile>(tilePos);

          if (tile != null)
          {
              currentFogOfWarTilemap.SetTile(tilePos, null);
              currentFogOfWarTilemap.RefreshTile(tilePos);

              UpdateRenderTexture();
          }
      }
  }                ```
#

@wintry quarry

wintry quarry
#

where did you drag TankPLlayer1 from?

#

Is it a prefab?

#

Or is it the player in the scene?

#

BTW there is no need for self references or transform references.

#

you can get your own GameObject with .gameObject and the Transform with .transform

queen adder
slender nymph
#

you can also call GetComponent on any component, including this

wintry quarry
#

Prefabs only live in the project folder

queen adder
#

I think I see the problem now

#

I am dragging it as a prefab

wintry quarry
#

Show exactly what you dragged into where? Because I think you're referencing the prefab

#

yep

queen adder
#

Thanks for the help

wintry quarry
#

So you're moving to the prefab's position, which is likely 0

queen adder
#

I can't drag the object from the hierarchy into the inspector now 💀

wintry quarry
queen adder
#

How do I make it so the prefab follows the player then?

wintry quarry
#

You have to give the enemy a reference to the player after you spawn it

#

simple example, for a spawner script that does it:

public Enemy enemyPrefab; // assign in the inspector to your enemy prefab
public Transform player; // assign in the inspector to your player in the scene

void SpawnEnemy() {
  Enemy newEnemy = Instantiate(enemyPrefab);
  newEnemy.player = player;
}```
queen adder
slender nymph
queen adder
#

but the problem is, when i set a tile to null in the tilemap, somehow the change does not propagate back to the camera render and subsequently to the render texture that is shown in my RawImage in the UI

queen adder
queen adder
wintry quarry
#

It needs to be whatever your actual enemy script is called

#

not GameObject

queen adder
#

Ohhhh

wintry quarry
#

btw you can do Quaternion.identity instead of Quaternion.Euler(0,0,0)

queen adder
#

ahh gotcha

#

my bad

#

ahh right because the prefab reference was an Enemy object not a GameObject

slender nymph
#

Instantiate is a generic method that returns the same type you pass to it as the first parameter. so if they pass an Enemy object as the first parameter then it returns an Enemy object

queen adder
#

yeah i misread the code oops

#

removed the stupid comment

#
You probably need to reassign the player variable of the 'MentosMinionController' script in the inspector.```
MentosMinionController is my 'Enemy' class btw
queen adder
#

Spawner code

wintry quarry
# queen adder

If you're doing this the player assigment stuff needs to be in Start not Awake

#

but realistically

queen adder
#

It works now

#

Thanks so much

valid palm
#

Hi! I need help please!
So, this is my character roster

#

whenever I press Shift, the present character gets disabled and I control another one

#

its all fine except for the animations

#

when I change controls while running the disabled script character keeps doing the run anim

slender nymph
#

sounds like you aren't updating parameters when you disable it. of course you haven't shown any !code so that's just a guess

eternal falconBOT
valid palm
#

I will send it

slender nymph
#

You only change the animation state in Update. Update does not run on disabled components

valid palm
#

which void can help me?

rich adder
valid palm
#

sorry, I meant function

slender nymph
#

Take a look at the docs for MonoBehaviour and see which one lines up most with what you want to do

valid palm
#

alright, will try, thanks!

hot niche
#

So the gizmos are incorrect causing me a boat load of issues. I opened the gun in blender, how do I fix the gizmos?

rich adder
#

blender

#

use the Apply Transform when you export

hot niche
rich adder
hot niche
#

Im pressing Z this is what shows up

rich adder
hot niche
#

aaaah gotchya

hot niche
#

axis is still busted

vernal ore
#

Try this on the mesh import settings

hot niche
rich adder
rich adder
hot niche
#

It reversed it

rich adder
hot niche
#

oops il go there sorry

hot niche
rich adder
hot niche
#

im exporting .obj

rich adder
#

ok so you didn't follow what I said..

hot niche
rich adder
hot niche
vernal ore
#

Me and my artist spent a bit of time to make Unity look the same as in blender. There are different ways to do this but you might be interested in our setup. This was based on the blender axis and not on the unity ones.

slender nymph
vernal ore
pastel flume
#

Hello I have a question about character movement
my character movement is functional but when I use a jump it doesn't work while the character is moving
and the code that makes the character fall down faster also don't work well while the character moves

#

I'm using the unity input system

#

it reads a 2d vector of wasd movement and applies it

#

to the rigid body

#

in a fixed update

eternal needle
eternal falconBOT
pastel flume
#

didn't wanna go with transform.translate tho

eternal needle
eternal needle
pastel flume
#

just storing the player movement

#

forceDirection += new Vector3(move.ReadValue<Vector2>().x, 0f, move.ReadValue<Vector2>().y) * movementForce; here sets it to 0

#

so that's the overwriting

eternal needle
pine dagger
#
public class MouseLook : MonoBehaviour
{

    public float mouseSensitivity = 0f;
    private float xRotation = 0;
    public Transform playerBody;
    // Start is called before the first frame update
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

    // Update is called once per frame
    void Update()
    {
        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;
        float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90, 90f);

        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
        playerBody.Rotate(Vector3.up * mouseX);
    }
}
```whys my sensitivity so god damn high
#

ive tried 100f, 0f, 3f

slender nymph
#

try 1

#

and make sure you're changing it in the inspector, not just the field declaration

pine dagger
#

slightly better for some reason

pine dagger
#

ah that fixed it for some reason - changing in the inspector

wintry quarry
vapid cypress
#

Question:
I have the above visual code that detects movement along a 2d player character based on left or right. I want to make it so that it flips my character to face the way that he is moving. IE) if he is moving left he is facing left and if he is moving right he is facing right.
How would I go about doing that with the current setup I have in visual coding?

pine dagger
summer stump
pine dagger
#

interesting

summer stump
#

Unless you do it in a method like Start or Awake

pine dagger
#

oh

timber tide
wintry quarry
#

How would you set two enemies to have different HP for example

pine dagger
#

I just assumed that once the game is ran the script runs from the start too initialising the variables to what you have set

wintry quarry
pine dagger
#

ohh right

vapid cypress
timber tide
#

the heck do I know

#

I don't really touch visual scripting

vapid cypress
wintry quarry
#

it's just... visual

#

but all the properties and functions are the same

#

So if you want to use flipX on the SpriteRenderer for example, you do exactly that

vapid cypress
#

the main thing I'm struggling with is getting it to link to the velocity

wintry quarry
#

well that's a property of the Rigidbody2D

vapid cypress
#

Specifically due to the fact that this script uses GetAxisRaw instead of normal inputs

wintry quarry
#

In what way is GetAxisRaw not normal?

vapid cypress
#

It is I've just never used it before, we started with 3D not 2d so we were using actual button inputs

wintry quarry
#

3D and 2D have nothing to do with input

#

Input works the same way in both

summer stump
#

I think they mean they had UI buttons that triggered events

vapid cypress
#

I mean that we used getkey

summer stump
#

Oh

vapid cypress
#

And so I could just attach the flipx to those

summer stump
#

Well it's exactly the same then

wintry quarry
#

otherwise it's not much different

#

(and also has nothing to do with 2d or 3d)

summer stump
#

Yeah, sorry I was flippant with my response. Not exactly the same.
It's just not gonna be different enough that it should be an issue

vapid cypress
summer stump
#

Convert to a bool condition like if (Input.GetAxisRaw("Horizontal") > 0);
Instead of it already being a bool

timber tide
#

usually you use GetAxis when you deal with analog controls because it's not just a true or false

#

I mean, it can be if you want to implement it that way

wintry quarry
#

this is for a facing left/right check

#

I believe

vapid cypress
#

yes

wintry quarry
#

so it will certainly be a check of > 0 or < 0

vapid cypress
#

Character movement is not an issue just the orientation of the facing

wintry quarry
#

getting the y part

#

do the same thing

#

but get the x

#

and then feed that into a comparison node

#

see if it's > 0 or < 0

#

and face right or left based on that

#

You could do it either with the velocity or with the horizontal input axis. Up to you

vapid cypress
#

So like this

wintry quarry
#

something like that yes

vapid cypress
#

doesn't it need to be lit up to work too

wintry quarry
#

I hav eno idea I don't use visual scripting

rich adder
#

I think its because ur missing Input from rigidbody

wintry quarry
#

Don;t you need to set that to happen in Update for examplke?

rich adder
#

is this needs to be connected to something no?

vapid cypress
#

The other one isn't

wintry quarry
timber tide
#

where's the entry point to all this

wintry quarry
#

right now you're not telling it WHEN to run this code

vapid cypress
#

So add a second update node

#

Yep

wintry quarry
#

maybe? Is that even possible? Can it be attached to the same one? Again I don't know how VS works

vapid cypress
#

Just one big massive brain fart

timber tide
#

oh I see

vapid cypress
#

Yeah it needed a second update node

#

Each update node can only have 1 pathway

timber tide
#

man who knew 5 lines of code required so much work

wintry quarry
#

you can just feed the bool directly into the value

#

nor do you need the if

vapid cypress
vapid cypress
summer stump
azure zenith
#

How do I disable player movement without accessing the player movement script?

vapid cypress
summer stump
vapid cypress
#

That was the last thing I needed too

summer stump
#

How does it move? Rigidbody? Transform? The animator? Is it in Update or Fixed update or using callbacks?

vapid cypress
#

For that project anyways

timber tide
#

I can see the use of this stuff, but it would be nice to just inject some c# code in places

vapid cypress
acoustic arch
#

https://hatebin.com/qcwkblqllg
it detects being grounded perfectly fine, but it only jumps id say 1/4 of the times i click the space bar which is odd
so it must be something with the playerVelocity.y

vapid cypress
#

🥲

#

Though huh it doesn't stay facing the last way it always defaults back to being facing the right

pastel flume
rich adder
summer stump
azure zenith
pastel flume
summer stump
pastel flume
#

but the jump gets overwritten or messed up

azure zenith
summer stump
summer stump
#

And what about the other questions? (About where the code to move is)

pastel flume
summer stump
pastel flume
#

how would you reccomend

#

implementing

#

the jump/movement

edgy hearth
#

im watching this tutorial for sprinting and crouching, and the dude is using a rigidbody for his character and not a CC. How can i change this code he wrote to work for my CC?

#

sorry if its a dumb question this is my first time doing game dev and even using c#