1st Person Melee Problems

Topics regarding Scripting with Reality Factory
IndigoWraithe
Posts: 13
Joined: Fri Feb 19, 2010 1:28 am

1st Person Melee Problems

Post by IndigoWraithe » Fri Jun 25, 2010 1:40 am

okay, so i searched like crazy through the forums, in the RF manual, and other places but have not been able to find a solution to my problem.

the short story is that i can't figure out why my melee weapon doesn't register as hitting the enemy. I have to get really really close to the enemy for it to register. The weapon i am using is a crowbar attached to a disembodied arm. I added the arm so that the crowbar would have reach without it floating mysteriously in space. what i need to know is just exactly how RF figures out if the enemy has been hit.

when i was unable to damage the enemy until i move in really close, i assumed that it only detects if the bones of the model collide with the enemy bounding box or something like that, since the bones ended at the hand, and there were no bones in the crowbar. so I added a bunch of bones that follow the shape of the crowbar, but that didn't work either. like i said, i looked all over, but there is virtually no info on melee weapons, everything is shooter oriented.


here's a screenshot of my weapon:

Image

as you can see, i have alot of bones running up the length of the crowbar. however, if it helps, i'll mention that none of them have anything assigned to them. the four key bones (upperarm, forearm, hand, and crowbar) are the only ones that have anything attached to them. maybe this is the problem? also, about where the hand meets the crowbar is how close i have to get to hurt the enemy. at this range, the enemy tears you to pieces.


here's the weapon definition:

;*********************************************************
; Crowbar
;*********************************************************
[Crowbar]
type = weapon
slot = 0
firerate = 0.5
catagory = melee
attribute = enemy_health
damage = 15
altdamage = 15
attacksound = swing.wav
hitsound = damage.wav
emptysound = swing.wav
meleeexplosion = GeneralExplosion
meleeammoactivate = false
;
; 1st person
;
viewactor = Weapon\v_crowbar.act
viewfillcolor = 255 255 255
viewambientcolor = 255 255 255
viewrotation = -50 -270 0
viewoffset = 9.30 -35.30 -5.30
viewscale = 1
viewanimationspeed = 1.2
viewarmanim = Idle
viewidleanim = Idle
viewattackanim = Attack1
viewaltattackanim = Attack2
viewhitanim = Attack1
viewalthitanim = Attack2
viewwalkanim = Idle
crosshair = hud\reticle.bmp
crosshairalpha = hud\a_reticle.bmp
crosshairfixed = false
allowlitcrosshair = true
crosshairlitcolor = 255 0 0
bobamount = 10
viewreloadanim = Idle
viewkeyreloadanim = Idle
viewattackemptyanim = Idle
environmentmapping = false
allmaterial = false
percentmapping = 0
percentmaterial = 0
;

any help would be appreciated. i don't want to waste anymore time trying to guess what the problem is, so i hope someone can tell me.

User avatar
AkillezMight
Posts: 20
Joined: Thu Aug 20, 2009 1:46 am

Re: 1st Person Melee Problems

Post by AkillezMight » Fri Jun 25, 2010 3:01 am

Yeah Ive got a melee weapon, its a knife. Those of you familiar with krockadile dundee know what I mean.
I have the weapon ini. set up to where when you shoot, a projectile comes comes out really fast but has a short lifespand. Set damage to whatever, speed to 50,000 and lifetime to .05 or 0.005. Depends. When you go to shank someone the bullet will definately travel faster than Superman but wont go across the room just far enough to get the job done.
Have you ever scripted an enemy pawn that totally owned, that you had to go back into the weapon ini. and create a bigger gun. Just so the fight will be fair? ' ;0

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: 1st Person Melee Problems

Post by GMer » Fri Jun 25, 2010 4:06 am

That's what I do. I didn't want to mess with the melee thing, because of the reasons here.
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
bernie
RF Moderator
Posts: 1249
Joined: Tue Nov 15, 2005 10:07 am
Location: Ireland

Re: 1st Person Melee Problems

Post by bernie » Fri Jun 25, 2010 12:02 pm

This is what I did in Talisman and it worked no problems at all.

Code: Select all

[ESword]
type = weapon
slot = 1
firerate = 0.5
catagory = melee
attribute = health
ammunition = stamina
ammopershot = 4
damage = 20
attacksound = sword.wav
emptysound = sword.wav
hitsound = swordhit.wav
;forceviewto = thirdperson
;
; 1st Person
;
;viewactor = v_cosh.act
viewactor = Weapons\p_Sword.act
viewfillcolor = 128 128 128
viewambientcolor = 128 128 128 
viewrotation = -60 94.4 -13.1
;viewrotation = -7.1 86.9 0
;viewrotation = -3.1 82 -3.1
viewoffset = -0.5 0.5 1.9
;viewoffset = -1.3 -1.5 -0.9
;viewoffset = -0.0 -1.2 -2.2
viewscale = 1.19
;viewscale = 0.08
viewanimspeed = 1
viewarmanim = Arm
viewidleanim = Idle
viewattackanim = Shoot
viewaltattackanim = Shoot1
viewhitanim = Hit
viewalthitanim = Hit1
viewwalkanim = Walk
;viewwalkshootanim = shoot1

;
; 3rd person
;
playeractor = Weapons\v_ESword.act
playerfillcolor = 128 128 128
playerambientcolor = 128 128 128
playerrotation = -90 180 0
playerscale = .87
;viewanimationspeed = 1
;viewarmanim = idle
;viewidleanim = idle
;viewaltattackanim = Shoot1
;viewhitanim = Hit
;viewalthitanim = Hit1
;viewwalkanim = Walk
shootup = Slash1
shootdwn = Slash1

IndigoWraithe
Posts: 13
Joined: Fri Feb 19, 2010 1:28 am

Re: 1st Person Melee Problems

Post by IndigoWraithe » Sat Jun 26, 2010 4:46 am

Bernie, i don't really see what the difference is between this and what i have except for the fact that you have ammunition activated for the weapon, which shouldn't affect my ability to damage the enemy. also, i am specifically asking about an FPS, so if your game isn't first person, than i don't really know that it fixes the issue i am having.

i'd prefer not to have to change it to a shooting weapon as AkillezMight suggested, since it would take away the altattack animation. does no one know what the actual problem is?

User avatar
bernie
RF Moderator
Posts: 1249
Joined: Tue Nov 15, 2005 10:07 am
Location: Ireland

Re: 1st Person Melee Problems

Post by bernie » Sat Jun 26, 2010 12:45 pm

My game has both 1st person and 3rd person & can switch to whichever you want. It works ok both ways. I think you need ammunition set as well try setting it. It worked for me perfectly well like that and I did if for 3 different melee weapons in that game.

User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Re: 1st Person Melee Problems

Post by Gamemaker » Sat Jun 26, 2010 6:44 pm

Why do you need eleven joints, if you can make it only with 5..?

This script worked fine for me. ;)

Code: Select all

[knife]

type = weapon
slot = 0
firerate = 0.2
catagory = melee
attribute = enemy_health
altattribute = enemy_health
ammopershot = 1
worksunderwater = true
damage = 10
meleexplosion = Smoke
hitsound = weapon\knife_slash1.wav
attacksound = weapon\knife_slash1.wav
;
; 1st person
;
viewactor = Weapon\knife1.act
viewfillcolor = 255 255 255
viewambientcolor = 255 255 255
viewrotation = -112.20 107.00 151.40
viewoffset = -3.80 -3.40 2.30
viewscale = 0.03
viewlaunchoffset = 0 0 25
viewlaunchbone = Bip01 R Hand
viewanimationspeed = 1
viewarmanim = knifearm
viewidleanim = knifeidle
viewattackanim = knifeattack
viewaltattackanim = knifeattack
viewhitanim = knifeattack
viewalthitanim = knifeattack
viewwalkanim = kniferun
crosshair = crosshair.bmp
crosshairalpha = a_crosshair.bmp
crosshairfixed = false
allowlitcrosshair = false
crosshairlitcolor = 255 0 0
allowzoommove = false
recoilamount = 10
recoildecay = 5
bobamount = 10
viewreloadanim = knifeidle
viewkeyreloadanim = knifeidle
viewattackemptyanim = knifeidle
environmentmapping = true
allmaterial = false
percentmapping = 0
percentmaterial = 0

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: 1st Person Melee Problems

Post by Allanon » Sat Jun 26, 2010 9:23 pm

Gamemaker wrote:Why do you need eleven joints, if you can make it only with 5..?
Maybe he wants to bend the bar or do collision detection on different sections of the bar.

IndigoWraithe
Posts: 13
Joined: Fri Feb 19, 2010 1:28 am

Re: 1st Person Melee Problems

Post by IndigoWraithe » Sat Jun 26, 2010 11:56 pm

Gamemaker, Allanon: not to be mean, but if you would read the post, you would know.
when i was unable to damage the enemy until i move in really close, i assumed that it only detects if the bones of the model collide with the enemy bounding box or something like that, since the bones ended at the hand, and there were no bones in the crowbar. so I added a bunch of bones that follow the shape of the crowbar, but that didn't work either.


