This project has moved and is read-only. For the latest updates, please go here.

pivtoing gun help(revolute and angle joint)

Apr 9, 2009 at 9:35 PM
Edited Apr 9, 2009 at 9:37 PM
Hello people,
I am working on a game that has shooting components.
The way i want the aiming system to be have is,
attatch the arms + gun + head (in one image file) to the body
I am using a revolute joint to do so,
then im applying a fixed angle joint so i can control rotation,
The problems i having with this are,
the origin and positions of the gun(refferring to the head arms gun) are all messed up.
The gun draws farrr away from the person and i have to adjust the origin to far outside the size of the image to get it to the position.
When i rotate the gun it pulls away from the body, like it has a spring on it, it pulls away then when i let go it gets pulled back in.(im changing the target angle)
When i removed the angle joint the revolute joint was not working properly at all, the object would fall far away but then when i change the rotation it would fly back up, then fall down again.
I have no clue what the problem is.
If someone could just give me a sample code of a rotating arm on a body that would be enough for me to figure it out on my own,
i looked through the samples and couldnt find a sample of this.

Edit: O yeah did you guys notice how the amount of downloads have been shooting up
like considerably over the past month, its about 2000 i think
I believe the amount was 7000 sumthing and now its like 9200.
Apr 11, 2009 at 10:19 AM
I've thought about i a while and the best i can suggest is to look at the Dynamic Angle Joints sample of the simple samples. It might be what you want to look at.
Apr 11, 2009 at 7:08 PM
Edited Apr 11, 2009 at 7:08 PM
Thanks, but ive already done that.
I fixed my thing though, i have no idea why it fixed it and why it didnt work befre but for some reason i put the same body and anhor for the revolute joint i had at the beginning and it worked.
The problem was mainly in the revolute joint i have no idea why it was acting so messed up buts been fixed.
The only thing thats bothering me about the gun now is the angle joint,
When i move the target angle the gun lags behind and wiggles when i stop it,
I set softness really low(float.epsilon), bias factor to 1, and made the weapon much closer to the torso and it fixed it enough to make it no longer visually a problem, but i would like to not have to change the position of my weapon closer just so i can do this.

ps. Changing the softness and bisfactor along didnt do anything to change it, only when i move it closer to the revolute joint would it make a difference.
Apr 12, 2009 at 8:33 AM
What method are you using to force the gun to target the cursor's location? if you're using (i forget waht its called) that lets you set a max torque, make sure its set to float.PositiveInfinity and maybe if you try setting softness to a (low) negative number it might help.
Apr 12, 2009 at 9:41 AM
I didnt realize it would go below 0 usually there is a limit.
But it went down to -1 before completely breaking, but even then their was lag,
i also set max impulse to float.positiveInfinity and that didnt work.
Right now im just setting the target angle of the fixed angle joint.
But dont worry about it dude i have gotten over it, ive got bigger fish to fry.
Apr 12, 2009 at 9:43 AM
All right... Sorry i couldnt help more.
Apr 12, 2009 at 9:46 AM
Edited Apr 12, 2009 at 9:47 AM
Tis alright ive been spending All day working on my weapons system,
so ive had alot bigger problems to deal with,
good news is though i finished the weapons system : )
Apr 12, 2009 at 12:07 PM
Ok im curious what kind of game are you making? is it the one that you had in that demo, and you've just added the capability to shoot stuff or is it something else? (for some reason whenever you describe a problem now i mentally picture it in terms of those little stick figures you had.... :D)
Apr 12, 2009 at 4:42 PM
haha nope,
i gave up on that for some reason,
I learned alot about inheritance and more things of farseer,
and I feel like now i could go back and do it quite easily(Except for damn map creation and xml, still working on that)
But for DBP I am making a stealth shooter,
I rushed into it before so i scrapped EVERYTHING and started from the beginning,
so far its going much better cause im focusing on one part at a time,
I didnt realize how much there was in just one part, so i was just scatter brained,
ya know do this, o did this too, i will do this as well, I am realizing that doesnt work well for me.

My main problems that I am trying to figure out is how I am going to do enemy AI,
i had implemented fuzzy logic for wandering, alert, and attack, but i culd not for the life of me get the vision to work correctly
I want to have a eye sight field and a sound field,
that respond to the soundstate and visibility state of the player,
the problem is I have no clue how to form the fields.
I want them to be dynamic perceptions, this means barriers and things can get in the way and block certain things.

This is very hard haha : )
There are two ways I can go about it (to my knowledge)
making an emitter of particles, attatch one to every enemy, and have them end their term if they collide with anything I want them to,
then check for collisions with the player and run certain AI code.
some kid on xna forums suggested i do bresenham lines,
i looked them up and the idea behind them are very good,
but I have no clue how to implement one, and it doesnt seem like it would be able to support a cone of vision.
Apr 13, 2009 at 12:03 AM
Edited Apr 13, 2009 at 1:30 AM
Aww man that platformer idea sounded so good... Please can you put it back on a to do list (after you finish the game your working on of course)? :D Im not really much for shooters but ill be sure to check out your entry when you register it. About your problem: The best way i can think of is this: what if you use ray-casting to check if you have clear line-of-sight to your player (i'm told that farseer has everything that you need to do raycasting it just needs some work at present). For sound, you could rig up something that just detects if A the player does certain things (like moves fast or fires a weapon or something) and B that there is some way to get to the player. Edit: i googled bresenham lines and from what the wikipedia article says, the only time that would seem to be useful is when yo're using a grid-based system and you want to see if there is a straight and clear line between locations.
Apr 13, 2009 at 7:45 AM
Yeah i would love to do it, but for now i realy wanna deck out the best game I can. Its not gonna be a shooter, i owuld file it under tactital shooter if I had to. I want it to be a splinter cell with more emphasis on offensive behavior.
In the sense that you will have to use sneaking capabilities to find the best way to launch attacks.
Im not sure if that makes much sense but its what i imagined : )
for sound and vision i  know how i will do the enemies AI the problem is making the vision dynamic,
the raycasting thing sounds solid,
another person was talking about using raycasting but I really have no idea what it is, how to use it, or anything about it.
From what ive found on google searches its between the bounding boxes or spheres of 3-d objects.
But of course thats probaly wrong(I hope so)
If you have any info on how I could do raycasting please share
Apr 13, 2009 at 8:47 AM
Hmm... i dont really need (nor know in specifics) raycasting, so i cant help you in specifics but the idea is that you generate a line from point one to point two and ask all of the geometries if they collide with this line. If none of them say they do, then you have clear line of sight to whatever your raycasting towards. Sorry i cant give more info, maybe other people can help.