Inlägg

Visar inlägg från mars, 2018

Adding some terrain!

Bron med flera plankor.

Piecing Everything Together - Our Final Project

Below is a summary of all our implementations (and their respective purposes) in our project.  A spring implementation (Hooke's Law)   - In order to simulate the elasticity of the rope-bridge. A shatter implementation   - In order to simulate the planks breaking. A pressure implementation   - In order to simulate when the planks should shatter. A wind implementation   - With the purpose to simulate and demonstrate the elasticity of the rope-bridge. These implementations was finally pieced together and the result is shown in the video below: https://i.gyazo.com/04c8f609283e1aaaf41d685b571e2475.mp4

Wind Simulation based on Vector Fields

Bild
Recap: Our previous wind simulation was based on forces (with constand directions and random magnitude) being applied on the planks of the rope bridge. Process:  We decided to see if the wind simulation would improve if we implemented wind with vector fields. The vector field we used was imported from JangaFX VectoreyGen plugin.  Since there was only a limited number of vector fields to choose between we chose a vector field we thought would match our project.  We chose to work with the inwards vector field which can be seen below: F : R3 --> R3 F(x, y, z) = (-x, -y, -z) The vector field (imported from the plugin) applies forces onto rigid bodies depending on where the they are located. The result can be seen in the gif below: https://giant.gfycat.com/TightImaginativeAlabamamapturtle.webm In order to make the forces more "wind-like" the vector field was given random rotation and translation during run-time. The result can be seen...

Pressure calculation on planks

Bild
We've recently implemented a feature that allows us to calculate the pressure on a given plank. This allows us to set a threshold whenever we want the plank to shatter (using the shatter implementation we recently made a post about). This is what it currently looks like if we manually increase the mass of our cube: To accomplish this simulation, we used the physics formula for pressure which is: P = -F/A Where P is the pressure, F is the magnitude of the normal force and A is the area of the collision. To get P, we first of calculate the normal force using the following formula: F = m*g*cos(theta) Where m is the mass of the object, g is the gravitational field strength and theta is the angle of the inclined surface (currently only looking at the incline on the x-axis, we will be looking into expanding this to atleast one more axis). The mass of the object and constant g are easy to grab, theta however is generated by looking at the difference in rotation of the object ...

Plank rotation and intermediate connection!

We have made some progress regarding the rotation of the planks. In our previous blogg posts the planks of the bridge have had a locked rotation. Using the function AddForceAtPosition from Unitys build in rigidbody solution, we managed to connect our own springs to the corners of the plank causing the rotation of the planks to act in a more normal fashion than they did before! See the videos below for the improvement in behaviour of the bridgeplanks. Before: After: We have also connected the appropriate plank edges together making the planks follow eachother. For example if one plank is hit by an object and gets dragged down, the others will follow (see video below). Oh and don´t mind the falling red robot in the background :) A challenge that waits us ahead is to integrate all the different systems (springs, wind, planks breaking) into one project in Unity, this is due us team members on this project working on different systems in parallell. We are also c...

Shatter effect implementation

We have added a very basic shatter effect for the wooden planks that will make up the bridge itself. This was made using the cell fracture feature in blender that we then imported into Unity where we use physics to make it look like a more realistic effect. Next step will be making a threshold using pressure formulas that will decide if the plank will break or not, currently it will just break when it comes in contact with any object with a certain tag. The effect is created by destroying the intact plank and replacing it with the shattered version where each separate cell has its own physical simulation. This is what it currently looks like:

A very basic wind simulation!

We have recently implemented a very basic wind-system for our project.  Unity has its own built in Wind Zone components that can be added to terrains. However, there is no built in wind-components that affect rigid bodies or simple game-objects. Hence we decided to implement our own implementation of wind in unity. Wind Implementation on Rigidbodies in Unity : 3D forces with fixed magnitude and direction are applied on the planks (rigid bodies) of the bridge. This is done with Unity's built in addForce-function and will make the bridge sway in a wind like motion. See gif below: https://media.giphy.com/media/35Kk3HkaDaMhEVpejw/giphy.gif

An early prototype of the rope bridge!

Using the script for spring system between to Objects as we did in the last blogg entry, we made a first prototype of how our bridge might look. Using multiple spheres connected via springs with different resting distances we ended up with something like this: After making this very simple prototype we decided to make it a little better with planks that can handle collision (via box colliders) and more spring forces connected to each plank to make it more stable. We also connect each plank to its plank "neighbors" via a spring. Note that in order for the planks to not smash together we restricted the planks movement in the z-plane. Now the prototype look like this: Challenges that awaits us ahead are, among others, to figure out how we want our planks of the bridge to be connected to the springs that hold them up. As of now we have locked the rotation of the planks and connect springs to the center of the planks. It would be great if we could have one spring connec...

Implementing springs!

We have now had some time to develop our project in Unity, and we decided that the first was to implement our own spring system between two objects. To do this used Hooke´s law that states that the force from a mekanical spring is proportional to the deviation from the equilibrium. Hooks law looks like this: F = k*x where k is a constant and x is the deviation from the equilibrium. We implemented Hooke´s law into a script in Unity connecting one GameObjects rigidbody to another GameObject. To start of with it looked something like this: As you can se from the video above the current stage of the spring script doesn´t allow the GameObject that is attached to the spring to stop bouncing. To fix this problem we added dampening to the script which, regarding to the rigidbodys velocity and a dampening factor, made the GameObject evetually slow down. Hooke's law together with the dampening force looks like this: F = k*x - b*v where b is the dampening factor (set to 0.8 in t...