How can I get the Rock to Fall upon the player colliding with the trigger box BELOW the rock
up vote
0
down vote
favorite
protected override void Update(GameTime gameTime)
{
int dt = gameTime.ElapsedGameTime.Milliseconds;
base.Update(gameTime);
player.storedPos = player.position;
Vector3 storedAcc = acceleration;
acceleration = new Vector3(0, 0, 0);
if (Keyboard.GetState().IsKeyDown(Keys.Left)) player.rotation.Y += 0.1f;
if (Keyboard.GetState().IsKeyDown(Keys.Right)) player.rotation.Y -= 0.1f;
player.velocity *= 0.9f; // friction
if (Keyboard.GetState().IsKeyDown(Keys.Up))
{
acceleration.X = (float)Math.Sin(player.rotation.Y) * 0.001f;
acceleration.Z = (float)Math.Cos(player.rotation.Y) * 0.001f;
}
// camera follow
gamecam.position = new Vector3(50, 50, 50) + player.position;
gamecam.target = player.position;
MovePlayer(dt);
foreach (basicCuboid WallSegment in walls)
{
if (player.hitBox.Intersects(WallSegment.collisionbox))
{
ElasticCollision(WallSegment);
}
}
if (player.hitBox.Intersects(door.collisionbox))
{
ElasticCollision(door);
}
if (player.hitBox.Intersects(TriggerBoxRockFall) && !rockFalling)
{
rockFalling = true;
rock.velocity = new Vector3(0, 0.2f, 0);
}
if (rockFalling)
{
Vector3 gravity = new Vector3(0, -0.01f, 0);
}
So this is the code I have so far, I am unsure about how to make the rock actually fall though. What am I missing or have I typed something in wrong? I need the rock to fall upon the player colliding with a trigger box below the rock.
c# xna
add a comment |
up vote
0
down vote
favorite
protected override void Update(GameTime gameTime)
{
int dt = gameTime.ElapsedGameTime.Milliseconds;
base.Update(gameTime);
player.storedPos = player.position;
Vector3 storedAcc = acceleration;
acceleration = new Vector3(0, 0, 0);
if (Keyboard.GetState().IsKeyDown(Keys.Left)) player.rotation.Y += 0.1f;
if (Keyboard.GetState().IsKeyDown(Keys.Right)) player.rotation.Y -= 0.1f;
player.velocity *= 0.9f; // friction
if (Keyboard.GetState().IsKeyDown(Keys.Up))
{
acceleration.X = (float)Math.Sin(player.rotation.Y) * 0.001f;
acceleration.Z = (float)Math.Cos(player.rotation.Y) * 0.001f;
}
// camera follow
gamecam.position = new Vector3(50, 50, 50) + player.position;
gamecam.target = player.position;
MovePlayer(dt);
foreach (basicCuboid WallSegment in walls)
{
if (player.hitBox.Intersects(WallSegment.collisionbox))
{
ElasticCollision(WallSegment);
}
}
if (player.hitBox.Intersects(door.collisionbox))
{
ElasticCollision(door);
}
if (player.hitBox.Intersects(TriggerBoxRockFall) && !rockFalling)
{
rockFalling = true;
rock.velocity = new Vector3(0, 0.2f, 0);
}
if (rockFalling)
{
Vector3 gravity = new Vector3(0, -0.01f, 0);
}
So this is the code I have so far, I am unsure about how to make the rock actually fall though. What am I missing or have I typed something in wrong? I need the rock to fall upon the player colliding with a trigger box below the rock.
c# xna
1
It appears you are using a game framework of some kind. Please add this as a tag to your question. Otherwise this question will be very difficult to answer.
– BJ Myers
Nov 12 at 2:43
Oh sorry, its XNA
– Liam Flanagan
Nov 12 at 4:13
I need a little more information to understand what you're trying, perhaps a screenshot to have a visual idea what you meant. For example I'm not sure if the 'trigger box' is a pressure plate/button, or a square box to intersect with. Does the box needs to be inside, or just on top of it?
– Steven
Nov 12 at 15:37
The trigger box is a square box the player will intersect with, the player just has to touch the box. The box is below the rock.
– Liam Flanagan
Nov 13 at 13:18
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
protected override void Update(GameTime gameTime)
{
int dt = gameTime.ElapsedGameTime.Milliseconds;
base.Update(gameTime);
player.storedPos = player.position;
Vector3 storedAcc = acceleration;
acceleration = new Vector3(0, 0, 0);
if (Keyboard.GetState().IsKeyDown(Keys.Left)) player.rotation.Y += 0.1f;
if (Keyboard.GetState().IsKeyDown(Keys.Right)) player.rotation.Y -= 0.1f;
player.velocity *= 0.9f; // friction
if (Keyboard.GetState().IsKeyDown(Keys.Up))
{
acceleration.X = (float)Math.Sin(player.rotation.Y) * 0.001f;
acceleration.Z = (float)Math.Cos(player.rotation.Y) * 0.001f;
}
// camera follow
gamecam.position = new Vector3(50, 50, 50) + player.position;
gamecam.target = player.position;
MovePlayer(dt);
foreach (basicCuboid WallSegment in walls)
{
if (player.hitBox.Intersects(WallSegment.collisionbox))
{
ElasticCollision(WallSegment);
}
}
if (player.hitBox.Intersects(door.collisionbox))
{
ElasticCollision(door);
}
if (player.hitBox.Intersects(TriggerBoxRockFall) && !rockFalling)
{
rockFalling = true;
rock.velocity = new Vector3(0, 0.2f, 0);
}
if (rockFalling)
{
Vector3 gravity = new Vector3(0, -0.01f, 0);
}
So this is the code I have so far, I am unsure about how to make the rock actually fall though. What am I missing or have I typed something in wrong? I need the rock to fall upon the player colliding with a trigger box below the rock.
c# xna
protected override void Update(GameTime gameTime)
{
int dt = gameTime.ElapsedGameTime.Milliseconds;
base.Update(gameTime);
player.storedPos = player.position;
Vector3 storedAcc = acceleration;
acceleration = new Vector3(0, 0, 0);
if (Keyboard.GetState().IsKeyDown(Keys.Left)) player.rotation.Y += 0.1f;
if (Keyboard.GetState().IsKeyDown(Keys.Right)) player.rotation.Y -= 0.1f;
player.velocity *= 0.9f; // friction
if (Keyboard.GetState().IsKeyDown(Keys.Up))
{
acceleration.X = (float)Math.Sin(player.rotation.Y) * 0.001f;
acceleration.Z = (float)Math.Cos(player.rotation.Y) * 0.001f;
}
// camera follow
gamecam.position = new Vector3(50, 50, 50) + player.position;
gamecam.target = player.position;
MovePlayer(dt);
foreach (basicCuboid WallSegment in walls)
{
if (player.hitBox.Intersects(WallSegment.collisionbox))
{
ElasticCollision(WallSegment);
}
}
if (player.hitBox.Intersects(door.collisionbox))
{
ElasticCollision(door);
}
if (player.hitBox.Intersects(TriggerBoxRockFall) && !rockFalling)
{
rockFalling = true;
rock.velocity = new Vector3(0, 0.2f, 0);
}
if (rockFalling)
{
Vector3 gravity = new Vector3(0, -0.01f, 0);
}
So this is the code I have so far, I am unsure about how to make the rock actually fall though. What am I missing or have I typed something in wrong? I need the rock to fall upon the player colliding with a trigger box below the rock.
c# xna
c# xna
edited Nov 12 at 4:13
asked Nov 12 at 0:19
Liam Flanagan
135
135
1
It appears you are using a game framework of some kind. Please add this as a tag to your question. Otherwise this question will be very difficult to answer.
– BJ Myers
Nov 12 at 2:43
Oh sorry, its XNA
– Liam Flanagan
Nov 12 at 4:13
I need a little more information to understand what you're trying, perhaps a screenshot to have a visual idea what you meant. For example I'm not sure if the 'trigger box' is a pressure plate/button, or a square box to intersect with. Does the box needs to be inside, or just on top of it?
– Steven
Nov 12 at 15:37
The trigger box is a square box the player will intersect with, the player just has to touch the box. The box is below the rock.
– Liam Flanagan
Nov 13 at 13:18
add a comment |
1
It appears you are using a game framework of some kind. Please add this as a tag to your question. Otherwise this question will be very difficult to answer.
– BJ Myers
Nov 12 at 2:43
Oh sorry, its XNA
– Liam Flanagan
Nov 12 at 4:13
I need a little more information to understand what you're trying, perhaps a screenshot to have a visual idea what you meant. For example I'm not sure if the 'trigger box' is a pressure plate/button, or a square box to intersect with. Does the box needs to be inside, or just on top of it?
– Steven
Nov 12 at 15:37
The trigger box is a square box the player will intersect with, the player just has to touch the box. The box is below the rock.
– Liam Flanagan
Nov 13 at 13:18
1
1
It appears you are using a game framework of some kind. Please add this as a tag to your question. Otherwise this question will be very difficult to answer.
– BJ Myers
Nov 12 at 2:43
It appears you are using a game framework of some kind. Please add this as a tag to your question. Otherwise this question will be very difficult to answer.
– BJ Myers
Nov 12 at 2:43
Oh sorry, its XNA
– Liam Flanagan
Nov 12 at 4:13
Oh sorry, its XNA
– Liam Flanagan
Nov 12 at 4:13
I need a little more information to understand what you're trying, perhaps a screenshot to have a visual idea what you meant. For example I'm not sure if the 'trigger box' is a pressure plate/button, or a square box to intersect with. Does the box needs to be inside, or just on top of it?
– Steven
Nov 12 at 15:37
I need a little more information to understand what you're trying, perhaps a screenshot to have a visual idea what you meant. For example I'm not sure if the 'trigger box' is a pressure plate/button, or a square box to intersect with. Does the box needs to be inside, or just on top of it?
– Steven
Nov 12 at 15:37
The trigger box is a square box the player will intersect with, the player just has to touch the box. The box is below the rock.
– Liam Flanagan
Nov 13 at 13:18
The trigger box is a square box the player will intersect with, the player just has to touch the box. The box is below the rock.
– Liam Flanagan
Nov 13 at 13:18
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254569%2fhow-can-i-get-the-rock-to-fall-upon-the-player-colliding-with-the-trigger-box-be%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
It appears you are using a game framework of some kind. Please add this as a tag to your question. Otherwise this question will be very difficult to answer.
– BJ Myers
Nov 12 at 2:43
Oh sorry, its XNA
– Liam Flanagan
Nov 12 at 4:13
I need a little more information to understand what you're trying, perhaps a screenshot to have a visual idea what you meant. For example I'm not sure if the 'trigger box' is a pressure plate/button, or a square box to intersect with. Does the box needs to be inside, or just on top of it?
– Steven
Nov 12 at 15:37
The trigger box is a square box the player will intersect with, the player just has to touch the box. The box is below the rock.
– Liam Flanagan
Nov 13 at 13:18