Spaceship movement

Hi,
I am trying to make a spaceship go forward, turn 45 degrees even out, go up more, and come back and land. And repeat. Anyone have any ideas, I am not sure that translate local and rotate local will work for the smoothness

@Codeknight999 I have done something similar here>

https://playcanvas.com/project/924146/overview/t2space

If you go into the room on the left thru the doors you will find a sentry bot walking a pattern on the floor. This was done in code by taking each waypoint and processing each one by one. The waypoints are simply by creating the points and saving them under the processing entity. My points were all surface points but you can also give them height as well so you can make a path in the sky all the way to the ground.

image

You keep surprising me, @Tirk182, also thanks, this should work.

1 Like

It works, kind of, the space ship rotates at certain points and goes through the wall, here is my project, the scene is citykeys PlayCanvas 3D HTML5 Game Engine

@Codeknight999 I can see that that could happen. So the points do not take into account the size of the item on the path. So you will have to position the points so they take into account the size of the item you are moving. Another thing you can have a look at is this section of code.

    var curveMode = pc.CURVE_LINEAR;

    // Create curves for position
    this.px = new pc.Curve();
    this.px.type = curveMode;

    this.py = new pc.Curve();
    this.py.type = curveMode;

    this.pz = new pc.Curve();
    this.pz.type = curveMode;

It’s been a while since I have used this script however, I think that rather than moving is a square pattern this code creates a curved path from point to point. You should experiment with it a bit to see what fits your application better.

I actually loaded the game and ran it. I am not finding where you are moving the ship.

Thanks for that info, to find the ship you have to look around, find the danger sign, go in that direction and look around again, then you will see it, in the editor if you search plant carrier you can see where I applied the code

Also this code is like nothing I have seen before.