#💻┃code-beginner

1 messages · Page 781 of 1

burnt perch
#

In my WEBGl build the cursor isnt hiding with Cursor.visible = false;

#

Can someone help me out?

naive pawn
#

i believe that is not supported for security reasons misremembered

fading marten
#

well hang on I want to use the LookObritX's inputvalue because it tells me exactly how much input is being put in there

#

If I can read it then it would be the same as the inputsystem

polar acorn
#

That's what you want

wintry quarry
burnt perch
#

The clicking and the image cursor that follows the cursor work fine

fading marten
burnt perch
#

Just the real cursor doesnt hide

wintry quarry
burnt perch
#

There are no errors

polar acorn
#

That's the value it's reading from the input action you've told it to listen for

fading marten
polar acorn
wintry quarry
fading marten
polar acorn
#

The thing you dragged in here

naive pawn
#

the input system can tell you when there's mouse input, or you can ask if there's mouse input

burnt perch
#

Ive found the reason, because WebGL can only make the invisible cursor after youve clicked once in the game, so it ignores this first hiding of the cursor

fading marten
polar acorn
fading marten
#

but I don't know how it does that

#

it did that itself

polar acorn
#

So, check out the link I sent for how to use the Input System

wintry quarry
#

Not unless you share your code etc

astral dock
#

Hey guys! 👋 Just dropped a quick guide on Unity Coroutines.

Check it out: https://youtu.be/jBLHdy9pExw

Stop writing messy code in your Update loop! In this comprehensive guide, we dive deep into Unity Coroutines. You will learn how to replace standard methods with efficient Coroutines, understand the power of different Yield Instructions, and master the best practices for starting and stopping them without errors.

Whether you are a beginner or l...

▶ Play video
rotund linden
#

hi im new to unity i used to use python but idk where to start in unity can someone help

slender nymph
#

!learn

radiant voidBOT
fading marten
naive pawn
#

you have unsaved changes

steady blade
#

why cant I change the tracking target of a CinemachineCamera at runtime ? None of Follow, LookAt, Target is working am I crazy or

wintry quarry
steady blade
#

No errors and the code is running, this is one of the code I tried, found online

  if (_camera != null)
  {
      CinemachineBrain cinemachineBrain = _camera.GetComponent<CinemachineBrain>();
      if (cinemachineBrain != null)
      {
          ICinemachineCamera virtualICamera = cinemachineBrain.ActiveVirtualCamera;
          if (virtualICamera is Component component)
          {
              var comp = component.GetComponent<CinemachineCamera>();
              var temp = comp.Target;
              temp.TrackingTarget = _transform;
              comp.Target = temp;
          }
          else
          {
              Debug.LogError("Active virtual camera is not a CinemachineVirtualCamera.");
          }
      }
      else
      {
          Debug.LogError("Main camera does not have a CinemachineBrain component.");
      }
  }

but i've also tried basic things like

_cinemachineCamera.Follow = _transform;

In play mode in the inspector the field stays empty

slender nymph
#

how have you confirmed that code is running

steady blade
#

I put a Debug.Log earlier and it showed in console I removed it in what I sent

slender nymph
#

where was the log and what did it print. and for future reference don't remove logs when sharing your code

steady blade
#

it was just below var comp = component.GetComponent<CinemachineCamera>(); and it was Debug.Log("Here", comp); it showed and when I clicked the log it pointed to the correct object in the scene

#

Ok nvm it works, I forgot to fill the _transform serialize field in the inspector

#

fck me

burnt perch
#

In my WebGL build, the video player doesnt run, anyone knows why?

wintry quarry
burnt perch
#

Ill try that

#

Embedded video clips are not supported by the WebGL player: Assets/Sprites/InicioFinal/Cutscenes/Cutscene Inicio.mp4. Use the Video Player component's URL option instead.

burnt perch
#

Yup... What a pain

grand snow
#

how would a virtual camera not be Component

naive pawn
#

not sure what exactly you're referring to, but i tried googling that for unity, and it gave cinemachine virtual cameras which did seem to be components

grand snow
#

doing the as cast in an if is what i mean

#

as casts are for when you want to silently handle a failed cast

naive pawn
#

im confused, what's the issue here

#

oh, i didn't notice this was related to a previous convo

grand snow
#

something something threads

naive pawn
#

CinemachineBrain.ActiveVirtualCamera is typed as ICinemachineCamera which is an interface

grand snow
#

specifically if (virtualICamera is Component component)

#

very unlikely we decided to make our own virtual camera thats also not component

#

anyway its not that important

naive pawn
#

im so confused what you're trying to say...

#

well, i see CinemachineCamera implements ICinemachineCamera
are you trying to say the cast could just be to that instead of indirectly through the component?

#

or the else statement? i mean, it could be null

grand snow
#

forget it i dont care enough

glass summit
#

I recently made a new scene, but for some reason when clicking my next button, it does not respond and events don't change. I think this might be a mistake that I did in my code so if anyone could take a look, that would be awesome (:

https://paste.ofcode.org/ZuVfxn44TMu6JVrw5NWQnj

slender nymph
#

where is the EventSystem

glass summit
#

i swear to god, i'm so dumb 😭

#

thanks man

burnt perch
#

Anyone knows how to hide a cursor in the WebGL build?

slender nymph
burnt perch
#

Nope, thought I did

slender nymph
#

then show what you tried, because from what you've said you already know how

burnt perch
#

Im testing it another way now. The problem is that it takes a while to build webgl

glass summit
#

When i click the notice board button or the staff room button, the character appears on screen, but the textbox does not appear. This is my assumption but i feel like i messed up with the eventPos. Could someone please take a look?

https://paste.ofcode.org/37RckMhNukW2YZX3SBN54qU

hexed terrace
#

a quick glance over it and I don't see where you set the position of the textbox

hexed terrace
#

ah, screenspace canvas

glass summit
hexed terrace
#

you'll need to go through and debug it

#

your code is far far far far too long, I'm about to go to bed so can't help further

#

You should be doing all that with 1 method and passing in the various params when you call the event

weary depot
#

hi

#

im brandnew to unity and ive been trying to get buttons to work

#

does anyone know how?

#

visual scripting btw if that makes a difference

hexed terrace
#

!learn

radiant voidBOT
daring sierra
hexed terrace
glass summit
naive pawn
#

that's a pretty broad question, you should start with researching

weary depot
naive pawn
#

or if you have a specific question, you'll have to ask

ivory bobcat
daring sierra
naive pawn
naive pawn
daring sierra
#

listeners are basically how you allow buttons to run methods, you can do whatever you want from there

naive pawn
#

(UI buttons, right?)

weary depot
#

ye ui buttons

glass summit
naive pawn
#

please do not try to get specific people to help you, just bump it to the channel as a whole

naive pawn
spare herald
#

hi im so confused about something, so basically im trying to change the xr origin camera view so i can get a better anglee but when i do that in game my camera starts falling for some reason and it gets fixed when i reset it to the default coardinates aka 0,0

weary depot
naive pawn
#

sounds like you don't have any work regarding the button so far, you should just find a tutorial yeah

daring sierra
naive pawn
spare herald
spare herald
#

HUUH oo alr thx

naive pawn
glass summit
naive pawn
#

the repetition

glass summit
#

yeah i'm not sure how to narrow it down 😅

naive pawn
naive pawn
glass summit
#

there are lines for when the character speaks, and the name of the person

#

however, the textbox doesn't show up at all

daring sierra
#

