Scripts / collision with an object

Author
Message
Lafette II
12
Years of Service
User Offline
Joined: 15th Oct 2012
Location:
Posted: 17th Feb 2018 17:52
Hi...

I have a little problem with a script.
The player should die if he collides with a certain object. I've made something together which works that way, but if I touch the object with a larger distance, nothing happens. Is there a simple solution? I would be very grateful for that.



Sorry for my miserable scripting
I can not do it better.

Lafette
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Feb 2018 18:03
Not sure I understand the problem, you have specified a distance of 40 in the script so why would you expect to have it hurt the player at a greater distance?
Been there, done that, got all the T-Shirts!
PM
Lafette II
12
Years of Service
User Offline
Joined: 15th Oct 2012
Location:
Posted: 17th Feb 2018 19:03
Thank you for your prompt reply. But i did not describe it well, here is a little video ...



That may be more understandable.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Feb 2018 19:31
Ahh, I see.

The PlayerDistance function will measure from the 'origin' of the model.

What you need instead is to detect when the player is in between the spear points rather than just a distance from the origin.

So what I would do is work out the xyz offsets from the middle for the points where the spear points start and calculate when the player is within a certain distance of the centre or either of those points, make the distance large enough to just overlap, if that is still too large make 5 points.

My utillib.lua module has all the component parts you need.

Btw you will need to rotate the x,y,z offsets by the angles of the model (again that function is in utillib.lua).

If you can give me the xyz offsets I can knock up a quick script that will do the job.
Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Feb 2018 21:08 Edited at: 17th Feb 2018 21:09
Try this, I've commented it so you can see what each bit does, obviously I've had to make a few assumptions and couldn't test the animation or sound bits.

Let me know if you need the utillib.lua script, it is in the latest GG build but you might still be on the DX9 version.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
UNIRD12B
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd May 2014
Location: Canada
Posted: 18th Feb 2018 15:30 Edited at: 18th Feb 2018 15:39
hi Lafette II ,
im sure not the Lua scripter that AmenMoses is by far ,
but this little lua script might work and be simple to set and place
and function and need to know nothing at all about the relative
position of the object you want to cause the players death.
Your other script can handle all the animation of the spears
and this one will kill him for sure , or you can change the damage
ammount to lessen his health with each hit.
You just place a TriggerZone to cover the are you want to effect the player
and add this script to it and Voila !...he dies and restarts.
let me know if it works for you at all if you want to give it a try.
save it as
killingzone.lua



Thx

UNIRD12B
Let\'s actually make something happen with this one !
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Feb 2018 16:12 Edited at: 18th Feb 2018 16:12
I think Lafette II needs a script to go with the model so zones are not a good solution as it makes the model too complicated for the users to use.

Now that the utillib is part of the GG distribution store scripts can be written to use it, not only will it ensure the store scripts work reliably but it will enhance performance across the board for all games made with this scripts.
Been there, done that, got all the T-Shirts!
PM
UNIRD12B
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd May 2014
Location: Canada
Posted: 18th Feb 2018 16:42
Hi AmenMoses ,
like I said , you have WAYY more experience and ability in this field than me.
I was only trying to come up with a simple method that would be totally independent
of any model but could be placed in conjunction to any model and used as a way to affect the player
within a certain base area close to that model in a specific way.
Like for example if he approached a barrel that was radioactive or an electrified fence or
if he fell in a pit trap or something similar.
Always appreciate your ideas and input as they help me stretch my thinking about lua and teach
me more ways of doing things....BOTH you and Smallg.

Thx

UNIRD12B
Let\'s actually make something happen with this one !
Lafette II
12
Years of Service
User Offline
Joined: 15th Oct 2012
Location:
Posted: 18th Feb 2018 19:40

Hi...

@ UNIRD12B
Thanks for your help and your script. I will definitely use it somewhere. But in this case, I wanted to bypass the whole trigger zone thing to provide a simple solution without any hassle.

@AmenMoses
Your killing zone works great. I just have to watch that I get the animation to work. Thank you also for the quick help ...
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Feb 2018 19:47
I didn't know what the orientation of your model was so went for longest dimension being along the x axis, if instead it is along the z axis you will need to edit this line:

local vx, vy, vz = U.Rotate3D ( 0, 0, distBetweenChecks, exa, eya, eza )
to
local vx, vy, vz = U.Rotate3D ( distBetweenChecks, 0, 0, exa, eya, eza )

Once you have that set, and tailor the 'width' parameter to suit the model then is should work at all angles.
Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-12-22 19:32:09
Your offset time is: 2024-12-22 19:32:09