AR. Is posible physics between two markers?


#1

Two entities of two markers can to have physics?


#2

Well, the problem is that, with PlayCanvasAR, the camera always remains static (at the world space origin) and the markers are positioned relative to the camera. So it’s hard to be sure what you should set for a gravity vector.

However, if you are confident that your marker will be placed on a horizontal, flat surface, you can assume that gravity should be set to:

var gravity = markerEntity.up.clone().scale(-1);

But, yes, it should be possible to use physics in conjunction with AR markers.


#3

I have been trying to move an entity in an AR project with the rigidbody.applyForce() function to no success. I am getting errors when using the function in the project. I am using the demo AR Playcanvas project.

I have applied collisions and dynamic rigidbody to the entity but just get errors when I try to move the entity using physics. Am I missing something?


#4

What errors are you getting? Can you share a link to a scene showing your problem?


#5

Here is the link to the editor https://playcanvas.com/editor/scene/749721.

The error I’m getting is shown below

And here is the line of code that is throwing the error (line 888)

I had actually asked this question in a different post which you can find here

Thanks for the help!


#6

The entity that you have attached the script to doesn’t have a rigidbody hence it’s null/undefined.


#7

I have attached rigid body and collision to the orange cube.


#8

But not on the Matrix Marker which is where the error is coming from:


#9

Okay I fixed that previous error but the object is not being affected by any force that I apply to it.