what is the script that is hiding/showing it? there might be some kind of edge case where the logic to enable it doesnt get triggered or forced to hide every frame

naive pawn
#

i'm not asking whether you have content intended for it

glass summit
#

i swear to god

#

i'm a dumbahh

#

you guys are my saviours 😭 🤌

weary depot
weary depot
#

i found a 500 view tutorial (absolutely peak)

naive pawn
glass summit
#

and i forgot to set it to true on the next event 🤦‍♂️

naive pawn
#

you should consider taking some time to just refactor this to make it more maintainable

weary depot
#

is there a way to get my Y velocity (im probably just really stupid)

#

my objects y velocity*

naive pawn
#

on the same object or of a different object?

weary depot
#

same object

#

wait im not doing it for rigidbody 2d

#

im stupid

naive pawn
#

you get the rb and then you get its y velocity

weary depot
#

thx

naive pawn
#

(you should already have a cached reference to the rb)

weary depot
#

i forgot about the fact it needs to be rb

#

oh jesus

#

i made a jumping mechanic

#

why does it do this?

naive pawn
#

that's basically 0

wintry quarry
weary depot
naive pawn
#

-1.212088E-08 = -1.212088 * 10^-8 = -0.00000001212088

weary depot
#

ah

#

that is alot more simple than i expected

naive pawn
#

it's scientific notation

weary depot
#

ah

real thunder
#

is there a better way to make a choice of a random animation other than adding more states at animator?

real thunder
#

interesting, would use in dire scenario

torn mango
#

Anyone can help me understand why my character is not animating the idle state?

teal viper
torn mango
#

I see

torn mango
sinful zinc
#

im using cinemachine Third Person Follow. it follows my player fine, but how do I look around with my mouse?

#

do i use script or is there a component for that

#

If i use a script, how should up and down rotation be handled if the script is on my player? horizontal is fine, and I want the player to rotate along with it, but when I go veritcal, the whole player rotates vertically too

timber tide
#

you look around by targeting something that rotates

sinful zinc
timber tide
#

well, if the head rotates independently from the torso you can target that too

#

otherwise you can do something like an invisible gameobject where the head is and rotate that instead

sinful zinc
#

my player is just a capsule

sinful zinc
#

should rotate

timber tide
#

right if the head doesn't move then empty game object is the idea

#

also I'm not usually a big fan of the third person camera and instead use the orbital so try that too

#

basically third person camera with more properties

sinful zinc
timber tide
#

there's a lot of things you can do with it, but yeah it can be very loose too if you want it to be

sinful zinc
timber tide
#

I dont play that unfortunately but perhaps

sinful zinc
#

I will try the orbital after but

#

would this approach work

#

The third person components target is an empty game object that rotates only up/down with mouse movement

#

then a script on the player manages left and right

#

So that the player can rotate left/right with mouse movement without the player rotating up/down?

timber tide
#

yeah sounds standard enough

#

if the empty game object is child to the player then it will move along with the body of the player, thus repositioning

#

both the posittional and rotational modules can also target different objects anyway

#

oh wait I see what you mean. So you're saying you cant rotate left and righ with the mouse in fortnite?

#

some funky control scheme

timber tide
#

unless you do mean you can strafe with 'A' and 'D" but also rotate 360 with the mouse

sinful zinc
#

no no no, essentially, a fps camera, but the camera is moved back so that its in third person

#

wait 360 yes but the player rotates along with the camera

timber tide
#

right yeah that's standard. Orbital and Rotational Composer probably

sinful zinc
#

so that the camera isnt just floating around the player

#

or should i figure that on my own

timber tide
#

like I said, if the empty game object is child to the capsule then when you rotate the capsule player then the empty will rotate with it

sinful zinc
#

my chinemachines target is the empty

naive pawn
#

you will make the capsule rotate (possibly through a rigidbody if you have a collider)

timber tide
#

well, if this is standard 3rd person controller, then you should have a rotational constraint on the empty* that it can't rotate further than something like 75 (+/-) degrees

#

and the closer it is to those values the more the rotation of the capsule will move

#

rather 45 ish

blissful stratus
#

how can i add a random int that have chances like 50% can i tried random.range but it doesnt have fixed chances

naive pawn
#

you could use Random.value as well

blissful stratus
naive pawn
#

no

solar hill
night raptor
#

Something like this:

float value = Random.value;
if (value < 0.5) //50% chance
    option1
else if (value < 0.85) //35% chance (0.85 - 0.5)
    option2
else if (value < 0.95) //20% chance (0.95 - 0.85)
    option3
else //5% chance (1 - 0.95)
    option3
blissful stratus
naive pawn
#

there is technically another option with AnimationCurves if you want to draw a distribution yourself, but that probably wouldn't be great for discrete outputs

night raptor
# blissful stratus i am making a casino so i want like the bad luck is 50 etc... and i have 5 choic...

Even with 5 choices, doing an if else chain may be quite prone to errors and hard to maintain (especially if you need many different distributions), 5 is also not nearly enough to make the alias method useful. If I was you, I would consider making a class like Distribution which you can create with different numeric weights for different values. Internally the weights can be stored as array of values normalized to add up to 1. You could then ask for numbers from the distribution where it would do the same logic present in the if else chain above, but by looping through the array instead

#

In it's simplest form it could work something like this: new Distribution(1, 5, 10, 17) (in this example the weights correspond to 0, 1, 2 and 3) where myDistribution.getRandom() would be 5 times likelier to return 1 (weight 5) compared to 0 (weight 1), and 2 times likelier to return 2 (weigth 10) compared to 1 (weight 5). I would prefer this kind of approach to not have to fiddle with the probability values by hand to always make them add up to 1

#

This is only very simplified example. In a real use case you would probably want to link the weights to a returned values too so they weren't just 0, 1, 2,... which would make you have to keep track of which value refer to which item/action

midnight plover
#

You could also just add a number from 0 to 100% for each item as possible weight distribution. Get all items weights combined, normalize them to 100/1 and get a random value from there. Bascially just remap your array of weights to a handleable sized dictionary and get your value back from there.

sudden ember
#

can i ask question about unity's visual scripting here? 'cause i'm struggling to play the animation although i have followed a youtube tutorial

frank delta
#

Hello! I wanted to ask if there is a way for OnTrigger.../OnCollision... to be run on FixedUpdate instead, the document saids it runs on Update and it is unreliable with my custom tick system, it goes as follows:

NO MORE HELP NEEDED!

edit: nvm documentation is half flawed, they do run on FixedUpdate

slender nymph
#

what documentation did you see that said they were called during the regular update loop rather than the physics update loop?

frank delta
#

you guys should really change this!

frank delta
#

they should fix that!

slender nymph
#

ah yeah, in that case "frame" being physics frame because it is a physics message

frank delta
#

yesss, they did not specify, my mistake!

naive pawn
frank delta
#

man, I gotta do more Debugging then!

slender nymph
frank delta
#

this is a bit strange, at 0.1 they just freak out

#

which if used with my tick system, they might miss a tick

frank delta
#

how should I safeguard this?

#

actually, let me debug this first

slender nymph
#

if you only ever expect to need two decimal places of precision you could just snap the value to the nearest 0.01 with Snapping.Snap

#

otherwise you would want to use some epsilon to check if a value is close enough, but of course how you address this entirely depends on what you are actually doing

frank delta
#

it doesn't seem to affect this:)

#

that's all my problem solved for now! thanks

gloomy heart
sly bronze
#

