[Solved] Getting started tutorial


#1

Hi.

I’m new to Xenko and trying to get started. I have everything setup and running and I was wondering if is there any getting started guide anywhere that would walk me through the very basics at least from creating an empty project, add a 2D mesh or sprite and add a script to move the mesh or sprite on any axis.

I am reading the docs and looking at the templates but I was unable to figure out the workflow so far. I know that much we are working with components and events but I could not figure out yet how to use them together to make anything work in Xenko.

If there is no tutorial, could anyone give us a kick start and explain only that how can we move anything on any axis with keyboard input in Xenko? It should be not that difficult but I could not figure out so far. :expressionless:

Thank you in advance.


#2

Actually. it was pretty straight forward. What was confusing me is that all the templates are using event listeners and broadcaster pretty extensively even for inputs but the fact is, we don’t actually need to use them we can use components just like in any other component based engines.

Maybe it is not practical but the solution to my question is:

  1. Create an empty project, we have a sphere in the scene by default.

  2. Create a new “Sync Script” to also have the Update method in the script out of the box

  3. Select the sphere and drag and drop the script to the properties panel of the sphere or click “Add component” and select the script from the list we just created.

  4. Open the script which is basically our component attached to the sphere
    First, prepare two private properties to store a reference to the object the script is attached to and the transform component just before the Start method.

    private Entity thisEntity;
    private TransformComponent trComponent;

5.Inside the Start method, let pick the object our script is attached to and it transform component.

 thisEntity = this.Entity;
 trComponent = thisEntity.Components.Get<TransformComponent>();
  1. Inside the Update method, check if the A keyboard key is down and then update the position of the object on the X axis

      if (Input.Keyboard.IsKeyDown(Keys.A))
      {
          trComponent.Position.X += 0.1f;
      }
    
  2. For this example, remove the CameraController component from the Camera to make sure it doesn’t move.

  3. Save it, go back to the editor, reload the project and press run.

When you press the A key on your keyboard the sphere should move.