About Store Forum Documentation Contact



Post Reply 
Vault, Climb, Jump and Run
Author Message
runewake2 Offline
Member

Post: #1
Vault, Climb, Jump and Run
I'm writing a simple parkour game based on Bloody Massacre and want to add some simple actions.

Pretty much the idea is this:

Their are three (possibly four) raycasts that are from the waist, neck and top of the head. If their is a collision with the waist point but not with the neck point then the player will vault onto the object. If their is also a collision with the neck point as well as the waist point then the player will climb over the object. If the object is higher then the players head they will run up to the wall and stop or continue normally. Finally if their is a cliff the player will jump off of it (no check for a landing place is necassary).

I plan on doing this by having, as stated, three raycasts that test about 1 meter in front of the player. Then setting some variables (can_vault, can_climb, can_jump). If any of these variables are true then the game will perform the action and animation.

Here is a quick picture I drew to show you what I mean:
[Image: %5C%5Clinus%5C2011%24%5Csawron%5CMy%20Pi...xample.png]

My question is how do I do the raycasts? I have not done much with Esenthel and have done nothing with Raycasts. How do I create the three/four raycasts I would need, all aligned facing the y direction of the player and 3 of the four facing flat along the XZ plane? Then the forth cast would have to test if their was any floor beneath the object. I havn't decided if a diagonal or vertical cast infront of the player would be.

If you know of a better way to do this then please let me know.
01-12-2011 04:30 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Vault, Climb, Jump and Run
search for tutorial with Physics.ray
01-13-2011 04:10 PM
Find all posts by this user Quote this message in a reply
Dampire Offline
Member

Post: #3
RE: Vault, Climb, Jump and Run
Raycast parcour system very unstable. I already tried to do this. Requires a combination of raycasting and actor-trigger. Some code from my project, where i realized climbing on wall. Just scanning.
Code:
climb_trigger1 = Box(T.ctrl.radius()*2, 0.1, 0.3);    
climb_trigger2 = Box(T.ctrl.radius()*2, 0.6, 0.3);
actor1.create(climb_trigger1);
actor2.create(climb_trigger2);
actor1.ray(false);
actor2.ray(false);

Matrix actor_matrix;
actor_matrix = T.matrix();
actor_matrix.normalize();
actor1.matrix(actor_matrix);
actor2.matrix(actor_matrix);
actor1.pos(T.pos() +
(T.matrix().y / T.matrix().y.length())*(T.ctrl.height()/2) +
(T.matrix().z / T.matrix().z.length())*(T.ctrl.radius() + 0.15));
actor2.pos(T.pos() +
(T.matrix().y / T.matrix().y.length())*(T.ctrl.height()/2 - 0.11 - 0.3) +
(T.matrix().z / T.matrix().z.length())*(T.ctrl.radius() + 0.15));

ReportTriggerHit rph1, rph2;

actor1.cuts(rph1);
actor2.cuts(rph2);

if(time_to_grab>0)
    time_to_grab-=Time.d();
if(!rph1.collision && rph2.collision && time_to_grab<=0) // we've encountered an obstacle
{
    ctrl.actor.ray(false);
    PhysHit phys_hit;
    if(Physics.ray(actor1.pos() - (T.matrix().x/T.matrix().x.length())*(ctrl.radius()/2)
        + (T.matrix().z/T.matrix().z.length())*(0.3/2),
        -T.matrix().y, &phys_hit)) // cast a ray from camera and check if it hits something
    if(phys_hit.dist>0.1)
    {
       T.pos(T.pos() - Vec(0,phys_hit.dist - 0.1, 0));
       ray_dist = phys_hit.dist;
    }
    if(Physics.ray(T.pos(), T.matrix().z, &phys_hit)) // cast a ray from camera and check if it hits something
    if(phys_hit.dist>ctrl.radius())
    {
        T.pos(T.pos() + T.matrix().z/T.matrix().z.length() *(phys_hit.dist - ctrl.radius()));    
        Vec nFacePoint;
        nFacePoint = T.pos() - phys_hit.plane.normal;        
        Flt angle_delta = AngleDelta(T.angle.x+PI_2, Angle(nFacePoint.xz() - T.pos().xz())); // calculate angle delta between current look angle and target angle
        T.angle.x+=angle_delta;
    }
ctrl.actor.ray(true);
T.ctrl.actor.freezePos(true);
is_climb = true;
}
As result we have this
http://www.youtube.com/watch?v=zdOGiE4Kji0
(This post was last modified: 01-13-2011 04:54 PM by Dampire.)
01-13-2011 04:51 PM
Find all posts by this user Quote this message in a reply
runewake2 Offline
Member

Post: #4
RE: Vault, Climb, Jump and Run
Dampire can you recommend a better way to do this?

I was having doubts when I originally posted this and you say you have tried it and had trouble.

My plan was to have the player move with WASD and use Space as a sort of action bar. You run while it's held down and when you meet one of the obsticles you parkour over/around/under it.

Now I think I might need to do something a little more player dependant.

