Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Rotation Joints dont allign together when spinning

Author
Message
THE_NOTORIOUS_PIGGY
8
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 31st May 2018 18:35
I have a problem in my current game. I have a rotational joint between the ball and and the base, and I want the stick sprite to rotate around the same position as my rotational joint. Let me explain.
It's meant to look like this, which works well most of the time:



however, depending on device, especially on middle-lower end devices, it looks like this:



Here is a debug screenshot so you can see exactly whats up




this is the code for the stick object


this is the code for the joint

global rotatespeed as integer = 1000000
rotatedirection = 20



I've had this problem for months and I am just steps away from releasing this game (my biggest project) onto the iOS App store and I want to have this game perfect. Any help on fixing this is appreciated.
[signature removed - due to inappropriate content]. User on moderation due to continuous infringement of forum rules
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 31st May 2018 19:29
I can't see your images
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 31st May 2018 19:37 Edited at: 31st May 2018 19:39
Link 1

Link 2

Link 3

Fixed those links for you.....
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 31st May 2018 19:47 Edited at: 31st May 2018 19:50
And your setting a constant rate of movement for the link rotation and assuming that that will tie up with the physics simulation of the ball.... by the looks of it. Unfortunately that wont be the case unless your framerate is perfectly constant.

Best thing to do would be to work out the angle of the ball from the stick and set the angle of the link to be equal to that.


Technically speaking the revolute joint should be between the vertical stick and the rotating link arm and the ball should have a weld joint to the link arm. Thats the way id of tried it unless there is a reason not to.
THE_NOTORIOUS_PIGGY
8
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 31st May 2018 21:29
@Bengismo thank you very much for the photos, I dont know how i messed that up. but that is an interesting point. What if I get the x & y's of both the ball and the static part of the rotator, then is there a formula that I can use to find the angle between them? and then simply set the angle of my sprite object as that value? Is there a formula like that?
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 1st Jun 2018 13:43 Edited at: 1st Jun 2018 13:45
To find an angle from an x and y offset you use ATanFull()

Or just use this code below to point the link arm at the ball (AngleOffset is 0 unless your link arm sprite was loaded sideways or upside down then its 90 or 180 etc..)


That will work.

As I said above...personally id create 2 joints ....the revolute joint between the post and the link arm then a weld joint for the ball to the link arm to do it properly
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 1st Jun 2018 19:29
i believe you're trying to do this?


i'm not an expert by any means but it looks good to me.

if you don't want the ball to rotate around on it's own axis then use a different type of joint as bengismo says
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
THE_NOTORIOUS_PIGGY
8
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 1st Jun 2018 20:44
Hello guys. Thank you so much for your help. For the first time ever I used ATanFull(), and this has worked exactly how I wanted it to. I did this:



This simple 2 line solutions has costed me months of stress because I couldn't figure out how to deal with this issue properly. Thank you @Bengismo.

As for @smallg, that is done in a different way from what my game is already built up upon, but seeing that great video you made, I have gotten a lot of ideas to use that in a separate game. May I have your permission to possibly use that code segment in another game? Thank you.
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 2nd Jun 2018 08:53
Of course
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu

Login to post a reply

Server time is: 2024-11-18 12:17:38
Your offset time is: 2024-11-18 12:17:38