-
Posts
938 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by tjheldna
-
I did this a while back for a projectile and I'm pretty sure it works like you need, it might help ya... This is called when the entity is created Shape *shape = Shape::Box(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.3F,0.3F, 0.3F); entity->SetShape(shape); shape->Release(); entity->SetPhysicsMode(Entity::RigidBodyPhysics); entity->SetMass(1); entity->SetCollisionType(Collision::Trigger); entity->SetGravityMode(0); entity->AddForce(GetProjectileVelocity());
-
Are you using AddForce or SetVelocity? From my experience SetVelocity should keep you moving in that direction. I think as well you can have mass on it and it will still go in the direction you set and gravity doesn't effect it. Correct me if I'm wrong.....
-
Adding 'Line of Sight' to Computer Enemies(Lua)
tjheldna replied to Haydenmango's topic in Programming
Hey Rick, Instead of hiding the model I believe the proper way is to use SetPickMode(0) before the pick and SetPickMode(Pick::Sphere) after. -
That would be good to have controll over, however what you need to do is, anything that needs no physic collision response is in Set it to trigger and in the oncollision have a switch statement to work out what initiated the collision. I use GetUserData() to store an object and it's type. Something like this.... void TriggerCollision(Entity *entity0, Entity *entity1, float *position, float *normal, float *speed) { BaseObject* object = (BaseObject*)entity0->GetUserData(); if(object->GetBaseType() == kObjectTrigger) { Trigger *trigger = static_cast<Trigger*>(object); if((trigger) && !trigger->IsDisabled()) { //Find what the hit target is BaseObject* hitObject = (BaseObject*)entity1->GetUserData(); if(hitObject) { switch(trigger->GetType()) { case kObjectDeathZoneTrigger: { trigger->Activate(trigger, hitObject); break; } etc.....
-
Modo has some real nice re-topology tools, however it's not free. As for UVW unwrapping I use this 80%+ of the time. http://www.pullin-shapes.co.uk/page8.htm I export out to .obj then unwrap the import it back in it's quick as to use. When in it select the "Select edges" and "Ignore backfacing" then go around your model using "c" to cut or "w" to "weld" When you bring it back into your modeling program you may want to edit the positioning and scale to make better use of your texture map.
-
Hmm I'm not experiencing any jittering when using GoToPoint. Are you only calling the function once? and not every frame?
-
With GoToPoint, the entity turns to face the directing it's moving which is all automatic. It's just the speed it rotates to face the desired direction, it too fast compared to what I want.
-
Do we have the ability to change the rotational speed value when GoToPoint is used? Cheers!
-
+Me if you need more testers.
-
Hi Einlander, This is working in C++ for my trigger class and gives me an onenter and onexit. The trigger saves every collided item to a list. If the item isn't in the list it is onEnter then it is added to the list. In the Physics update checks a value has been set on all objects in the list every loop, if it's not there it's onExit. There is a lot of **** in my code which is not necessary as I did a straight copy paste, but hope it may give you an idea. Cheers! Trigger.h struct CollisionItem { std::string address = ""; bool hasCollision = false; }; class Trigger : public GameObject { public: std::list<CollisionItem*> collisionList; Trigger(long type); ~Trigger(); void EnterWorld(void); void Update(void); std::list<Trigger*>::iterator it; static std::list<Trigger*> List; static void UpdateEach(void); void AddCollision(std::string address); void RemoveCollision(std::string address); void Activate(BaseObject *trigger, BaseObject *activator); void Save(pugi::xml_node *xmlNode); void Load(pugi::xml_node *xmlNode); }; Trigger.cpp std::list<Trigger*> Trigger::List; void TriggerCollision(Entity *entity0, Entity *entity1, float *position, float *normal, float *speed) { GameObject* object = (GameObject*)entity0->GetUserData(); if(object->GetBaseType() == kObjectTrigger) { Trigger *trigger = static_cast<Trigger*>(object); if((trigger) && !trigger->IsDisabled()) { //Find what the hit target is GameObject* hitObject = (GameObject*)entity1->GetUserData(); bool found = false; //Check if item exists std::list<CollisionItem*>::iterator it; for (it = trigger->collisionList.begin(); it != trigger->collisionList.end(); it++) { CollisionItem *object = (CollisionItem*)(*it); if(object->address.compare(hitObject->GetAddress()) == 0) { object->hasCollision = true; found = true; } } //We havent found the hit object so call Entered if (!found) { trigger->AddCollision(hitObject->GetAddress()); hitObject->OnEnter(trigger); } if(hitObject) { switch(trigger->GetType()) { case kObjectDeathZoneTrigger: { trigger->Activate(trigger, hitObject); break; } case kObjectFoodZoneTrigger: { //trigger->Activate(trigger, hitObject); break; } case kObjectLevelLoadTrigger: { if(hitObject->GetBaseType() == kObjectCharacter) { GameCharacter *character = static_cast<GameCharacter*>(hitObject); if(character->GetGamePlayer() == TheGame->GetLocalPlayer()) { trigger->Activate(trigger, hitObject); } } break; } default: { trigger->Activate(trigger, hitObject); trigger->Disable(); } } } } } } void TriggerUpdatePhysics(Entity *entity0, Entity *entity1, float *position, float *normal, float *speed) { GameObject* object = (GameObject*)entity0->GetUserData(); if (object->GetBaseType() == kObjectTrigger) { Trigger *trigger = static_cast<Trigger*>(object); if ((trigger) && !trigger->IsDisabled()) { //Check if item exists std::list<CollisionItem*>::iterator it; for (it = trigger->collisionList.begin(); it != trigger->collisionList.end() { CollisionItem *collItem = (CollisionItem*)(*it); if (!collItem->hasCollision) { GameObject *object = (GameObject*)TheGameWorld->FindObjectByAddress(collItem->address); object->OnExit(trigger); delete collItem; collItem = NULL; it = trigger->collisionList.erase(it); } else { collItem->hasCollision = false; ++it; } } } } } Trigger::Trigger(long type) : GameObject(type) { SetBaseType(kObjectTrigger); List.push_front(this); it = List.begin(); } Trigger::~Trigger() { std::list<CollisionItem*>::iterator collit; for (collit = collisionList.begin(); collit != collisionList.end(); collit++) { CollisionItem *object = (CollisionItem*)(*collit); delete object; object = NULL; } collisionList.clear(); List.erase(it); } void Trigger::EnterWorld() { GameObject::EnterWorld(); //Material *material = Material::Load("Materials/Game/Trigger/triggerAlpha.mat"); //entity->SetMaterial(material); entity->AddHook(Entity::CollisionHook, (void*)TriggerCollision); entity->AddHook(Entity::UpdatePhysicsHook, (void*)TriggerUpdatePhysics); } void Trigger::Update() { GameObject::Update(); } void Trigger::UpdateEach() { std::list<Trigger*>::iterator it; for (it=List.begin(); it!=List.end(); it++) { Trigger *object = (Trigger*)(*it); if(!(object->IsDisabled())) object->Update(); } } void Trigger::AddCollision(std::string address) { CollisionItem *item = new CollisionItem; item->address = address; item->hasCollision = true; collisionList.push_front(item); } void Trigger::RemoveCollision(std::string address) { CollisionItem *item = new CollisionItem; item->address = address; collisionList.push_front(item); } void Trigger::Activate(BaseObject *trigger, BaseObject *activator) { GameObject::Activate(trigger, activator); } void Trigger::Save(pugi::xml_node *xmlNode) { GameObject::Save(xmlNode); short index = 0; std::list<CollisionItem*>::iterator it; for (it = collisionList.begin(); it != collisionList.end(); it++) { CollisionItem *object = (CollisionItem*)(*it); std::ostringstream oss; oss << "coll" << index; xmlNode->append_attribute(oss.str().c_str()) = object->address.c_str(); oss << "has"; xmlNode->append_attribute(oss.str().c_str()) = Utill::BoolToString(object->hasCollision).c_str(); index++; } xmlNode->append_attribute("collInd") = index; } void Trigger::Load(pugi::xml_node *xmlNode) { GameObject::Load(xmlNode); //rot.x = atof(xmlNode->attribute("rotx").value()); int index = atoi(xmlNode->attribute("collInd").value()); //Load link addresses for (unsigned int i = 0; i < index; i++) { ostringstream oss; oss << "coll" << i; CollisionItem *item = new CollisionItem(); item->address = xmlNode->attribute(oss.str().c_str()).value(); oss << "has"; item->hasCollision = Utill::StringToBool(xmlNode->attribute(oss.str().c_str()).value()); } }
-
It's not the normal program I would buy, however I did anyway. It's exactly what I was looking for! Ordering all the ideas in my head; planning and I am finding that new ideas are flowing just from being able to visualise things. I only wish I knew about it earlier! Thanks Einlander!
-
This is an optimisation to opening prefabs as I see it, you may not agree with me so do with this as you want. I'm just starting to get more picky now, as It's getting increasingly harder to find bugs =). When you open up a prefab using File->Load, the prefab in the world is where ever it was when you created it. i.e I save the model in the original scene at x = 30.0, y = 1.0, z = 23.0 If you open up the prefab file you created, the models will be positioned at that location above. I guess I would expect it all centered when I go to edit it at 0.0, 0.0, 0.0. Cheers!
-
I haven't read them in there entirety, but they look really good . Thanks for sharing Yougroove
-
Hi all, What I'm onto now is a bit of story line and I find myself struggling. I'm not really struggling as far as imagination goes, it's rather how to plan on paper what happens in the game from start to finish. Is it really as simple as saying in a word doc or something.. 1. Talk to this guy 2 .Pick up this object etc What if things don't need to be done in order? It could get confusing. Is there some sort of method (program like visio or otherwise) that people use for this purpose? Any thoughts would be great! Cheers
-
Just wondering in future is it going to be possible to take screenshots via the api? Obviously we would have to add the code into our game and assign to a key etc. Or is it available already and I've missed something? Cheers!
- 1 reply
-
- 1
-
Hi All, I've been in 3.0 land all this time and am wondering in 3.1 Material Editor->shader shadow field, do you have to add a shadow shader here? It looks like models are get shadows regardless? Cheers!
-
I asked the same question a while ago also and thought it was a bug. Listeners don't have range. http://www.leadwerks.com/werkspace/topic/7981-listener/ Hope this helps.
-
I haven't tried AlignToVector as it was getting a little late last night, but I'll give it a go and if I do I'll let you know. Event if I don't, the way it is now is perfect. Also do you wan't me to post the C++ code for the align to terrain part? It wasn't hard to do but, this could be real useful for anyone trying to do prone for a character or an animal like I'm doing. Thanks again.
-
Thanks beo6 translated to C++ and is working!
-
I had no I idea that's what it was doing, I did a search for the first child bone and it all animated with physics as expected. I'll have to modify my rig to include a root node I think. Thanks Josh! I guess this isn't a bug.
-
Hi Josh, I'm having an issue with an entity with rigid body physics applied v3.0. This is occurring if you are animating a skinned entity with rigid body, shape and mass. Apply any kind of physics i.e AddForce, gravity etc, the entity is not effected by these forces. Let me know if you need more detail? It's real busy for me at the moment but I'll see if I can do a quick sample of the issue. Cheers!
-
I'm basically creating a quick prototype of an idea I had and am seeing if it is at all possible in Leadwerks 3. In the game you control a 4 legged animal so conforming to the terrain is needed. In LE3 friction seems to be the only attribute exposed for physics objects no linear/angular damping or restitution exposed.
-
Hi, Just wondering if someone knows a solution to my problem. I'm creating a custom character controller with a rigid body object. I'm using AddForce to push the character which is working. My problem is when I turn the object. As the character turns there must still be a residual force still being applied in the old direction. Although the new directional force is being applied and the character starts to drift. I'm using PhysicsSetRotation for the rotation of the object. Any one know what I need to do to stop this drifting (Physics isn't a strong point)? Thanks!
-
The way I did it quickly is to use a timer when you jump after a certain time while airborne you are falling, which surprisingly worked quite well. Thinking about it if you saved the value of your previous y every step and compared it to your current y value while jumping. If it's less then the previous you are falling, maybe that's an idea or a place to start.
-
I haven't even scratched the surface on what it can do also. Just started playing around with the topology tools... Real nice. It just has everything I need and works well with Leadwerks.