playMaker

Author Topic: [SOLVED] Add force (impulse) continues to add force when changing facing  (Read 887 times)

Odd_But_Awesome

  • Playmaker Newbie
  • *
  • Posts: 22
    • Odd but Awesome
Hi all,

I am trying to create a ship with behaviour similar to those moon thruster games / Asteroids where you can rotate the ship and add a bit of thrust to send it moving in that direction but in 3D. Not sure if anyone has played the Amiga game Virus - similar to that.

My ship thrusts / lifts correctly as well as moving and facing correctly - controls work basically.

The issue is when I tap and release the thrust it adds force and my ship flies up as it should and it would gradually slow and drop to the ground if left unattended, but if I tilt my ship in a different direction my momentum changes direction as if I was still holding the thrust button. Almost like residual force is still being expelled. Facing any direction does this.

I would like to be able to burst thrust while the ship is facing forwards and stop thrusting and spin my ship around but still be flying in the same direction as if to escape an enemy and spin around and shoot backwards. But in this case I would stop moving forwards and start moving backwards into the enemy instead of momentum continuing to carry me forwards.

I've tried different settings on Add Force - Impluse, Acceleration etc. as well as played with drag on the parent.

Thanks for taking the time to read. Please let me know if you have any ideas.

Cheers
JJG

« Last Edit: February 05, 2021, 09:56:18 PM by Odd_But_Awesome »
Check out my games & VR Cardboard titles at https://oddbutawesome.weebly.com/apps-new.html

curb47

  • Sr. Member
  • ****
  • Posts: 256
Re: Add force (impulse) continues to add force when changing facing
« Reply #1 on: February 05, 2021, 09:16:52 AM »
Oh I loved Virus. I had it on the Atari ST

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Add force (impulse) continues to add force when changing facing
« Reply #2 on: February 05, 2021, 07:26:00 PM »
I also loved Virus! Super hard game but the satisfaction you got when you pulled off crazy maneuvers was incredible!

We're actually working on a complete Asteroids game sample made with PlayMaker. It's not quite ready for release, but I've attached a test scene with just the spaceship and one asteroid. I think you might find it a useful reference.

For example, if you look at the Spaceship prefab, it shows how to apply force while a button is down and stop when released.

The test scene:
Assets\Samples\PlayMaker\Games\Asteroids\SpacehipTest.unity

Controls:
A/D or Left/Right to rotate
Left mouse button to thrust
Right mouse button to shoot

« Last Edit: February 05, 2021, 07:35:58 PM by Alex Chouls »

Odd_But_Awesome

  • Playmaker Newbie
  • *
  • Posts: 22
    • Odd but Awesome
[SOLVED] Add force (impulse) continues to add force when changing facing
« Reply #3 on: February 05, 2021, 09:55:43 PM »
Thanks for the reply Alex. :)

I copied your example (asteroids ship) and the issue was still there. It was a useful reference for layout and methods tho so thanks for that. I ended up making a simple cube with only thrust and mouse look FSMs on it. I discovered the issue was with Mouse Look 2 (from Ecosystem). Swapping it out for Mouse Look (original) and it fixed the drifting issue.

I have attached the TestCube.prefab for anyone interested. The "FSM_MouseLook ABS" has both Mouse Look 2 and original - just activate/deactivate either action between plays to see the difference. When using ML2 thrust about a few times and rotate using the mouse. Stop Thrust and only rotating the cube will result in it moving about. Mouse-L thrust. Mouse move for rotate cube.

Cheers
JJG
Check out my games & VR Cardboard titles at https://oddbutawesome.weebly.com/apps-new.html