Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperCube > Help with CopperCube
Collision Detection Tip (non-code)
Author Text

Registered User
2022-09-15 08:22:32

Whilst making my game "Rebel County", I devised a Non-Code Collision Detection System (Using the "Shoot" action). It's a little bit complicated to set up, but it has multiple uses, so maybe people will find it useful. I can make a ccb if anyone wants it:

1: Create 3 "dummy node's" (3 spheres with 0,0,0 dimensions and polygons).
2: Rename dummy-nodes as "Collision_Emitter", "Collision_Bullet", "Collision_Detector".
3: Attach/Child the "Collision_Emitter" to the Player/Character node (Child-Position 0,0,0).
4: Add an "every few seconds" behaviour to the "Collision_Emitter" (every 5ms, Shoot).
5: Use the "Collision_Bullet" node as a bullet and add/check the "Action on impact".
6: Set "Action On impact" to "Change Position to Last Bullet Impact" for "Collision_Detector" node.
7: Add "On Proximity" events to the "Collision_Detector" node (examples: change-animation/play-sound etc).

What this does:
Every 5miliseconds, the Player/Character shoots an invisible node to the front.
Whenever the bullet-node hits any object, the detector-node is placed at that position.
If the Player walks near the detector-node, "collision" is detected.
On collision detection, an action is carried out such as change animation, play sound etc (see examples below).

You can set-up multiple emitters to detect collision to front/sides/rear and bottom.
You can rotate the shooter to shoot bullets in a circle around the player.
You can shoot the Collision Emitter from the camera to the camera's aim.

Examples of use in my game:
Events when Vehicle crashes into walls or other vehicles.
Trigger events when player leaves/contacts irregular terrain.
Missile/Grenade Explosions on impact with enemies/buildings/terrain.
3D aiming/Line of sight.
Characters can avoid walking into each other and scenery.
Aeroplane "Fly-by-wire" flight system.
1st and 3rd person "move player using mouse".
LASER-dot/Torch beam effect (attach/child a visible light or billboard to "Collision_Detector" node).
Trigger a sound when near an object.
Action when aim moves over a target object.
Climb walls/ladder when close by.
Parkour: Automatically jump over gaps.
Crouch/crawl through tunnels.
Change an animation when close to a hazard.
Simple Path-finding (find/follow route with least collisions).

Why use bullets instead of standard "On Proximity"?
Bullet-collision provides multiple uses not available with standard "on proximity" events.
Standard "On proximity" may require multiple instances.
Bullet-collision recycles a single "on proximity" event, so it's very fast and resource friendly.
A "Bullet_Collider" is very accurate and will detect collision of very complex shapes.
The "Shoot_Collider" will detect collision of moving objects/nodes (not just static nodes).
One set-up detects collision with any other scene node - no need to add multiple "on proximity" events.
"Bullet Collision" has multiple (endless?) possibilities.

2022-09-15 08:29:29

This is a great guide for non-coders thanks @VP

Registered User
2022-09-15 08:55:32

Thanks just_in_case, a pleasure. There are 3 major non-code tips I've picked over the years of chatting to others on this forum.

I'll add the other 2 non-coding tips soon:

1: how I control all my events using "Every few seconds" and "If variable" switches. (the non-code equivalent of code-looping)

2: how I use "marker nodes" to recycle single-instances - to make the game seem complex but really keeping it very simple and massively saving time and resources.

2022-11-01 01:19:16

Thanks veganpete.

The point "LASER-dot/Torch beam effect" made me really curious. Would you mind sharing some insights about it?

Registered User
2022-11-02 09:47:48

Sure thing Chris. In my "Rebel County game", I made an aeroplane that aims down onto the city as it flies above. I used a green dot as the target, which automatically adjusts height/distance as it traces over the buildings/terrain etc.

It's very easy to do...

1- The LASER dot is a transparent png applied to a billboard.
2- The Aeroplane has "every 10 milliseconds", shoot a bullet-node (to the camera center) with "no damage".
3- Then when the invisible bullet hits, I use "on hit, change position of the LASER dot billboard", relative to the "last bullet position".

What happens is, every 10ms the aeroplane shoots an invisible bullet. When it hits the ground or a building, it moves the LASER dot to that position. This gives the impression of a LASER dot.

*Once you get it working, you can set the shoot speed of the invisible bullet quite high, so there is no visible delay when the dot moves, otherwise (if the shoot speed is too low) the LASER dot's movement will be jerky. Also set the shoot distance quite high so that the bullet reaches the terrain, otherwise it wont work if the bullet can;t actually hit anything.

You can then make a missile fly to the LASER dot when a key is pressed (by using "change position" of missile model, relative to LASER dot node, animate the movement over 5000ms, for example).

To make a beam, I just use a transparent png, stretched out from the gun/torch model, then place the LASER dot/Torch dot to gove the effect of the beam hitting a surface. I don't make the beam too long (otherwise it will poke through the other side when it gets close to an object) - just enough to give the illusion of the beam - the dot will complete the illusion. This is demonstrated in my T2 Arcade game for the enemy gun sights. I clone the beam and rotate the clone through 90 degrees (to make a cross) so it can be seem from all angles.

If you then attach a point-light node to the bullet, the "beam" actually lights the scene as the bullet node shoots. This technique can be used for fire-projectiles/magic-effects, lightening (in my Cas-Evac game), explosions or LASERs/torches etc.

I can make a ccb file as an example if you need it.

Registered User
2022-11-07 17:18:00

It's a really class for us how to use the Coppercube! thanks VP!

Registered User
2022-11-12 21:47:49

A ccb as you mentioned earlier would be great:)

Create reply:

Posted by: (you are not logged in)

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




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



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