Do I need to have some kind of fail safe for that eventuality
yes
Quote:
and how would you suggest doing it?
Code:
... bodyTilt = math.asin(bodyLRHeight/25) ... BRA = math.asin((BR_height-bodyLRHeight)/47) FRA = math.asin((FR_height-bodyLRHeight)/47) BLA = math.asin((BL_height+bodyLRHeight)/47) FLA = math.asin((FL_height+bodyLRHeight)/47) ...
Remember what the definition of sine is in a right triangle, or better in the unit circle.
Now because sine is a ratio between two numbers, its inverse is only valid where that ratio exists (has a defined value). This happens to be between -1 and 1. If you pass in a value outside that range, you get back a special value which represents a non-number, aka NaN. So, clamp any argument v to math.asin such that -1 <= v <= 1.
Joined: 12 Jan 2005, 10:25 Location: Still signing off after all these years
OK, so that makes a lot of sense (obviosly if the cliff height is large than the track length one divided by the other will be more than 1, should have noticed that)
So question is... is there a usefull way to set the number to 1 or -1 that doesn't require 2 if statments for each wheel (as I assume thats probably not the best way to do it.)
at the moment all I can think to do is assign "BR_height-bodyLRHeight" to a varible, then do an if >1 then be 1 or if < -1 be -1, but it feels like there must be a better way...
local clamp = function(x) return math.max(-1,math.min(1,x)) end BRA = math.asin(clamp((BR_height-bodyLRHeight)/47)) FRA = math.asin(clamp((FR_height-bodyLRHeight)/47)) BLA = math.asin(clamp((BL_height+bodyLRHeight)/47)) FLA = math.asin(clamp((FL_height+bodyLRHeight)/47))
Joined: 12 Jan 2005, 10:25 Location: Still signing off after all these years
OK, thanks with the help, I've got it checking now and I get no more errors.
Now however I'm stuck with a slightly different but related problem.
The move def means it can go down the side of these cliffs, which is exactly what I want. However... because the unit is 5 x 5 it can easily overhang cliffs/ embed itself into cliffs, as it seems to let the centre of the unit go to the edge of the cliff. Is there anything I can do to make it not do this? Or is it a limitation I'll have to live with (unless I find time to learn c as well... which Is unlikely)
Joined: 12 Jan 2005, 10:25 Location: Still signing off after all these years
No, thats not the problem... it needs to be able to do that to get up slopes in its slope tollerance... I dont mind the fact the legs do that when they overhang, what I don't want is it to unit overhang. (Cars dont drive with half the bodywork hanging over the side of a cliff, or have the ability to become incorpral to move the back half through a wall)
I mean in that case 3 of the legs match, and the final deviates quite badly, so you can put minimum and maximums relative to the other legs depending on wether the slope underneath would cause clipping or not. This would prevent instances where 3 legs are flat and one leg is inside a pot hole.
Alternatively, think of it as a piece of paper and your 4 legs are the corners, if you hold 3 on a plane, how far is the 4th corner allowed to bend? At the moment it's infinity.
Joined: 22 Feb 2006, 01:02 Location: cheap kitchen
Everything that leaves the unit's footprint can potentially clip into terrain or other units. That's how it works... No idea if there are plans to allow for non-square footprints for mobiles.
Joined: 23 Nov 2005, 06:16 Location: Dunedin, New Zealand
Hard to say without having seen how you've coded it. Is the problem that it's tilted that far over or that it picked such a path where it's hanging off the cliff?
Joined: 12 Jan 2005, 10:25 Location: Still signing off after all these years
Quote:
Hard to say without having seen how you've coded it. Is the problem that it's tilted that far over or that it picked such a path where it's hanging off the cliff?
The latter, IE the path it picked hangs of the cliff. The script is doing exactly what I want it to do. It's the engin and were it thinks the unit can travers thats borked. Imagin it was just a normal tank (say a Challenger 2) and say I was nuts enough to make it 10 by 10 in spring terms.... currently a 10 x 5 bit of footprint would be over the edge of the cliff.
It would make more sense if the pathing only let the footprint move to the edge, not the center.
However I assume that would mean an engine change.
Hard to say without having seen how you've coded it. Is the problem that it's tilted that far over or that it picked such a path where it's hanging off the cliff?
The latter, IE the path it picked hangs of the cliff. The script is doing exactly what I want it to do. It's the engin and were it thinks the unit can travers thats borked. Imagin it was just a normal tank (say a Challenger 2) and say I was nuts enough to make it 10 by 10 in spring terms.... currently a 10 x 5 bit of footprint would be over the edge of the cliff.
It would make more sense if the pathing only let the footprint move to the edge, not the center.
However I assume that would mean an engine change.
aGorm
You have indeed correctly identified the issue, and I'm pretty sure it would not be a trivial thing to change.
Joined: 23 Nov 2005, 06:16 Location: Dunedin, New Zealand
Probably a massive effort to change. That being said, could, when a tile has a path cost>k1, the pathfinder increase the cost to nearby tiles with path cost<k2? Where k1 is steep and k2 is flat.
Joined: 12 Jan 2005, 10:25 Location: Still signing off after all these years
OK, so for now I'm gonna ignor the visual stupidity of the unit doing that as its not like I can do much about it for now.
So moving on... I have worked out how to make it deploy and do the animation for that, but what I dont know is how to tell it it can't move while deployed, and how to stop it shooting when its not deployed. (Also, if you know how to make it deploy automaticly if its not but has been told to shoot... that would be usefull as well.)
I'm assuming it's somthing to do with setting the maxspeed to 0, but I can't find the bit of the wiki that tells you how...
Joined: 12 Jan 2005, 10:25 Location: Still signing off after all these years
Relly not sure, its possible I had seen that at some point and it inspired me later down the line... didn't have a visual referance when I originaly made them though other than my own doodles.
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum