Facing Waypoint Direction

I want my model to face in the direction of the waypoint during the interval. Obviously this

self.Mod1HprIv = self.Mod1.hprInterval(5, Point3(Vec3(self.waypoint.getPos()),0,0))

…is not the way to do it, because I keep getting an error:

TypeError: a float is required

I have seen dir used before, but I am not getting it to come together.
What’s the correct way to get my character face the direction of the waypoint? Thanks

I think it explains how to do a float and why it’s used in the Roaming Ralph sample.

As for having your character face the waypoint (sorry, no clue what you’re reffering to) use the lookAt method.

I know how to do it, but I’m not very good at explaining things in python yet, so I will leave it to: https://discourse.panda3d.org/viewtopic.php?t=3830

The character is always “looking at” that crosshair. It’s the first one I can remember, but there are others as well if you search the forums.

Maybe there are other methods, and maybe this isn’t what you’re asking, so I apologize. I try to help as best I can :smiley:.

I think the problem is here:

You try to create a new Point3 instance, with these arguments:

Point3( vector3, float, float )

There is no matching constructor for this (and I wouldn’t know what the resulting point should be). The “closest” constructor is this one, and this is probably why you get the error message “a float is required”:

Point3( float, float, float )

Other valid constructors are:

Point3( float )
Point3( vector3 )


Well, I understand what you are saying, but I don’t understand what to do.
The x coordinate part of Point3 is wrong. I just need to know what to put here for the object’s location.

Why is the X coordinate wrong? Anyway you can get and set positions piecewise. (i.e. [color=darkred]myNodePath.getX(); [color=darkred]myNodePath.setX(x)) This is all explained in the manual under the scene graph section.

I already used myNodePath.getX().
Sorry for not being clear. Let me explain a little more.
I am using intervals.
My model needs to face the direction of my waypoint (an object) during the interval. So my code I believe should be something like this:

self.Mod1HprIv = self.Mod1.hprInterval(5, Point3(my waypoint’s position,0,0))

So that my model turns on the x-axis only.
I tried many alternatives for my waypoint’s position, but I get the same error - TypeError: a float is required

How can you get the correct orientation using positional point ?

        self.Mod1.headsUp(self.waypoint) # headsUp keeps it upright
        self.Mod1HprIv = self.Mod1.hprInterval(5, self.Mod1.getHpr(), oldHpr)

getPos() returns a Point3, and Point3(Point3, float, float) is just out of sense.

It just seemed to make sense to me, since I had done something similar using a different language.
I’ll try your code. Thanks

Looks workable.
My model faces in the opposite direction though.
I know this is because of the direction my model was facing in the modeller when exported. (This is the case with the ralph model)
How can I get him to face the other direction, without altering his direction in my modeller?

This could be incorrect, but I believe you can use the command-line egg-trans function to rotate your model 180 degrees about its z-axis. This should fix the egg file.

egg-trans -TR 0,0,180 model.egg -o model.egg

Yep. Or you could just do it in Panda’s scene graph, by introducing a new node:

myObject = NodePath('myObject')
model.setHpr(180, 0, 0)

Then use myObject to move your model around, instead of directly using model.