Home || Previous || Next

Best way to jump – applying force to a rigid body (attache to character) rather than moving the character up. Engine Physics works better than faking it with animation.

 

Limit jump by limit hight – if difference between start and up, go down.

Should be attached to state machine:

Screen Shot 2015-10-22 at 10.13.37

 

//Under class

public Rigidbody rBody;

//Under void Start

rBody = GetComponent<RigidBody>();

//Under void Update

if(Input.GetKey(“space”)){
rBody.AddForce(Vector3.up * 500);
rBody.freezeRotation = true;

Lurping:

Transition between different points. Moving between points on line, which reflects a curve.

Additional extra’s if the camera isn’t behaving.

 

Editing the Diablo cam:

Screen Shot 2015-10-22 at 10.24.25

What is the distance from the player, then find where the player is – what is the distance we want to stay away from them. Transform to that updated position.

Add another Vector 3 Lurp function (adds a number of points of a distance in time)

Lurp Variable = Lurp function (addition of extra points) are where we are and where we want to be – in time.

Update Position = use lure version over the ‘desired’ version.

Have to make sure the alignment is right so we add a LookAt function.Screen Shot 2015-10-22 at 10.23.12

Re-aligns the camera as we want it.

Zooms out if your moving, zooming in if you don’t.

using UnityEngine;
using System.Collections;

public class Diablo : MonoBehaviour {

public GameObject player;
Vector3 diff;

// Use this for initialization
void Start () {

player = GameObject.Find(“Player”);
diff = transform.position – player.transform.position;

}

// Update is called once per frame
void LateUpdate () {

Vector3 updatedPosition = player.transform.position + diff;
Vector3 lerpPosition = Vector3.Lerp(transform.position, updatedPosition, Time.deltaTime);
transform.position = lerpPosition;

transform.LookAt(player.transform.position);

}
}

Rules for Lurp: where you are – where you want to be – time.

Original Code:

Screen Shot 2015-10-22 at 10.36.48

Using Lurp with different camera type:

Screen Shot 2015-10-22 at 10.38.55

using UnityEngine;
using System.Collections;

public class RE4 : MonoBehaviour {
public GameObject player;
Vector3 diff;

// Use this for initialization
void Start () {

player = GameObject.Find(“Player”);
diff = player.transform.position – transform.position;

}

// Update is called once per frame
void LateUpdate () {

float currentAngle = transform.eulerAngles.y;
float editAngle = player.transform.eulerAngles.y;

float lerpAngle = Mathf.lerpAngle(currentAngle, editAngle, 1);

Quaternion rotation = Quaternion.Euler(0, lurpAngle, 0);
transform.position = player.transform.position – (rotation * diff);
transform.LookAt(player.transform);

}
}

 

Home || Previous || Next

Advertisements