does anyone have any idea what this means because i didnt switch anything

slender nymph
#

!input and welcome to using a version that is 6.1 or higher

radiant voidBOT
naive pawn
sly bronze
#

thanks boxfriend

blissful stratus
#

public class RpgBullet : MonoBehaviour
{
    [SerializeField] float force;
    [SerializeField] float fieldOfImpact;
    [SerializeField] LayerMask hitLayer;
    [SerializeField] float BulletSpeed = 7;
    Rigidbody2D rb;
    private void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        rb.linearVelocity = transform.right * BulletSpeed;
    }
    private void Update()
    {
        Explode();
    }

    
    private void FixedUpdate()
    {
        transform.right = rb.linearVelocity;
    }
    void Explode()
    {
        Collider2D[] objects = Physics2D.OverlapCircleAll(transform.position, fieldOfImpact,hitLayer);
        foreach (Collider2D obj in objects)
        {
            Vector2 dir = obj.transform.position - transform.position;
            obj.GetComponent<Rigidbody2D>().AddForce(dir * force);
        }
        
    }
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.green;
        Gizmos.DrawWireSphere(transform.position, fieldOfImpact);
    }
}```
i am making a rpg bullet
how can make it work well
#

i tried to make it when trigger enter 2d didnt work well also

eternal needle
#

It looks like it's doing exactly what your code says to do in that first video

blissful stratus
polar acorn
#

What is the issue

blissful stratus
#

i want it to have a high force like a normal rpg i made the force = 5000 still it doesnt make it high

polar acorn
naive pawn
#

use an instantaneous force

#

wait, you're calling Explode in Update?

polar acorn
blissful stratus
#

i am calling it in the on trigger enter 2d

naive pawn
#

ok, so use an instantaneous force

blissful stratus
#

thats enemys

naive pawn
blissful stratus
polar acorn
# blissful stratus yeah why

Because if you're setting the velocity to a specific value then it will become exactly that value, regardless of however much momentum they've gotten from previous AddForces

naive pawn
blissful stratus
naive pawn
#

that won't solve the issue digi mentioned

#

it's just another issue

polar acorn
#

You do want to use Impulse, but if you're setting the velocity to 0 every frame they're not moving, they're going to stop the instant the force is no longer applied

white matrix
white matrix
blissful stratus
white matrix
#

nvm mb

naive pawn
naive pawn
#

no, it's just something you could make more straightforward and easier to read and maintain

naive pawn
#

it could be part of the issue though if this object can pitch up/down

white matrix
#

im gonna change one sec

naive pawn
#

then the forward vector wouldn't be horizontal

polar acorn
naive pawn
blissful stratus
naive pawn
#

you already tried that

#

it resets the velocity

#

are you sure that's what you want

white matrix
polar acorn
#

Check to make sure your collider isn't bigger than your mesh

white matrix
#

i did its fine

#

this the collider

tawny cave
#

im making a gorilla tag type game, any update ideas

#

(i ran out)

white matrix
#

do a lava mode that the flor is lava

tawny cave
#

ight

#

fun idea

polar acorn
tawny cave
#

yeah no

polar acorn
tawny cave
#

im to stupid to

polar acorn
white matrix
polar acorn
white matrix
polar acorn
# white matrix

You seem to have two player movement scripts on this object, and one of them involves a "Ground check" object which is probably your issue

#

Where is that object in relation to the character

white matrix
polar acorn
white matrix
#

so i didnt get what you asked

polar acorn
tender mirage
#

Is there a reaosn why my 3D raycast isn't working?

private void PlayerGroundedCheck()
{

    Ray groundRay = new Ray(transform.position, transform.right * 2);

    isGrounded = Physics.Raycast(groundRay, 1f, LayerMask.GetMask("Terrain"));



    //Draw debug ray
    Debug.DrawRay(transform.position, transform.right * 2, Color.blue);

   
}
polar acorn
#

DrawRay by default draws it for exactly one frame

tender mirage
#

it's in fixed update.

#

yeah i think there's a duration parameter too

white matrix
tender mirage
#

if i recall

naive pawn
polar acorn
tender mirage
naive pawn
tender mirage
#

i wanted to see if the ray wasn't visible

#

under my character.

naive pawn
polar acorn
tender mirage
#

but it's in fixed update. not even the debug raycast is showing up for me

tender mirage
naive pawn
#

the default value is 1 frame, as mentioned

polar acorn
#

Yeah, the default value is 1 frame. Since FixedUpdate runs on a schedule independent of the update loop, that frame might have passed before it actually has a chance to render it.

naive pawn
#

If depthTest is set to true then the line will be obscured by other objects in the Scene that are nearer to the camera.
consider setting that to false if you're worried it'll get obscured

polar acorn
#

Try giving it a higher value and see if you get anything then

tender mirage
polar acorn
naive pawn
polar acorn
#

Making it longer means it might double up but it would definitely show whether it's activating at all

naive pawn
#

oh true

#

this wouldn't be an issue if it were done in Update though right, if i'm understanding you correctly?

tender mirage
ivory bobcat
#

Potential culprit would be gizmo not being enabled

naive pawn
tender mirage
polar acorn
tender mirage
#

It's weird, it's just not working for some reason lol

naive pawn
ivory bobcat
#

Did you try a longer duration?

naive pawn
#

also make sure your objects are appropriately sized

ivory bobcat
#

Place a debug log in the function and see if it prints

tender mirage
naive pawn
#

it's the parameter after the color

#

what do you mean you can't find it

eternal needle
#

you could see if it's actually showing in scene view. that'd tell you if it's a code issue or if you just need to enable something for it to show in game view

naive pawn
eternal needle
#

i remember there being some weird things about it not showing in game view lately but not sure if that was an actual bug that got reported

tender mirage
#

so it's suppose to work.

tender mirage
eternal needle
#

look at it in scene view side by side with game view, see if it appears in one

tender mirage
#

even with longer duration it's not showing up

tender mirage
#

what. i've never seen that happen

slender nymph
#

make sure gizmos is actually enabled for game view

naive pawn
#

The line will be drawn in the Scene view of the editor. If gizmo drawing is enabled in the game view, the line will also be drawn there.

tender mirage
#

having it in game is also more convenient

#

wait its not even visible in the screenshot lmao

#

but i can ensure you its not there

ivory bobcat
tender mirage
#

like this?

ivory bobcat
#

Check which gizmo elements are enabled

tender mirage
#

everything is checked.

#

No worries.

#

and i get your concern, it is really weird, and it's putting me for a loop as well

#

lol

#

it should be there in the gizmo

#

game view

#

worst part about this? raycast isn't even activating my bool..

naive pawn
#

does the ground have the proper setup

tender mirage
#

Yeah, it has the terrain tag

naive pawn
#

does it have a collider

tender mirage
#

Yeah. I don't fall off the map.

#

wait it's probably because i put the distance to 1

#

🤦‍♂️

#

nope..

#

what the fuck

blissful mulch
#

can anyone help teach me scripting?
i know its a lot to ask but ive broken a finger punching my wall out of frustration

every tutorial is outdated and basically says i suck at scripting

warped meteor
#

As a practice project I'm trying to recreate pong, this is the code for the player paddle. Right now I'm trying to make it so if the paddle would move higher than 4 its position is just set to 4 so that it doesnt go off screen. Unity is unhappy with how im trying to do this and saying I cant just modify tranform.position.y and I am unsure about what to do

cosmic dagger
cosmic dagger
warped meteor
#

wait so how would I do that

naive pawn
cosmic dagger
#

note that is pseudo-code . . .

naive pawn
warped meteor
naive pawn
cosmic dagger
warped meteor
#

so would I create a vector 3 like [Vector3 paddlePos = transform.position] and then set it through that

gloomy heart
warped meteor
#

I assume this is an abomination

naive pawn
#

yes, that's not how c# works

cosmic dagger
naive pawn
warped meteor
warped meteor
#

this doesnt make any red

cosmic dagger
naive pawn
warped meteor
#

I updated the code to this but the paddle doesnt stop at 4 like it should

naive pawn
#

well, now paddlePos.y doesn't go above 4

#

but you want transform.position.y to not go above 4

warped meteor
#

oh wait I need to update the transform to paddlePos at the end then?

naive pawn
#

sure, that's one way to do it

#

btw, you don't need the == true

warped meteor
#

yay it works

warped meteor
#

oh yeah since it is inherently a bool

#

that evaluates to true

#

its like saying true == true right

cosmic dagger
#

you really don't need paddlePos at all. you're just assigning the transform.position to the new vector . . .

naive pawn
#

it's not inherently a bool, it just.. is a bool, outright

naive pawn
#

the desired effect was transform.position.y = 4, not transform.position.y += 4

fathom wind
#

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

public class NewBehaviourScript : MonoBehaviour
{
public float moveSpeed;
public float jumpHeight;
public KeyCode Spacebar = KeyCode.Space;
public KeyCode L = KeyCode.A;
public KeyCode R = KeyCode.D;
public Transform groundCheck;
public float groundCheckRadius = 0.2f;
public LayerMask whatIsGround;
private Animator anim;
private bool grounded;

// Start is called before the first frame update
void Start()
{
    anim=GetComponent<Animator>();
}

// Update is called once per frame
void Update()
{
    // Jump
    if (Input.GetKeyDown(Spacebar) && grounded)
    {
        Jump();
    }

    // Move left
    if (Input.GetKey(L))
    {
        Debug.Log("Moving Left");
        GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);

        if (GetComponent<SpriteRenderer>() != null)
        {
            GetComponent<SpriteRenderer>().flipX = true;
        }
    }

    // Move right
    if (Input.GetKey(R))
    {
        Debug.Log("Moving right");
        GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent<Rigidbody2D>().velocity.y);

        if (GetComponent<SpriteRenderer>() != null)
        {
            GetComponent<SpriteRenderer>().flipX = false;
        }
    }

    anim.SetFloat("Speed",Mathf.Abs(GetComponent<Rigidbody2D>().velocity.x));

    anim.SetFloat("Height", GetComponent<Rigidbody2D>().velocity.y);
    anim.SetBool("Grounded", grounded);
}

void Jump()
{
    GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
}

void FixedUpdate()
{
    grounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);
}

}

naive pawn
#

!code

radiant voidBOT
naive pawn
#

see the "large code blocks" section

#

support is a 2-way street, mate. you gotta help us be able to help you.

cosmic dagger
# gloomy heart whats the issue there

i explained in the message. they're having issues understanding how to assign a value properly. though, your version works, it's adding to the current position, which is not their intent

this will cause confusion and can lead to them using it for every assignment, thus, receiving undesired results when the other axes don't match

yours works because you have 0 for the x and z values. you'd have to specifically explain why it works and the meaning of using those values . . .

gloomy heart
tender mirage
fathom wind
gloomy heart
#

try any other service

tender mirage
naive pawn
naive pawn
tender mirage
#

Thanks alot.

#

Although, the debug raycast is not showing up in my game gizmos that's still weird.

midnight topaz
#

I have a player object with a running script, and I have a jump platform with a jumping script. There is a bool in the jumping script that triggers a jump in the running script. The jumping script is referenced in the running script, but my problem is that when I turned the jump platform into a prefab, I expected the code to work for every jump platform. Instead, it only works with the specific object that is referenced in the running script.

How can I make it so that every jump platform works with the running script?

naive pawn
#

you can make the running script detect the jump platform and react accordingly, or vice versa - depends on the design

fathom wind
naive pawn
#

send it here, sure

fathom wind
naive pawn
tender mirage
naive pawn
#

not sure what you mean by "clone script", but that would be tight coupling, it would make it harder to work with in the future

tender mirage
#

usually when you have prefabs it's better for the prefab to reference the script rather then referencing the prefabs

naive pawn
#

yeah that's not really how it works

#

it's also just not possible

tender mirage
#

It is. each new instance of a prefab that has a script can simply run a code on awake that gets the component of a another gameobject , in this case a script.

naive pawn
tender mirage
#

Nah nah not serialized xD. And yes, there are definitely a million other ways to handle that, which i can bet a few pennies on that you know more then me about.

#

also i saw you on the aseprite discord server, i was kinda suprised. do you do pixel art?

naive pawn
#

i wish 😔

tender mirage
next plume
#

Hey, y'all, I'm newer to making actual games in Unity. I'm trying to make a game called "Multi-Paul" for a class project, and the concept is that each time you press a button (in this case: F), you respawn at main spawn and a clone is made following the path you made before the reset. Essentially like replaying a recording.

It's a puzzle game. I finished the first level, but I wanna implement a mechanic where when you can't see the clone anymore (due to an obstruction) you can see the outline of the clone through the object/ wall. This is because I also wanna make it so that you can destroy the clone when pressing E on it, even through walls.

I'm having trouble getting the outline concept to work. Can anyone help me out?

polar acorn
#

Record all the inputs and the frame number they were sent on. Then, spawn a copy of the player object and instead of getting input from a controller, they get it from the list of inputs

#

Ah, wait, I read further, you want the outline

midnight topaz
polar acorn
#

That's going to be a Render Feature in URP, and you can set it to draw "After Opaques" to draw on top of it.

naive pawn
polar acorn
naive pawn
#

but yeah you'd be referencing it eventually, just not directly with serialized references

next plume
polar acorn
naive pawn
naive pawn
polar acorn
naive pawn
#

@fathom wind have you checked this? i asked quite a while ago

have you checked its transform to make sure it's actually not moving, or if it's perhaps moving very little?

polar acorn
#

Look at the transform and see if the numbers are changing

fathom wind
#

ohh

#

yes it transform

polar acorn
#

So, it's moving?

naive pawn
#

have you tried checking the scene view

#

in case your camera and background are following the character

fathom wind
polar acorn
#

What is your move speed set to

fathom wind
#

move speed 50 and jump height 25

polar acorn
#

And how big is the character

naive pawn
fathom wind
next plume
#

That don't have any correlation.

#

Is it outdated?

fathom wind
naive pawn
#

that's not what i asked

#

check the scene view and see if it's moving

#

check if the camera and background are moving

#

also while you're at it, make sure your script is saved

fathom wind
fathom wind
naive pawn
#

it's just that the camera and background are moving with it, so there's an illusion of no movement

#

you probably don't want the background to move perfectly along with the player, unless it's a really far background for parallax purposes

brittle isle
#

I am a newb. I'm trying to figure out how to make boomerangs go in an arc

fathom wind
naive pawn
naive pawn
naive pawn
fathom wind
brittle isle
naive pawn
#

ive already told you what the issue is

#

it's not the character

naive pawn
next plume
#

Figured it out.

brittle isle
sharp mirage
#

!paste

radiant voidBOT
sharp mirage
#

im tryna make my character swing when they attach to a specific object via using a hinge joint 2d but when i do press the button which adds the component which connects them together they just stay in place

#

heres my code

fathom wind
naive pawn
rotund imp
#

quick question what would be a good way to fix this i am just messing around no tutorials trying to get this working using System;

gloomy heart
#

!code =

radiant voidBOT
rotund imp
rotund imp
#

There sorry did not know i was meant to do that

gloomy heart
#

What’s wrong in your current code?

rotund imp
gloomy heart
#

does it ahs any constrainstconstraints if it moves only in one direction

gloomy heart
brittle isle
naive pawn
#

you might want to consider using coroutines here

#

it'd probably make it easier to work with

brittle isle
#

makes sense. i'm just scared they'll overlap

naive pawn
#

not sure what you mean by that

brittle isle
#

ah, i see. it's how the movement is calculated. it doesn't go in an ellipse at all, it goes in a v. No idea how i screwed that up

#

this is more complicated than expected

naive pawn
#

also consider making it parabolic rather than elliptical

#

which.. i guess are pretty similar

lavish thorn
#

am I correct that: a Rigidbody cannot be temporarily "disabled" and then reenabled because the physics system doesn't like that? I want my player to have a mode where they are a drone, and I am using a Rigidbody with force/rotation applying functions, while also having a CharacterController component for easy walking around, but it seems Rigidbodys are not very good when attached to a CharacterController using gmaeboejct

gloomy heart
#

rigidbody can't be disabled

#

What you can do is iskinematic true

polar acorn
naive pawn
# lavish thorn am I correct that: a Rigidbody cannot be temporarily "disabled" and then reenabl...

a Rigidbody cannot be temporarily "disabled" and then reenabled because the physics system doesn't like that?
this is not true
a rigidbody cannot be truly disabled, that's just not something it can do - not because the physics system doesn't like that, just that it's not a thing
what you can do is make it kinematic - but this disables physics simulations, not the entire rigidbody. it'll still be trying to control the transform afaik, so it'll still fight the CC.

#

you could maybe consider having the drone and walking forms completely separate

gloomy heart
#

Or either remove the Rigidbody component and readd it?

warped tinsel
#

hi chat

lavish thorn
#

Thnx I will probably have the drone and walking be separate, I am just curious on why RBs can't just be disabled willynilly like a normal component

sour fulcrum
#

components being disabled only mean anything if the code in said component actually cares about it (aside from some niche stuff like findobjectsoftype)

#

if there isn't any usage of stuff like Update, OnDisable & OnEnable you can't even toggle the bool in inspector

lavish thorn
#

ohh so e.g. its just a tag

sour fulcrum
#

no but similar line of thinking yeah

naive pawn
naive pawn
#

Component doesn't have an enabled prop

#

Behaviour does

lavish thorn
#

oh yeah... they're all MonoBehaviour... i think i get it

warped tinsel
#

anybody have tips on where to learn ?

gloomy heart
#

/learn

#

!learn

radiant voidBOT
warped tinsel
#

ah

#

thanks

#

damn it

#

i downloaded the wrong module

#

and it wont let me remove it mad

gloomy heart
#

You can't remove the installed module through Hub

warped tinsel
#

i have to do it through files ?

gloomy heart
warped tinsel
gloomy heart
#

staff solution also says [its for android module but]

warped tinsel
#

thanks for the help

marble kindle
#

So I'm trying to clamp a car so it don't roll over. I want it to lean and stuff, but I don't want it to be able to tip or flip. Unfortunately for me, my code seems to just make the car glitch out horribly. Been trying to figure this out for the past few days and I feel like I'm beating my head against a wall.

    Vector3 localRotation = transform.localEulerAngles;
    float localRotationZ = localRotation.z;
    if (localRotation.z > 20)
    {
        transform.rotation = Quaternion.Euler(0, 0, 20);
    }

    if (localRotation.z < -20)
    {
        transform.rotation = Quaternion.Euler(0, 0, -20);
    }
#

Is there any easy way to clamp this thing so it'll just lean and stuff and not like, tip over or glitch out? Thank you.

ivory bobcat
#

You'd probably still get glitches though as converting from quaternion to euler has some issues. For the best of results, keep a field to retain the actual rotation and simply apply it to rotation rather than reading the rotation from the Transform component.

rain solar
#

can someone link me to a premade equation for gradient fractal perlin noise for terrain? i dont feel like doing hours of trial and error

marble kindle
#

Admittedly I have next to no idea what I'm doing. Only been dabbling with code for a few weeks now.

timber tide
#

if you're using a rigidbody you can just freeze the rotational axis

marble kindle
#

I would, but I want it to be able to lean side to side a bit.

timber tide
#

probably want to clamp x too then

#

your image doesn't tell enough

marble kindle
#

Yeah. But I figure if I can get Z, I can get X too.

#

It's the MotionSicknessMobile...

#

Like, at all times it's trying to set z rotation to 20. It kinda just flickers horribly. And my video of it won't go through.

timber tide
marble kindle
#

I'll need to give that a lookthrough after I wake up. Even if it doesn't fix it, it's at least information about what I'm doing wrong which is one step closer to getting it right

#

Thank you.

keen dew
#

You can't read (or write) how much the car is tilted from the Euler Z rotation, it won't tell you that. You'll have to check the angle between transform.up and the ground normal (or Vector3.up) and rotate towards it if the angle is too large

quick plaza
#

How to start unity can any help

#

Currently I am new

naive pawn
radiant voidBOT
quick plaza
#

750 hours+😮

#

😵

noble forum
#

I have just imported a scene from the the other project, with the same version as my current one who was specifically boosted to match the version.
For some reason none of the colliders seem to work (projectiles just pass through)

noble forum
noble forum
sour fulcrum
#

how do you know that

wicked cairn
noble forum
sour fulcrum
#

show the debug related code

noble forum
#
    {
        AudioClip atk = null;
        int r = Random.Range(0, 3);

        if (r == 0) atk = audioManager.Atak1;
        else if (r == 1) atk = audioManager.Atak2;
        else atk = audioManager.Atak3;

        audioManager.PlaySFX(atk);
        if (Time.time < nextAttackTime)
            return;

        if (Input.GetMouseButtonDown(0)) // Left click
        {
            if(atacanimation)Swordanimator.SetTrigger("Up");
            else Swordanimator.SetTrigger("Side");

            atacanimation = !atacanimation;

            nextAttackTime = Time.time + attackCooldown;

            int totalDamage = baseAttackDamage + (abilities != null ? abilities.BonusAttackDamage : 0);

            Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(
                transform.position,
                attackRange,
                enemyLayers
            );

            Vector3 mouseDir = (Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position).normalized;

            foreach (Collider2D enemyCollider in hitEnemies)
            {
                Debug.Log("" + enemyCollider.gameObject.name);
....```
sour fulcrum
#

