Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Need some help with maths

Discussion in 'Scripting' started by Khena_B, Aug 11, 2016.

  1. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    Hey,

    My character is using a Rigidbody2D (Box2D physics)

    On a 45 degree slope, with a gravity of -25, a physical material with 0 friction and no drag, my character slides down continuously at a velocity of 0.5 on X and Y

    I'm trying to stabilize my player by adding enough velocity on X to counter the sliding, i have a raycast that gives me the angle or the normal of the slope i'm standing on but i just don't know where to go from there, there has to be a simple equation to get the counter velocity?

    Some help would be appreciated
     
  2. Shiikarii

    Shiikarii

    Joined:
    Feb 6, 2014
    Posts:
    89
    Write a simple raycast script to for the rigidbody and zero the velocity when raycast hit's down direction.
    Does the controller need a physical material?
     
  3. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    I'm not sure i understand your suggestion.

    I do not want any friction so i have to use a physical material otherwise the friction would default to 0.4.

    Friction seems useless, to stop sliding i would have to set it so high that i wouldn't be able to move anymore and stick to walls.