- Home /
Curved transform.translate
Hi I'm making a parkour game and I would like to know how could I make the wall run more in a curve, have a scheme of what I mean and what I want: I think the scheme is understandable, I think to do that curved movement I need to use Mathf.Clamp, I don't remeber but I think it was that, I have some videos on my youtube channel of the current gameplay, but in those I actually did no full wallrun so you could see what I mean. Also I give you my script, it's using triggers to detect walls by the way, from the script you can see that it would obviously not make a curve, so can anyone tell me waht I need to add to make it do a curve? I will probably ahve to remake most of the script right?
#pragma strict
var mainPlayer : GameObject;
var timer : float = 4;
var mainPlayerVars : PlayerMovementScript;
function Start () {
}
function Update ()
{
}
function OnTriggerEnter ()
{
}
function OnTriggerExit ()
{
mainPlayer.rigidbody.useGravity = true;
timer = 4;
}
function OnTriggerStay ()
{
if(Input.GetButton("Jump")){
timer -= Time.deltaTime;
mainPlayer.rigidbody.useGravity = false;}
else{
mainPlayer.rigidbody.useGravity = true;}
if(timer >=3 && Input.GetButton("Jump"))
mainPlayer.rigidbody.transform.Translate(0,0.15*Time.deltaTime,0.3*Time.deltaTime);
if(timer < 3 && Input.GetButton("Jump"))
mainPlayer.rigidbody.useGravity = true;
if(Input.GetButtonUp("Jump")){
mainPlayer.rigidbody.AddRelativeForce(Vector3.right * 8000 * Time.deltaTime);
mainPlayer.rigidbody.AddForce(Vector3.up * 4000 * Time.deltaTime);}
if (mainPlayerVars.grounded)
timer = 4;
}
another thing is that I heard that transform.translate ignores physics, maybe that could be bad for a parkour game, i don't know, tell me what you think. (The character is a rigidbody). thanks in advance, hope you can understand what I want. EDIT: I think it's Mathf.Lerp, but I don't know if I can use Mathf.Lerp with 3 points
Answer by robertbu · Mar 26, 2013 at 03:25 PM
Whether you want to use a rigidbody or not will depend on the needs of your app. One way to get what you want is to simulate gravity. That is, at each frame you decrease the 'Y' component of your translaton Vector3. Character controller scripts have to do this since usually character controllers and Rigidbodies are not mixed. See the use of gravity in this example code for CharacterController.Move(). At the end of the movement, when the character meets he wall, the 'X' and 'Z' movement is halted, but the simulated gravity continues until the character is again grounded.
Your answer
![](https://koobas.hobune.stream/wayback/20220613095123im_/https://answers.unity.com/themes/thub/images/avi.jpg)