Character Jump (69347)

we have our character moving about the way we want it to in orthographic camera view.
Here is the coding so far.
any help is greatly appreciated.
:slight_smile:
PS: I am not using character controller that comes with unity and not using rigidbody

private var insideObject:Transform;

// The gravity for the character
var gravity = 20.0;



function Start(){
	insideObject=transform.Find("Capsule");
	
}
function Update () {
	Debug.Log(insideObject.rotation.eulerAngles);
var dwn = transform.TransformDirection (Vector3.down);
	
if (Input.GetKeyDown(KeyCode.UpArrow)) {

var fwd = transform.TransformDirection (Vector3.forward);
        if (Physics.Raycast (transform.position, fwd, 1)) {
            print ("There is something in front of the object!");
        }else{
			var forwardPos:Vector3=transform.position + Vector3.forward;
			if (Physics.Raycast (forwardPos,dwn, 1)) {
				transform.position += Vector3.forward;
			}
			
		}
}

if (Input.GetKeyDown(KeyCode.DownArrow)) {


    
		var bk = transform.TransformDirection (Vector3.back);
        if (Physics.Raycast (transform.position, bk, 1)) {
            print ("There is something in front of the object!");
        }else{
			var backPos:Vector3=transform.position + Vector3.back;
			if (Physics.Raycast (backPos,dwn, 1)) {
				transform.position += Vector3.back;
			}
			
		}
}
if (Input.GetKeyDown(KeyCode.RightArrow)) {


var r = transform.TransformDirection (Vector3.right);
        if (Physics.Raycast (transform.position, r, 1)) {
            print ("There is something in front of the object!");
        }else{
			var targPos:Vector3=transform.position + Vector3.right;
			if (Physics.Raycast (targPos,dwn, 1)) {
				transform.position += Vector3.right;
			}
			
		}
		
	insideObject.rotation.eulerAngles.y=90;
}
if (Input.GetKeyDown(KeyCode.LeftArrow)) {

var l = transform.TransformDirection (Vector3.left);
        if (Physics.Raycast (transform.position, l, 1)) {
            print ("There is something to the left of the object!");
        }else{
			var leftPos:Vector3=transform.position + Vector3.left;
			if (Physics.Raycast (leftPos,dwn, 1)) {
				transform.position += Vector3.left;
			}
			
		}
insideObject.rotation.eulerAngles.y=-90;
}




}

1 Answer

1

Hello there!

…and nice piece of controller. Putting a little more time on the formating next time would be great :slight_smile:


Anyhow, I think that you should check this out:

Unity Answer Character Jump

thanks, but i am not using character controller that comes with unity and am not using rigidbody. thus, i need faux gravity and what not.

–