HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Useage of CreatePhysicsBoxCharacter()  (Read 3225 times)

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Useage of CreatePhysicsBoxCharacter()
« on: Jan 19, 14, 05:42:03 AM »

In my journey through physic i am using the "CreatePhysicsBoxCharacter()" _external Function, but it leads to some questions:

1. What is the parameter "physics_character_id_out references ID" representing ?
How can i get information about the Character_Object referenced?
I cant access any information. "\sn /sn" doesnt show any properties. Which seems normal, as its an ID that starts with "1". If you create more PhysicBoxCharacters() this ID is counted upwards.
Which function is meant to be used to get information about the physics_character_id?


2. Is there a tool that displays properties for PhysicsBoxCharacter?
The output shows, that the Object has been created, but i cant trace anything.
Do I need to search for a PhysicServer Logfile?

3. If MovePhysicsCharacter() is called and it returns "true", what does the vector
    in the callback method mean?


The Callback Methods looks like: _PHYSICSCHARACTERMOVECOMPLETE(a as ID,b as Vector3)
In the case below the returned vector is always (0,0,0).
Does it mean the move operation was calculated, but the move was denied?

4. Explanation of Parameters in CreatePhysicsBoxCharacter() 
I dont untersand parameters like "extents as Vector3, slopeLimit as Float, skinWidth as Float"
Is there any documentation available? Or a working code example?
If i search ALL client and ALL server scripts I still dont find a single code line that uses this _external function.



Code: [Select]

acct as NodeRef of Class E_playerAccount = SYSTEM.REMOTE.CLIENT
pc as NodeRef of Class E_playerCharacter = acct.GetMyChar()
phys_id as ID
pos as Vector3 = pc.GetPosition()

//We need a requester Node, simply take the selected "clicked" target
ctarget = MiscUtils:ClientToServerNode( acct.GetClickTarget() )
myid as ID = ctarget

//Specify class that handles callbacks from physic operation
glomclass("EO_Physic_Node",myid)

//Extents - ? no idea what the input means
newvec as Vector3
newvec.x=1
newvec.y=1
newvec.z=1

//FYI: How the Method is described in _external
//CreatePhysicsBoxCharacter( requestingNode as NodeRef, physics_character_id_out references ID, extents as Vector3, slopeLimit as Float, skinWidth as Float, position as Vector3, gravity as Float ) as Boolean

if CreatePhysicsBoxCharacter( myid, phys_id, newvec, 2.0, 1.4, pos, 1.0 ) == true
   $CHAT.ChatPlayer( acct, "","Physic Created box: "+phys_id)
.

if MovePhysicsCharacter( ctarget, phys_id, pos ) == true
  $CHAT.ChatPlayer( acct, "","Physic Box moved: "+phys_id)
.


Output when Executed:
Physic Created box: 1
Physic Box moved: 1

[hsl_debug] 9223372056307022385,4: SCRIPT[EO_Physic_NodeClassMethods]: physchar created:9223372073882021740 a:1 b:true

[hsl_debug] 9223372056307022385,4: SCRIPT[EO_Physic_NodeClassMethods]: physchar moved:9223372073882021740 a:1 b:(0,0,0)




Code: [Select]
Class EO_Physic_Node

method _PHYSICSCHARACTERCREATED(a as ID, b as Boolean)
  println("physchar created:"+me+ " a:"+a+" b:"+b)   
.

method _PHYSICSCHARACTERMOVECOMPLETE(a as ID,b as Vector3)
  println("physchar moved:"+me+ " a:"+a+ " b:"+b)
.

// !Information
//  the me object in those objects is not kindof PhysicInstance
//  So you cant access properties or handle it alike
 



Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #1 on: Jan 19, 14, 06:57:53 PM »

Extents are generally the dimensions of the box from the center point.

An extent of 1,1,1 would create a cube that is from the center point 1 unit in each direction.
   1    1
┌──┬──┐
│    │    │1
├──┼──┤
│    │    │1
└──┴──┘
   1    1
Logged

Kaithro

  • Developers
  • *
  • Posts: 22
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #2 on: Jan 21, 14, 09:35:50 PM »

I am not an authority on this subject and I cannot answer all your questions, but here is the code I was able to get working.

  StartPhysics()
  PlayerID as ID = SYSTEM.REMOTE.CLIENT
  //PID references PlayerID
  if not CreatePhysicsCapsuleCharacter(subject, PlayerID, 2.0, 2.0, 0.35, 0, pos, 1 )
    println("could not create a PhysicsCapsule for GUID:" + SYSTEM.REMOTE.CLIENT )
  .

