Issue when i set position of other entity then position is not change


var Trigger = pc.createScript('trigger');

// initialize code called once per entity
Trigger.prototype.initialize = function() {
     this.entity.collision.on('triggerenter', this.onTriggerEnter, this);

  var p=this.Newobject.getPosition();  
    // this.Game2.enabled=true;  
  //  this.Game2.setPosition(p.x,p.y,p.z);  
  // // // console.log(event.Game2.position);  

Hi @HasnainX,

Is your this.Game2 an entity with a dynamic rigidbody component? If that’s the case you can change it’s position only by using the teleport() method on that component. Since this object is fully controlled by physics:

this.Game2.rigidbody.teleport(p.x, p.y, p.z);
1 Like

No Game2 is other entity i want to add position of newobject in Game2 when my object collides then trigger function will be called.

Can you share your project url to take a look? Not sure what’s wrong here.

I want to add other patch when they collide the end box

Hi @HasnainX, any chance you share your editor url or at least screen grabs of you set up these entities?

1 Like

Right now, setPosition() on Game2 entity won’t work because, this entity has children with static rigidbody. You can move a rigidbody component by using teleport() method. So you need to go and teleport each child entity that has a rigidbody component.

One way you can achieve what you want more easily with a trick, is to have your second level aligned with the first, have it disabled on initialize and when the time comes (on collision) just enable it by using this.entity.enabled = true . While the entity is disabled it isn’t part of the physics simulation, so you can use the regular setPosition() method.

1 Like