On hitting a physical object with any item, the physical object is now removed (vanishes), can be tested on tutorial by shooting bowling balls at the boxes
This commit is contained in:
@@ -3,5 +3,6 @@ void onCollision()
|
||||
/*
|
||||
Currently activates on Kart collisions
|
||||
*/
|
||||
displayMessage("Whoa! Road rage... between Kart: " + getCollidingKart1() + " - " + getCollidingKart2() + " " + getCollisionType());
|
||||
displayMessage("Whoa! Road rage... between Kart: " + getCollidingKart1() + " - " + getCollidingKart2() + " " + getCollisionType() + "ID is : " + getCollidingID());
|
||||
disableAnimation(getCollidingID());
|
||||
}
|
||||
|
||||
@@ -56,14 +56,13 @@ PhysicalObject::Settings::Settings(const XMLNode &xml_node)
|
||||
{
|
||||
init();
|
||||
std::string shape;
|
||||
xml_node.get("id", &m_id );
|
||||
xml_node.get("id", &m_id );
|
||||
xml_node.get("mass", &m_mass );
|
||||
xml_node.get("radius", &m_radius );
|
||||
xml_node.get("shape", &shape );
|
||||
xml_node.get("reset", &m_crash_reset );
|
||||
xml_node.get("explode", &m_knock_kart );
|
||||
xml_node.get("flatten", &m_flatten_kart);
|
||||
|
||||
m_reset_when_too_low =
|
||||
xml_node.get("reset-when-below", &m_reset_height) == 1;
|
||||
|
||||
@@ -132,6 +131,7 @@ PhysicalObject::PhysicalObject(bool is_dynamic,
|
||||
m_init_hpr = object->getRotation();
|
||||
m_init_scale = object->getScale();
|
||||
|
||||
m_id = settings.m_id;
|
||||
m_mass = settings.m_mass;
|
||||
m_radius = settings.m_radius;
|
||||
m_body_type = settings.m_body_type;
|
||||
|
||||
@@ -94,7 +94,7 @@ private:
|
||||
btCollisionShape *m_shape;
|
||||
|
||||
/** ID of the object. */
|
||||
std::string m_id;
|
||||
std::string m_id;
|
||||
|
||||
/** The corresponding bullet rigid body. */
|
||||
btRigidBody *m_body;
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
void hit (const Material *m, const Vec3 &normal);
|
||||
bool isSoccerBall () const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the rigid body of this physical object. */
|
||||
/** Returns the ID of this physical object. */
|
||||
std::string getID() { return m_id; }
|
||||
// ------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -250,13 +250,14 @@ void Physics::update(float dt)
|
||||
Scripting::Physics::setCollisionType("Projectile-PhysObj");
|
||||
Scripting::Physics::setCollision
|
||||
(
|
||||
p->getUserPointer(1)->getPointerPhysicalObject()->getID,
|
||||
p->getUserPointer(1)->getPointerPhysicalObject()->getID(),
|
||||
"item"
|
||||
);
|
||||
script_engine->runScript("collisions");
|
||||
p->getUserPointer(0)->getPointerFlyable()
|
||||
->hit(NULL, p->getUserPointer(1)->getPointerPhysicalObject());
|
||||
PhysicalObject* obj = p->getUserPointer(1)->getPointerPhysicalObject();
|
||||
|
||||
if(obj->isSoccerBall())
|
||||
{
|
||||
int kartId = p->getUserPointer(0)->getPointerFlyable()->getOwnerId();
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <angelscript.h>
|
||||
#include "script_physics.hpp"
|
||||
|
||||
|
||||
namespace Scripting{
|
||||
|
||||
namespace Physics{
|
||||
@@ -33,6 +32,11 @@ namespace Scripting{
|
||||
{
|
||||
gen->SetReturnDWord(m_collidingkartid2);
|
||||
}
|
||||
void getCollidingID(asIScriptGeneric *gen)
|
||||
{
|
||||
void *pointer = &m_collider1;
|
||||
gen->SetReturnObject(pointer);
|
||||
}
|
||||
void getCollisionType(asIScriptGeneric *gen)
|
||||
{
|
||||
void *pointer = &m_collisionType;
|
||||
@@ -65,7 +69,7 @@ namespace Scripting{
|
||||
r = engine->RegisterGlobalFunction("uint getCollidingKart1()", asFUNCTION(getCollidingKart1), asCALL_GENERIC); assert( r >= 0 );
|
||||
r = engine->RegisterGlobalFunction("uint getCollidingKart2()", asFUNCTION(getCollidingKart2), asCALL_GENERIC); assert( r >= 0 );
|
||||
r = engine->RegisterGlobalFunction("string getCollisionType()", asFUNCTION(getCollisionType), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
r = engine->RegisterGlobalFunction("string getCollidingID()", asFUNCTION(getCollidingID), asCALL_GENERIC); assert(r >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace Scripting{
|
||||
void getCollidingKart1(asIScriptGeneric *gen);
|
||||
void getCollidingKart2(asIScriptGeneric *gen);
|
||||
void getCollsionType(asIScriptGeneric *gen);
|
||||
void getCollidingID(asIScriptGeneric *gen);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user