playMaker

Author Topic: Help slowing "Add Torque" based on slope?  (Read 178 times)

serenefox

  • Junior Playmaker
  • **
  • Posts: 83
    • View Profile
    • Serenefox Games
Help slowing "Add Torque" based on slope?
« on: February 13, 2017, 06:48:37 PM »
Hi,

I am building a ball platformer and I am trying to find a way to detect when my sphere is going up or down a slope. I am using "add torque" to move my sphere character and its great but I can basically go up almost vertical slopes with it, which I don't want. I want to slow down the sphere if it is going uphill and speed it up going downhill. I am assuming I am going to have to use raycasting but not sure.

My sphere has a rigidbody and a collider instead of a character controller if that's helpful info.

TL;DR I need a way to detect a slope's value so I can change the speed of my add torque.

Thanks for any info!
Recent Published Games:

Don't Pop! Dungeon - iOS/Android

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12348
  • Official Playmaker Support
    • View Profile
Re: Help slowing "Add Torque" based on slope?
« Reply #1 on: February 14, 2017, 12:12:07 AM »
Hi,

If your goal is to reach a constant velocity, then simply enforce a constant velocity to begin with, that's all is required.

 have you checked the m2h samples on the wiki? there is a ball platformer, maybe it could have a solution for you on this.

as to detect slope, you could get the point of contact and check the angle of that point to the center of the ball against the vertical axis of the world. that will give you a hint on the slope.

Bye,

 Jean

serenefox

  • Junior Playmaker
  • **
  • Posts: 83
    • View Profile
    • Serenefox Games
Re: Help slowing "Add Torque" based on slope?
« Reply #2 on: February 14, 2017, 02:37:54 AM »
Hi Jean,

I don't want a constant velocity. Let say the ball starts to go uphill, I want to start to slow it down based on the slope of the hill to a certain point. Basically what a character controller does but with a rigidbody and collider instead. I think what you told me in the latter half of your reply is what I was looking for though. I will have time to test and see for sure tomorrow.

Thanks!
Recent Published Games:

Don't Pop! Dungeon - iOS/Android