Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
How to turn off collision dynamically?

creaturefreak
Registered User
Quote
2019-12-23 08:52:24

Is there a code snippet to turn off collision on an object dynamically while in game?
was thinking something like this?

ccbSetSceneNodeProperty(Node, 'Collision', false);


nrasool
Registered User
Quote
2019-12-27 21:20:10

Hey CF

Looking at https://www.ambiera.com/forum.php?t=2916 it seems there is no way of achieving this. Niko mentioned to use ccbSetSceneNodePositionWithoutCollision

ccbSetSceneNodePositionWithoutCollision(sceneNode, x, y, z)

Sets a new position of a scene node, even if the scene node has a 'collide with walls' behavior attached to it. So it it possible to move such a scene node through walls. Note that you have to ensure that the new position of the scene node is not inside a wall, otherwise the node will be stuck.

Examples:

var s = ccbGetSceneNodeFromName("cubeMesh1");
ccbSetSceneNodePositionWithoutCollision(s, -22.097015, 9.848448, -40.738777);
Makes a scene node change its position, independent of its collision behavior.



just_in_case
Moderator
Quote
2019-12-28 11:57:59

No, you can't do this currently but you can delete the collision
object and move the collsion object somewhere else which can be a workaround.

for that you can use the inbuilt action delete a scene node or just move the node somewhere else and then use this command

ccbUpdatePhysicsGeometry() on every few seconds. this might help in most cases but if you simply want to disable the collision then no you can't do this another workaround is create 2 instances of your object one with collsiion adn another without collision and when you want to disable collision of a scenenode simply move the colliding object to somewhere else or delete it then only the noncolliding object will be there and no collision will occur. or maybe changing faces of the object might help as shows in the post mentioned by nrasool above all you need is use the ccbUpdatePhysicsGeometry() command otherwise it won't work.


creaturefreak
Registered User
Quote
2019-12-29 12:28:23

Thank you nrasool and just_in_case!

I will look into those options as soon as I can, I was looking for an easy way to turn it off but those options are fine.

Thanks again for the reply!

CF


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (you are not logged in)


Text:

 

  

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


   






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