1. #1

    How to input rotation from stick?

    Hi,

    I'm new, so I apologise for jumping right in with a question but it is driving me insane!

    I've searched and searched but can't quite find the answer or work it out.

    I have an object that I want the user to control its yaw/ pitch/ rotation (whichever) (only one at a time) with the stick. So for example... a an arrow on the ground pointing to 12o'clock. The user holds the stick to the right and the arrow on the ground rotates through 360degrees, at any point, stopping if the user lets go of the stick. But also, should the user then push the stick in a direction again, the arrow on the ground will start rotating again from its new position, perhaps ending up at 3o'clock.

    The amount of rotation is directly representative of the time the user holds the sticks down. I guess in the same way you have steering input or whatever.

    I've tried to copy the UFO Example, and I've done all sorts of inputs and filters and I can't quite get it to work without either resetting or if you nudge the stick, jumping to an arbitrary angle.

    Help!!
    Share this post

  2. #2
    Morfyboy's Avatar Senior Member
    Join Date
    Mar 2014
    Location
    UK
    Posts
    8,183

    Re: How to input rotation from stick?

    Welcome to you mate..im sure someone will help with this.sorry i cant.just thought id say hello..
    Share this post

  3. #3

    Re: How to input rotation from stick?

    Cheers!



    It's doing my nut! I can get it to rotate in a billion ways, just not smoothly.

    I'll try and post a level I did at some point. I did a fair few on Trials so it's a shame they couldn't be transfered.
    Share this post

  4. #4

    Re: How to input rotation from stick?

    I've done some stuff with this getting the bike to spin and barrel roll based on the right stick position. Not quite the same thing, but I think what you want might be a bit simpler. I have a hard time stating things in a clear way the first time, so xbox chat with mic is the best way for me. Still here's my take on it:

    put an object to be the center of your "clock" and connect this with a physics joint to the stick. Set it up so it has unlimited rotation and make sure the rotation is set to the plane you want (i.e. it rotates the way you want to).
    put in the game variable data source (the one with gas, brake, right and left stick, etc). Set it to the stick you want 'll pretend that it is right stick horizontal value for this example). This will send values between -3 and 3 based on the right stick's left and right position.

    you can either send this straight to your angular motor on the physics joint or you can multiply the value to get a wider range of speeds. For simplicity, let's say you take this value straight up. Go to your physics joint-angular settings-angular motor. Pick value object will be the right stick horizontal value.
    Physics should be on for the stick and off for the center object.

    I think this will still allow the stick to continue rotating after you let go, so you might try turning the angular dampening up or setting up a filter like this:
    if (right stick horizontal = 0) -----On True---->turn off physics on stick
    ----------On--False----->turn on physics on stick.
    I hope that is clear enough to help. If not hit me up on LIVE.
    Share this post

  5. #5
    Morfyboy's Avatar Senior Member
    Join Date
    Mar 2014
    Location
    UK
    Posts
    8,183

    Re: How to input rotation from stick?

    Have you checked out the tutorials on redlynxtv on youtube?they give good object advice..i thought you might get some tips from these...
    Share this post

  6. #6
    dasraizer's Avatar Senior Member
    Join Date
    Apr 2014
    Location
    UK, Isle of Wight
    Posts
    1,195

    Re: How to input rotation from stick?

    while stick active do
    {
    add to user variable some value, could be taken from stick.
    modulo this value with 360
    use this value for the angular upper AND lower limit of say the Y (if Y is the rotational axis) of the physics joint
    }

    using the upper/lower limit in this fashion makes the physics joint act kind of like an OPE.
    on a side note try not to make the joint strength too high as it can cause problems.
    Share this post

  7. #7

    Re: How to input rotation from stick?

    Aah, I think I have mislead you slightly. I want the object to be able to move while still being rotated.

    I've altered my plan a bit! I can get a stationary object to rotate with the joints as you guys have said but if that object moves about then it throws off the calculations.

    Imagine a sled going down a hill, constantly moving that I want to alter its orientation bu holding left or right as you can with the sticks as ususal.

    I am so close, I can get it to do it loads of ways but it is never smooth and relative to its current position, it always tries to snap to a pivot point and won't allow me to alter course as the object moves.

    Maybe talk to me like I am a five year old lol as I can't get the above routes to quite work
    Share this post

  8. #8
    dasraizer's Avatar Senior Member
    Join Date
    Apr 2014
    Location
    UK, Isle of Wight
    Posts
    1,195

    Re: How to input rotation from stick?

    oh, are you looking for something along the lines of the rider holding a pole spinning a plate, or a drivable object that turns with stick movement and goes in that direction.
    Share this post

  9. #9

    Re: How to input rotation from stick?

    I suppose more like a rider altering his angle of direction yeah.

    God, I'm explaining this so badly lol. I can make the object rotate and exclusively have velocity in a certain direction. But I cannot get the object to be angle adjustable on the fly.

    So,what you say is the best way of explaining it! A driver with steering. Left and Right stick rotates the vehicle.

    Thanks for taking the time to read my rambling!! I promise to post should I ever make it work!

    Share this post

  10. #10
    dasraizer's Avatar Senior Member
    Join Date
    Apr 2014
    Location
    UK, Isle of Wight
    Posts
    1,195

    Re: How to input rotation from stick?

    cool beans

    two methods are on offer

    global, you need (and somewhat very simplified)
    TranslateX=X+Velocity*sin(YAW)
    TranslateZ=Z+Velocity*cos(YAW)

    but this is only good for a flat surface that is on the X/Z plane, think about this, up end the plane so its on Y/Z and X doesn't move, so this formula will break.

    however, local coordinates follow the rotation of the object, drop a dummy object, Red is the X axis, Green is the Y axis and Blue is the Z axis;
    so if you rotate an object about the green and move it on the x it will follow the red line.

    this maybe harder to achieve with physics joints, however what about building a pseudo vehicle that looks and smells like the object you are using and let the physics engine handle the hard parts, and as i've said you can drive the angular rotation of a physics joint by setting the Upper/Lower limits to the same 0..360' variable value.

    i found that the upper/lower limits go from -180 to 180 duh but have a problem when it transitions from the -180 to 180 jump, not sure why this is.
    Share this post