# Squash the creeps movement not working

4.2.1

### Question

I’ve followed the tutorial for Squash the Creeps, and I’m aware that it may not be perfectly up-to-date. I wanted to use the C# version of the script, but when I copied the code, it didn’t work. The character did not move. I would appreciate any help on the matter!

Here’s the code:

``````using Godot;

public partial class Player : CharacterBody3D
{
// How fast the player moves in meters per second.
[Export]
public int Speed { get; set; } = 14;
// The downward acceleration when in the air, in meters per second squared.
[Export]
public int FallAcceleration { get; set; } = 75;

private Vector3 _targetVelocity = Vector3.Zero;

public override void _PhysicsProcess(double delta)
{
var direction = Vector3.Zero;

if (Input.IsActionPressed("move_right"))
{
direction.X += 1.0f;
}
if (Input.IsActionPressed("move_left"))
{
direction.X -= 1.0f;
}
if (Input.IsActionPressed("move_back"))
{
direction.Z += 1.0f;
}
if (Input.IsActionPressed("move_forward"))
{
direction.Z -= 1.0f;
}

if (direction != Vector3.Zero)
{
direction = direction.Normalized();
GetNode<Node3D>("Pivot").Basis = Basis.LookingAt(direction);
}

// Ground velocity
_targetVelocity.X = direction.X * Speed;
_targetVelocity.Z = direction.Z * Speed;

// Vertical velocity
if (!IsOnFloor()) // If in the air, fall towards the floor. Literally gravity
{
_targetVelocity.Y -= FallAcceleration * (float)delta;
}

// Moving the character
Velocity = _targetVelocity;
MoveAndSlide();
}
}
``````

You remembered to add the named move_ controls right? What are you seeing when you debug it?

1 Like

I put the controls here:

But only thing that happens is this:

Nothing moves when I click the buttons.

And I found it. The class name was capitalized - it shouldn’t have been.

1 Like