Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: serenefox on February 13, 2017, 08:48:37 PM

Title: Help slowing "Add Torque" based on slope?
Post by: serenefox on February 13, 2017, 08: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!
Title: Re: Help slowing "Add Torque" based on slope?
Post by: jeanfabre on February 14, 2017, 02: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
Title: Re: Help slowing "Add Torque" based on slope?
Post by: serenefox on February 14, 2017, 04: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!