Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Killed because too far from a grabbable object
Danny Boy Offline
Posting Freak

Posts: 2,718
Threads: 85
Joined: Mar 2011
Reputation: 81
#1
Killed because too far from a grabbable object

I have a question... is it possible to kill the player if he gets too far from a grabable object? like for example a box?

like for example... i walk whit that object... but i felt like put it in the floor and continue whitout it... after i reach some distance like 10 meters the player simple dies... how can i do this IF possible?
12-23-2011, 12:59 AM
Website Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Killed because too far from a grabbable object

I'm not sure if it is possible to create something similar and practical in order to work around the limitations of the engine (since, as far as i know, you can't attach areas to objects, and GetEntitiesCollide doesn't support Player), but how about changing the game mechanic to being forced to hold the object and when placed down the user has only a certain amount of time to pick the object right back up before dying? GetPropIsInteractedWith should be able to allow for that (though i've never used GetPropIsInteractedWith before).

Tutorials: From Noob to Pro
12-23-2011, 01:18 AM
Website Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#3
RE: Killed because too far from a grabbable object

A similar problem was faced when i was detecting the lantern for my "Observable" map & engine.

Quick overview of one potential solution:
Create a copy of block_box.ent - call it something like "detector.ent". Open it in the model editor and delete it's body. Create a new sphere shape and scale it to be the radius around the object the player must be within to survive. Make the sphere a body, attach the body the sub-mesh. Disable "collides character" and "collides non-character" in the body properties, give the body 0 mass.

In the script for your level, use AddAttachedPropToProp to attach this detector entity to your grabbable object. Then use AddEntityCollideCallback w/ the name of the attached prop and use this to determine if the player leaves the radius of the object. E.g:

void OnStart()
{
AddAttachedPropToProp("PlayerDetector","Grabbable_Object","detector.ent",0,0,0,0,0,0);
AddEntityCollideCallback("Player","PlayerDetector","cbGrabbableRadiusCollide",false,0);
}

void cbGrabbableRadiusCollide(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
   //Player has entered the radius
}
else
{
  // Player has left the radius
}
}
You will want to couple this with SetEntityPlayerInteractCallback to determine if the player has picked up your grabbable object yet.

Edit: clarity.
(This post was last modified: 12-23-2011, 01:53 AM by Apjjm.)
12-23-2011, 01:44 AM
Find
Khyrpa Offline
Senior Member

Posts: 638
Threads: 10
Joined: Apr 2011
Reputation: 24
#4
RE: Killed because too far from a grabbable object

(12-23-2011, 01:44 AM)Apjjm Wrote: A similar problem was faced when i was detecting the lantern for my "Observable" map & engine.
Holy mother of spaghettimonster! I can understand something you explain, and it seems simple!

12-23-2011, 02:01 AM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#5
RE: Killed because too far from a grabbable object

(12-23-2011, 01:44 AM)Apjjm Wrote: A similar problem was faced when i was detecting the lantern for my "Observable" map & engine.

Quick overview of one potential solution:
Create a copy of block_box.ent - call it something like "detector.ent". Open it in the model editor and delete it's body. Create a new sphere shape and scale it to be the radius around the object the player must be within to survive. Make the sphere a body, attach the body the sub-mesh. Disable "collides character" and "collides non-character" in the body properties, give the body 0 mass.

In the script for your level, use AddAttachedPropToProp to attach this detector entity to your grabbable object. Then use AddEntityCollideCallback w/ the name of the attached prop and use this to determine if the player leaves the radius of the object. E.g:

void OnStart()
{
AddAttachedPropToProp("PlayerDetector","Grabbable_Object","detector.ent",0,0,0,0,0,0);
AddEntityCollideCallback("Player","PlayerDetector","cbGrabbableRadiusCollide",false,0);
}

void cbGrabbableRadiusCollide(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
   //Player has entered the radius
}
else
{
  // Player has left the radius
}
}
You will want to couple this with SetEntityPlayerInteractCallback to determine if the player has picked up your grabbable object yet.

Edit: clarity.
So much was said here but wow... Genius. I need to think a little further into this, I could use this trick for my campaign a bit =]
12-24-2011, 12:19 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#6
RE: Killed because too far from a grabbable object

I could have sworn i had tested that out a long time ago and it didn't work for me then. Just tried it out now, and it worked. Not sure what i did wrong back then, but at least now i can fix a few issues i had with my Amnesia's Creed map. I remember now what i was trying to do: i was trying to attach a prop onto a monster, but couldn't because monsters aren't considered props.

Tutorials: From Noob to Pro
(This post was last modified: 12-24-2011, 01:39 AM by Your Computer.)
12-24-2011, 12:40 AM
Website Find




Users browsing this thread: 1 Guest(s)