Skip to content

Instantly share code, notes, and snippets.

@iggyvolz
Created September 12, 2018 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iggyvolz/a9d390e2bd8d440ed0a56895a7305bda to your computer and use it in GitHub Desktop.
Save iggyvolz/a9d390e2bd8d440ed0a56895a7305bda to your computer and use it in GitHub Desktop.
namespace CryEngine.Game
{
[EntityComponent(Guid="8edf52be-45b8-d8f1-0cd5-e784c1abacd2")]
public class PlayerController : EntityComponent
{
/// <summary>
/// Called at the start of the game.
/// </summary>
protected override void OnGameplayStart()
{
}
/// <summary>
/// Called once every frame when the game is running.
/// </summary>
/// <param name="frameTime">The time difference between this and the previous frame.</param>
protected override void OnUpdate(float frameTime)
{
base.OnUpdate(frameTime);
Vector3 pos = Entity.Position;
Log.Always("Old position: " + Entity.Position.ToString());
if (Input.KeyDown(KeyId.Up))
{
Log.Always("Up key");
pos += new Vector3(1, 0, 0);
}
else if(Input.KeyDown(KeyId.Down))
{
Log.Always("Down key");
pos -= new Vector3(1, 0, 0);
}
Entity.Position = pos;
Log.Always("New position: " + Entity.Position.ToString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment