Make camera follow object

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

I need the cube to make a ground effect like splash or something. I need the cube to move smoothly

Yes, I think it should be all capital letters.

If you study the code you could figure this out yourself.

Ok, moves at a good speed. But the box moves right through the obstacle, I need it to hit it and stop and reset scene.

In your case you can add a kinematic rigidbody component and a collision component that you need to give a matching shape and size. Then you need to write the code to detect the collision. On the page below you can find more information about this.

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

Is the collision and rigidbody on the box or…

On all entities.

ok

I added it to them but it didn’t work.

Screenshot 2023-03-20 6.40.32 PM

Screenshot 2023-03-20 6.40.23 PM

What about this?

I am kinda confused about this, I don’t know what to put. Can you help me out on which ones to choose. The obstacles will be solid and will have a little bit of physics and the box will have to avoid the obstacles but when the box touches them, the cube stops and the scene resets. I need help doing this.

You can create a new script with the name collider.js and replace all the code with the code below. Save the script and add the script to the Box entity of your player.

var Collider = pc.createScript('collider');

// initialize code called once per entity
Collider.prototype.initialize = function () {
    this.entity.collision.on('collisionstart', this.onCollisionStart, this);
};

Collider.prototype.onCollisionStart = function (result) {
    if (result.other.tags.has('obstacle')) {
        this.entity.setPosition(0, this.entity.getPosition(), 0);
    }
};

You need to give all your obstacles an obstacle tag, like below.

image

Let me know if it works.

Do I delete this ammo script? I think I added it on accident

No it’s necessary for physics of the project.

Ok, it still won’t work. What should the rigidbody and the collision components be for the obstacle and the cube? I am confused. After this, I need help with Make cube fall off when not on a plane and after 5secs of falling it resets the scene if you can. I really hope I can get this game going since this idea was originally made for Unreal Engine.

The rigidbodies can be kinematic (or static if they don’t move). Maybe you can share what you have so far?

You can create an obstable at the end of the plane. If you want to make the player fall down from the plane, you need to use a dynamic rigidbody. Be aware that in that case you can’t use my example scripts anymore, bacause movement of a dynamic rigidbody is different.