How can I get the Rock to Fall upon the player colliding with the trigger box BELOW the rock












0














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.










share|improve this question




















  • 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
















0














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.










share|improve this question




















  • 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














0












0








0







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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma