How to detect actors at certain co-ordinates

UnrealCanine

  • Posts: 244
I have the following idea;

1) The player controls an enemy who uses different weapons such as shotguns and smgs, etc.

2) Enemies further away obviously take damage

3) The way I have it set up at the moment is as thus. There is a certain chance of hitting an enemy at max range, with the difference closer on a linear scale. This means if the chance at 800 units is 50%, 400 units will be 75% and so forth. Then the game runs a random float between 0.0 and 1.0. If the float is greater than the chance, it's a miss, otherwise it's a hit.

4) There are a few problems with this. First enemy size does not account for damage dealt. an elephant-sized enemy is just as hard to hit as a rat-sized one

5) Second,  it doesn't account for whether you get a direct hit, or  just skim an enemy. Worse, if you slightly miss, you do nothing instead of slight damage

6) Third, any enemies next to the target take no damage, even it they should be close enough to be hit.

Is there a way to tell if an actor/enemy exists at a point, or as an alternative, is there a way to tell how much percent of an actor is in an area?

ceosol

  • *
  • Posts: 2279
Use math

x of self + width of self > x of actor
y of self + height of self > y of actor

etc.

UnrealCanine

  • Posts: 244
what if the actor in question isn't a perfect rectangle, and is actually an odd shape?

tigerteeth

  • Posts: 733
Re: number 4. You have blocks for height of self, width of self. You could use those as part of the equation for if a hit is successful or not. For example: if the float is greater than the (chance minus height of self), it's a hit.

Re: number 5. You'd need to create a local attribute for each enemy with a HP. In the case of a successful hit, do another random float to decide whether it was a direct hit or just a skim, and then deduct either a lot or a little from the HP.

Re: number 6. You'd have to use global attributes to mark the x and y location of the explosion and then have a behaviour in each enemy character that deducts HP based on their relative location.

Re: your last question. I think you need to decide if you're gonna actually use real physics to do all of this or if you want to do it all with code.

UnrealCanine

  • Posts: 244
so I have an alternative

instead of totally random chance, firing a gun causes multiple pellets to appear around the mouse. The pellets have random poisition based on distance from target and spread factor. However, they do spread in a square like fashion. Anyone know how to create pellets in a circle like fashion?