is that return happening and are you left clicking (can confirm via debug after thse conditions)

#

are the enemies the right layer of that mask

#

is that mask setup right

#

is this function even running

noble forum
#

i mean, animation does play

#

the same exact code is in the well working version

#

so its probably something in unity itself

sour fulcrum
#

which could be any of the four things i mentioned

#

a debug log right before the foreach confirms that 1 and 4 are dead ends

#

you'd need to look in unity for 2 and 3

noble forum
#

Ohhhh, the layer turned blank

#

that explains it

#

I looked at tags that... got imported normally?

#

I assumed layers did too

sour fulcrum
#

potentially not if those layers aren't defined in that project

#

not sure

#

(and defined in the right order)

noble forum
#

Okay, i just added Enemy and Player layers and it filled it in automaticly

#

Gosh, i wouldn't have noticed for some time by myself

#

Now it works

#

Thank you!

sour fulcrum
#

no worries, remember all i really did was narrow down what could and couldn't be the problem

#

easy to do in the future 😄

noble forum
#

Yea, i have some experience in Unity, but i took a break aside from 24h hackaton this project is from, and now im a little sleep deprived

#

gotta give some progress to my teacher today, i decided to hand in 2 things instead of 1

#

Idk if the grade in game programming will be any useful in the resume, but oh well, might as well try for that one subject

