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
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


Messages In This Thread
RE: Killed because too far from a grabbable object - by Apjjm - 12-23-2011, 01:44 AM



Users browsing this thread: 1 Guest(s)