Aug 17, 2008 at 5:13 AM
Edited Aug 17, 2008 at 5:14 AM
I'm working on a basic player and AI class, what I would like to do is add them to the scene and have them auto update as needed.  It looks like you have a system in place in BasicScene.cs

        public void Update(GameTime gameTime)
            foreach (ISpatialComponent item in items.Items<ISpatialComponent>(updateBounds))
                if (!item.Disposed && item.Enabled)

So I took my player class and derived it from SpatialComponent and added it to the scene.

    public class Player : SpatialComponent
        public Player(IOxServices services, IMyScene scene)
            : base(new Transform(new BoxPrimitive()))

        public new void Update( GameTime gameTime )

I followed pretty much the same format as MyROAMPlanet.cs, but Update isn't called from the scene update.

Am I missing something pretty simple here?

Thanks in advance
Aug 17, 2008 at 3:23 PM
Ah yes, the code for ROAMPlanet is not implemented fully or correctly. This is code is done by Sjef, the same guy who is doing the yet to be functional scene editor. So, until that code gets working fully, please don't use it as a reference. It will be merely misleading. In fact, ignore that code is even there. It can't be used for its functionality or as a good example.

I suppose I should have kept Sjef's code in a different branch since it has caused such confusion.

I'll explain why your code doesn't work. If you put "new" before your update method, you're explicitly telling your update method to NOT be called when ISpatialComponent's Update is called. That's the purpose of using "new" in front of methods. Perhaps Sjef had a reason to do this, but you definitely don't :)

So, if you have code in your player class that needs to update every frame, you have to handle its inherited OnUpdate(GameTime gameTime) event. An example would be Ox.Scene.SceneSkinnedModel.

Thanks for your question!
Aug 17, 2008 at 5:48 PM
Oh, and BTW, ISpatialComponent will be renamed to ISceneComponent in the next release. SpatialComponent will be renamed to SceneComponent as well. Just wanted to give you a heads up :)
Aug 18, 2008 at 1:14 AM
Excellent, thanks for the quick response, That worked perfectly!