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 / Mouse joint like for 2nd (AI) player

Author
Message
JRNTexas
13
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 29th Oct 2013 06:13
Continuation.....

I'm writing an "air hockey" game.

I am using mouse joint on the user controlled player to prevent the "puck" from being stopped by the "pusher".

However I need to add an opponent "pusher" and for it to react the same way the user play piece reacts, that is, when the player piece (pusher) contacts the puck, it can either increase the speed or decrease the speed, depending on how you make contact (going toward or away).

But I don't know how to get the computer controlled opponent to react the same. When the puck contacts the opponent pusher, it always slows down the puck and will eventually stop it.

Any suggestions on how to make this happen?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Oct 2013 08:40
You could use SetSpritePhysicsMass() and make the puck extremely heavy.

You might also need to adjust the forces to make it move, and the friction to make it stop faster as well to get the right effect.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 29th Oct 2013 10:18 Edited at: 29th Oct 2013 10:19
why not simulate a second mouse x,y for AI player?
at contact you can put in a impulse once.
SetSpritePhysicsImpulse( iSpriteIndex, x, y, vx, vy )
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Oct 2013 10:39
I would use a mouse joint and lerp the mouse joint position between the start and end location for the AI controlled player.

You can use more than one mouse joint

oct(31) = dec(25)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Oct 2013 12:25
Quote: "I would use a mouse joint and lerp the mouse joint position"


just had a nice thought...how about berping the position? That would imitate a real person's arm action, overshooting slightly then drawing back. It would even add more realism to the movement.

Here's a berp function I took from Scraggle's post some time ago, and finetuned by Hodgey



Login to post a reply

Server time is: 2024-11-24 21:32:29
Your offset time is: 2024-11-24 21:32:29