I recall just guestimating some of the parameters to get the capsule to roughly fit the character model I was using.  Your parameters may be a little different but should be easy enough to work out.

Edit:   Oh, and if it is not clear, this is part of a server script.
Logged

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #3 on: Jan 23, 14, 12:36:51 PM »

@Kaithro:
How does your capsule behave?
Is it a clientside controlled capsule (like a player?).
How can you further control your capsule (e.g. make move tests)?
Do you see the capsule in the Heroblade? (Physics wireframe boundry or such?)
Logged

Kaithro

  • Developers
  • *
  • Posts: 22
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #4 on: Jan 24, 14, 04:26:58 PM »

It appears in HeroBlade in wire-frame form when you have the right options selected.  It is attached to the character avatar it was created for.  It basically shows where collision detection will take effect for the character. 
Logged

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #5 on: Feb 02, 14, 11:01:43 AM »

Can you add the lines that do the assignment of vars "subject and pos" to your example?
Its not working here. I dont see any new capsules ever be created.

Tried all kind of visualizations "checkboxes" in physics windows.
I do see already existing capsules as wireframes, but never a new one.



>>
  PlayerID as ID = SYSTEM.REMOTE.CLIENT
  //PID references PlayerID
  if not CreatePhysicsCapsuleCharacter(subject, PlayerID, 2.0, 2.0, 0.35, 0, pos, 1 )
    println("could not create a PhysicsCapsule for GUID:" + SYSTEM.REMOTE.CLIENT )
  .
Logged

Kaithro

  • Developers
  • *
  • Posts: 22
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #6 on: Feb 02, 14, 12:39:18 PM »

oops, that was a bit sloppy of me. 

Here is the server script I was using:

untrusted function Start(subject as NodeRef, pos as Vector3)
  StartPhysics()
  PlayerID as ID = SYSTEM.REMOTE.CLIENT
  if not CreatePhysicsCapsuleCharacter(subject, PlayerID, 2.0, 2.0, 0.35, 0, pos, 1 )
    println("could not create a PhysicsCapsule for GUID:" + SYSTEM.REMOTE.CLIENT )
  .
.

I removed the comment because it may confuse people, I was just working out how to get that reference parameter working right.
Logged

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #7 on: Feb 02, 14, 01:03:22 PM »

:) what do you PASS as content for the subject?
Logged

Kaithro

  • Developers
  • *
  • Posts: 22
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #8 on: Feb 02, 14, 10:11:21 PM »

This is the relevant code in the client script:

        pos as Vector3
        GetNodePosition( SYSTEM.INFO.PLAYERCHARACTER, pos )
        call server KenElevatorPhysicsClassMethods:Start(SYSTEM.INFO.PLAYERCHARACTER, pos )

If you still can't get it to work let me know, I may have inadvertently assumed it was working for me when the capsule I was looking at was already there.  I can double check that by trying the physics box instead.
Logged

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #9 on: Feb 03, 14, 02:53:08 PM »

I will try your example as well, now that i know the "exact parameter assignments".
I have only seen already existing capsules so far.
Anyhow always a "true" is returned from physics calls. I disbelieve the actual state of the physics server.
And surprisingly noone ever tried to look into a physics logfiles (see other thread).

*Ok tested your implementation and:
i cant see new physics capsules beeing created (despite the obvious, returned TRUE from the function)
« Last Edit: Feb 03, 14, 03:02:34 PM by Tarra2012 »
Logged

Kaithro

  • Developers
  • *
  • Posts: 22
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #10 on: Feb 03, 14, 04:01:15 PM »

I tried using the PhysicsBox instead and I get a script error:  ... method [_PHYSICSCHARACTERCREATED] not found on node [9223372058185021566]

that node number is my character avatar's GUID. 

I guess this bears further investigation, it kind of looks like I missed a step where the target is somehow setup as a physics character.
Logged

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Re: Useage of CreatePhysicsBoxCharacter()
« Reply #11 on: Feb 03, 14, 04:07:02 PM »

Create a class like the one I have shown in my entry post: Class EO_Physic_Node

Glom it to the subject. Now the callbacks work. Its a simple callback error, as the method was not found on the node.
Yet it doent change at all the behavior. "Physics Function return true" yet no evidence to be found, that they actually did sth.
Logged