ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Help with CopperCube
forum topic indicator Help with Enemy behavior
person icon
Silveraxe
Guest
Quote
2026-02-25 03:19:00

So I am working on enemy behavior for a game I am prototyping. I wanted to make enemies that chase you as a horde. I used this extension by Hadoken Records and it works pretty well for what I need: https://hadoken-records.itch.io/coppercube-transform-to-target It is a paid asset so I'm unsure if that will help you guys answer my question but hopefully we can find a solution. The issue is when I use the behavior every few seconds with multiple enemies they merge together which is not what I want, I will provide a YouTube vid of the issue here: https://www.youtube.com/watch?v=fXg3w5faZXk, can anyone help me with this?

person icon
Monks
Guest
Quote
2026-02-25 11:21:20

Hello, I believe this will help you more

https://5v3n.itch.io/coppercube-...

person icon
hadoken
Registered User
Quote
2026-02-25 11:58:55

@Silveraxe, @Monks is right you should probably use a more enemy specific tailored extension like @Sven's one or CopperCube's default enemy system adjusted to your needs.

The transform to target extension was created for things like doors, gates, platforms etc. in mind - meaning static objects that once should move, rotate or change sizes triggered at some point in the game. The problem of the usage shown in your video seems to be that multiple enemies transform to the same one target, therefore the merging happens. If you want to use my extension I would advise you to implement different targets (maybe with collision shapes) to prevent any overlapping issues.

person icon
okeoke
Registered User
Quote
2026-02-25 13:09:06

I don't even know there to start on that issue you have.

First of all, what you want in that scenario is to either:
a. dynamically build paths for enemies so the paths do not overlap
b. detect collisions between enemies and resolve them somehow, i.e. push enemies apart from each other

I would not advice using plan a, not because of complexity of implementation or something like that, but because it will be really hard to optimize the code to run for a "horde" of enemies at the same time.

Plan b is more doable, but has own issues though. CopperCube is not particularly good at handling collisions between moving nodes. Basically, you have only type of collision that works from the box without any workaround, it's sphere vs polygonal world collision which you set up by adding "collide than moved behavior". It will not work in your case, because this sphere colliders also do not collide with each other. Only with world.

What could be done, and what I would do is the following: set up a script that will check enemies positions and in case distance between them is less than a certain threshold push them apart in different direction by the total amount of that distance.

It also have some limitations though. Checking every enemy vs every other enemy is not doable from performance view. Even getting position for 100 enemies alone is very cpu demanding, I'm not saying calculating distance (which requires using sqrt which is slow in js). Instead I would check a single enemy every frame.

I've made this: https://drive.google.com/file/d/1MCIA6HPMNhYqSnii2bkp-zW31J3cBUCh/view?usp=drive_link

Not sure if it works, since I'm not able to test it right now, but you should get the idea from the comments to the code. In order for it to work put all your enemy nodes in the same folder and specify that folder as extension property. Second property is the distance at which enemies are considered as colliding.

Also what I would do first before adding any other behaviors actions or whatever to your game - try increasing the amount of enemies closer to what you suppose to have in your game, and make sure the set up you use actually scales performance-wise.

person icon
nilefox
Guest
Quote
2026-02-26 12:41:42

hi, i tried it out but it doesn't seem to work, can you test it?


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |