Staredit Network > Forums > SC2 Assistance > Topic: Bullet Physics
Bullet Physics
Jan 2 2011, 1:32 am
By: LoveLess  

Jan 2 2011, 1:32 am LoveLess Post #1

Let me show you how to hump without making love.

How, plain and simple.

I want to make bullets originate from a unit, if it hits terrain or armored units, it stops/bounces. If it hits a unit, deals damage. I am in no means too familiar with this realm though, so any help is appreciated.



None.

Jan 2 2011, 1:44 am lilneo Post #2



No pro, but I'm pretty sure that's a bit far for the editor...
But, don't take my word for it I'm not saying because I know that but just because with my huge experience with sc1, and my fairly big experience with sc2. That seems a bit much.

I played a tps map a while back, and even with that you couldn't shoot voluntarily in a direction. You had to be aiming at a unit, then it would command the marine to attack.

~lilneo



None.

Jan 2 2011, 1:51 am FatalException Post #3



Don't listen to lilneo, it's doable. :P

I was having trouble with this several patches ago (the last time I worked on my map), as the GetHeight functions weren't working properly, but the basic idea is pretty simple. You get the angle that you want the bullet to come out at and you move a point along the bullet's path. You center a small region on the point, with a radius equal to or greater than the distance that the bullet travels each loop so you don't miss any spots, and you check that region for units each loop. If there is a unit in the region, apply damage and terminate the bullet loop. If there isn't, continue on.

Now, it gets more difficult when you start dealing in three dimensions, or if you want more accuracy without lag. To check if you've hit terrain, you need to get the bullet's relative height to the terrain: If it's less than 0, the bullet is underground. However, this method doesn't work with cliffs--the bullet will do a fun little jump when it reaches a cliff and continue on like nothing happened--and it starts breaking when you start working with hills larger than dimples (or at least it did several patches ago). Do you want more detail, either on the code flow or the math? I'll probably end up writing a tutorial for this sometime, anyway.

Attached is a prototype third-person shooter map that I worked on during the beta. It uses the methods I've described above, and has the problems I've described above. Hopefully the height functions will have been fixed by now, but I don't remember if I left the map in a working state. You may have to select the ghost to start, and you can use 1 and 2 to switch between a rifle and a grenade launcher. Pl0x don't completely rip off my systems from this map. :P

Attachments:
test 2a.SC2Map
Hits: 2 Size: 284.96kb

Post has been edited 2 time(s), last time on Jan 2 2011, 2:01 am by FatalException.



None.

Jan 2 2011, 1:51 am NicholasBeige Post #4



Look up "Trace Line Functions".

As of right now we cannot create collision between missiles and terrain/cliffs. And, I don't think we ever will be able to unless a 3rd party creates it or if a work-a-round is constructed.



None.

Jan 2 2011, 3:35 am LoveLess Post #5

Let me show you how to hump without making love.

Ah, alright. Thank you. I will update the topic if and when I make a viable system for bullet physics.



None.

Jan 2 2011, 8:02 pm payne Post #6

:payne:

Search for "SCCAP" when creating a game on Battle.net 2: the guy did make missiles bounce off walls and such. :O



None.

Jan 3 2011, 9:13 am BeDazed Post #7



Maybe you could make an invisible sprite that encompasses walls/terrain you want to bounce off.



None.

Jan 3 2011, 11:06 am NicholasBeige Post #8



Quote from payne
Search for "SCCAP" when creating a game on Battle.net 2: the guy did make missiles bounce off walls and such. :O

He used regions on all of his walls and simply detected if a unit entered the region and was a missile, then just did some fancy mathematics to calculate the angle of bounce and sent the missile on its way. Not sure how he did the actual bounce or whether or not he used a unit as his actual missile and gave them 'move' commands. Most likely it was the latter.

A missile has a constant height (as far as I am aware). This is offset from the Terrain Height from where it is launched. I think if you look at marauders shooting up a ramp, you can see that the missile just follows the terrain height. Or create a massive hill using raise/lower terrain and shoot missiles over it. As far as I am aware you can't change this (and I believe it's just laziness on Blizzard's part). Especially noticeable when collosus and other units are shooting through cliffs...

For the most bang for your buck in terms of customization, use the good old fashioned dummy unit and order it to move to the point where you want it to be shot at... Then you just give it an ability, create persistent > search area > baneling suicide. So that if it comes within x range of another non missile unit (or even missiles included) it will explode. Only downside is that, this is simple but it relies heavily on triggers.



None.

Jan 4 2011, 3:49 am FatalException Post #9



You can change the height of the missile.

This video is from the map I attached above, when it was working. As you can see, I got it traveling in nice parabolas over flat land, and I can detect where it lands accurately; the problems start when shooting it over uneven ground--you can see the jumps in its path in the second half of the video. The numbers on the left side are the reported height of the missile over the terrain (which are clearly wrong). If the height functions are working better than they were in the beta, I could probably get this map in working order so you can look at it.



None.

Mar 29 2011, 11:05 pm Bolshevik09 Post #10



inst there a condition called "if ground is passable"
Also there is Pathing called no air. So it would make the unit move a different direction when it collided to try and go around. You could detect this via conditions.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:41 am]
v9bettel -- Nice
[01:39 am]
Ultraviolet -- no u elky skeleton guy, I'll use em better
[10:50 pm]
Vrael -- Ultraviolet
Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
hey cut it out I'm getting all the minerals
[10:11 pm]
Ultraviolet -- :P
[10:11 pm]
Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
[2024-4-17. : 11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
[2024-4-17. : 1:53 am]
Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
Please log in to shout.


Members Online: Roy, Orman