0 votes

I'm creating an endless runner. The player can move in a certain range that is determined by an invisible box. Both the player and the box are KinematicBodies. Here is how it looks in the example scene:

Scene Structure

The blue box is the player, the collision box before that belongs to the "Box" node. In this example, the box is constantly moving forward and the player is moving backwards (towards the box's CollisionShape):


The problem is that, if after a while I increase the speed of the box, the distance between the player and the box changes.

Low speed of the box:
Output 1

High speed of the box:
Output 2

Any guesses how to fix that?

asked Apr 2 in Engine by bastilo (49 points)

1 Answer

0 votes

In order to let camera follow player, you can simply just attach Camera to it.

Here's how your hierarchy should looks like:

  • Bug

    • Player

      • CollisionShape
      • MeshInstance
      • Camera
    • Timer

And physicsprocess should be:

func _physics_process(delta)
    $Player.move_and_collide(Vector3(0.0, 0.0, 1.0) * delta)
answered Apr 2 by imjp94 (142 points)

Problem is that I want the player to move forwards and backwards, even sideways without the camera following. Imagine an endless runner but you can move within a certain area.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.