Simulation in Games: Week 5
Week 5’s lecture was all about Mass, Forces and Free Body Diagrams, so that’s what I’ll be going over this blog post! And Spellcaster Academy, naturally.
Mass, Forces and Free Body Diagrams
Mass
Mass is a scalar quantity which:
- Determines the amount of matter in an object.
- Is a measure of inertia.
- Constant for an object, regardless of its location, unless it undergoes a physical change.
Forces
A force is any interaction that, when unopposed, changes the motion of an object. It can be represented as a vector with a magnitude (mass) and its direction (acceleration).
The basic equation for a force is thus:
There are two general groups of forces:
Contact forces
Friction
A force resisting the relative motion of solid surfaces. It is opposite to the direction of the object moving on the surface. Its value is dependant on the normal force and the friction coefficient of the surface.
Normal
A reaction force, produced by the contact between an object and a surface, that is perpendicular to the aforementioned surface. Per Newton’s third law of motion: “For every action, there is an equal and opposite reaction.”
Weight
The force of an object as a result of gravity.
Others
- Applied forces
- Tension
Action at a distance
- Gravitational force
- Magnetic foce
Free Body Diagrams
Diagrams that helps visualize the acting forces on an object in a given time.
Spellcaster Academy
As promised last week, here’s the rundown on how the player works; or more specifically, the player’s movement system.
Move Towards
When the ground is pressed, the Interaction class’s OnLeftClick event is triggered. The player’s MoveTowards method is subscribed to this event and is thus activated. MoveTowards is in charge of taking the position passed into it by OnLeftClick and setting it as the player’s current target position and normalised direction. It also sets an isMoving boolean value to true, activating actual moving functionality in the form of the InputMovement method, which is called by Update every frame.
While isMoving is true, the player will be accelerating towards the target location until the distance between the player’s current location and the target location is less than 1.5 units. Once it is less, the player is at target location and isMoving is set to false.
That’s it for the movement. Until next week, then! And as always, thank you for reading.