About Store Forum Documentation Contact



Post Reply 
Phys hit doesnt work good
Author Message
Truelegend Offline
Member

Post: #1
Phys hit doesnt work good
Hello so i readed the tutorial about detecting object under mouse and i tried add it to my code. Everything works but it shows same User Id to all Characters

so i added
Code:
enum ACTOR_GROUPS
{
    GROUP_CHRS,
};

later in Init function

Code:
REPA(Chrs)
   {
       //Chrs[0].actor.group(GROUP_CHARS).user(Ptr(i));
       Chrs[i].actor.group(GROUP_CHRS).user(Ptr(i));
   }

and for last:
Code:
        if(Physics.ray(start,end-start,&phys_hit)){
         D.text(0,0.9f,  "Ray has hit an actor");
         D.text(0,0.8f,S+"Actor's group: "            +         phys_hit.group);
         D.text(0,0.7f,S+"Actor's user data (index): "+(UIntPtr)phys_hit.user );

        } else {// Mouse on clouds :)

            D.text(0,0.9f,"PhysHit=No");

        }

For Actors group it shows 28 for chrs and player and 31 for background (world)+for statics object. and user index is always 0. on every object ;/ i tried everyting but nothing helps ;/

Can anyone help me please smile
Please help ;/
(This post was last modified: 07-04-2011 07:52 PM by Truelegend.)
07-04-2011 07:20 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #2
RE: Phys hit doesnt work good
Characters use AG_CONTROLLER actor group (which is 28) and terrain uses AG_TERRAIN (which is 31).

There is no need to create a new group for characters, however, custom actor groups should start at 1, not 0:

Code:
enum ACTOR_GROUPS
{
    GROUP_CHRS = 1,
}

There is no such thing as Chrs[i].actor, it's Chrs[i].ctrl.actor.
07-06-2011 07:42 AM
Find all posts by this user Quote this message in a reply
Truelegend Offline
Member

Post: #3
RE: Phys hit doesnt work good
Thanks Driklyn.

But how i can get index of Chr or Stati items ? and Player ?
07-06-2011 06:47 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: Phys hit doesnt work good
Should be working already, if you coded it right:

Code:
REPA(Chrs) Chrs[i].user(Ptr(i));

It's all there in the tutorial...
07-06-2011 08:58 PM
Find all posts by this user Quote this message in a reply
Truelegend Offline
Member

Post: #5
RE: Phys hit doesnt work good
Ok thanks smile
I wrote like that:
Code:
REPA(Chrs){
    
       Chrs[i].ctrl.actor.user(Ptr(i));

   }
and shows 0 to every chr :(
(This post was last modified: 07-07-2011 08:59 AM by Truelegend.)
07-07-2011 08:56 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #6
RE: Phys hit doesnt work good
Yeah, sorry, user is apart of the actor, like you have it now.

If you're going to call that in Init(), you need to call Game::World.update(Cam.at) before setting the user data, as Chrs will have 0 elms until the first update call.
07-07-2011 09:06 AM
Find all posts by this user Quote this message in a reply
Truelegend Offline
Member

Post: #7
RE: Phys hit doesnt work good
Still doesnt work :(

My Init function:
Code:
Bool Init()
{
   Physics.create(CSS_NONE,true,"../Installation/PhysX");
   Sky    .atmospheric();
   Sun.image=Images("gfx/sky/moon.gfx"); Sun.light_color=0.4/*D.ambColor()*0.5*/;
   Sun.image_color=WHITE;


   Ms.cursor(Images("../data/gfx/cursor/cur.gfx"));

   REPA(Chrs){
    
       Chrs[i].ctrl.actor.user(Ptr(i));

   }

      // create the world
   Game::World.init()
              .setObjType(Statics,OBJ_STATIC)
              .setObjType(Players,OBJ_PLAYER)
              .setObjType(Items  ,OBJ_ITEM  )
              .setObjType(Lights, OBJ_LIGHT_POINT)
              .setObjType(Parts, OBJ_PARTICLES)
              .setObjType(LCone, OBJ_LIGHT_CONE)
              .setObjType(Chrs, OBJ_CHR)

            
              .New("world/new.world");


   return true;
}

and my Chr extended class:
Code:
STRUCT(Chars, Game::Chr)
//{
   virtual Bool update();
   Actor actor;
};
[/code]
07-07-2011 09:09 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #8
RE: Phys hit doesnt work good
Read my last post better, more specifically, the last sentence.
07-07-2011 07:40 PM
Find all posts by this user Quote this message in a reply
Truelegend Offline
Member

Post: #9
RE: Phys hit doesnt work good
I tried too what u said. And doesnt work :(. I dont know why. it says i have 4 characters on scene but i controll just 1. And same to Phys_hit
07-08-2011 06:17 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #10
RE: Phys hit doesnt work good
If you're code is the same now as it was, Chrs has no characters in it (i.e. Chrs.elms() is 0), so the REPA(Chrs) isn't even executing.

If you changed the code, post what you have now.
07-09-2011 09:37 AM
Find all posts by this user Quote this message in a reply
Truelegend Offline
Member

Post: #11
RE: Phys hit doesnt work good
Code:
Bool Init()
{
    Physics.create(CSS_NONE, true, "../Installation/PhysX");
    Sky.atmospheric();
    Sun.image=Images("gfx/sky/moon.gfx"); Sun.light_color=0.05;
    Sun.image_color=BLACK;

    Ms.cursor(Images("../data/gfx/cursor/cur.gfx"));

    Game::World.init()
        .setObjType(Statics, OBJ_STATIC)
        .setObjType(Players, OBJ_PLAYER)
        .setObjType(Items  , OBJ_ITEM  )
        .setObjType(Characters, OBJ_CHR)
    .New("world/new.world");
    
    REPA(Characters) {
        Characters[i].ctrl.actor.user(Ptr(i));
    }

    return true;
}
07-09-2011 06:34 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #12
RE: Phys hit doesnt work good
You still didn't understand.

"If you're going to call that (the REPA) in Init(), you need to call Game::World.update(Cam.at) before setting the user data, as Chrs will have 0 elms until the first update call."
(This post was last modified: 07-09-2011 10:51 PM by Driklyn.)
07-09-2011 10:48 PM
Find all posts by this user Quote this message in a reply
Truelegend Offline
Member

Post: #13
RE: Phys hit doesnt work good
Ok. I understand now pfft. Sorry before i was think that was before Game::World.init pfft
07-11-2011 11:47 AM
Find all posts by this user Quote this message in a reply
Post Reply