My request here is very simple – why won’t my model walk?? I have included the relevant code below (there is more to it, but doesn’t effect this so I have taken it out). Basically what I am trying to do is when the W button on the keyboard, the animation walk begins. For the time being I want it just to run the spot, to make sure the animation is correct before I start moving it around.
When I press the w button nothing happens, but I get a load of output on the dos screen (which I haven’t included but will do if it is useful).
I got the alien model from the models download section on the panda3d website.
import direct.directbase.DirectStart # Start Panda
from pandac.PandaModules import * # Import the Panda Modules
from direct.showbase.DirectObject import DirectObject # for event handling
from direct.task import Task # To use Tasks
from direct.actor import Actor # To use animated Actors
from direct.interval.IntervalGlobal import * # To use Intervals
import math # To use math (sin, cos..etc)
import sys
class World(DirectObject):
def __init__(self):
base.disableMouse() # Disable default camera.
self.loadModels()
# Setup key controls
self.accept("w",self.walk)
# end __init__
def loadModels(self):
# load the alien model
self.Alien = Actor.Actor("Models/alienmodel",{"Walk":"Models/alienmodelwalkanim"})
self.Alien.reparentTo(render)
self.Alien.setScale(.5)
# Position the camera
camera.setPosHpr(Vec3(0,-15,7),Vec3(0,-15,0))
# end loadModels
def walk(self):
AlienWalk = self.Alien.actorInterval("Walk")
AlienWalk.start()
# end walk
w= World()
run()
If you need anymore information, then please let me know.
Tony, just for the heck of it, I decided to test your code to see if my solution was correct. It was! Yay for me!
But there appears to be something wrong with the alien model itself (I downloaded it too) when I try to run your code using the alien model it doesn’t work and I get lot’s of error messages.
So I tried substituting the alien model with the Ralph model (also downloaded from this site) and it now works just fine. Here’s the code:
import direct.directbase.DirectStart # Start Panda
from pandac.PandaModules import * # Import the Panda Modules
from direct.showbase.DirectObject import DirectObject # for event handling
from direct.task import Task # To use Tasks
from direct.actor import Actor # To use animated Actors
from direct.interval.IntervalGlobal import * # To use Intervals
import math # To use math (sin, cos..etc)
import sys
class World(DirectObject):
def __init__(self):
base.disableMouse() # Disable default camera.
self.loadModels()
# Setup key controls
self.accept("w",self.walk)
# end __init__
def loadModels(self):
# load the alien model
self.Alien = Actor.Actor("Models/ralph",{"Walk":"Models/ralph-walk"})
self.Alien.reparentTo(render)
self.Alien.setScale(.5)
# Position the camera
camera.setPosHpr(Vec3(0,-15,7),Vec3(0,-15,0))
# end loadModels
def walk(self):
self.alienWalk = self.Alien.actorInterval("Walk")
self.alienWalk.start()
# end walk
w= World()
run()
like you i’m new to this and trying things as i go along. i thought that there was a problem with the model, as nothing that i done worked! whilst i am no expert, i do pick this kind of thing up quick and couldn’t understand why it wasn’t working!
am going to try ‘ralph’ now and see if it works.
just tried it and it works!!! thanks again - i’m so happy that there wasn’t a problem with something that i was doing otherwise i would have been really upset!