Hi, I have worked through most of the examples and I'm now trying to add a little more to them [C#].
I can make an object, move it around the map, rotate it etc. What I would now like to do is actually give it a velocity. ie kick a ball.
So my question is how do i get the get the scenemanager to keep drawing the position based on a velocity (ie push one button then keep the ball moving) cos at the moment I have to hold the button down.
I am basically hacking example 4 at the moment. i would like to basically build a billiards type game eventually.
I am a physics graduate, so i have the physics and maths concepts. I am trying to learn the programing concepts.
I have tried things like;
node.position.X = node.position.X + vel * time
where vel is just some velocity i define.
but i cant get hold of the timer in the eventhandler.
and it doesn't let me multiply node.position.X with a float (or int etc).
and even if I could get that to work, I don't want to just draw the ball once in its new calculated position, I want ts position to be continually updated after receiving only one event.
any help or direction on where to get it would be appreciated.
need help with basic physics / vectors.
I'm guessing gives a compiler error? C# has something against modifying members of a property, since ISceneNode.Position is implemented using get/set property, hence you cant modify Position.X or its members directly.
Try this instead:
For letting the node continously moving, put the animation code somewhere where it will get executed every frame, like in animateNode() of a ISceneNodeAnimator, or around the SceneManager.DrawAll() in the while(device.Run()) loop (though that would be really messy code if all your animation's in the main render loop).
And putting your animation code in your own custom ISceneNodeAnimator will also solve your problem of being unable to get the time, since the animateNode(ISceneNode theNode, int timeMs) passes the current time in as a parameter.
Alternatively you could just create a static class to store a reference to IrrlichtDevice.Timer, so you can access the time anywhere in your code.
I don't use Irrlicht.Net, but I hope that was helpful.
Code: Select all
node.position.X = node.position.X + vel * time
Try this instead:
Code: Select all
node.position = new Vector3D(node.position.X + vel * time, node.position.Y, node.position.Z);
For letting the node continously moving, put the animation code somewhere where it will get executed every frame, like in animateNode() of a ISceneNodeAnimator, or around the SceneManager.DrawAll() in the while(device.Run()) loop (though that would be really messy code if all your animation's in the main render loop).
And putting your animation code in your own custom ISceneNodeAnimator will also solve your problem of being unable to get the time, since the animateNode(ISceneNode theNode, int timeMs) passes the current time in as a parameter.
Alternatively you could just create a static class to store a reference to IrrlichtDevice.Timer, so you can access the time anywhere in your code.
I don't use Irrlicht.Net, but I hope that was helpful.