How can I change position of an entity using a script?

This is the link for the project.

I have written a script in a folder structure like this:
gravity -
physics -
- gravityforobstacle.js

I tried running it but it doesn’t work.

Hi @Rixz and welcome,

The JavaScript variables and properties you are setting in your for loop aren’t used anywhere, so it’s expected they don’t have any impact.

In plain terms to update the position of an entity you do something like this:

this.entity.setPosition(5, 0, -2);

You can follow this tutorial on how to make a game to see how to write gameplay code using PlayCanvas, you will be better suited to do what you are looking for: