Make camera follow object

I am new to PlayCanvas and need help making a camera follow an object and I need help making text and making an object stop when in collision with another. I need some visuals for this

Hi @Luminity and welcome!

Maybe one of the tutorial projects below can help you.

https://developer.playcanvas.com/en/tutorials/first-person-movement/

https://developer.playcanvas.com/en/tutorials/third-person-controller/

@Albertos This would be helpful, but to me it seems a little advanced since i’m new to this editor. Can you see if you can help me with the other things?

Luminity

What are you going to make?

That’s correct, but you don’t have to understand everything from start.

https://developer.playcanvas.com/en/user-manual/packs/components/element/

https://developer.playcanvas.com/en/user-manual/user-interface/text-elements/

https://developer.playcanvas.com/en/tutorials/collision-and-triggers/

I am making a game where you are a cube trying to not touch the obstacles and there is three levels with some other screens/scenes main menu, win screen, game screen, pause screen. If you fall off, you respawn like normal. If you get to a certain spot of the scene/level, you spawn on the next level/scene

Allright, in that case you can just make the camera entity a child of the box entity. You can do this in the hierarchy (left side of the editor), by dragging the camera entity into the box entity. Make sure the box is in front of the camera by changing the position and rotation of the camera entity.

Ok, I will give some screenshots to make sure it’s correct

Ok, here is some screenshots

Is this correct
Screenshot 2023-03-19 12.48.09 AM

How to make the camera straight?

Yes, that’s correct.

When you select the camera entity, you can change the position and rotation on the right side of the screen.

1 Like

Ok, I want to add movement to this block and I want the camera right in front of the cube a little bit up. I was messing with the rotation and it doesn’t fix anything.

You can first reset the values to 0 and then move the camera backwards a bit.

I moved it where I want I will give a screenshot of the screen

@Albertos Ok, here it is. I am trying getting this part done so it will be quick and I can get the other levels done with no problem. I was thinking of this in Unreal Engine and stuff but I had some issues so I started this. Unreal Engine was much easier but I moved to GDevelop for 2D and found this and I think I am gonna love it.

Edit: forgot to put screenshot

In the top left corner you can see the actual view in the game. In the top right corner you can change the values to get the desired view.

image

I know that, I can’t seem to make it do it. Let me try again

Ok, I kind of got it! I need it moved at a crooked like view.
Picture the user viewing it on the right side and the camera is pointed behind it, it needs to be at a view to see the top and back faces of the cube/block. I will give you a hand example. lol

Ok, the quality is terrible but you can see how my hand is pointed to the cube. If you can give my the xyz rotations as an example to change later through out the build.

@Albertos How to change color of this CUBE and I need to know how to make a main menu with a plain white screen with the buttons. I need the cube to move repeatedly with left and right controls to make it go left and right. I need to add an invisible object to add somewhere on the plane and when the cube passes that spot, it goes to the next level. I want the player to click space to make the cube start moving repeatedly forwards so the cube doesn’t go when the level starts.

Like this?

A bit old, but I think the video below can help you with this.

Create a new script with the name movement.js. Replace all code with the code below and save the script. Add the script to your Box entity.

var Movement = pc.createScript('movement');

// initialize code called once per entity
Movement.prototype.initialize = function() {

};

// update code called every frame
Movement.prototype.update = function(dt) {
    // Move forward
    this.entity.translateLocal(0, 0, -0.1);

    // Move left with A key
    if (this.app.keyboard.isPressed(pc.KEY_A)) {
        this.entity.translateLocal(-0.1, 0, 0);
    }

    // Move right with D key
    if (this.app.keyboard.isPressed(pc.KEY_D)) {
        this.entity.translateLocal(0.1, 0, 0);
    }
};

First things first and please keep every question or problem in it’s own topic.

I just didn’t want to make too many, just wanted it together. I have made the camera rotated the way I wanted it to be. With the code, can I just change the keys to the arrow keys with key_left and Key_right. How to make cube faster