About Store Forum Documentation Contact



Post Reply 
PhysicsTriggers, Stopping Chr, Disabling collision actorgroup, Stop collision
Author Message
KraaxLeNain Offline
Member

Post: #1
PhysicsTriggers, Stopping Chr, Disabling collision actorgroup, Stop collision
Hi there,

Got several question about Physics, because behavior is not crystal clear for my right now and I'd like to understand exactly how it works to use it the right way.

1) PhysCallback:


How physic wall backs exactly works ? You set it up in main trhread and it is processed in the next physic thread and then disabled ?

For instance I puted this code in my Chr Update :
Code:
if(!has_reached_waypoint)targeted_waypoint.cuts(targeted_waypoint_trigger);

And the callback does this :
Code:
struct TargetedWaypointTrigger : PhysCutsCallback /
{  
   virtual Bool hit(ActorInfo &actor_info)
   {
      if(actor_info.obj)
      {
          [some tests]
          {
          <something stopping the Chr>
          tempChr.has_reached_waypoint=true;
          Log(S+"You found me ! \n ");  
            }
         }
      }
      return true;
   }
};

It works fine but I have a delay stopping the character... At low speed it's barely noticable if I use "extreme" stop methods but at high speed the collided object is often pass before stopping even with this methods.

Nota : I would not use high speeds for my game but use for testing robustness, since I had issues of missing stops with low perf computers.

So I need to know : does thing in the callback processed during the physics (it's the point of callbacks nhé ?) and shall be done immediatly or are they done when the ".cuts" is invoked ?


2) Stopping a chr:


I'd like to stop immediatly a character on a certain event. At some point it oftens "slide" when using "stop move" or "action break" methods.

I've tried this :
ctrl.actor.freezePos() : Does not give a far much better result...
tempChr.input_move=0; That's giving the best result I could get if I pull it right into the previously discussed trigger (but is it a bad thing ? Documentation says it's really really bad habbit to do things in the trigger grin)

Anyway I could never achieve a straight block like I can have if I activate collision (but fr some reason I don't want to) ! Is there a better way to stop my char ?


3) Disabling actor group :


I've put this line in my code on inting the game :
Code:
Physics.ignore(IndexToFlag(AG_PLAYER),IndexToFlag(AG_NPC), true);

I don't notice any difference the two bojects of this kind still collide >_<

Is it normal ? What am I forgetting ?

Edit : Error was using IndexToFlag : Unnecessary >_<



4) Stop collision :


When colliding with an NPC or when they collide with me one is getting pushed (me or them). I'd like to straight stop both. I may do a workaround with a trigger to proceed during any collision (I've also seen quickfix done by others in this forum) but I'd like to prevent pushing in a cleaner way.

Is there any clean tools to say "this actor should not be pushed" ?

I've tested setting gravity to 0 (infinite) when a character stop moving... Did not worked all the time (but seems to work some cases... Weird).


5) Consider specific actor :


Code:
Actor& ignore (  Actor     &actor, Bool ignore=true) ; /

If I make an object ignoring one whole CollisionGroup (AG_Player for instance) and then set that to false for a specific player. Would that player report collision despite the actor group ignoring ?




Have a nice day all !
(This post was last modified: 02-10-2014 09:57 AM by KraaxLeNain.)
02-05-2014 06:38 PM
Find all posts by this user Quote this message in a reply
KraaxLeNain Offline
Member

Post: #2
RE: PhysicsTriggers, Stopping Chr, Disabling collision actorgroup, Stop collision
Okay so for the forth point "Stop collision"

I've tried to use the CollisionReport, comparing the angle between the collided object and my proper direction with a const angle I created (collision_angle=45°)... It works (kind of) but the problem is : it's called after my move to command, so if move called again there is a little bump (the time it found collision) resulting in sliding when two objects keep colliding.

There are few things I could do in order to prevent this from happening, for instance keep record of last (s) collided object and check if they are on the move... Or find a "clear" path using raycast. However these quickfix will result in "semi automated behavior" (searching clear path) or in really constraining behavior (hard to get unstuck from collided object : have to go a little bit back and then turn). I could also try to prevent the colliding thing using raycast and a little bit of steering but again : side effects I might don't want.

So how can I make a clean collision between two chars without one pushing the other ?

-I've tried, beside what I said upper, to override void Game.Chr::enable(), like Gregz suggested in this topic. But this override is now forbidden by the engine (I get an error compiling) !

-I've tried in the Physics.create to put the CSS_XXX parameter saying that object have to stand still on the ground when static : not working.

-I've tried to put density of Chr when stopping to 0 (infinite) not working (besides, don't fix problem in movement).

I'm sure (hope ?) there is something on physics or in the engine I could make for disabling collision "pushing effect" and obtain a collision identical than one with a static object (which works well BTW). In a clean way (I'd like not to play too much with density, because I'm afraid at some point it could create a perverse side effect like throwing one of the chr in the air).

If anyone has the solution for it please share it !

(Besides if some of you wants to have partial source code of the way I investigated I'll share them gladly but I don't consider them "clean").
(This post was last modified: 02-07-2014 09:37 AM by KraaxLeNain.)
02-07-2014 09:33 AM
Find all posts by this user Quote this message in a reply
Post Reply