Pass property in collision without a script component / go.property

In my game I have lots of bullets. Likely not reaching the total limit of script instances - yet - and I’m not sure how close I’ll get.

My player ship shoots bullets instantiated by a factory and moved with go.animate.
It collides with enemy ship. Enemy ship handles collision message. Here, I want to deliver x amount of damage to the enemy ship, and I’d like the bullet to carry the damage in its game object.

Is there any way to put this data in the game object without a script component?
And then have the enemy ship read that damage amount off of the bullet at collision message parsing.

Factory instantiation lets me put properties on game object but that requires go.property set up as well.

If you’re not using z you could use it to store a damage value. You could store a bunch of data in z with data packing. Then whatever is being hit could check the z of whatever has impacted it.

1 Like

We do not provide a way to do this. I’d probably store the additional data in a Lua table keyed on game object id.

2 Likes

A variant on @britzl’s suggestion is to check the other_group to see what type of bullet it is. Again, it’s stored in a Lua file (or perhaps in the enemy script properties)

You can go one step further and check the fragment of the sender and identify specific bullets. :slight_smile:

1 Like

Wont the fragment always be empty if I’m not using a component? Using a simple bullet factory, they’d only be /instance45, /instance46 etc?
Maybe I misunderstand your suggestion.

@Mathias_Westerdahl I thought about that too but don’t want to use too many groups (will hit limit, many weapon types!)

A simple table looks like a good solution right now.

As soon as you have a collision object component that will be the fragment.

But I misthought. Each instance will be uniquely identified by the path, not the fragment. If you have an object with several collision objects you can separate them via the fragment though (for instance if you have hit boxes on a character).

2 Likes

That’s awesome though, easy way to make bosses take more dmg if you hit them in the eye!

3 Likes

Yes, exactly!