A list of puns related to "Carrier Sense Multiple Access With Collision Detection"
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?
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()
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 :)
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 β‘Maybe somebody could help me to add collision with raycast? I have my code shared on stackoverflow ( link here )
Please help!
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!
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!
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...
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.
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 β‘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?
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?
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.
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?
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
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 β‘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.