Thanks for the codes though. I will have to make a lot of changes (probably won't even use them) but they are a great reference, thanks.

Also, your game looks good. But it's really white. To Mirror's Edge for me.
01-13-2011 06:15 PM
Find all posts by this user Quote this message in a reply
Dampire Offline
Member

Post: #5
RE: Vault, Climb, Jump and Run
>>Dampire can you recommend a better way to do this?
I post it above
--Requires a combination of raycasting and actor-trigger(s)
Because only rays works perfectly if you use 2d graphics (rays very thin)
At first scan space in front of the player with physics actor as trigger. And after for precision use rays. This way more faithful, IMHO. At least it works much and much better unlike only rays system.
>>Also, your game looks good. But it's really white. To Mirror's Edge for me.
It is just prototype, not game)))

P.S. Sorry for my english.
P.P.S. Standart player controller is not good for PK-game. You can't change height of actor in realtime.
(This post was last modified: 01-13-2011 07:30 PM by Dampire.)
01-13-2011 07:19 PM
Find all posts by this user Quote this message in a reply
runewake2 Offline
Member

Post: #6
RE: Vault, Climb, Jump and Run
Thanks. I'll see what I can whip together this weekend. I'm really busy at the moment. I guess we'll see how it all works.
01-13-2011 07:28 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Vault, Climb, Jump and Run
cool videos!
01-14-2011 02:55 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #8
RE: Vault, Climb, Jump and Run
I agree, cool videos. Obviously inspired by Mirror's Edge.
01-14-2011 03:58 AM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #9
RE: Vault, Climb, Jump and Run
Really nice and unique graphics. I love the slow motion effects and the contrast of the red really brings it out. Great job Dampire!
01-16-2011 09:05 PM
Find all posts by this user Quote this message in a reply
runewake2 Offline
Member

Post: #10
RE: Vault, Climb, Jump and Run
A few more questions:

1. How do I get the Y Velocity of the player? I am using the default player from bloody massacre and want to add damage that occurs when the player jumps from too high a height. I just need to know 2 things: How do I get the players velocity and how do I tell if the player has hit the ground?

2. Next, how do I change the run and move speed of the player? The codes set
run = Kb.b (KB_LSHIFT);
but how do I change the speed at which the player moves?

3. How do I change the fog in Bloody Massacre? I have not found any code for it. Do I have to change the environmentals and if so where do I save them afterward?

4. How would I implement a simple pointer into the codes GUI? I want to add some simple quest objects and have the player have to find them. I want to add a simple arrow to the minimap that points towards the nearest one and also places an icon at each of the quest objects positions. Basically I want to know how do I find an object near the player of type OBJ_QUEST or something similar?
01-18-2011 06:48 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #11
RE: Vault, Climb, Jump and Run
1. Players[0].ctrl.actor.vel()
Players[0].ctrl.onGround() - but this only works with heightmap ground.

2. check speed variable in Chr structure.

3. I add fog in game Render() function in RM_BLEND render mode:

FogDraw(OBox(Box(D.viewRange(),D.viewRange(),D.viewRange(),Cam.matrix.pos)),0.8,​Vec(0.6));

Check FogDraw and tutotial about local fog in Renderering section.
01-18-2011 08:38 PM
Visit this user's website Find all posts by this user Quote this message in a reply
runewake2 Offline
Member

Post: #12
RE: Vault, Climb, Jump and Run
Thanks Harry.
01-18-2011 08:57 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #13
RE: Vault, Climb, Jump and Run
3. in BM the fog is obtained by settings Sky. parameters
01-18-2011 10:53 PM
Find all posts by this user Quote this message in a reply
runewake2 Offline
Member

Post: #14
RE: Vault, Climb, Jump and Run
For jumping if something is infront of you I used this code:

Code:
Players[0].speed = 9;
         Vec     start, // starting position of ray
                 end  ; // ending   position of ray
         start = Players[0].ctrl_pos.xzy();
         end   = Players[0].ctrl_pos.xzy()+Vec(0,0,3);
         PhysHit phys_hit     ; // phys-hit object for receiving hit parameters if any

         if(Physics.ray(start,end-start,&phys_hit)) // if ray hit something
         {
            input.jump = 7.5;
         }
         else input.jump = 0;

This works, sort of. It causes the player to jump while running but I don't really know what is causing it. The jumping seems random to me. I assume it has to do with the Vec(0,0,3) which I used to calculate a position 3 meters before the player. That doesn't seem to be the case.

Also when I turn on Draw Physics the ray is not visible. Why is this?
01-19-2011 03:04 AM
Find all posts by this user Quote this message in a reply
Dampire Offline
Member

Post: #15
RE: Vault, Climb, Jump and Run
Need to cast ray forward? Replace Vec(0,0,3) by Players[0].matrix().z * (your lenght).
Or so
Code:
Vec    start = Players[0].matrix().pos,
         dir   = Players[0].matrix().z * (your lenght);
         PhysHit phys_hit;
         if(Physics.ray(start,dir,&phys_hit)) // if ray hit something
         {
            input.jump = 7.5;
         }
(This post was last modified: 01-19-2011 12:01 PM by Dampire.)
01-19-2011 12:00 PM
Find all posts by this user Quote this message in a reply
Post Reply