How to access cloned objects?

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

How to access cloned objects?

Postby Locutus » Sat Mar 09, 2013 9:52 am

Hey guys!

I have a question, maybe someone here might be able to help me. For an Uru machinima project I need to create multiple Bahro custom avatars and control them individually. I know how to create and control one of them just fine, and I can clone the one, but how can I control the clones...

In the "Funhouse" Python script collection I found a function that clones objects, using the PtTransferParticlesToObject Plasma function. For one, I'm wondering how that function clones things, its name totally doesn't sound like it. :)

And then, how can I get ptSceneObject instances for each of the cloned objects?

Thanks a lot in advance for any help!
Locutus
 
Posts: 29
Joined: Sat Mar 09, 2013 9:41 am

Re: How to access cloned objects?

Postby Christopher » Sat Mar 09, 2013 10:21 am

Do I understand it correctly that all you want to do is to spawn multiple Bahros and controll them? If this is the case you can either make some NPC Spawner in Max (or Blender if this is supported by PyPRP) or you use
Code: Select all
key = PtLoadAvatarModel(modelname, spawnpointkey, userstr)

key is the ptKey object of the NPC Sceneobject, modelname is the name of the model you want to load, spawnpointkey is the ptKey from the ptSceneobject where you want to spawn the NPC and userstr is some string (I use it as unique name for the NPCs, but currently it isn't really used by the engine). With the key of the NPC ptSceneObject you should be able to control them.

Christopher
User avatar
Christopher
 
Posts: 276
Joined: Mon Jul 19, 2010 3:25 am

Re: How to access cloned objects?

Postby Locutus » Sat Mar 09, 2013 11:24 am

Christopher wrote:
Code: Select all
key = PtLoadAvatarModel(modelname, spawnpointkey, userstr)

PERFECT! This works like a charm. You SO made my day! :D Thank you very much!

Also, I like your Furious avatar! :)
Locutus
 
Posts: 29
Joined: Sat Mar 09, 2013 9:41 am

Re: How to access cloned objects?

Postby Locutus » Sat Mar 09, 2013 12:34 pm

Oh, while we are at it:

Do you happen to know how this "ptAnimation" structure works? So far I've only been using the "oneShot" method of ptAvatar to play animations on them. For one I'd like to be able to use ptAnimation to do that, and more importantly, I'm looking for a way to do the walking animation on an avatar "in place", i.e. without actually having him move forward.

Ultimately I'd like a player to be able to "play" a Bahro, by attaching the Bahro avatar to the player and hiding the player's actual avatar. Problem is that the Bahro doesn't do the walking animation, and when I do that using oneShot, the Bahro actually moves forward, away from the player.
Locutus
 
Posts: 29
Joined: Sat Mar 09, 2013 9:41 am

Re: How to access cloned objects?

Postby Sirius » Sat Mar 09, 2013 1:06 pm

If you really want the player to control the Bahro, why not use PtChangeAvatar(avatar) ?
I assume you are working on a Myst Online client, since you have the Bahro model ? (PtChangeAvatar will not work on Complete Chronicles since there is no bahro avatar)
For instance, with the Offline-KI, you can "/avatar Zandi" to control Zandi.
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: How to access cloned objects?

Postby Locutus » Sat Mar 09, 2013 3:44 pm

Holy hell, that works indeed. I'm totally baffled now. Many thanks!

(Yes, I'm using the Uru Online client.) I would have tried that, but according to the Plasma API documentation, PtChangeAvatar command is only good to switch the Avatar's gender. I had no idea you can use custom avatar names with that!
Locutus
 
Posts: 29
Joined: Sat Mar 09, 2013 9:41 am

Re: How to access cloned objects?

Postby Christopher » Sat Mar 09, 2013 3:55 pm

If you want the avatar to walk in place you can disable the physics on it. If "avatar" is the sceneobject of your avatar you can do:
Code: Select all
avatar.physics.disable()
(IIRC)

Then your avatar can do the walkanimation, but do not walk. The ptAnimation object is used for objectanimation like opening doors and such things. AFAIK you can't use it with avatars.

Christopher
User avatar
Christopher
 
Posts: 276
Joined: Mon Jul 19, 2010 3:25 am

Re: How to access cloned objects?

Postby Locutus » Sat Mar 09, 2013 4:08 pm

@Sirius: Changing the local avatar works fine. Question: Is that command net-propagated? I.e. will other players see my avatar change as well? I'm asking because we're going to do filming with camera players and acting players, and the camera players will need to see the actors' changes. :)

@Christopher: I tried your physics disable suggestion, but unfortunately it didn't work. Here's what I did:

Code: Select all
om=PtGetLocalAvatar()
km=om.getKey()
k1=PtLoadAvatarModel("Bahro1",km)
o1=k1.getSceneObject()
o1.physics.warp(om.getLocalToWorld())
PtAttachObject(o1,om)
o1.physics.disable()
o1.avatar.oneShot(k1, 1, 1, "kgWalk", 0, 0)


The Bahro then still walks away from me. :(

EDIT: @Sirius: Just tried it out on a more-or-less unsuspecting victim on the Cyan server. ;) (Invited them to my Relto of course, will never use developer commands on public ages.) They could see me as a Bahro just fine. Great stuff!
Locutus
 
Posts: 29
Joined: Sat Mar 09, 2013 9:41 am

Re: How to access cloned objects?

Postby Mystler » Sun Mar 10, 2013 5:40 am

The avatar movement is right in the animation, so your avatar is walking when you use oneShot.

EDIT: You can, however, try to disable the movement of the handle. Maybe this works (untested):

Code: Select all
o1.avatar.oneShot(k1, 1, 0, "kgWalk", 0, 0)
User avatar
Mystler
 
Posts: 116
Joined: Sun Mar 22, 2009 4:55 am
Location: Germany

Re: How to access cloned objects?

Postby Christopher » Sun Mar 10, 2013 7:51 am

I see the problem with this. Mystlers code also doesn't work. The problem is that the movement is included in the animation. So if you play the animation on the avatar, it is moving forward cause this is part of the animation. AFAIK there is no possibility to stop the avatar from doing this. Alternative you can disable the physics of your local avatar if you are the bahro. Another way is to let the avatar seek to a point (other than itself) with disabled physics. It should walk for 5 seconds in place and then warp to the specified location.

Christopher
User avatar
Christopher
 
Posts: 276
Joined: Mon Jul 19, 2010 3:25 am

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests