Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / Setting up bullets with DP?

Author
Message
culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 8th Sep 2007 01:25
Yeah, I was thinking I wanted to set up my bullets with DP so I could maybe have them knock over boxes on contact and such. It's just not working right... any ideas how I could do it with my current script?

(Script & media attached) - ZIPped, 13 Megs.

Thanks much.
Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 9th Sep 2007 10:13
Sorry, can't you just do raycasting and add forces at the point of the raycast hit?
MartinS
18
Years of Service
User Offline
Joined: 15th Dec 2005
Location: Rochester, NY
Posted: 9th Sep 2007 14:33
Precisely. Unless the gun is throwing it.

Coming soon...
culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 10th Sep 2007 01:26
But if I just used raycasting I wouldn't have any visual representation of the bullet. I need one.
Redmotion
21
Years of Service
User Offline
Joined: 16th Jan 2003
Location: Mmm mmm.. Marmite
Posted: 10th Sep 2007 13:58
Er... Since when could you see actual bullets coming out of a gun, except in slow motion?

Even with slow motion, you should use ray casting and don't worry about the bullet with DP - its a waste of CPU power. As long as you know the trajectory just show a model of the bullet speeding along it. Delete it when it reaches the impact point.

culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 11th Sep 2007 01:04
What's the difference between that and just having the bullet hit stuff?

Besides, how would I do bullet holes with raycasting? I want it to be delayed until the bullet reaches where it will hit, but there's no set time I can make the program wait.

Whatever, that's beside the point. I just wanted to know if I can set my bullets up so that they have no gravity and aren't knocked off-course by objects. I know I have to phy set rigid body gravity (bullet),0 and then phy set rigid body mass (bullet),900000000, but I just can't figure out where the script would go. That's what I wanted help with.

And ever played Halo or Killzone:Liberation? You see the bullets coming out of those guns.
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 11th Sep 2007 23:02
Most likely those bullets in Halo and Killzone are only there to represent bullet trails. I can almost guarantee you that those 2 games use ray cast style bullets. Almost every game does. It's faster and there's no extra 50 bullet objects to deal with. What they might do is just show the bullet in a random position somewhere down the ray cast's trail. I have done this in my game and it works great. Can't even tell you aren't firing real bullets.

culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 12th Sep 2007 04:24
Yeah, except in Killzone the bullets are slower and stuff... if you've played the PSP Killzone you'll know what I mean. Hard to explain. But anyway,
Quote: "that's beside the point. I just wanted to know if I can set my bullets up so that they have no gravity and aren't knocked off-course by objects. I know I have to phy set rigid body gravity (bullet),0 and then phy set rigid body mass (bullet),900000000, but I just can't figure out where the script would go. That's what I wanted help with."
Juggernaut
19
Years of Service
User Offline
Joined: 9th Jan 2005
Location:
Posted: 11th Oct 2007 18:20
If you create a raycast from your bullet objects initial position to its position after a movement update, you can use that one for precisely what you want.
The problem most people have is that they just make a raycast from the point of fire. This is called the hitscan method, and was used mainly in 90's FPSs.
So yeah, just make the bullet move the desired distance each cycle, and the cast a ray from its starting location to its end location. That way the bullet can move at any speed and have exact collision detection.

Just someone obsessed with making games(this will be updated whenever...)
culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 17th Oct 2007 04:26 Edited at: 17th Oct 2007 04:28
That sounds good... one thing - where would I cast the ray from, if not the point of fire? And in following cycles, would the bullet just follow that single ray (repeat...until), or have a new ray cast from its current position (as of that cycle) to the end point?

Hmm... that's a bit confusing. Lemme draw some crap to show what I mean...



Or did you mean something else altogether? If you did PLEASE show me pictorially, during the week I have no brainpower left after school.

EDIT: I guess #1 wouldn't make sense if I wanted curving bullets or something, and also because it is dependant on cast position. So I'm assuming you meant #2, or something different?
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 17th Oct 2007 05:11
each time you press the button to fire a bullet you need to cast a new ray. once the bullet is fired the end poit is already set.

I may be confused here but you may be confused here or maybe I am confused here. as I see it there are two different cases here.

case #1. A rifle/machine gun/pistol type of a shot.

case #2. A grenade/rocket/launcher projectile.

In case #1 you would use a ray cast method. cast ray, "bullet travels along path" only there is no bullet, just a muzzle flash and what looks like bullet tracers. Almost instantly the damage is registered on target. Take approprate action. rinse and repeat.

In case #2 you need to see it land this is more of a toss than a fire. In this method you need to figure out the forces you need to apply to an object that originates at the players location. for a grenade style toss or rock throw. you can have a variable power meter so you know how much force to apply to the tossed object so it goes "x" amout of distance, at "x" angle. rinse and repeat.
Juggernaut
19
Years of Service
User Offline
Joined: 9th Jan 2005
Location:
Posted: 17th Oct 2007 18:05 Edited at: 17th Oct 2007 18:07
Each cycle, you have your bullet object move the desired distance. Let's say it moves about 1.5 world units per cycle. Always save the coordinates that your bullet was in at the beginning of the cycle. I typically use something like oldx#,oldy#,oldz# but anything will work. Then, cast a ray from the old position to the new position (oldx#,oldy#,oldz# --> newx#,newy#,newz#). That way, it can tell if the bullet hit anything in between its start and end points for that cycle, which means that no matter how fast or slow your bullet object goes, it will always have a precisely timed and correct collision.

Do this EVERY cycle. That means 1 ray per cycle using the bullets position at the beginning and its position at the end of that one cycle.

I would draw a picture, but I think I explained it well enough. And like I said before, casting 1 ray per shot that extends from the gun is called the hitscan method, which means no matter how far away the object is, it will get hit at the same time of firing. This is unrealistic and doesn't allow for slower bullets(say, the plasma rifle in Halo or the silenced round in Killzone PS2). There is a really good explanation of hitscan weapons on Wikipedia if you want more insight. My method is a projectile weapon, meaning the bullet actually "travels", even when it seems instant(like in close range).

Just someone obsessed with making games(this will be updated whenever...)
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 17th Oct 2007 22:18
the only problem with that method is "tunneling". say for example you frame rate drops then jumps. then what? its possible your object could pass right through the intended target.

The best method for "fast rate of fire" weapons is the hitscan method. You just put a timer in vs the distance. So a further distance will not "impact" as soon as a short distance. This is controlled by a timer, that is initiated as soon as the fire button is pressed.

The best method for "slow rate of fire" weapons is the object method. You actually have a bullet object. It can travel straight or in arc's. It doesnt matter. What matters is the player can see the object moving and impacting. And since it is slow you dont need to ray-cast, only check for the collision for the objects in its killzone.
Juggernaut
19
Years of Service
User Offline
Joined: 9th Jan 2005
Location:
Posted: 18th Oct 2007 18:53
I don't think you understand what I am saying. In my method, instead of using one long ray, that ray is essentially broken up into smaller rays. Their is no gaps between them because on rays endpoint is the next rays start point. Even if the framerate slowed down, the ray cast will still happen in this fashion.

Just someone obsessed with making games(this will be updated whenever...)
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 18th Oct 2007 22:17
oh ok. got it. my bad lol. great idea.
icy
18
Years of Service
User Offline
Joined: 26th Apr 2006
Location: Antarctica
Posted: 19th Oct 2007 03:08
Hmmm
culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 19th Oct 2007 06:59 Edited at: 19th Oct 2007 07:01
Awesome idea Juggernaut. I'll get to work on that tomorrow after school. It should work. It's pretty much the same as my collision system, using oldx#-z# and raycasting. Should I use sparky's? Yeah... I'll do that.

Thanks much... I'll post my results but it may be a while.

EDIT: Oh yeah, and how would I get my bullets to move the boxes on the ground a bit? Apply linear velocity on contact? But how would I do that...? Apply it until it = my selected amount of velocity and then reset it to 0? That should work. Anyway, I'll catch up later, thanks again.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 19th Oct 2007 13:17
I have an example that I can show you I used it in my Ageia Compo entry. you would shoot a crate and it would apply a force to the object at the point of impact. not just at center mass. Anyways I have to got to work right now. I'll post it when I get home.
culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 19th Oct 2007 15:21
Cool, I'd like to see that. I've heard from Shiny Edge that the eXtends DLL lets you create infinite objects (bullets?). That would be fun.

Anyway, gotta go to school . I DO want to be late, but shouldn't be.
FINN MAN
20
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 21st Oct 2007 17:38
david are you going to post that example, I would love to see it.

david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 24th Oct 2007 04:10
I am going to post it,,,Its embedded into the project,,,Im trying to get it into one nice function that you can just drop into your code...It just takes some time. I work a full-time job.
culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 25th Oct 2007 01:08
Cool thanks... I feel your pain with my school.
FINN MAN
20
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 25th Oct 2007 05:05
I am sorry did not mean to sound like that; I as well fell your pain with collage.

Juggernaut
19
Years of Service
User Offline
Joined: 9th Jan 2005
Location:
Posted: 25th Oct 2007 07:46
I just realized I sounded like a jerk in my last post. I wasn't trying to be at all, sorry.

Just someone obsessed with making games(this will be updated whenever...)

Login to post a reply

Server time is: 2024-11-24 20:51:32
Your offset time is: 2024-11-24 20:51:32