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 / Need help establishing Physics forces always directly *behind* an object - propulsion system.

Author
Message
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 28th Feb 2013 23:39
I'm attempting to construct a propulsion system for a physics sprite which will do nothing other than provide a force to push the object from the back to the front - think ship engines.

What it should not do is articulate 'direction', that function is handled elsewhere.

My problem is that the SetSpritePhysicsForce and SetSpritePhysicsImpulse functions 'both' have vx and vy parameters which dictate that the force itself pushes up/down/left/right depending on the positive/negative/zero values and the magnitude is determined by the size of the numbers (vectors). Unfortunately for me, it sets direction.

All I want is the push, not the direction...

Has anyone worked this out elsewhere?

I've done this before when manually articulating the directional values but it's really spit and duct tap ... and I can't do that at this stage.



----
From the Desk of Prof Versaggi ...
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 28th Feb 2013 23:53
Thinking in terms of Math, particularly Trigonometry - the Pythagorean Theorem is useful if the calculations can be made.

h2 = a2 + b2
h = sqrt(a2+b2)

Objective: Determine side 'a' and 'b'.
We know the angle of "h" is the angle of the sprite (enemy boat)
We know the other angle has to be 90 degrees (angle opposite 'h')
We know it's a right triangle by definition (so angle opposite 'h' is 90 degrees)

We don't know 'h', 'a' or 'b' directly ... but if 'h' could be determined (which I 'think' is possible, than calculating both 'a' and 'b' would be possible, and then a formula could be constructed.

To make matters more interesting, considering the following:

This sprite is an enemy boat (physics sprite) having just gone through a function that did a PhysicsRayCast between it and it's target, and produced an angle (which the boat was assigned to) which pointed it 'directly' at the target. Thus no need for directional components of the thrust, just thrust...

I have access to:
x#=GetRayCastX()
y#=GetRayCastY()
and the resultant
angle# = ATan(yoffset#/xoffset#)+bias

so that 'might' provide some of the missing information needed.

Any ideas, suggestions, clues?

----
From the Desk of Prof Versaggi ...
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 1st Mar 2013 00:21
As a side note: I use SetSpritePhysicsVelocity for torpedo's, bullets, and cannon projectiles propulsion and am happy with the results ... maybe that's an avenue in some way for ship propulsion mechanisms ...

----
From the Desk of Prof Versaggi ...
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 1st Mar 2013 11:10
UPDATE:

OK, I've figured it out, so I'll answer my own question

Here's what I did:



----
From the Desk of Prof Versaggi ...
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 1st Mar 2013 11:14 Edited at: 1st Mar 2013 14:27
For those of you who are interested ...

Here is the point function that takes a sprite (physics enabled) and points it to a target (another physics enabled sprite).

Combined with the PropelEnemyVehicle() function and you have a bona fide Autonomous Agent "Seek" function ....

Here's the PointAtTarget() Function:




NOTE: *** Sorry for the multi-posting ... I just found the edit button :-(

----
From the Desk of Prof Versaggi ...
mr_d
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Mar 2007
Location: Somewhere In Australia
Posted: 1st Mar 2013 14:24 Edited at: 1st Mar 2013 14:25
***sorry, not related to your topic***
please don't quadruple post - that's what the "edit" button is for...

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Mar 2013 16:45
Thank you for the great set of code. While not necessarily useful in my current WIP, it has great potential. And I can see how it would be useful in the sequel to my WIP (assuming it is a success).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 1st Mar 2013 16:54
I'm going to be writing the following sets of functions and will post them for you as a library once I'm finished it it'll be useful:

Wander
Seek
Flee
Pursue
Evade
Arrive
Avoid_Obstacke
Flock
Idle
Hide

and a few others ... just let me know

----
From the Desk of Prof Versaggi ...

Login to post a reply

Server time is: 2024-05-03 03:41:18
Your offset time is: 2024-05-03 03:41:18