Jump to content

Waypoint Navigation fails


nl2012
 Share

Recommended Posts

Hi Guys

I have a problem ,I,m using using the script by Nick.ace (thanks Nick) like attached.

Offcourse the default crawler works fine with a simple animation sequence.But for example rigs from dexsoft, arteria, Fuse (Mixamo Rigged) and the ones i made myself seem not to be able to go to the specified waypoint. Animation works fine on all models.

Wierd thing is, even removing the animation the entity doesn't follow (goto) the specified waypoints.It doesn't move at all.

Maybey related to Character Controller settings? (for the record I used the crawler settings). Setting the mass as a test to 600 will move the character a few inches.

Or am i missing some script related things (I'm a LUA and programming noob but learning).

By the way.. currently converting some game content from my stores (other engines) to leadwerks and will make them available for free later next month on steam.

 

Any ideas

Thanks

 

Script.Speed=1.0--float

Script.Sequence=0--int

 

function Script:Start()

self.patrol={}

self.currentpatrol=0

self.patrol[0]=self.entity:FindChild("Pivot0"):GetPosition()+self.entity:GetPosition()

self.patrol[1]=self.entity:FindChild("Pivot1"):GetPosition()+self.entity:GetPosition()

self.patrol[2]=self.entity:FindChild("Pivot2"):GetPosition()+self.entity:GetPosition()

 

end

 

function Script:UpdatePhysics()

self.entity:GoToPoint(self.patrol[self.currentpatrol].x,self.patrol[self.currentpatrol].y,self.patrol[self.currentpatrol].z,1.5,1)

if self.entity:GetPosition():DistanceToPoint(self.patrol[self.currentpatrol])<1 then

self.currentpatrol=self.currentpatrol+1

if self.currentpatrol>=3 then

self.currentpatrol=0

end

end

end

 

 

function Script:Draw()

self.entity:SetAnimationFrame(8,1,4)

local t = Time:GetCurrent()

self.entity:SetAnimationFrame(t/100.0*self.Speed,1,self.Sequence)

end

HP Z820 workstation / 2 x Intel Xeon Processor E5-2650 v2 8c / 64GB / Geforce 980 gtx

/ MODO801 / MARI / ZBrush 4R7 / UU3D / Substance Designer / PS

Link to comment
Share on other sites

well my initial guess is that the calculated position of the Pivot#+entity position is not reachable via the navmesh or all 3 calculated positions are less than 1 meter away so it will just constantly cycle through the waypoints without ever moving.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Well you could have a strong point there (and a probable solution)

All of the imported characters i've imported had to be rescaled big time. I used around 200cm tall for the rescale. which comes down to many hundreds in procentage. If 1 meter is a minimun for proper nav (following the pivots) and LW shows the 200cm but calculates the original size of the character the pivots sould be "miles' apart to work well. And rescaling doesn't hurt the actual bones to be animated correctly.

rescale is the only difference between them and the Crawler.

When i get back home i set up a scene without a rescaled char and let you know.

 

Thanks

HP Z820 workstation / 2 x Intel Xeon Processor E5-2650 v2 8c / 64GB / Geforce 980 gtx

/ MODO801 / MARI / ZBrush 4R7 / UU3D / Substance Designer / PS

Link to comment
Share on other sites

I'm confused about that script. Are you attaching that to the character? Why are the pivots built into the character? That seems a little odd to me. You'd be better off taking pivots as parameters to the script (as a basic way of handling it). That way scaling of your model has nothing to do with the waypoints (as I'd argue they shouldn't have anything to do with each other).

Link to comment
Share on other sites

Hi Rick

 

The reason i used this script is easy... it was there ...and looked logical to me, because as i said before, programming/scripting for now is kinda rocketscience to me ;-). But , just to give my wife even less attention as i do already, i give that a try for sure and try to script it (by the way... i've tried the default waypoint.lua making the pivots targets but that didn't solve it)

Thank you for your time!

 

http://www.leadwerks.com/werkspace/page/tutorials/_/script/waypoints-and-simple-ai-r120

HP Z820 workstation / 2 x Intel Xeon Processor E5-2650 v2 8c / 64GB / Geforce 980 gtx

/ MODO801 / MARI / ZBrush 4R7 / UU3D / Substance Designer / PS

Link to comment
Share on other sites

So in the editor those pivots are far enough apart and their y location is at ground level?

They should be (just replaced the crawler with another char so the scene settings where identical) so distance should be fine as well as that pivot placement (unless you maybey take in account the scaling mentioned previously)

I do some more "research" this evening. Keep you posted

HP Z820 workstation / 2 x Intel Xeon Processor E5-2650 v2 8c / 64GB / Geforce 980 gtx

/ MODO801 / MARI / ZBrush 4R7 / UU3D / Substance Designer / PS

Link to comment
Share on other sites

Yes it appears the scaling of the model is affecting the child's returned local position. You can see the results of it by looking at each of the pivot's General tab position property (at least in the beta). I would call this a bug.

 

You can get around this by changing the code to find the global position of just the pivots themselves.

self.patrol[0]=self.entity:FindChild("Pivot0"):GetPosition(true)
self.patrol[1]=self.entity:FindChild("Pivot1"):GetPosition(true)
self.patrol[2]=self.entity:FindChild("Pivot2"):GetPosition(true)

 

Edit -- Josh pointed out that a child's position would have to take into account the parent's scale to be placed properly. so if the parent is scaled then the child's local position values will be affected by this- so its probably safer to just use the global position like in the above code to avoid any scaling issues. Something to note that i never realized the editor was doing - the position shown in the general tab for a child entity is shown as the local position and not the global position like all parent or standalone objects,

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I started playing around again last night and everything kept pointing to my initial thought, the scaling. I'm glad that the scaling "issue" is confirmed now. I will try the global positioning a.s.a.p. I might have even found a simple work around concerning scaling third party rigged characters, keep you posted on that (when i've tested it). Thank you for your time and support macklebee!

HP Z820 workstation / 2 x Intel Xeon Processor E5-2650 v2 8c / 64GB / Geforce 980 gtx

/ MODO801 / MARI / ZBrush 4R7 / UU3D / Substance Designer / PS

Link to comment
Share on other sites

Something to note that i never realized the editor was doing - the position shown in the general tab for a child entity is shown as the local position and not the global position like all parent or standalone objects,

 

Isn't local and global positions for standalone objects the same? So they could still be showing local positions in the editor but they would have the same values so we wouldn't know the difference. My understanding of this is that global positions are to the world and local positions are to their parents. Non parented objects would have the world as the parent by default so it's local and global position are the same.

 

I'm glad that the scaling "issue" is confirmed now

 

I don't think this is an "issue". I think it's by design. If you have children and scale the parent the local positioning will be affected, but you can always get the global positioning if you want. The point of the local positioning is to be affected by it's parent. So it's not really an issue/bug.

Link to comment
Share on other sites

Isn't local and global positions for standalone objects the same? So they could still be showing local positions in the editor but they would have the same values so we wouldn't know the difference. My understanding of this is that global positions are to the world and local positions are to their parents. Non parented objects would have the world as the parent by default so it's local and global position are the same.

 

Yes that is correct. But I prefer to think of it as the global just for making it simpler to think of the position in the overall context of the scene. But it probably is a local position based on the root just being at (0,0,0) of the world. But it begs the question why there is a button to toggle between global and local coordinates in the editor if this is the case. The problem that you will run into is between local/global rotation for standalone objects. These are not the same - or I should say will not return the same values. There is a recent bug report about this which mirrors the same question I asked about LE2 several years ago. This has been an ongoing issue in LE for as long as I can remember.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I started playing around again last night and everything kept pointing to my initial thought, the scaling. I'm glad that the scaling "issue" is confirmed now. I will try the global positioning a.s.a.p. I might have even found a simple work around concerning scaling third party rigged characters, keep you posted on that (when i've tested it). Thank you for your time and support macklebee!

Well the workaround for the scaling of models and the effects on its children can be solved by scaling the model to its proper size using a modeling app before bringing it into LE. Then the scale applied in LE will be (1,1,1). If you use the LE model editor to scale then you have to be aware of the scaling effect on any child's local position, which can be worked around by getting the global position instead.

 

Edit -- And thinking about it, the initial code above was essentially doing that but in a convoluted way. It was finding the child's local position (assuming the parent scale was 1,1,1) and adding the local (global) position of the parent... which is the same as just finding the global position of the child.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I changed the code to find the global position of the pivots themselves. And guess what... works great ..thanks guys!

HP Z820 workstation / 2 x Intel Xeon Processor E5-2650 v2 8c / 64GB / Geforce 980 gtx

/ MODO801 / MARI / ZBrush 4R7 / UU3D / Substance Designer / PS

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...