#

if not for anything else

normal arrow
#

Hi i've got something like this :


IEnumerator LoadExperienceHttp(string url_Complete)
    {
        Debug.Log("Url complete : " + url_Complete);
        yield return new WaitForSeconds(1);

        using (UnityWebRequest www = UnityWebRequest.Get(url_Complete))
        {
            yield return www.SendWebRequest();

            if (www.result != UnityWebRequest.Result.Success)
            {
                Debug.Log("Erreur : " + www.error);
            }
            else
            {
                Debug.Log("Réponse serveur : " + www.downloadHandler.text);
            }
        }
    }```


And since it's an http url, i have an "not securised connection, abort" error, so my question is, is there a way to adapt this code to http ?
keen dew
#

https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.html

HTTPS is supported and the server certificate is validated against the root certificate store available on the system the app runs on. Validation can be disabled (for example, for development server using self-signed certificate) or changed to custom handling by assigning the UnityWebRequest.certificateHandler property.

noble forum
#

I have yet another question

#

I change the scene in the middle of playtime, yet i have UI from both for some reason

midnight plover
noble forum
#

I expected the text UI to dissapear

midnight plover
#

Also, as this is a code channel. If you think its code related, show the code that handles your UIs, so we can follow

noble forum
#

How do i bypass it without really changing their code

#

i mean, if i can i would like to work around the working system rather than change it

midnight plover
elder canyon
#

Using an Event vs Function call from another sctipt.

noble forum
midnight plover
noble forum
#

i'll try disabling in the runtime

midnight plover
noble forum
#

i'll find a proper method later

midnight plover
noble forum
midnight plover
# noble forum Done

glad you found it, as this will be the proper way to do it. Imagine you just disable the gameobject and someone forgot to check against that in the package, you can spawn random errors just because you stitch into their package mid execution of their dialoguesystemloop 🙂

noble forum
noble forum
#

Can someone tell me why is this button even here?

#

Like, is this supposed to be some kind of mockery lmao?

midnight plover
naive pawn
noble forum
#

Any idea why they took a nice design of a menu of building projects, and turned it into unintentional mess?

#

I came from version 2022 to 6000

#

And gosh, I don't even see where do I input the desired path anymore

naive pawn
#

the path of what?

noble forum
#

Of the build

#

Where I want it to appear

midnight plover
visual moss
#

Hi

midnight plover
# visual moss Hi

Dont just say hi in a topic channel please. If you got an issue, just ask 🙂

candid pilot
#

Hi

#

İ wonder how i can make a online game using peer to peer connection

#

1 host version

#

Are there any experienced dev here about that?

keen dew
#

With effort, persistence and difficulty

blissful mulch
#

can anyone tell me why my rotate thing doesnt work? it doesnt print anything but jumping and moving works

using UnityEngine.InputSystem;

public class MovementHandler : MonoBehaviour
{
    [SerializeField] private float speed = 5f;
    [SerializeField] private float jumpHeight = 2f;
    [SerializeField] private float gravity = -9.8f;

    private CharacterController controller;
    private Vector3 moveInput;
    private Vector3 velocity;
    private Vector2 viewInput;

    void Start()
    {
        controller = GetComponent<CharacterController>();
    }

    public void OnMove(InputAction.CallbackContext context)
    {
        moveInput = context.ReadValue<Vector2>();
    }
    public void OnJump(InputAction.CallbackContext context)
    {
        velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
    }

    public void OnRotate(InputAction.CallbackContext context)
    {
        viewInput = context.ReadValue<Vector2>();
        print(viewInput);

    }

    void Update()
    {
        Vector3 move = new Vector3(moveInput.x, 0f, moveInput.y);
        controller.Move(move * speed * Time.deltaTime);

        velocity.y += gravity * Time.deltaTime;
        controller.Move(velocity * Time.deltaTime);
    }
}```
wintry quarry
sonic zenith
#

