Added bool in Physics to toggle gravity for entities.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<Physics xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Physics.xsd">
|
<Physics xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Physics.xsd">
|
||||||
<Velocity X="0" Y="0" Z="0"/>
|
<Velocity X="0" Y="0" Z="0"/>
|
||||||
|
<Gravity>true</Gravity>
|
||||||
</Physics>
|
</Physics>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="Velocity" type="t:Vector" minOccurs="0"/>
|
<xs:element name="Velocity" type="t:Vector" minOccurs="0"/>
|
||||||
|
<xs:element name="Gravity" type="t:bool" minOccurs="0"/>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ void PlayerMovementSystem::UpdateComponent(World* world, EntityWrapper& entity,
|
|||||||
ComponentWrapper& cPhysics = entity["Physics"];
|
ComponentWrapper& cPhysics = entity["Physics"];
|
||||||
|
|
||||||
glm::vec3& velocity = cPhysics["Velocity"];
|
glm::vec3& velocity = cPhysics["Velocity"];
|
||||||
velocity.y -= 9.82 * dt;
|
if (cPhysics["Gravity"]) {
|
||||||
|
velocity.y -= 9.82 * dt;
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3& position = cTransform["Position"];
|
glm::vec3& position = cTransform["Position"];
|
||||||
position += velocity * (float)dt;
|
position += velocity * (float)dt;
|
||||||
|
|||||||
Reference in New Issue
Block a user