# football94

Member

64

211 Neutral

• Rank
Member
1. ## Double jump 3d

Problem solved I had much help from the link below http://xboxforums.create.msdn.com/forums/t/113607.aspx         modified code bool doubleJump; //logs whether the player has done a double jump yet void DudeGravity2(GameTime gameTime) { float treshold = 0.0f; float terrainHeight = GetExactHeightAt(avatarPosition2.X, -avatarPosition2.Z); if (avatarPosition2.Y < terrainHeight + treshold) { newPos = avatarPosition2; newPos.Y = terrainHeight + treshold * (float)gameTime.ElapsedGameTime.TotalSeconds; avatarPosition2 = newPos; gravityVelocity = 0;// On ground so not falling. //jump if (keyState.IsKeyDown(Keys.L)) { doubleJump = false; gravityVelocity = 1f; // Adjust this value to control height of jump. } } else { // Not on ground so must be falling. //Add in effect of gravity on current velocity. // m/sec^2 float g = -1.10f; gravityVelocity += g * (float)gameTime.ElapsedGameTime.TotalSeconds; //Add effect of velocity to position. newPos = avatarPosition2; newPos.Y += gravityVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds; avatarPosition2 = newPos; //jump if (!doubleJump && keyState.IsKeyDown(Keys.L)) { doubleJump = true; gravityVelocity = 1f; // Adjust this value to control height of jump. } } another way of doing the same thing separate from the dudegavity2 method KeyboardState oldState; KeyboardState newState = Keyboard.GetState(); // get the newest state if (newPos.Y <= 1f) { //jump if (oldState.IsKeyUp(Keys.R) && newState.IsKeyDown(Keys.R)) { doubleJump = false; gravityVelocity = 1f; // Adjust this value to control height of jump. } else { //jump if (!doubleJump && keyState.IsKeyDown(Keys.R)) { doubleJump = true; gravityVelocity = 1f; } } oldState = newState; }
2. ## Double jump 3d

Thanks for the response Norm but I have one more question, is there a way to apply this technique while in mid air like in such games as mario 64( I provided sample examples below)                                                                      Thanks again :)       (Mario does a mid air double jump at about 21 seconds into the video)       here's a 2d version of the midair double jump       here's a 2d jpeg illustration. The character does a mid air jump avoiding the water [attachment=31758:IMG_1356.jpg]
3. ## Double jump 3d

HI everyone Ive been experimenting with gravity in my project and with much input from others Ive managed to add a jumping element, and now I'm working on implementing a double jump to the method but so far Ive run into many brick walls trying to do so, and was hoping if anyone had any suggestions as to how to go about doing it.                                                                       Thankyou             The Methods I used are below             The jump method void DudeGravity2(GameTime gameTime) { float treshold = 0.0f; float terrainHeight = GetExactHeightAt(avatarPosition2.X, -avatarPosition2.Z); if (avatarPosition2.Y < terrainHeight + treshold) { newPos = avatarPosition2; newPos.Y = terrainHeight + treshold * (float)gameTime.ElapsedGameTime.TotalSeconds; avatarPosition2 = newPos; gravityVelocity = 0;// On ground so not falling. //jump if (keyState.IsKeyDown(Keys.L)) { gravityVelocity = 1f; // Adjust this value to control height of jump. } } else { // Not on ground so must be falling. //Add in effect of gravity on current velocity. // m/sec^2 float g = -1.10f; gravityVelocity += g * (float)gameTime.ElapsedGameTime.TotalSeconds; //Add effect of velocity to position. newPos = avatarPosition2; newPos.Y += gravityVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds; avatarPosition2 = newPos; } The method I used to get the height of the terrain (GetExactHeightAt) public float GetExactHeightAt(float xCoord, float zCoord) { bool invalid = xCoord < 0; invalid |= zCoord < 0; invalid |= xCoord > floorPlan.GetLength(0) - 1; invalid |= zCoord > floorPlan.GetLength(1) - 1; if (invalid) return 10; int xLower = (int)xCoord; int xHigher = xLower + 1; float xRelative = (xCoord - xLower) / ((float)xHigher - (float)xLower); int zLower = (int)zCoord; int zHigher = zLower + 1; float zRelative = (zCoord - zLower) / ((float)zHigher - (float)zLower); float heightLxLz = floorPlan[xLower, zLower]; float heightLxHz = floorPlan[xLower, zHigher]; float heightHxLz = floorPlan[xHigher, zLower]; float heightHxHz = floorPlan[xHigher, zHigher]; bool cameraAboveLowerTriangle = (xRelative + zRelative < 1); float finalHeight; if (cameraAboveLowerTriangle) { finalHeight = heightLxLz; finalHeight += zRelative * (heightLxHz - heightLxLz); finalHeight += xRelative * (heightHxLz - heightLxLz); } else { finalHeight = heightHxHz; finalHeight += (1.0f - zRelative) * (heightHxLz - heightHxHz); finalHeight += (1.0f - xRelative) * (heightLxHz - heightHxHz); } return finalHeight; } The terrain I used is from riemers flightsim tutorial(link below)   http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Loading_the_floorplan.php
4. ## Terrain scaling

Hi guys    Ive been experimenting with a terrain from riemers xna tutorial website( link below) and came across a problem with scaling the terrain, in my draw method(code below) I added Matrix.CreateScale and the terrain looks to be scaled but when begin to move across the terrain I get an out of bounds exception and I think the problem is even though the terrain is scaled visually  it still seems to reading the boundary data from the original size of the terrain,so I was hoping if anyone had any tips on how to help me solve the problem.                         Thank you private void DrawCity(string technique) { effect1.CurrentTechnique = effect1.Techniques[technique]; effect1.Parameters["xTexture"].SetValue(sceneryTexture); effect1.Parameters["xWorld"].SetValue(Matrix.Identity ); effect1.Parameters["xLightPower"].SetValue(lightPower); effect1.Parameters["xWorldViewProjection"].SetValue(Matrix.Identity *Matrix.CreateScale(10) * view * proj * Matrix.CreateTranslation(0,0,0)); effect1.Parameters["xLightPosition"].SetValue(position ); effect1.Parameters["xAmbient"].SetValue(ambientPower); effect1.Parameters["xlightsWorld"].SetValue(Matrix.Identity * lightsViewProjectionMatrix); effect1.Parameters["xShadowMap"].SetValue(shadowMap); effect1.Begin(); foreach (EffectPass pass in effect1.CurrentTechnique.Passes) { pass.Begin(); device.VertexDeclaration = new VertexDeclaration(device, VertexPositionNormalTexture.VertexElements); device.Vertices[0].SetSource(cityVertexBuffer, 0, VertexPositionNormalTexture.SizeInBytes); device.DrawPrimitives(PrimitiveType.TriangleList, 0, cityVertexBuffer.SizeInBytes / 3); pass.End(); } effect1.End(); riemers link http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Loading_the_floorplan.php
5. ## uneven 3D tile map

Thanks for the reply HappyCoder but Ive managed to come up with a solution which was to just change the int floorplan into a float floorplan which works perfectly for me since that I now have more options to play around with the number values     Thankyou   new code below public void LoadFloorPlan() { floorPlan = new float[,] { {0.1f,0.1f,0.1f,0.1f,0.1f,0.1f,0.1f,0.1f,0.1f,0.1f,0.1f,0.1f,0.1f,0.1f,0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.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, }; }

7. ## Cloning a 3D Model

Thankyou imoogiBG I never thought of that, thanks for teaching me something new.                                                       Thanks again
8. ## Cloning a 3D Model

Hi guys Ive been researching the sub zero ice clone technique(pic below) in the mortal kombat games and been trying to figure out how I can implement this techique in xna but Im not quite sure how its done and was hoping if anyone would be so kind as to give any pointers or comments on the subject.                                                                                Thankyou       Resources Ive researched so far but still not sure http://xbox.create.msdn.com/en-US/education/catalog/sample/mesh_instancing http://xboxforums.create.msdn.com/forums/p/26056/142855.aspx           Subzero clone pic   [attachment=28614:subzero clone.png]       Subzero clone video from youtube           I think a simpler example of what Im looking for is in the youtube video below when the ball starts to repeat about 35 seconds into the video

13. ## Shadow Casting

FANTASTIC!!   Thankyou so much L. Spiro for answering my post and for taking time out of your day to help me with my problem, its people like you that make these forums so great.                                    Thanks again       below is a pic after adjustments [attachment=18847:11 20 2013 7 43 51 PM.jpeg]