Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAF Shooter - bullets only show for others #213

Closed
craftecode opened this issue Jun 14, 2020 · 3 comments
Closed

NAF Shooter - bullets only show for others #213

craftecode opened this issue Jun 14, 2020 · 3 comments

Comments

@craftecode
Copy link

Hi there, in NAF Shooter it seems that the user who instantiates the bullets doesn't see them, only others participants do.

@kylebakerio
Copy link
Member

Sounds like 'attachTemplateToLocal' may be set to false for the bullets. Try setting that to true if it isn't already?

@vincentfretin
Copy link
Member

There is definitely an issue in the shooter.html example, but I don't know what yet. In js/gun.component.js createBullet is using el.setAttribute('networked', 'template:' + this.data.bulletTemplate); so defaulting to attachTemplateToLocal:true normally.

@vincentfretin
Copy link
Member

The user that created the bullet creates this:

<a-entity networked="" forward="" position="" rotation="" id="naf-46k69y7" class="bullet" scale="" color="#fff"></a-entity>

so not a-sphere so missing the material and geometry components, so not visible.
This is because in createBullet we do document.createElement('a-entity') and not document.createElement('a-sphere')

The other participants create element like this:

<a-sphere class="bullet" scale="0.1 0.1 0.1" color="#fff" networked="" material="" geometry="" id="naf-46k69y7"></a-sphere>

If now I change the template from

<template id="bullet-template">
  <a-sphere class="bullet"
    scale="0.1 0.1 0.1"
    color="#fff"
  ></a-sphere>
</template>

to:

<template id="bullet-template">
  <a-entity>
    <a-sphere class="bullet"
      scale="0.1 0.1 0.1"
      color="#fff"
    ></a-sphere>
  </a-entity>
</template>

The user that creates the bullet creates this:

<a-entity networked="" forward="" position="" rotation="" id="naf-42fa2om">
  <a-sphere class="bullet" scale="0.1 0.1 0.1" color="#fff" material="" geometry=""></a-sphere>
</a-entity>

The other participants create this:

<a-entity networked="" id="naf-42fa2om">
  <a-sphere class="bullet" scale="0.1 0.1 0.1" color="#fff" material="" geometry=""></a-sphere>
 </a-entity>

All good. I fixed it in d6ef569

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants