Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Alter Game Through Perception

Author
Message
Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 1st Feb 2012 03:24 Edited at: 1st Feb 2012 03:25
Hello all,

so I have a concept for a game I want to try, but need a little help on how I would go about doing it. So here it is:

A game in first person, where there will be a small block or something in front of a gap in the floor, like this:


The trick to this game is to solve how to get past the gap, so you back up until you can see the wall and the gap, but the wall looks like it covers the gap. Press a button (like "z" or something) and all the sudden there will be a bridge where the wall appeared to cover the gap when you were backed up. I wanna know how I could do this process. it could be a simple as recreating the wall into the gap, but how would I do this?

Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 2nd Feb 2012 21:14
anyone?

Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 3rd Feb 2012 02:32 Edited at: 3rd Feb 2012 02:38
i think i understand. the gap (obstacle) only exists because the player sees it. if the player cannot see the gap (in your example, the wall hides it from vision), the obstacle ceases to exist and the player can continue onward.

in its simplest form, the logic would be whether the gap is or is not visible, which would be relatively simple to pull off.

but, you want the player to use the wall to eliminate the obstacle. otherwise, if the player simply turned around, facing away from the gap, ducked or otherwise couldn't see the gap, the above logic would be satisfied and the bridge would spawn, regardless.

so, you'd need to check that the wall is visible (probably the side of the wall opposite the gap, right?), that the gap is not and, probably, that the player is facing the gap.

satisfy those conditions and the bridge would spawn so the player could be on his/her merry way.

does this sum it up? if so, some math and variable comparisons could perform those checks (and maybe commands like intersect object would help some of that). if the results were within your set bounds, we'd be ready to move on to the next puzzle.

Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 3rd Feb 2012 04:10
hmmm that might work. How could I make it dynamic in the sense that if you are looking at it at an angle it would create the bridge based on that angle?

Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 3rd Feb 2012 04:58 Edited at: 3rd Feb 2012 05:10
Quote: "create the bridge based on that angle"


yrotate object bridge, camera angle y()

?

depending on how "extreme" the angle might be, i'd either:

1) cap the angle at, say, ±45 degrees if you'd use a static bridge object/model (which you'd put together to accomodate the maximum distance involved).

or

2) develop a simple but dynamic "bridge building" routine. think Legos™ :



or



whichever you choose

Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 3rd Feb 2012 21:45
well how would that still fit the gap?

Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 6th Feb 2012 02:00
okay, so Maybe I didn't explain this well enough. Ill post the example again:



So I need a dynamic system that can, based on the perception of the camera which is in first person, take whatever obstructions of view that block the gap (in this case the wall) and fill the gap BASED ON THE PERCEPTION OF THE WALL. that means there could be infinite angles and possibilities for the gap to be covered, based on where the player is and how it's looking at the wall blocking the gap.

If anyone has any idea of how I could implement this, please share

Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 7th Feb 2012 02:17
perhaps trying to take the camera data (position and angle), and have a limb attatch to it and if it intersects somehing check if there is a gap and extend the block?

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Feb 2012 08:45 Edited at: 7th Feb 2012 09:05
@Derekioh

I think get what you're saying now! This isn't so much about the physical building of the bridge as it is the "trigger" that makes the bridge happen.

There's a couple of ways you can get the trigger to happen. Here's one:

1. You have 2 positions that are the farthest edges of the wall. You move the camera around in first person and you take it's position as you go along, etc.

You compare the distance from the camera position to each of the 2 key points at the edges of the wall. The distance from the camera to each of the positions individually have to be within a range or exact distance you specify. This distance would be based on where the camera would be in relation to the wall to create the "perception" (perspective) you desire. You can also check the y angle of the camera to make sure it is within a certain range so that you know the camera is facing the wall.

Here's an example (written in DBC but should work for DBPro). You have to navigate the camera using the arrow keys and the mouse to face the center of the wall such that the edges of the wall cam be seen within the screen but just at the edges. The range is between 140000 and 190000 units (squared distances to avoid calculating the sqrt() ).

When in range, the wall will fall across the gap.



It's not real complicated and you can box the limits by adding more points to check from, etc and make sure to check the camera angle.

A simpler variation would be:

2. Just create an area, or a plane or some invisible object that is a certain distance from the wall. Place an invisible object at the cameras position and if it collides with your hidden area, that's the trigger to activate the gap bridging. Again to keep the idea of the perspective triggering the event, have a check for the current camera angles and if they are within a certain range (one you decide on that has the perspective you want) then whammo! The hidden area can rotate from the center of the wall based on a radius and an angle that the camera is at. This way, you can address any angle you want to bridge the gap.

In the case of the two edge positions for number 1, just rotate their position around the y axis based on the center of the wall and the camera position to the center of the wall. That angle is found with



Enjoy your day.
Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 7th Feb 2012 12:33
I think that might work! Ill try it out today! I tell you my results, thanks Latch

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Feb 2012 22:30 Edited at: 8th Feb 2012 01:22
@Derekioh

I thought about what you had written a little more and I get the impression that you want the bridge to change shape or angle based on the position of the observer (camera). I didn't take this approach before because based on your diagrams, the camera was always centered behind the wall, which made me think that the bridge would only form when the user was behind the wall in such a way that it blocked the gap completely from view.

Now the vibe I get is that you want the angle of the bridge to change. I though this was quite interesting so I knocked together an example of that!

It's similar to the idea I posted earlier but without the distance check. The trigger is the left mouse button and the right mouse button.

When you press the left mouse button, the wall will fall and all of the stacked bricks will shift left or right across the gap based on the camera angle. When you press the right mouse button, the wall will stand back up.

The example I'm supplying actually has very little code. Half of it is just drawing the brick texture! The idea is the wall is made up of individual blocks. Each block is a limb tied to the base block. Each block is offset a certain distance from the key block which is in the bottom center position.

Based on the camera y angle relative to the y angle of the wall, the blocks are shifted on the local x axis (i.e. the x axis of the wall object itself - not the world axis) when the trigger is set off. This is accomplished by using only the x portion of polar coordinate calculations. That sounds more complicated than it is... basically the value for the shift is



Which can be attained using the newxvalue() command



So, here's the example:



The same idea could be used for a single mesh - say an actual bridge model. The difference would be that you would have to shift the local x vertices. That would likely skew the bridge in strange ways, but you could put a limit on just how far the verts get shifted. The transformation from the wall to the bridge could be handled in various ways (as was discussed in a previous thread and also some suggestions were made in this thread).

But I think (hopefully), this is what you are after.

Enjoy your day.
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 7th Feb 2012 23:05
@Latch: I tried your example, quiet nice indeed! And I think that it is what he wants

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 8th Feb 2012 01:07
Latch, I love you this is exactly what I need, and I shall mess with this some. I eventually want to apply this for almost anything so make dynamic and solve other puzzles through perception. but thank you!

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Feb 2012 01:20
@Cybermind
Thanks!

@Derekioh
Thanks!

I just thought of something though; in the command:



the 30 is based on the y height of an individual block. You can increase this value to make a larger shift left or right or decrease it to make the shift less dramatic. The size of the blocks and the shift will ultimately determine the true angle of the bridge.

Enjoy your day.
Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 8th Feb 2012 01:24
okay, thanks

Login to post a reply

Server time is: 2026-07-10 04:20:35
Your offset time is: 2026-07-10 04:20:35