Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperCube > Programming and Scripting
Is there any good way to create custom collision?
Author Text

dekon_17
Registered User
Quote
2022-07-22 17:58:35

Yes, I know that there is a built-in collision that allows you to make a simple collision in CopperCube. However, this doesn't really suits me. The thing is, that this collision model is round. So, this allows me to crawl on tables and other props when I don't really need this. For the last few days I was trying to make my own collision, but doing this with ccbGetCollisionPointOfWorldWithLine command is a bit... Terrible, to say the least. I mean, I don't really need so complicated collision check, since my levels doesn't have a very complicated geometry (or at least for now). So... Is there any other way to make a custom collision?


okeoke
Registered User
Quote
2022-07-22 19:04:57

Hi,
If you're targeting windows or mac you might try enabling physics engine - it support different types of collision shapes: https://www.ambiera.com/coppercube/doc/cnt_physics.html. But this could be only applied to object which are not controlled by player or AI. Probably, it will do for the table, but your player node will still have to use a shpere collider from "collide than moved behavior". I think this actually might work for you.
Also you don't need the raytracing for detecting collision - you generaly need sizes and positions. You can find more formulas on how to calculate different types of collisions here: https://plutiedev.com/basic-collision.
But, downside is that detect collision is only a part of a job - you need to handle it. And with that you will most likely have to rewrite the gravity and slopes logic.
If nothing works just create a cube, add a black (0,0,0) material toi it and pick material type "transparent add", so it's completely transparent. Put it around your table - now you have a box collider there.


dekon_17
Registered User
Quote
2022-07-22 19:49:08

Well... Here's the thing about most of these methods:
Physics engine isn't suited for player, as you mentioned, which is already a big "No".
The thing about the formulas... Well, I'll need to better understand it first. But now, I don't know if it is useful in my case, considering that most of the levels should have some vertical gameplay. I mean, adding some plane meshes for main collision and turning off collision parameter on the level might work, but this is a bit weird way, as I think. Plus, it will not work (probably) if there is a slope, since the bounding box will represent cubic form.
And about box collider... Well, it isn't practical for FPS games, because it will also block bullets. But if I'll extend my shooting behaviour a bit... It might actually work.
Still, I am really appreciated for your help, okeoke.


VP
Guest
Quote
2022-07-22 21:53:15

Use every few seconds "shoot".
Then, use the same "every few seconds" event to move a node to the "Last bullet position".
On that node, add an "on proximity to player" event to change (hash)playermovement.speed=0


What this does is continually shoot from the player and then continually move a node to the last bullet position. When the player enters proximity of the node, player movement speed is set to "0".

This creates a very simple (and very fast) collision detection system with no need to use "collide when moved".

If you want, I can upload a demo ccb for you, no problem.


okeoke
Registered User
Quote
2022-07-22 22:06:10

Hi VP, it's an interesting approach. Could you please upload a demo? Probably, I didn't understand but it seems to me that you need to look into the direction you walk for this to work, right?


VP
Guest
Quote
2022-07-22 23:53:17

Sure, I'll make a demo ccb and upload it for you (hopefully tomorrow)... Yes, depending which camera you use, either shoot from a 3rd-person object (with/without shoot offset) or shoot from 1st person camera to the camera target - both will work.


dekon_17
Registered User
Quote
2022-07-23 08:56:57

Hm-m... I've also found a bit different way to make collision. Except, it uses built-in collision model.

The thing is, I've added multiple collision spheres (but it might be better to squeeze them a bit, maybe?). And only one of them is affected by gravity - the one on the bottom. This is kinda good, in my opinion, so, I might use this.

🔎︎


I've tried this before, but I wasn't thinking about the problem it had: it glitched so badly. That's because back then I didn't disable affection by gravity on upper ones, which made it hop everywhere.

Still, not the best option, but I am tired of trying to code the collision by myself, so, maybe I will use it for some time.


just_in_case
Moderator
Quote
2022-07-23 09:13:50

I do have a video that tells you the exact same thing that you can use multiple collide when moved behavior, for any scenenode. Also, shooting a bullet is a good way to detect collision, it is actually line picking, but without coding, so you can shoot a line and if it hits you get a collision, both methods are suitable.

here is the link to the video, maybe you can get more help with it.
https://www.youtube.com/watch?v=...


okeoke
Registered User
Quote
2022-07-23 14:15:37

I've tried to use multi-collisions in my sheep racing game. Unfortunately, no matter how I set it up everything starts to bump into there air as soon as a car gets near the sheep.
Probably, there is just no all-purpose solution.


dekon_17
Registered User
Quote
2022-07-23 14:30:49

Yeah, I have some problems with it as well. Too bad that only the physics models have different shapes...

At least, we have some variants to use.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (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© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact