Jump to content

Animation, models tutorial request


epsilonion
 Share

Recommended Posts

I have grown and expanded a lot within the past month with leadwerks and think I have most things figured out, then today lol...

 

I finally got a Character model imported with all the animations, looking good..

 

I looked at the animation manager and the MonsterAI script, my problem is I have not touched animations like this before so I have no idea where to start or what I am looking for or even at tbh.

 

I have modified the MonsterAI.lua script so my character follows me around etc but it would be great to know why and how it follows you about, then there's that when he gets into hitting distance and the game crashes.....

 

Basically what I am looking for is a character see's me moves to a range of me then stands still faces me and does a weapon firing animation, I am having problems figuring it out looking at them two script...

 

I think this would be a great one for a tutorial as most new people like myself would benefit from it, instead of asking the same question over and over.. :D

 

 

Thank you in advance.. :D

Link to comment
Share on other sites

Basically what I am looking for is a character see's me moves to a range of me then stands still faces me and does a weapon firing animation, I am having problems figuring it out looking at them two script...

 

So basically a ranged AI script?

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

I'd go with something like this in the monster script, with an extra parm at the top

 


-- maximum distance to shoot from

Script.ShootRange = 30 --float

 

then a new function later on

 


-- test to see if it is valid to shoot an enemy

function Script:CanShoot(shooter, target)

{

local pi = PickInfo()

 

-- in range at all?

local dist = shooter:GetDistance(target)

if dist > self.ShootRange then return false end

 

-- now do we have line of sight?

if (shooter:Pick(shooter:GetPosition(true), target:GetPosition(true), pi, 0, true)) == false then return end

 

-- did we hit our target?

if pi.entity == target then return true end

 

-- we hit something else

return false

}

 

Then when running through Script:UpdateWorld() on the monster I'd have something like

 


-- test to see if we can target the player

if (self:CanShoot(self.entity, player_entity)) then

-- start by stopping the nav mesh tracking

self.entity:Stop()

 

-- orientate creature to point at player

 

-- run firing animations

 

-- create bullets

 

end

 

I'm assuming you've already done the work for the monster to know what the player entity is. In my code I'd be working with a navmesh and would have done

 

self.entity:GoToPoint(player_entity:GetPosition(true))

 

which I'd be refreshing once every second or so. I'd rather the monster have some lag in response to the player actions rather than be a homing missile smile.png

 

Caveat: the above was just typed in the website, its not run or tested code or any such.

 

Hope this is roughly what you are looking for.

content over form, game play over all.

Link to comment
Share on other sites

The problem with that approach is that the enemy will only attempt shooting from points along the path to you, concider;

 

 

...............(You)
_____|B|___________
/////|R|///////////
/////|I|///////////
/////|D|//(Water)//
/////|G|///////////
-----|E|-----------
...................
...................
..............(Monster)

 

In this case the monster will attempt move over the bridge (because that's the path to you) even though moving to the river side would put him in range to shoot. - and if you do not have a ranged weapon this would be a great advantage to him.

 

It is ofcourse far the easier approach ;)

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

The function itself should be fine, if in range and it has line of sight, then pew pew pew.

 

In that example it won't shoot at you if the range is barely enough to reach across the water. If the shot range were say 50m and the direct distance between player and monster were 40m then it would stop and shoot without crossing the bridge. If a brick wall were in the way blocking the shot then of course it would start moving towards the bridge for a chance of a clear shot.

 

Lets see, if I wanted to keep nav mesh simplicity but allow for across the river type stuff I'd create an invisible sphere around the player of shot range radius then do the pick, if the pick hits the sphere then I'd test at the intersect point whether or not its in the navmesh, if it is I could then make that the go to point otherwise just normal navmesh navigation. I'd probably also make the sphere slightly smaller to allow for players jigging around a bit.

content over form, game play over all.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...