ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Help with CopperCube
forum topic indicator Custom Collision Behavior! Help Needed!
person icon
archangel
Registered User
Quote
2025-04-02 20:07:23

So, I have been working on a custom collision behavior but i cant seem to get it to work. If any one has any insight on what i maybe doing wrong or if this just wont work at all, please share! Thank you, beforehand!

person icon
archangel
Registered User
Quote
2025-04-02 20:08:00

/*  
<behavior jsname="action_collision_detection" description="Detects collision between two scene nodes ignites action">
<property name="SceneNode1" type="scenenode" description="Select first scene node" />
<property name="SceneNode2" type="scenenode" description="Select second scene node" />
<property name="CollisionAction" type="action" description="Action on collision" />
</behavior>
*/

action_collision_detection = function() {
this.SceneNode1 = null;
this.SceneNode2 = null;
this.CollisionAction = null;
};

action_collision_detection.prototype.onAnimate = function(currentNode, timeMs) {
if (!this.SceneNode1 || !this.SceneNode2) return false;

// Get transformed bounding boxes
let box1 = this.getBoundingBox(this.SceneNode1);
let box2 = this.getBoundingBox(this.SceneNode2);

if (this.isColliding(box1, box2)) {
console.log("Collision Detected!");
if (this.CollisionAction) {
ccbInvokeAction(this.CollisionAction); // Invoke action
}
}

return true;
};


action_collision_detection.prototype.getBoundingBox = function(node) {
let box = node.getTransformedBoundingBox();

return {
minX: box.MinEdge.X,
minY: box.MinEdge.Y,
minZ: box.MinEdge.Z,
maxX: box.MaxEdge.X,
maxY: box.MaxEdge.Y,
maxZ: box.MaxEdge.Z
};
};


action_collision_detection.prototype.isColliding = function(box1, box2) {
return (
box1.minX <= box2.maxX && box1.maxX >= box2.minX &&
box1.minY <= box2.maxY && box1.maxY >= box2.minY &&
box1.minZ <= box2.maxZ && box1.maxZ >= box2.minZ
);
};


person icon
swordmaster
Guest
Quote
2025-04-02 23:33:23

Archangel the colision in coppercube can be complicated thing; In coppercube for webgl exportation the physics engine is the most basic but functional, the box2d physics (maybe you extension is not accessing the functions of box2d or not accessing well box2d functions).
In the itchio from robo, there is packed of extensions for coppercube one of these extensions is one colision behavior, try to give one look.
In coppercube for make colision work for somethings is necessary add the extension colission in one object to apply colission proprieties (but the results can be diferents from box2d and physics simulation, physics simulations is bullet physics, and will only work for desktop exportation)
The okeoke once in forum worked and showed one integration from coppercube with another physics engine, (I thought was cannon js, i don t have certain but I know is one physics engines can be used in web exportation)

person icon
swordmaster
Guest
Quote
2025-04-02 23:34:19

For webgl projects the physics engines more used is box2d, cannon js, ammo js, havok now is can be used in babylon, jolt is being be used with three js in gdevelop game engine; maybe you will make one integration with another pyshics engine to do what you want.
I coppercube normally the people use the action shot to apply some collison effects, especially raycasting in action shot. Another alternative is use sensor and variables to simulate collison system action.
I hope some of this information can help you
thanks the attention


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 |