QuakeWiki
August 5, 2019

Forums

Welcome Guest

Pages: 1 2 3
Tales From A Newbie's Foray Into The World Of Game Dev.
Mr.BurnsPostDecember 13, 2018, 23:29
Rogue
Posts: 47
Registered:
January 12, 2018, 09:03
Very Hot topicReply To: Tales From A Newbie's Foray Into The World Of Game Dev.

Hi MG

DMP or DeathMatchPlus is a Quake 1 Multiplayer Mod which was IMHO a whole lot of fun to play as it added new weapons and powerups rarely seen in quake at the time. I will always be grateful to Zop for trying to help as he very kindly contributed a number of updates a few years ago and the updated prototype is on newyork.quakeone.com:26002. Yes there are a number of bugs but the changes felt well balanced and didn't detract from the look and feel when you played it.

It looks like there is a Wiki page at https://quake.fandom.com/wiki/DeathMatch_PLUS_PACK! but it doesn't quite do it justice. I would certainly be looking to add some/most of the DMP, RuneQuakePlus (RQP, see newyork.quakeone.com:26009) and Rquake (co-op mod at newyork.quakeone.com:26001) features in any FPS if I could manage it, purely for the fun they can provide if you use them wisely ;) .

Hope this helps

Monty

Mr.BurnsPostJanuary 14, 2019, 12:14
Rogue
Posts: 47
Registered:
January 12, 2018, 09:03
Very Hot topicReply To: Tales From A Newbie's Foray Into The World Of Game Dev.

Just in case anybody else is a Unity newbie like me and comes across the following problem I thought i would try and help with a possible solution.

The problem: I have a simple grenade launcher model and when selected and the  fire key (mouse1) is pressed it creates a copy of the grenade at the end of the GL and adds some force to it to give the impression that it is shot from the the Launcher. All good so far.  Each grenade object has a collider attached to it so it can detect when it has hit it's target (or not). It also has a rigidbody attached to it so it will bounce, react to gravity and so forth. This is where the problem creeps in, after you fire the grenade it flies out of your GL and if it sometimes hits a solid wall sometimes it will bounce back (which is expected behaviour), but mostly it just goes through the wall. There are no common denominators for these "ghost" grenades as they are all from the same object and nothing of any significance changes between a nade that works and a nade that phases throughthe wall.

The cause: Although you might think like I did that a problem detecting collisions might be in the collider script attached to either the wall or the grenade you would be wrong. After much head scratching and frustration it seems that the problem is within the Rigidbody attached to the Grenade. It has a property called "Collision Detection" and by default it is set to a value of "discrete".

The resolution: For rapid fire high speed items like my grenade this clearly isnt enough and needs to increase the rate at which it looks for a collision. When you edit your grenade object, by expanding the Rigidbody and scrolliing down to a property called "Collision Detection" and then selecting Continous" in the drop down, the grenades no longer disappear through the wall.

I'm sure there is probably a much better way and I only added this as I hope this helps somebody avoid many hours of befuddlement.

Kind regards

Monty

OneMadGypsyPostJanuary 14, 2019, 14:54
Moderator
Posts: 307
Registered:
November 12, 2017, 00:13
Very Hot topicReply To: Tales From A Newbie's Foray Into The World Of Game Dev.

Collision

Continuous will collide with any component that does not have a static mesh geometry attached to it. This will eventually create problems. When you start to create monsters they will obviously have a static mesh geometry and your bullet will not work. Continuous Dynamic will collide with anything but, it comes at a processing cost (maybe a huge one). No matter what you use, projectiles can still potentially go right through something.

Your solution is not wrong. However, you are eventually going to have to consider adding your own approach to what already exists or live with possible missed collision checks and bad frame rates. There are a lot of ways to do collision detection but the easiest for bullet~enemy collision would be to check if the bullet co-ordinates are inside of the enemy co-ordinates. You can do this with either a point or intersecting boxes

pseudo code for point

function isPointInsideAABB(point, box) {
  return (point.x >= box.minX && point.x <= box.maxX) &&
         (point.y >= box.minY && point.y <= box.maxY) &&
         (point.z >= box.minZ && point.z <= box.maxZ);
}

pseudo code for interecting boxes

function intersect(a, b) {
  return (a.minX <= b.maxX && a.maxX >= b.minX) &&
         (a.minY <= b.maxY && a.maxY >= b.minY) &&
         (a.minZ <= b.maxZ && a.maxZ >= b.minZ);
}

By using the continuous option to check non-rigidbody collisions and incorporating your own function for rigid body collisions, based on a switch that can be turned on/off, you can have the best of both worlds cheaper. For instance, you only have to run the intersection codes when something fires a projectile or when an enemy has gotten within a certain range of the player (for player~enemy collisions).

This video gives a decent description of the 3 collision types as-well-as an example of them all in use.

Cloning

You may want to consider using a pool. You said the grenade makes a copy of itself. I'm assuming this means you destroy that grenade once it has done it's job. That is not good. Look at your code as a pregnant lady. Labor is hard. If a woman had to give birth to the same kid every day there would be a lot less people in this world. Your code is no different really. It has to keep cloning the same projectile every time it needs one. This means it has to put a new copy in the buffer and then take that copy out. That is not free. Depending on unity's method that could be expensive. If you knew the max amount of clones you could ever possibly need at one time you could create a pool of clones when the weapon is selected (or even populate the pool as the weapon is fired for the first few shots).

Consider this, you have mathematically figured out that the most amount of grenades that could ever be on the screen at the same time is 3 (as an example). You make a pool of 3 grenades. As each one is fired you mark it in your pool as "inUse". When it explodes, you don't destroy it. You make it invisible, reset all of it's data (ie frame = 0, exploded = false, whatever) and you mark it in your pool as "available". As grenades are fired you simply pull the next available one from the pool. Your current way may entail making and destroying 100 clones. The way I described, you will never make more than 3 and none of them get destroyed until you switch guns.

Pages: 1 2 3
Page loaded in: 0.022 seconds.