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 / Doing a slingshot with built in physics system??

Author
Message
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 23rd May 2013 05:34 Edited at: 24th May 2013 04:26
I'm making a game similar to Angry Birds (in ways, I'm pretty sure it's different enough to not have any Intellectual Property issues )
but I'm having difficulty doing the slingshot motion on the character

edit: Issue Fixed
edit2: Second Issue Fixed as well
Thanks everyone!

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd May 2013 11:27 Edited at: 23rd May 2013 11:33
maybe try line/mouse joints and other sprite [ to hold your * contents that you will shot.
also interesting command is SetJointLimitOn
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd May 2013 11:50
I think you'd have to reset the physics, then step through and plot a dot line according to the position of the bird. It can be a real pain to get working - I tried this with a pool game a while ago. At least you'll probably just want to track the position of 1 sprite, and you won't necesserily want to show it after there's a collision - so it should be more straightforward, but there is an easier option that might be doable.

So - I would suggest that you just make an invisible sprite, give it the same properties as your 'bird' will have, same velocities etc - and just position sprites at the invisible sprites location - if that invisible sprite hits something or goes beyond a certain number of dots - set it back to the start. so you'd have a dotted line that kinda stutters - after a few moments it'll show the actual trajectory perfectly - but it just depends if that would be a pain or cause problems.

I have had some difficulty in updating the physics system and tracking sprite positions without actually updating them - that may have improved since I looked, but anyway I think having the invisible sprite repeatedly launch itself and drop dot sprites as it goes is a good start.

I got a fever, and the only prescription, is more memes.
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 23rd May 2013 19:39 Edited at: 23rd May 2013 19:40
Quote: "So - I would suggest that you just make an invisible sprite, give it the same properties as your 'bird' will have, same velocities etc "

Taking this idea further, why not have an animated arrow that flies the current path set by the slingshot show show the current aim.

It could use the same physics to plot the path, just not interacting with anything on the way.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd May 2013 21:40 Edited at: 23rd May 2013 21:41
maybe u can use StepPhysics(t) positive to run some steps invisible forward , memory the fly position and
then run the steps negative to go back your normal position.
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 24th May 2013 03:33 Edited at: 25th May 2013 02:05
Quote: "maybe u can use StepPhysics(t) positive to run some steps invisible forward , memory the fly position and
then run the steps negative to go back your normal position. "

Unfortunately you can't run the physics backwards (it's logically impossible), but expanding on this idea, I could simply record the positions/angles/physics movements for every single object in the scene, then step forward the physics for a few seconds while recording the object's position (it's a bunny, btw). Then reset all the positions/angles/physics movements to all the objects.
I'll try this soon and post back here with the result

edit/: It works!! [attached, use left click to pan and right click to zoom (move left and right) get the bunny into the door]

Code I use:
(wall[] is an array (UDT) containing the data for all the walls. aims[] is an array containing the sprite-id's for the 60 red dots, they're created when you tap on the bunny and deleted automatically when you release, tapping is a global flag to say if the user is tapping on the bunny)


Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 24th May 2013 12:03
looks funny

the time is part of the formulas, i think the physic engine can do it. maybe the command StepPhysics limit the parameter =>0.
i make a feature request for it and wait what paul say.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th May 2013 12:07
That's what I did, but I found that the step physics didn't quite match the real physics - like the velocity of the sprite or something wasn't being updated, so I'd just end up with weird results as soon as there is a collision. That's why I ended up using a repeating simulation, rather than step physics.

As I said though, maybe things have been fixed since I last checked, it could be that step physics is a lot more useful and reliable now.

I got a fever, and the only prescription, is more memes.

Login to post a reply

Server time is: 2024-11-24 13:40:37
Your offset time is: 2024-11-24 13:40:37