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 / Physics Impulse - Seems simple BUT!

Author
Message
Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 9th Sep 2014 13:11 Edited at: 9th Sep 2014 13:22
Hi everyone, back after quite some time away so getting my soggy brain matter working again.... or not as the case may be!

Problem with Sprite Physics Impulse... A simple matter of applying a Physics Impulse to my spaceman sprite!

My sprite has it's offset set to its centre. There is no Gravity or Restitution and the sprite shape is set to Polygon. The sprite is stationary in the centre of the screen using VirtualResolution.

Using the Left Cursor key (37) I apply and impulse directly from the 'Right' of the sprite using GetSpriteXByOffset and adding a value for the impulse point X and using the GetSpriteYByOffset for the impulse point Y. For the Vector coords I simply use the GetSpriteXByOffSet and the GetSpritYByOffset values to aim the impulse to the centre of the sprite.

Seems logical to me... However the sprite spins clockwise and moves from left to right and down then screen slightly... instead of directly right to left???

Here is the code I have used:



Any help would save my sanity right now, many thanks
lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 9th Sep 2014 13:56
Quote: " For the Vector coords I simply use the GetSpriteXByOffSet and the GetSpritYByOffset values to aim the impulse to the centre of the sprite."


That's your issue.

The vector is, just that, a vector. Which basically means a positive value on X will give the sprite force to the right, and a negative number to the left. On Y this would be down and up.

Thus,



Also don't think you'll want to offset the force from the sprite, but that's up to you.

My hovercraft is full of eels
Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 9th Sep 2014 14:57
Thanks lilpissywilly,

totally misunderstood the 'Help' explanation. Works great now.

Rudders

Login to post a reply

Server time is: 2024-11-25 09:34:04
Your offset time is: 2024-11-25 09:34:04