Error in reading ‘teleport’

Hi I am a beginner and is currently making a 3D FPS game. I’m having problems on the weapon and bullet, it always sends an error prompt and it doesnt work despite the code coming from my professor and also cross-checked my other classmates’s works and theirs have worked. I have tried everything for hours but I can’t fix it.

the BulletInstance.rigidbody.teleport(BulletPosition);
is the one always erroring.

I an trying to get the sphere to be the bullet on the icing bag.

Here is the link to my editor, please help me fix this.
PlayCanvas | HTML5 Game Engine

Hi @hhj325 and welcome!

You’re getting the error because your bullet instance doesn’t have a rigidbody component.

It probably also need a collision component to work properly.

hello! thank you for answering!

I don’t really know how that works or how to do that, how can I put the rigid body and collision to the said bullet instance?

It looks like you have a template asset for your bullet. You would do something like this:

  • drag the template into the Hierarchy panel
  • select the entity in the template with the bullet render component
  • add rigidbody and collision components to the same entity (and configure the properties correctly)
  • apply the template overrides in the Inspector
  • delete the template from your Hierarchy

(Note that you have to do the above because there’s no dedicated template editor in the Editor…so you have to edit your template assets via the Hierarchy panel and Inspector)

1 Like