Page 4 of 7
Re: aGorm Mod Images
Posted: 18 Nov 2011, 19:20
by Kloot
Or Is is because I'm doing somthing wrong?
yes
Do I need to have some kind of fail safe for that eventuality
yes
and how would you suggest doing it?
Code: Select all
...
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.
edit: goddamn ninjas
Re: aGorm Mod Images
Posted: 18 Nov 2011, 23:17
by aGorm
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...
Re: aGorm Mod Images
Posted: 18 Nov 2011, 23:45
by zwzsg
maybe something like:
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))
Re: aGorm Mod Images
Posted: 21 Nov 2011, 15:16
by aGorm
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)
aGorm
Re: aGorm Mod Images
Posted: 21 Nov 2011, 15:46
by AF
You could make limit how far each track is able to deviate from the other tracks and the center?
Re: aGorm Mod Images
Posted: 21 Nov 2011, 16:01
by aGorm
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)
Re: aGorm Mod Images
Posted: 21 Nov 2011, 17:17
by AF
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.
Re: aGorm Mod Images
Posted: 21 Nov 2011, 17:18
by AF
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.
Re: aGorm Mod Images
Posted: 21 Nov 2011, 18:35
by FLOZi
No solution I am aware of at present aGorm.
Re: aGorm Mod Images
Posted: 21 Nov 2011, 18:48
by knorke
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.
Re: aGorm Mod Images
Posted: 21 Nov 2011, 19:52
by zwzsg
Give its suspensions a wide course, and pump them high when the body is at risk of grating an edge.
Re: aGorm Mod Images
Posted: 22 Nov 2011, 00:06
by Das Bruce
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?
Re: aGorm Mod Images
Posted: 22 Nov 2011, 10:06
by aGorm
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
Re: aGorm Mod Images
Posted: 22 Nov 2011, 18:14
by FLOZi
aGorm wrote: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.
edit: iirc <--- disclaimer
Re: aGorm Mod Images
Posted: 23 Nov 2011, 01:51
by Das Bruce
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.
Re: aGorm Mod Images
Posted: 25 Nov 2011, 14:55
by aGorm
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...
aGorm
Re: aGorm Mod Images
Posted: 25 Nov 2011, 15:10
by knorke
Re: aGorm Mod Images
Posted: 25 Nov 2011, 15:22
by aGorm
becasue then I'll be spamming up teh forum with each new one, instead of just 1 thread ...
aGorm
::EDIT:: Also that site is awesome, I shall look there first from now on and post questions there.
Re: aGorm Mod Images
Posted: 01 Dec 2011, 09:53
by Warlord Zsinj
hey agorm, I just spotted this and was curious
Was the little building next to the big wind generator where you got the idea for the IW power generators?
Re: aGorm Mod Images
Posted: 05 Dec 2011, 15:35
by aGorm
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.