Collision detection for multiple instances of the same object?

Hello everyone,

I just started learning SFML and to an extent I'm still learning C++. I wrote a really small program which shows a ball and a the image of a floor. I set the position of the floor sprite to the bottom of the screen, and instructed the ball to keep falling if it is above the height of the floor. everything works fine if I just want to have a flat floor with no pits or ledges to jump over..Basically I'm trying to create multiple instances of the floor sprite (either array or vector) and make the ball stop falling when it comes into contact the top edge of any of the floor sprites.

I tried looking to tutorials on how to make the ball fall off the floor sprite when it reaches the end, or stop falling if it comes into contact with another floor sprite. through google but it's difficult to put what I'm looking for into words. Can someone point me in the right direction?

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/pctopgs
πŸ“…︎ Jan 28 2020
🚨︎ report
TIL of the Gotland class submarine, a Swedish vessel so stealthy that the U.S. Navy leased one to teach its commanders submarine detection . It successfully "sunk" multiple nuclear subs, frigates an one aircraft carrier during a training exercise. foxtrotalpha.jalopnik.com…
πŸ‘︎ 63
πŸ’¬︎
πŸ‘€︎ u/Jaws76
πŸ“…︎ Jun 24 2016
🚨︎ report
After not doing game dev for almost 10 years, I decided to get back into it. Pretty happy with this pathfinding and collision detection code gfycat.com/greedybriefblu…
πŸ‘︎ 25
πŸ’¬︎
πŸ‘€︎ u/msleeper
πŸ“…︎ Apr 26 2020
🚨︎ report
I made a fully animated, interactive Space Invaders with collision detection... in Overwatch! [workshop] gfycat.com/harshuniformam…
πŸ‘︎ 1k
πŸ’¬︎
πŸ‘€︎ u/Opaquer
πŸ“…︎ May 01 2019
🚨︎ report
The LIGO gravitational-wave detector will get a major boost in sensitivity with a new instrument that reduces quantum noise. The device should increase LIGO's detection range by 15%, which will help scientists detect about 50% more gravitational waves from collisions between black holes and stars. astronomy.com/news/2019/1…
πŸ‘︎ 226
πŸ’¬︎
πŸ‘€︎ u/clayt6
πŸ“…︎ Dec 10 2019
🚨︎ report
After not doing game dev for almost 10 years, I decided to get back into it. Pretty happy with this pathfinding and collision detection code gfycat.com/greedybriefblu…
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/msleeper
πŸ“…︎ Apr 26 2020
🚨︎ report
I have a problem with collision detection I'm so tired of trying!

And YES I MADE THE CONTACT MONITOR ON TRUE!! I want to detect a colision in godot and when queue_free() the ridgidbody, but I get this error erverytime I try:

Condition '!contact_monitor!' is true, returned: Array()

Here is the code:

func _physics_process(delta):

`var bodies = get_colliding_bodies()`

`for body in bodies:`

	`if body.is_in_group("Ziele"):`

		`if elapsed_seconds > max_seconds:`

elapsed_seconds = 0

partex = true

queue_free()

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Ceetive
πŸ“…︎ Jan 01 2020
🚨︎ report
Help with Combining Perspective Projection and Collision Detection

EDIT: If you open any of the links and don't see a video, just refresh and it should appear :)

Hello all,

I posted a question here recently about a toy model 3D environment that I've been working on coding up from scratch and received amazing responses, so I thought I'd try again (I actually have a pair of questions this time).

My first question boils down to: Where exactly should I place my projection plane (I'm only working with a near plane at the moment)? Is there a formula or convention that does the best job of giving the impression of first-person viewing? Or is it just a matter of playing around with values until you get something that looks proper (I don't suspect this to be the case)?

My camera/perspective plane setup

Arbitrarily choosing d=1, vw=1.6, vh=0.9 (the latter two to attain 16:9 aspect ratio), after perspective projection I see the following (Note: my code also implements triangle clipping):

https://photos.app.goo.gl/dGc9qgXgMGV3UxbXA

As you can tell, the cube is getting clipped way too far in front of our "eye". If I change the z-value of the projection plane to d=0.5, I see the following (again, after perspective projection):

https://photos.app.goo.gl/zfxm1Je6M2K5HCzq6

Evidently, the cube gets much closer to our "eye" before it starts to get clipped. So again I ask: What is the optimal placement of the projection plane to best imitate first-person seeing? Right now, I'm just playing around with values until things look proper but that approach never feels right to me.

My second question boils down to: how do you implement collision detection between the camera (i.e. our "eye") and objects (e.g. the cube) such that you don't run into any clipping issues with first-person perspective projection and you can also move past/around objects naturally? Furthermore, how do you constrain the rotation of your "world" about your "eye" without running into clipping issues as seen in this clip:

https://photos.app.goo.gl/QbJxULG5NppdTosf9

I know I'm asking a lot here but any help/advice/guidance that any of you could provide -- big or small -- would be profoundly appreciated. Thank you all so much and stay safe during these crazy times :)

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/nebuer1995
πŸ“…︎ Mar 19 2020
🚨︎ report
Collision Detection with Two Player Objects Help

I am creating a 2D Java game that will have two players going against each other for the most points. The issue I am running into is when either player fires a bullet that player takes damage. Currently, the bullet is doing damage, but it should not be damaging itself to fire. Originally I was using the method intersect to detect the collision, but the results were basically the same with the exception of the players taking damage faster.

I believe my issue is I need a way to set who owns the bullet, but my thought process is I can use the enumeration class to have the ID set to Player and Player 2. This process has been working for collisions of a bullet at the enemy, bullet at the wall, and enemy at the player. I provided my attempt at handling the collision of the bullet into the player and also the method that creates the bullet for the player that shot.

    for (int i=0; i<handler.object.size(); i++) {
        GameObject tempObject = handler.object.get(i);

        if (tempObject.getId() == ID.Bullet) {
            // Player 1 hit with bullet
            if (id == ID.Player) {
                if (getBounds().contains(tempObject.getBounds())) {
                    System.out.println("Player 1 Health: " + game.hpPlayer1);
                    game.hpPlayer1--;
                    System.out.println("Player 1 Health: " + game.hpPlayer1);
                }
            }
            // Player 2 hit with bullet
            if (id == ID.Player2) {
                if (getBounds().contains(tempObject.getBounds())) {
                    System.out.println("Player 2 Health: " + game.hpPlayer2);
                    game.hpPlayer2--;
                    System.out.println("Player 2 Hit: " + game.hpPlayer2);
                }
            }
        }
    }

    // Creates the bullet for the player that shot
    private void shootBullet() {
        // Limits the tank to one shot per second
        if (System.currentTimeMillis() - LastFired > 1000) {
            // Player 1
            if (id == ID.Player) {
                if (game.ammoPlayer1 >= 1) {
                    handler.addObject(new Bullet(x + 20, y + 19, ID.Bullet, handler, ss, angle));
                    LastFired = System.currentTimeMillis();
                    game.ammoPlayer1--;
                }
            }
            // Player 2
... keep reading on reddit ➑

πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/Kickassemo
πŸ“…︎ Oct 28 2019
🚨︎ report
HELP, I need some help with raycast collision detection..

Maybe somebody could help me to add collision with raycast? I have my code shared on stackoverflow ( link here )

Please help!

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/shakelt
πŸ“…︎ Dec 11 2019
🚨︎ report
The LIGO gravitational-wave detector will get a major boost in sensitivity with a new instrument that reduces quantum noise. The device should increase LIGO's detection range by 15%, which will help scientists detect about 50% more gravitational waves from collisions between black holes and stars. astronomy.com/news/2019/1…
πŸ‘︎ 26
πŸ’¬︎
πŸ‘€︎ u/clayt6
πŸ“…︎ Dec 10 2019
🚨︎ report
I require assistance. I am currently having issues with collision detection in a basic maze game.

Greetings!

I am currently trying to create a basic maze game in python, for a school project. In this game, the player's goal is to guide a blue rectangle to the end of a maze/dungeon-esque type of map. Eventually, I would also like to add a field of view limiter to the game.

Howerver, I am currently stuck. I am having difficulties while attempting to implement collision detection in my program. I would like the blue rectangle to be unable to pass through the grey obstacles that act as the walls of the maze. I would also like to use this collision detection to tell the player if they have found the maze's exit. I have tried using other ressources and postes to help me, but I find them confusing to read.

My code can be found and used here :

https://py3.codeskulptor.org/#user304_4XxEXr68qp0lMAH.py

Please keep in mind, my knowledge of python in extremely limited, and this is my first GUI-involving project.

Thank you for taking time out of your day to help me, I really appreciate it!

P.S. I might not reply to comments for a while, but I will do my best!

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/matrac101
πŸ“…︎ Nov 13 2019
🚨︎ report
I just updated my custom wheel collider’s collision detection. Couldn’t do this with the Unity standard wheel collider. v.redd.it/hg7mptlv34o21
πŸ‘︎ 64
πŸ’¬︎
πŸ‘€︎ u/StudioTatsu
πŸ“…︎ Mar 24 2019
🚨︎ report
My last project descended into spaghetti when I tried to implement my own collision detection. So after more than a year break, I have started fresh, and the first task was to get acquianted with Box2D. v.redd.it/eah1zaeb4ux21
πŸ‘︎ 35
πŸ’¬︎
πŸ‘€︎ u/Klonan
πŸ“…︎ May 12 2019
🚨︎ report
I figured it out!!!! Basic collision detection with movable points

https://reddit.com/link/bszzsn/video/sv5b383hff031/player

https://www.desmos.com/calculator/4fqkscsuxp

After listening to u/swoyer2, u/Minerscale and u/MaliciousMonkey's conversation about whether or not collision detection was possible, I messed around a bit with domain restrictions and figured out how to make a variable's domain depend on the value of that same variable using regressions.

This graph is a simple example of a point that cannot be dragged through a box, but the same concept can be reapplied to a variety of different shapes or in different situations.

Ideas that this could be applied to:

-Basic platforming games

-Interactive mazes

-Click-and-drag adventure games, where the player has to be within a certain proximity of an entity in order to interact with it

-Super basic physics simulators

-Pachinko?

Again, please let me know what you think/if you have any ideas about how to apply this!

πŸ‘︎ 18
πŸ’¬︎
πŸ‘€︎ u/vaultthestars
πŸ“…︎ May 25 2019
🚨︎ report
cool detail: a thrown matchstick's collision detection with a pot (knocks off lid) youtube.com/watch?v=NFXD7…
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/s1n0d3utscht3k
πŸ“…︎ Oct 26 2019
🚨︎ report
Problem with collision detection - Kasper Fauerby algorithm

Hey, as in topic, I need help with collision detection algorithm from this paper: http://www.peroxide.dk/papers/collision/collision.pdf

I assume I am colliding with sphere of radius 1, just to make everything not important easier...I am concerned with formula, which finds intersection point with plane (page 14):

planeIntersectionPoint = basePoint - planeNormal + t0 * velocity

where:
basePoint = center of Sphere

planeNormal = normalized normal vector to colliding plane

t0 = number from [0,1] interval, first moment from this interval during which collision happens, assuming we are moving with velocity vector

velocity = velocity vector

I think that this formula doesn't work... Assuming that I am already intersecting with plane at t0 = 0, I just get:

planeIntersectionPoint = basePoint - planeNormal

What gives me point which doesn't even belong to plane, what fails further parts of the algorithm, when I check if intersection point is in triangle...

I will be grateful for every answer... Is the algorithm wrong, or that's me misunderstanding something?...I posted this here, because here I found recommendation of this algorithm, so maybe someone knows it and implemented it, so he will know what's going on...

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Mentos1105
πŸ“…︎ Jun 23 2019
🚨︎ report
Help with Collision Detection, please

So i made this Sphere charge onto the Player - > https://youtu.be/QYFCFHC0Gnk

Now i want the Player ( whichever way works) to lose health on collision when the Sphere charged successfully.

I need help with the Syntax for "check collision, if collision is player body ", any ideas?

Thank you.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Therapsid_g
πŸ“…︎ Nov 27 2019
🚨︎ report
[::] Let me show you why MC 1.9 is called the "Combat Update"! - 10 unique weapons with real physics & accurate collision detection using ray-casting method in 1370 Commandblocks. Multiplayer compatible. Explanation & download in comments. gfycat.com/WellmadeWeakGa…
πŸ‘︎ 2k
πŸ’¬︎
πŸ‘€︎ u/GamerGuppy
πŸ“…︎ Oct 19 2015
🚨︎ report
Confirmed detection on a cheat known as pentagon banning over 200+ users with multiple accounts" twitter.com/OverwatchPD/s…
πŸ‘︎ 688
πŸ’¬︎
πŸ‘€︎ u/gmarkerbo
πŸ“…︎ Dec 17 2019
🚨︎ report
Feathernet: one-wire multi-drop network with collision detection and retransmit imgur.com/a/wIqYu
πŸ‘︎ 68
πŸ’¬︎
πŸ‘€︎ u/justarandomgeek
πŸ“…︎ Jun 20 2017
🚨︎ report
Need help with collision detection in simple pong game.

So i tried making a simple pong game but i can't get the ball to bounce off the paddles. i have no idea if i'm using colliderect correctly, i can't even find the full syntax to it.

import pygame
import random

pygame.init()
win = pygame.display.set_mode((500, 500))
win.fill((0, 0, 0))
list = [i for i in range(6, 10)]


class ball:
    def __init__(self, x, y, width, height):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.vel = 10
        self.movex = random.choice(list) * random.randrange(-1, 2, 2)
        self.movey = random.choice(list) * random.randrange(-1, 2, 2)
        self.rect = pygame.Rect(self.x, self.y, self.width, self.height)

    def draw(self):
        pygame.draw.rect(win, (255, 255, 255), (self.x, self.y, self.width, self.height))

    def move(self):
        self.x -= (self.vel * (self.movex / 10))
        self.y -= (self.vel * (self.movey / 10))

    def collide(self):
        if self.y > 500 - self.height or self.y < 0:
            self.movey *= -1
        if self.rect.colliderect(paddle1.rect) or self.rect.colliderect(paddle2.rect):
            self.movex *= -1
            self.movey *= -1

class paddle:
    def __init__(self, x, y, width, height):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.vel = 20
        self.rect = pygame.Rect(self.x, self.y, self.width, self.height)

    def moveup(self):
        self.y -= self.vel

    def movedown(self):
        self.y += self.vel

    def draw(self):
        pygame.draw.rect(win, (255, 255, 255), (self.x, self.y, self.width, self.height))


paddle1 = paddle(450, 200, 20, 250)
paddle2 = paddle(30, 200, 20, 250)
ball1 = ball(250, 250, 15, 15)

run = True
while run:
    pygame.time.delay(50)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    keys = pygame.key.get_pressed()
    if keys[pygame.K_UP] and paddle1.y > 0:
        paddle1.moveup()
    if keys[pygame.K_DOWN] and paddle1.y < (500 - paddle1.height):
        paddle1.movedown()
    if keys[pygame.K_w] and paddle2.y > 0:
        paddle2.moveup()
    if keys[pygame.K_s] an
... keep reading on reddit ➑

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/spiderharry02
πŸ“…︎ Sep 08 2019
🚨︎ report
A GZDoom Success Story (Kinda): Fun With Collision Detection

Ok, here's the skinny: I'm doing an arcade-style flight game in Doom's engine.

Yes, you read that right. Arcade flight game. Doom's engine. Why even bother when Unreal/Unity exist? Because kicking reason to the curb is my modus operandi. Plus, I had already started on the project last year, so I might as well see it through to completion. Especially after the wondrous fun I had last night.

My Doom engine of choice is the delightfully modern GZDoom engine and it's C-wannabe scripting language ZScript, and I've been really surprised at how flexible this engine and its language are. So far I've been able to get my player plane to move at a constant velocity, speed up and down, pitch and yaw realistically, and even roll 360 degrees. It's neat, really. But even neater is a nifty little function that's aided my developments in enemy AI for the game: LineTrace.

In a nutshell, LineTrace fires an invisible line from the calling actor's center, at the bottom of their hitbox. This line can be customized in a number of ways, such as the origin, the angle and pitch, and even how far the line extends. But what really makes me giddy is that it can store data on what exactly the line hit, if it hit anything at all. It can even differentiate between walls, ceilings, floors, and other actors. All that's required is to create a struct to store the data, and that struct can be accessed separately of the function.

See where I'm going with this? Using LineTrace, I was able to get an AI bot to 180 when it was about to hit a wall, pitch up when it's about to hit a floor, or swerve away if it's about to hit my plane. It's all thanks to the struct data and how I was able to use it to manipulate the actor. Of course, it's still rough around the edges (I catch the bot faceplanting into floors every now and then), but I'm pretty impressed with this development so far.

Now I'll admit, I am FAR from an experienced programmer, so I'm probably making a bigger deal of this then I probably should. I'm just pleased with my ability to learn and adapt with new information, as I do question my competence from time to time.

So what about you guys? Any fun stories with AI/collision detection, or even anything else at all, that you wanna share?

πŸ‘︎ 17
πŸ’¬︎
πŸ‘€︎ u/VenomousWoe
πŸ“…︎ Mar 09 2019
🚨︎ report
You can teleport anywhere, but it activates at random with no collision detection.
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/RevolsinX
πŸ“…︎ Oct 13 2019
🚨︎ report
Accessing multiple cameras + motion detection with Python & OpenCV pyimagesearch.com/2016/01…
πŸ‘︎ 78
πŸ’¬︎
πŸ‘€︎ u/zionsrogue
πŸ“…︎ Jan 18 2016
🚨︎ report
Gibka-S air defense system passing tests. It can use Igla-S or Verba MANPAD missiles and mounted on a GAZ Tigr LAV it is highly mobile. At 0:27 a Command Vehicle is visible (with a radar able to exchange data with carrier vehicles and HQ for target detection and distribution). youtube.com/watch?v=x-W2h…
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/zhacem
πŸ“…︎ Feb 12 2020
🚨︎ report
Over 100 simulated vehicles with more advanced junctions and collision detection. streamable.com/dx3vp
πŸ‘︎ 108
πŸ’¬︎
πŸ‘€︎ u/PhonicUK
πŸ“…︎ Jan 21 2018
🚨︎ report
[::] Bot with PathFinding AI that autonomeously switches between three Algorithms: Dijkstra's Concurrent, semi-A* and a simple Chase algorithm, all compatible with 3d terrain, collision detection & easily configurable search radius - More info in comments gfycat.com/CompleteDistan…
πŸ‘︎ 2k
πŸ’¬︎
πŸ‘€︎ u/GamerGuppy
πŸ“…︎ May 31 2015
🚨︎ report
For all of you out there with E-ZPass transponders on your vehicles who are not supposed to put them on your windshield for safety reasons (e.g., collision detection sensors, etc.). Where do you put them?

I've seen people with them on the front of their dashboards, but I worry they wont trigger properly, then I'll get embroiled in one of those legal situations where the E-ZPass people say they sent me a ticket, but it doesn't show up in the mail, then I all of a sudden owe them $10,000.00 for late fees.

Seriously ... do they trigger well when placed on the dashboard?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/My-Work-Reddit
πŸ“…︎ Mar 29 2019
🚨︎ report
Collision Detection with more complex objects

Hi! How would you handle collision checking, is character grounded, in more complex enviroments?

I'm currently struggling with my character sliding on the wall to the ground on one big composite collider.

OnCollisionEnter/Exit with Normal of the Contact Point approach doesn't work cause it isn't triggered when it hits the floor while still touching the wall.

OnTriggerEnter/Exit on 4 box colliders on every side of character creates a lot of bugs where character touching wall with only 1 side sometimes triggers more then one collider.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/kamkaskan
πŸ“…︎ Oct 08 2019
🚨︎ report
Problems with collision detection and my spritesheet

My problem is I have a spritesheet of a character, and the width of the character in each frame varies. So when it's narrower it uses less than the frameWidth specified in this.load.spritesheet

The problem comes when doing collision detection. It detects a collision when my character is far away from the collision, it's the transparent space of the spritesheet that's triggering the collision.

How do I do it? Do I use something different than a spritesheet loaded in the standard way?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Robert_Bobbinson
πŸ“…︎ Jun 15 2019
🚨︎ report
Collision Detection with Divide and Conquer [OC]
πŸ‘︎ 58
πŸ’¬︎
πŸ‘€︎ u/egolf_cs
πŸ“…︎ Aug 18 2018
🚨︎ report
Help with collision detection in a game I'm making
πŸ‘︎ 21
πŸ’¬︎
πŸ‘€︎ u/yoctometric
πŸ“…︎ Mar 25 2018
🚨︎ report
A new JavaScript Collision Detection course for Game Development starts on June 7th. 17+ tutorials; ends with 2D platformer slope collision detection and RPG examples. The last tutorial in the series explains how to build your own physics engine.

Hello game devvers,

I want to invite game developers to my free course intro [YouTube] that starts on June 7th. Until then I am trying to build a bit of an audience, for the entire series of tutorials (including source code for each example) that are already recorded.

During last 3 weeks, I recorded a series of 17 tutorials, that I plan on publishing on my YouTube channel for 30 days, with an interval of 2-3 between each. It's totally free for anyone who wants to learn about collision detection with JavaScript. The source code provided can be ported.

At first, I wanted to just upload everything in one day, but that's unwise for so many different reasons. Dealing with this amount of content, I had to split everything into separate tutorials.

To make the story short. Here is what the course contains.

The Content

    1. Introduction to collision detection types (rect, line, circle vs line, point in concave and convex polygons, etc.)
    1. Creating canvas point, line and polygon drawing library from scratch in JavaScript
    1. Intersection between two dynamic lines
    1. Rectangle vs Rectangle test and AABB explained
    1. Visual explanations, incl. how does Circle vs Circle collision works?
    1. Collision of a Circle vs Line, with complete detailed explanations
    1. Cross and Dot product briefly explained (brief trig; limited to game development)
    1. Collision of a 3D ray with a 3D polygon
    1. Making a basic 2D Platformer with doors, elevators and power ups
    1. Example of an RPG game with collision against walls, and moving objects, like boxes etc.
    1. Writing your own physics engine on canvas in JavaScript, using the collision library built in this course.

I started the game development tutorial series in 2014, and have gained some experience recording educational material during the last two years. Now, I felt like it was the right time to release this course for free. But with this amount of already-existing content, I have to schedule with an interval of about 2-3 days.


I am looking for an audience, before it all starts on June 7th.

How/where to get it?

To get the new series, simply subscribe to my YouTube channel. All 17 tutorials that will be published are 100% free, and are of quality you would see on paid tutorial websites. I had a choice to sell them to those sites, but since the beginning of the series, I chose the free content model.

I rarely self promote on reddit,

... keep reading on reddit ➑

πŸ‘︎ 353
πŸ’¬︎
πŸ‘€︎ u/tigrisgames
πŸ“…︎ May 28 2016
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.