Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Collision Detection Tip (non-code)

veganpete
Registered User
Quote
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).

Modifications:
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.


just_in_case
Moderator
Quote
2022-09-15 08:29:29

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


veganpete
Registered User
Quote
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.


Chris
Guest
Quote
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?


veganpete
Registered User
Quote
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.

https://www.youtube.com/watch?v=...

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.


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

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


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

A ccb as you mentioned earlier would be great:)


veganpete
Registered User
Quote
2023-02-13 09:44:29

Sorry for the late reply- all my games on itch.io have ccb files as well as exe file. Most of my projects use the same principals so you'll see examples throughout my work. If you want examples of something specific, let me know.

https://veganpete.itch.io/


billy
Guest
Quote
2023-02-20 14:07:12

Hi, I've got a question about using bullets for enemy "sight." I was able to create a stealth mechanic by using sight bullets for the patrolling enemy. I set these bullets to do 0 damage. However, when the enemy sight bullets hit other enemies, it still triggers the enemy "on hit" command. So I am having trouble with sight bullets creating reactions like setting off "hit" sound effects. Do you have any advice on how I could avoid this problem? In a way, it is a problem of "friendly fire". How can I make it so the enemy sight bullets will only react to hitting the player, instead of other enemies?


VP
Guest
Quote
2023-02-21 07:57:33

That's great! Glad you tried it.

Yes, the "hit" detection can be a problem in that case - a workaround would be to use an "on proximity" event attached to the "sight" bullet's node and attached to the "gun" bullet nodes to set a variable - then use that variable as a gate to
control the "on hit" events for the characters.

Example:
Sight Bullet:
On Proximity (sphere, radius10) "sight bullet", set variable "friendly_fire?"=1

GunBullet:
On Proximity (sphere, radius10), set variable "friendly_fire?"=0

...then in the "on hit" section of your characters, you can control the events using variables.....

Example:

Character1: On Hit, If variable "Friendly_Fire"=1, play sound "Don't_Shoot.ogg", set animation to "put-your-hands-in-the air"

Character1: On Hit, If variable "Friendly_Fire"=0, Play sound "scream.ogg", set animation to "death-fall"

This way, if you aim at character1 (ie:hit them with the sight-bullet), they will put their hands in the air and say "Don't shoot".
But, When you shoot them with the actual gun-bullet, they will scream and fall over instead.


billy
Guest
Quote
2023-02-22 02:55:06

Wow, this is method is specular! My previous problem was that I didn't have a way to distinguish different bullets. I tried adding the proximity event to the bullet node which was being cloned, but that never worked. I guess I figured "last bullet impact" would refer to the last bullet impact in general, but it's great to know that it will be specific for each object. Thanks!


VP
Guest
Quote
2023-02-22 09:40:01

You're welcome Billy. I'm glad you found it helpful. I use the "shoot" action a lot, you can do quite a lot of unusual things with it, especially with the "last bullet impact" - which is always great for a quick/simple collision detection tool.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internatio?al" (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