for some reason the playback time on this particle system is like 30 sec i dont want that it is just a muzzle flash how can i change it?

rough granite
#

Also not a code question

latent reef
#

Do you guys recommend to learn modeling and all like become full stacked

gloomy heart
#

As a indie dev you have to be in all fields

rough granite
latent reef
#

since ive been switching from LUA, JS, and now C#

rough granite
latent reef
#

So js wanna know if its better to be a full stack on unity

#

alright

rough granite
gloomy heart
#

yes, im too looking for a teammate can't do all the things alone

serene cargo
#

Hi everyone, I'm having an issue in build with Unity, my CharacterController.Move function doesn't move my character when on ground (move vector is correct and all). The moment I jump and move he can walk, even on ground, but as soon as I stop it doesn't move on ground anymore unless I jump and move again...

if(!character) return;
        
Vector3 targetVelocity = playerVelocity;
        
if(new Vector3(targetVelocity.x, 0, targetVelocity.z) != Vector3.zero)
{
  if(character.isGrounded)
  {
    playerVelocity.x = Mathf.Lerp(character.velocity.x, targetVelocity.x, accelerationRate);
    playerVelocity.z = Mathf.Lerp(character.velocity.z, targetVelocity.z, accelerationRate);
  }
}
else if(new Vector3(targetVelocity.x, 0, targetVelocity.z) == Vector3.zero)
{
  playerVelocity.x = Mathf.Lerp(character.velocity.x, 0, deccelerationRate);
  playerVelocity.z = Mathf.Lerp(character.velocity.z, 0, deccelerationRate);
}
        
character.Move(playerVelocity * Time.deltaTime);

Here is the movement code in Update
The playerVelocity isn't the culprit I already debugged it in dev build

In editor play mode it works flawlessly

wintry quarry
#

seems like a chicken and egg problem

#

and you can easily debug this

#

Also if(new Vector3(targetVelocity.x, 0, targetVelocity.z) != Vector3.zero) kind of makes my eyes bleed

serene cargo
#

Yeah I used that to debug

#

The issue is it's working in editor but not in build for some reason

#

And the character.Move is outside of the if statements so it is set even if velocity is zero

solar hill
serene cargo
#

But even so, why would it work in the editor in that case?

solar hill
#

did you debug your isgrounded variable?

#

are you ensuring you are still grounded after jumping and landing

serene cargo
#

Yup, it is always true when I'm on ground

#

Yep, in the state machine, I can only enter move state when on ground, and I have a label that shows me that I am indeed in movestate

solar hill
#

if it works properly in build but not in editor makes me think it might be framerate dependant issue

serene cargo
#

It's the opposite

#

It doesn't work in build but works flawlessly in editor

#

And it shouldn't be framerate dependant as I'm multiplying the target velocity by delta time in the Move function

solar hill
#

i think it could be this

if(new Vector3(targetVelocity.x, 0, targetVelocity.z) != Vector3.zero)

#

i think it might have to do with some floating point precision differences between the editor and build

