Basic movement?

In a way thats how

base.camera.setX(base.camera, - (elapsed*25))

works, it takes base.camera pos then takes away or adds the elapsed times 25, then sets it to either Y or X.

Only jump I can think of, is when your fps is way to low it will cause “lag” I saw it today at my school pc when I ran it there.

Well I guess its just not repeating the jump for some reason.

So its working now?

No not quite. I think it might be trying to move, but it’s also trying to snap to its center at the same time, so it kinda gets stuck, then moves back after I let go. Is there a way to disable the mouse movements for the camera?

base.disableMouse()?

Ok sorry I mean like using the middle button for rotation, right button for zooming that stuff.

But you want to change the X value. base.camera does not return an X value. You need base.camera.getX().

True, actully theres a reason behind what I did, if he moves his camera H or P a little at all, it will mess up the x and y setup. Oh aka, when he moves left he’ll only turn left instead of trung with the camera left.

Add this code right above self.prevtime = task.time

      #move the mouse
      self.md = base.win.getPointer(0)
      self.x = self.md.getX()
      self.y = self.md.getY()
      if base.win.movePointer(0, base.win.getXSize()/2, base.win.getYSize()/2):
        base.camera.setP(base.camera.getP() -  (self.y - base.win.getYSize()/2)*0.4) 
        base.camera.setH(base.camera.getH() - (self.x - base.win.getXSize()/2)*0.4)

This will give you a 360 look or a FPS, but you’ll have to disable the mouse.

Ok I added that code, and I think I know whats going on. I think the camera is snaped to a fixed location and orientation. Even mouse look snaps back to its original orientation.

oh haha XD kk its cus I think you put the self.prevtime = 0 in the wrong spot, it goes with the

    self.loadcloth() 
    self.loadskyground() 
    self.loadmananitmations() 
    self.Controls()
    self.prevtime = 0 #<<---- here

I think thats what resetting you

or its not having the base.disableMouse() called

in witch case, call it, then use the code above, it gives you the same power as having base.disableMouse() on/enable.

Well thats where I put it, and I don’t think I even put in base.disableMouse().

Hello,

I am familiar with the normal way of moving e.g. ralph or any node based on keypresses by manually updating the velocity/position every frame of the rendering process according to the state of the keys.

But I find this approach a little inelegant when we have something like the Intervals system also available for doing similar things.

Can someone suggest a way I could use Intervals instead to move the player’s own character, still relying on the character to start when I press down on the key and stop when I lift up.

My initial impression is that this is difficult since ‘duration’ of the Interval and target position do not have their normal meanings since we don’t know how long the interval should run for. But surely there is a way to use Intervals to achieve what I’m describing?

I ask because I don’t like having to introduce code to manually update the player each frame. I would rather the interval system takes care of it just like it takes care of all the moving objects in my scene.

Thanks for any ideas.

Greg

That’s not really what intervals are for. Intervals are great for scripted actions, or long chains of events that occur by themselves after the initial input, but they’re really hard to adapt to dynamic input that changes constantly from the user. For responding to the user’s input, nothing beats a task running every frame.

David