Unity Experiments: FPC Character Controller 03:03

Unity has a Character Controller Function which can make creating a FPC quite simple (I wanted to code a FPC first so that I could begin to understand what is going on ‘under the hood’).

Tutorial: https://youtu.be/n-KX8AeGK7E

I will now implement both FPC’s in my basic white box modelled environments so that I can begin to get a feel for how the player might experience the game. 
If I add some simple interactions (including some isolated object movement) I will be able to experiment with the game play.
I can then go on the further create environments based on natural formations as previously identified. This will lead the way for further ‘wayfinding’ experiments.

Unity Experiments: FPC Character Controller 03:03

Unity has a Character Controller Function which can make creating a FPC quite simple (I wanted to code a FPC first so that I could begin to understand what is going on ‘under the hood’).

Tutorial: https://youtu.be/n-KX8AeGK7E

I will now implement both FPC’s in my basic white box modelled environments so that I can begin to get a feel for how the player might experience the game. 
If I add some simple interactions (including some isolated object movement) I will be able to experiment with the game play.
I can then go on the further create environments based on natural formations as previously identified. This will lead the way for further ‘wayfinding’ experiments.

Unity Experiments: FPC Coded Scripts 03:02

Starting from where I left off in the Wheels project, I have researched how to create a First Person Controller with code and also using a character controller.

First Person Controller Code 
(From Tutorial) 


Controller Body Script

Using System.collections; 
Using System.collections.Generic; 
Using UnityEngine; 

Public class PlayerMovementController:MonoBehaviour 
{
[SerializeField] private float speed;
[SerializeField] private float jumpForce;
[SerializeField] private float raycastDistance;
private Rigidbody rb;

private void start()
{
rb = GetComponent<Rigidbody>();
}

private void Update ()
{
Jump();
}

private void FixedUpdate()
}

Move()
}

private void Move()
{

float hAxis = Input.GetAxisRaw(“Horizontal”);
float hAxis = Input.GetAxisRaw(“Vertical”);

Vector3 movement = new Vector3 (hAxis,0,vAxis) * speed;

Vector3 newPosition = rb.position + rb.transform.TransformDirection(movement);

rb.MovePosition (newPosition);
}

private void Jump()
{

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

if (Isgrounded()
{

rb.AddForce(0,JumpForce,0,ForceMode.Impulse);
}
}

private bool IsGrounded()
{
Debug.DrawRay(transform.position,Vector3.down * raycastDistance, Color.blue);

return(Physics.Raycast(transform.position,Vector3.down.raycastDistance)
}




Player Camera Controller Script

Using System.collections; 
Using System.collections.Generic; 
Using UnityEngine; 

public class PlayerCameraController:MonoBehaviour
{
[SerializeField] private float lookSensitivity;
[SerializeField] private float Smoothing;

private GameObject player;
private Vector2 smoothedVelocity;
private Vector2 currentLookingPos;
void Start ()
}

player = transform.parent.gameObject;
Cursor.LockState = CursorLockMode.Locked;
Cursor.visible = false;

private Void Update()
{
RotateCamera();
CheckForShooting();
}

private void RotateCamera()
{
Vector2 inputValues = new Vector2(Input.GetAxisRaw(“Mouse x”), (this is all on one line) Input.GetAxisRaw(“Mouse Y”));

inputValues = Vector2.scale(inputValues,new Vector2 (lookSensitivity * smoothing,lookSensitivity * smoothing )); 

smoothedVelocity.x = maths.Lerp (smoothedVelocity.y,inputValues.y, 1f / smoothing);

currentLookingPos += smoothedVelocity;

transform.localRotation = Quatenum.AngleAxis(-currentLookingPos.Vector3.right);
player.transform.localRotation = Quaternion.AngleAxis (currentLookingPos.x, player.transform.up);
}

private CheckForShooting()
}
if (Input.GetMouseButtonDown (0))
{
RaycastHit whatIHit;
if (Physics.Raycast(transform.position,transform.forward,out whatIHit, Mathf.Infinity))
{
Debug.Log (whatIHit.collider.name);
}
}
}
}







Unity Experiments: FPC Coded Scripts 03:02

Starting from where I left off in the Wheels project, I have researched how to create a First Person Controller with code and also using a character controller.

First Person Controller Code 
(From Tutorial) 


Controller Body Script

Using System.collections; 
Using System.collections.Generic; 
Using UnityEngine; 

Public class PlayerMovementController:MonoBehaviour 
{
[SerializeField] private float speed;
[SerializeField] private float jumpForce;
[SerializeField] private float raycastDistance;
private Rigidbody rb;

private void start()
{
rb = GetComponent<Rigidbody>();
}

private void Update ()
{
Jump();
}

private void FixedUpdate()
}

Move()
}

private void Move()
{

float hAxis = Input.GetAxisRaw(“Horizontal”);
float hAxis = Input.GetAxisRaw(“Vertical”);

Vector3 movement = new Vector3 (hAxis,0,vAxis) * speed;

Vector3 newPosition = rb.position + rb.transform.TransformDirection(movement);

rb.MovePosition (newPosition);
}

private void Jump()
{

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

if (Isgrounded()
{

rb.AddForce(0,JumpForce,0,ForceMode.Impulse);
}
}

private bool IsGrounded()
{
Debug.DrawRay(transform.position,Vector3.down * raycastDistance, Color.blue);

return(Physics.Raycast(transform.position,Vector3.down.raycastDistance)
}




Player Camera Controller Script

Using System.collections; 
Using System.collections.Generic; 
Using UnityEngine; 

public class PlayerCameraController:MonoBehaviour
{
[SerializeField] private float lookSensitivity;
[SerializeField] private float Smoothing;

private GameObject player;
private Vector2 smoothedVelocity;
private Vector2 currentLookingPos;
void Start ()
}

player = transform.parent.gameObject;
Cursor.LockState = CursorLockMode.Locked;
Cursor.visible = false;

private Void Update()
{
RotateCamera();
CheckForShooting();
}

private void RotateCamera()
{
Vector2 inputValues = new Vector2(Input.GetAxisRaw(“Mouse x”), (this is all on one line) Input.GetAxisRaw(“Mouse Y”));

inputValues = Vector2.scale(inputValues,new Vector2 (lookSensitivity * smoothing,lookSensitivity * smoothing )); 

smoothedVelocity.x = maths.Lerp (smoothedVelocity.y,inputValues.y, 1f / smoothing);

currentLookingPos += smoothedVelocity;

transform.localRotation = Quatenum.AngleAxis(-currentLookingPos.Vector3.right);
player.transform.localRotation = Quaternion.AngleAxis (currentLookingPos.x, player.transform.up);
}

private CheckForShooting()
}
if (Input.GetMouseButtonDown (0))
{
RaycastHit whatIHit;
if (Physics.Raycast(transform.position,transform.forward,out whatIHit, Mathf.Infinity))
{
Debug.Log (whatIHit.collider.name);
}
}
}
}







Unity Experiments: Form 03:01

I am interested in how newtonian physical force influence growth formation in the natural physical world and so I have been scouring texts for useful models which I could recreate in unity.

I have identified a number of forms that examine various formation processes.

References 

BREIDBACH, O. And EIBESFELDT, et al. 1998 Art Forms from the Ocean Ernst Haeckel London, Prestel Publishing. 

BREIDBACH, O. 2005 Art forms in Nature Earnst Haeckel  London, Prestel Publishing. 

STEVENS, P. S. 1974 Patterns in Nature London, Peregrine. 

THOMPSON, D, W. 2005. On Growth and Form Thompson, Cambridge Press

(I am considering if this mentally anchors digital artefacts in the players mind when navigating a virtual world)

This is how I am going to approach learning Unity’s modelling, interaction and navigation functions quickly using ProBuilder and simple code.

  1. Set up a Unity file using Unity 2019. 2.7f2 
  2. Install Probuilder 4.0.5 and construct simple white box model environments based on natural formations. 
  3. Script simple object interaction. 
  4. Script a first person controller.   

Probuilder Experiments

https://unity3d.com/unity/features/worldbuilding/probuilder

 Probuilder Standard Primitives

Leads to the construction of a simple platform Game Environment 

 2D Platform Experiments
Glitch
 

 

Platform design after natural surface pattern formations 

Other forms that could be explored include the following formations (I will complete these over the next week or so but I am really focused on testing interaction at this point) … 
  • Branching
  • Meander 
  • Explosion 
  • Bubble 
  • Packing 
  • Cracking 
  • Fractal  (algorithmic plug – in)    
  • Stochastic (Cloud and other phenomena)
 

Unity Experiments: Form 03:01

I am interested in how newtonian physical force influence growth formation in the natural physical world and so I have been scouring texts for useful models which I could recreate in unity.

I have identified a number of forms that examine various formation processes.

References 

BREIDBACH, O. And EIBESFELDT, et al. 1998 Art Forms from the Ocean Ernst Haeckel London, Prestel Publishing. 

BREIDBACH, O. 2005 Art forms in Nature Earnst Haeckel  London, Prestel Publishing. 

STEVENS, P. S. 1974 Patterns in Nature London, Peregrine. 

THOMPSON, D, W. 2005. On Growth and Form Thompson, Cambridge Press

(I am considering if this mentally anchors digital artefacts in the players mind when navigating a virtual world)

This is how I am going to approach learning Unity’s modelling, interaction and navigation functions quickly using ProBuilder and simple code.

  1. Set up a Unity file using Unity 2019. 2.7f2 
  2. Install Probuilder 4.0.5 and construct simple white box model environments based on natural formations. 
  3. Script simple object interaction. 
  4. Script a first person controller.   

Probuilder Experiments

https://unity3d.com/unity/features/worldbuilding/probuilder

 Probuilder Standard Primitives

Leads to the construction of a simple platform Game Environment 

 2D Platform Experiments
Glitch
 

 

Platform design after natural surface pattern formations 

Other forms that could be explored include the following formations (I will complete these over the next week or so but I am really focused on testing interaction at this point) … 
  • Branching
  • Meander 
  • Explosion 
  • Bubble 
  • Packing 
  • Cracking 
  • Fractal  (algorithmic plug – in)    
  • Stochastic (Cloud and other phenomena)