since i have no idea how it detects a hit, i tried a bunch of different things before asking for help.

@Bernie: hmm, well, it's worth a shot. if it works, my many thanks to you my friend.

@Gamemaker: it appears the only real difference between my script and yours is fire-rate, which i will try as well.

thanks for the help that has been given, i will go and implement these changes, and hopefully it will make a difference.

~Wraithe

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: 1st Person Melee Problems

Post by Juutis » Sun Jun 27, 2010 12:11 am

IndigoWraithe wrote:the short story is that i can't figure out why my melee weapon doesn't register as hitting the enemy. I have to get really really close to the enemy for it to register.
I believe RF uses the player's bounding box to determine whether the enemy is close enough or not. The bounding box of the player has to touch the bounding box of the enemy, or something like that. However, I'm not 100% sure and would like a confirmation on this one.
Pain is only psychological.

IndigoWraithe
Posts: 13
Joined: Fri Feb 19, 2010 1:28 am

Re: 1st Person Melee Problems

Post by IndigoWraithe » Sun Jun 27, 2010 12:18 am

@Juutis: thank you. if that is the case, then it doesn't matter how much "reach" i give the weapon if the enemy doesn't come close enough to the player bounding box. that's at least a step in the right direction to solving the problem.

@Bernie/Gamemaker: i implemented the solutions you two proposed, but to no effect. which would make sense given what Juutis has said.

as with Juutis, some confirmation would be nice, as this would totally explain what is going wrong and perhaps i could figure out a way to work with it, or just bite the bullet, so to speak, and implement the projectile workaround proposed earlier.

thanks to everyone. hopefully i can get this matter resolved one way or another.

~Wraithe

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: 1st Person Melee Problems

Post by QuestOfDreams » Sun Jun 27, 2010 9:40 am

The melee attack indeed uses a bounding box to check for collision. This BB is based on the player's BB: it has the same width but only half of height of the player's BB; it is offset 1/4 of the player's BB height in the Y direction and 5/4 of the width in the direction the player is facing.

You don't need to specify ammunition for melee weapons. However, if you do so the specified attribute will be reduce by ammopershot each time you attack. If you run out of ammunition you won't be able to attack anymore.

Wraps
Posts: 41
Joined: Sun Jun 06, 2010 2:04 am

Re: 1st Person Melee Problems

Post by Wraps » Mon Jun 28, 2010 3:15 pm

I think, just by judging from his first post, that he's trying to implement a true First person-type melee object with just the arm as the main actor.Not sure how Rf would do that.........He's not trying to use a melee object with a full height .act,only a partial height .act ( from what it looks like).

RF is more of a third-person-style engine....you have to attach the melee weapons to a complete .act model, from what I've seen.


Maybe you can do that, and set your camera to first person?Unless there's a specific reason why you only want an arm?


Do that, and then attach the melee model to it, and the methods above will work perfectly.

IndigoWraithe
Posts: 13
Joined: Fri Feb 19, 2010 1:28 am

Re: 1st Person Melee Problems

Post by IndigoWraithe » Tue Jun 29, 2010 12:00 am

@QoD: thank you for clearing that up for me. in the end, i will have to use the projectile work around. the point of having a melee weapon with some reach is to be able to attack the enemy from a safe distance. but in RF if you are close enough to attack the enemy, the enemy is also close enough to attack you. since i am working on a survival/horror type game, that would make the melee weapon pretty useless.

@Wraps: what you are proposing i do not believe is possible in RF, nor is it what i'm trying to do. as for RF being a third person engine, it is both third and first. in third person, it is true that you have a main actor and you attach stuff to him. but in first person, you need not have an actual main actor. you can use an actor that is simply a single bone as a stand in, since the weapons don't attach, but free float and are positioned relative to the actor's center point. while it would be possible to attach a camera to the actors face and "fake" a first person perspective via the fixed camera, that's alot of extra work that is probably not worth doing.

anyway, everything is cleared up for me now. so, there is no need to discuss this further. thank you to everyone who answered my post. the help was greatly appreciated.

~Wraithe

Wraps
Posts: 41
Joined: Sun Jun 06, 2010 2:04 am

Re: 1st Person Melee Problems

Post by Wraps » Tue Jun 29, 2010 3:58 pm

I know in other engines, there's a type of " vweapon".Never knew RF could do that.If you read what QoD said, the bounding box is determined by the size of the main actor.If the main is the arm, and the weapon is what's supposed to hit something with....might have to make the main actor larger, just based on what QoD said about the bounding box size.

Just an idea.


It'd be nice in some engine some day to be able to set collisions from the editor itself.

Post Reply