#

im not too sure

#

try something like this

#
Vector3 horizontalVelocity = new Vector3(targetVelocity.x, 0, targetVelocity.z);

if(horizontalVelocity.sqrMagnitude > 0.0001f)
{
    //move 
}
else
{
    //do the opposite of moving
}```
#

just as a test too see if the issue still happens

serene cargo
#

I'll give it a try

#

Mmmh, still the same result in build

serene cargo
#

Ok, after a few tests the issues seems to be my acceleration/decceleration code, for some reason in build it doesn't lerp and just straight out not move

#

Same thing for the decceleration, it just stops instantly while in editor everything works for some reason...

placid jewel
blissful mulch
twin pivot
#
_buttonArray[i].upgradeAttack = GameObject.Find(_buttonArray[i].upgrade.ToString() + "Spawner").GetComponent<PlayerUpgradeAttack>();
#

Behold my sinful code

wintry quarry
wintry quarry
# blissful mulch

cool - so yeah you should definitely see some logs happening when you move the mouse

#

are you looking at the console window?

blissful mulch
#

i am yeah

#

ive been asking for help from chatgpt for the last hour but that hasnt helped

wintry quarry
#

And what is it printing?

blissful mulch
#

when i move my cursor?

wintry quarry
#

yes

blissful mulch
#

nothing at all

wintry quarry
#

Have you clicked into the game window to give it focus

blissful mulch
#

i did yeah

wintry quarry
#

Can you show how you configured the action?

blissful mulch
wintry quarry
#

I think this is a control schemes issue

#

Are you doing local multiplayer?

#

if you're not doing local multiplayer I recommend avoiding control schemes, they will just cause you a headache

blissful mulch
#

uhh its just a singleplayer game...

#

ive just heard the old input system is outdated...

wintry quarry
#

I didn't say anything about old input system

#

I'm talking about control schemes

blissful mulch
#

then idk what a control scheme is

wintry quarry
#

Well you seem to have set at least one of them up

blissful mulch
#

oh wait i remember

#

my bad

wintry quarry
#

I recommend deleting all control schemes, they are not useful for single player

#

and they will jsut cause issues

subtle python
#

i just started unity and c# overall, how do i set up intellisence for unity with vs code?

blissful mulch
radiant voidBOT
blissful mulch
#

thank you so much dude

#

i dislocated a finger punching my wall out of frustration yesterday🥹

subtle python
# wintry quarry !ide

i followed all the steps and im not getting autocomplete words or anything like that

subtle python
#

like what.

wintry quarry
# subtle python like what.

Like one of the steps:
The extension in VSC
or the VSC package in Unity
or setting the external editor in Unity

subtle python
#

all of them are set

#

i got the unity extension and c#

#

and the rest are set in unity

wintry quarry
#

did you press the "trust this solution" button or whatever in VSC

#

Do you have any compile errors in your console window in UNity?

subtle python
#

it does say at the bottom failed to find entry points?

wintry quarry
#

It says that at the bottom of where

subtle python
#

unity

wintry quarry
subtle python
#

okay

#

nvm i fixed it

serene cargo
twin pivot
#

whats the difference between System.Random.Range and UnityEngine.Random.Range?

slender nymph
#

System.Random is an object that must be constructed, UnityEngine.Random is a static class. System.Random also does not have a Range method

wintry quarry
twin pivot
polar acorn
#

So, check the line, and see what variables come before a . or a [

twin pivot
slender nymph
#

where do you actually assign a List<T> object to that variable anyway?

polar acorn
slender nymph
#

null != empty, null == null. a null list cannot be empty because it isn't anything. an empty list is explicitly not null

twin pivot
#

wait what the hell

#

the code is on line 34 now but the null reference hasnt moved?

polar acorn
#

What's line 33 now?

twin pivot
polar acorn
twin pivot
slender nymph
#

incorrect, that is adding to the list, not assigning a list to the variable

polar acorn
slender nymph
#

where do you assign a new list to the variable

twin pivot
polar acorn
#

There's your error

slender nymph
twin pivot
#

oh my god i see the problem now XD

polar acorn
#

Find the thing on that line that's null

#

And make it not be that

twin pivot
#

i didnt know that creating a list worked differently to creating an array whoops

slender nymph
#

here's a fun fact: it doesn't work differently

twin pivot
#

wait nevermind then im not sure what im doing wrong then

slender nymph
#

your arrays are just not null because they are serialized by unity so unity is creating the instances for you

twin pivot
slender nymph
twin pivot
slender nymph
#

that's literally what i said and you said that was an odd choice

twin pivot
rancid tinsel
#

!code

radiant voidBOT
slender nymph
radiant voidBOT
#

success @edward031633 muted

Reason: Too many messages in multiple channels
Duration: 29 minutes and 47 seconds

serene cargo
#

The thing is, how could I make it really framerate independant in that case?

#
if(!character) return;

Vector3 targetVelocity = playerVelocity;
Vector3 horizontalVelocity = new Vector3(targetVelocity.x, 0, targetVelocity.z);

if(horizontalVelocity != Vector3.zero)
{
  if(character.isGrounded)
  {
    playerVelocity.x = Mathf.Lerp(character.velocity.x, targetVelocity.x, 1 - Mathf.Exp(-accelerationRate * Time.deltaTime));
    playerVelocity.z = Mathf.Lerp(character.velocity.z, targetVelocity.z, 1 - Mathf.Exp(-accelerationRate * Time.deltaTime));
  }
}
else if(horizontalVelocity == Vector3.zero)
{
  playerVelocity.x = Mathf.Lerp(character.velocity.x, 0, 1 - Mathf.Exp(-deccelerationRate * Time.deltaTime));
  playerVelocity.z = Mathf.Lerp(character.velocity.z, 0, 1 - Mathf.Exp(-deccelerationRate * Time.deltaTime));
}

character.Move(playerVelocity * Time.deltaTime);

if(character.height != targetHeight)
{
  character.height = Mathf.Lerp(character.height, targetHeight, 0.75f);
}

ivory bobcat
rocky canyon
#

Mathf.MoveTowards is amazing.. its my pick of the two ☝️ (2:cents:)

serene cargo
#

MoveTowards kinds of give me parasite move on the sides when moving forward and same thing forward when moving on the sides ^^"

#

I'm trying to do everything in fixedUpdate but get this kind of stutter and movement blur when playing the game

#

And I don't seem to find a way to interpolate CharacterController

naive pawn
#

CharacterController works on Update

#

it doesn't need to be interpolated

serene cargo
#

Mmmh, doesn't seem to work in build with the usage of lerp then ^^"

#

Or at least doesn't work when the framerate is too high

ivory bobcat
#

You need to log some data. Chances are, the improved wrong-lerp has some unexpected values.

naive pawn
#

the wrong lerp fix here seems a bit weird to me

serene cargo
#

I tried both anyway, same result

#

When the framerate is higher than 144 it doesn't lerp as expected anymore ^^"

naive pawn
#

are you setting playerVelocity outside of this function?

#

it seems to be the targetVelocity, but you're modifying it

ivory bobcat
#

I found it strange that they were using character.velocity

naive pawn
#

on frame 2, character.velocity.x and targetVelocity.x would be the same value

serene cargo
#

character.velocity is the actual velocity of the character, targetVelocity is the velocity I'm trying to get to (it changes with player input)

ivory bobcat
#

Ideally wrong lerp would be cs value = Mathf.Lerp(value, target, constant);

naive pawn
#

this isn't wronglerp

#

this is the fix to wronglerp with consistent results

ivory bobcat
#

Not cs value = Mathf.Lerp(somethingElse, target, constant);

serene cargo
#

playerVelocity is set in that function only

naive pawn
serene cargo
#

targetVelocity is set according to input

naive pawn
ivory bobcat
naive pawn
serene cargo
#

sry

naive pawn
#

what's the current code

serene cargo
#

Forgot to specify that

#
if(!character) return;
        
        Vector3 horizontalVelocity = new Vector3(targetVelocity.x, 0, targetVelocity.z);
        
        if(horizontalVelocity != Vector3.zero)
        {
            if(character.isGrounded)
            {
                playerVelocity.x = Mathf.Lerp(playerVelocity.x, targetVelocity.x, 1 - Mathf.Exp(-accelerationRate * Time.deltaTime));
                playerVelocity.z = Mathf.Lerp(playerVelocity.z, targetVelocity.z, 1 - Mathf.Exp(-accelerationRate * Time.deltaTime));
            }
            else
            {
                playerVelocity.x = targetVelocity.x;
                playerVelocity.z = targetVelocity.z;
            }
        }
        else if(horizontalVelocity == Vector3.zero)
        {
            playerVelocity.x = Mathf.Lerp(playerVelocity.x, 0, 1 - Mathf.Exp(-deccelerationRate * Time.deltaTime));
            playerVelocity.z = Mathf.Lerp(playerVelocity.z, 0, 1 - Mathf.Exp(-deccelerationRate * Time.deltaTime));
        }
        
        character.Move(playerVelocity * Time.deltaTime);
naive pawn
#

ok, where do you declare/define playerVelocity and targetVelocity

#

is playerVelocity local or a member

serene cargo
#

playerVelocity is a member

cloud agate
#

I've made a main menu for my 3d game, and for some reason when I load the scene it's all dark

serene cargo
naive pawn
serene cargo
#

Mmmh

#

I tried a clean build and it seems to be working now

#

Maybe there was an issue with the build

#

After I made the change with targetVelocity

#

And lerping playerVelocity instead of character.velocity

serene cargo
#

It clearly was a logic issue on my behalf ^^"

#

Thanks to @ivory bobcat too btw 🙂

pliant dome
#

is there a way to refer to a bool method as false in a if statement? I know its already set to false automatically but I need it so that when Im jumping its specifically makes my bool method false

slender nymph
#

you can't set a method to anything, methods return values, so whatever is being returned needs to include that condition you'd like to impose

naive pawn
#

you also usually want to call methods rather than just referring to them

#

what exactly are you trying to do, in a broad overview? it sounds like you don't have the experience to use the proper terminology precisely yet

polar acorn
rocky canyon
#
  if (!IsGrounded())
  {
     // weeeeeeeee
  }```
