Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question if the variable Pippo increases gradually increases the variable Pluto

Discussion in 'Editor & General Support' started by Fuocartex, Jun 19, 2020.

  1. Fuocartex

    Fuocartex

    Joined:
    Jun 2, 2020
    Posts:
    13
    I have two variables: one calculates an angle, the other is a fixed value.
    I would like that when the angle increases the other variable also increases gradually.
    how can I do?
    thanks
     

    Attached Files:

  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,206
    All the images you uploaded are broken. Use code tags to post code.

    There's a bunch of ways to do what you want to do. The simplest is just a statement in your Update method that sets value A based on value B. For example, `A = Mathf.Sin(B);' If that's not a viable option for you, please explain the situation in more detail.
     
  3. Fuocartex

    Fuocartex

    Joined:
    Jun 2, 2020
    Posts:
    13
    the images Ido not know what they are I have not uploaded them and anyway they are not needed. while my player walks he detects the slope of the ground. then the second variable is the distance from the ground. if the plane is more inclined by n degrees then the ground check does not work and therefore I would like to increase the distToGround as the angle increases.

    also in this post, there are those images but I don't know.

    so cause another problem I can't walk on stairs because the angle of the plane under the stairs is too high
     

    Attached Files:

    Last edited: Jun 19, 2020
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,206
    I'm not sure what you're pasting into your posts to get them to be treated as images. Anyway...

    You still haven't shown any code, so I'm only guessing here. But how do you know the angle of the plane if your ground check doesn't go far enough to hit what's under you? You're kind of saying that for steep slopes, you want to test a further distance for the ground. But you won't know the slope of the ground unless you hit it in the first place...

    Anyway, you may simply be running into issues because your ground test is using a Raycast. I can't tell, because you haven't posted code. You can instead use a spherecast to avoid the kind of issue you're running into.