solar hill
#

thats not a bool method though

#

thats just an if statement that uses a bool UnityChanHuh

#

im guessing a bool method would be a bool function that returns a true or false statement

polar acorn
#

Well, IsGrounded() would be

cunning narwhal
#

Whats going on whenever I see code like this?

someVar.someProperty = () =>
{
....stuff....
};

solar hill
#

the arrow function?

#

used for callbacks mostly iirc

cunning narwhal
#

yeah like why is it = to a blank parenthesis and then the lambda to some code block?

pliant dome
#

Just recently added a raycast along side using comparetags for ground check and this if statement kepted things working for some reason

cunning narwhal
#

Like whats the long-hand version of that? I dont know what this is specifically called so trying to search for it is difficult

polar acorn
cosmic dagger
polar acorn
# pliant dome

You can't set a function to a value. getisGrounded() will give you a boolean. You can't set it to false

cunning narwhal
#

Awesome, thanks!

solar hill
#

so what is it youre trying to do then?

pliant dome
#

I just put it there to show what I initially did then realized I couldnt do that

polar acorn
#

What would it even mean to set the function to false?

solar hill
#

i guess to make it always return false if some condition is met?

#

i guess you could do that with a seperate bool and an if statement within the bool function

rocky canyon
#

boolean function could run conditionals b4 the return

pliant dome
#

For some reason my idle animation would play when Im jumping and this if statement in my update method would stop this from happening. I legit could not tell you why

#

Well Ill figure something out

solar hill
#

well since its the idle animation im assuming its overriding the jumping UnityChanHuh

#

you would need some kind of conditional to ensure it doesnt play when you are airborne

pliant dome
#

Yeah I already have a isJumping = true or false in place for this

#

and it doesnt change so iunno

solar hill
#

it doesnt change?

#

i mean your isjumping is just the opposite of your isgroundedd

#

you dont really need a seperate jumping bool

#

at least i dont think you would, you can just use !isgrounded

#

to drive the parameter for the animation

rocky canyon
solar hill
# pliant dome

also i dont understand this? isnt this the opposite way of doing this? why are you setting your isgrounded manually at all?

rocky canyon
#

see if they print out to the console when u expect

#
    void Update()
    {
        PlayerGroundCheck();

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

        if (!playerIsGrounded) // same as saying if(playerIsGrounded == false)
        {
            // airborne logic
        }
        else
        {
            // grounded logic
        }
    }
``` as kuzmo says ^ 1 boolean should be enough for what i think ur doing.. its either *this* state or *that* state.. and depending on that you can branch off and run seperate logic for both states..

your ground check should become false if its programmed correctly.. you shouldn't need to manually set it..
it overcomplicate things when u have (2) booleans like isGrounded and isJumping.. since they both just mirror each other anyways.. instead of working from there and getting stuck w/ contradicting booleans maybe try to re-think your logic and setup to make it more simple
hallow sun
#

What happens when a script has a virtual function, and the script that inherits it also has it but not using override? do both trigger? just the newest?

class Parent {
  void virtual Something() {/*do something*/};
}
class Child : Parent {
  void Something() {/*do something else*/};
}
#

trying to read someone else's code where testing isnt possible rn

polar acorn
#

You can still write your own and run that

naive pawn
#

you could copy that snippet into an online c# compiler and fix all the issues

#

you wouldn't even have to run it, you'd get a warning telling you exactly what happens

verbal dome
#

Thought i'd point that out as it isn't immediately obvious if you just "try it and see".

naive pawn
#

the warning that pops up makes it pretty obvious imo 🤔

#

the warning says it acts like new

hallow sun
#

aight ill try and see

spiral lynx
#

does anyone here use the Nova UI framework?

hallow sun
#

turns out they have different parameters so i was just overthinking the "virtual"

#

it just uses the one whose parameters you match

weary depot
#

im trying to put my panel inside of this and its not working

#

anyone know why?

slender nymph
weary depot
#

ah

#

thx

queen adder
#

is there any easier way to rotate my builds without code

#

or to snap them

queen adder
polar acorn
queen adder
#

what has this planet come to

#

so soft

#

get a grip 😬

naive pawn
#

rules exist, yes

queen adder
#

suck a fat one!

sour fulcrum
#

in fairness

polar acorn
#

I'm sure the twelve years or so you've been alive have been hard, yes

naive pawn
queen adder
#

sad for u

polar acorn
naive pawn
#

sadly true

#

the projection is strong, man...

polar acorn
queen adder
north kiln
#

!mute 1430691199160815717 1d if you want to continue posting here you will need to be less antagonistic. Follow basic posting etiquette, don't cross-post, and re-read our conduct if you have trouble.