playMaker

Author Topic: Zero Out/Change Object Velocity on Collision  (Read 6652 times)

SammyJoeUK

  • Playmaker Newbie
  • *
  • Posts: 32
Zero Out/Change Object Velocity on Collision
« on: October 16, 2016, 08:04:17 AM »
So I currently have a project where there is Set Velocity movement as soon as the game starts.


However, when it collides with the cube, I want to be able to stop the velocity movement, currently when I move the obstacle, the velocity continues. I've tried using a trigger on collision but the moving object passes right through and continues.

Any ideas on how I can Zero Out/Change Object Velocity?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Zero Out/Change Object Velocity on Collision
« Reply #1 on: October 16, 2016, 08:39:59 AM »
Hi,
you can use 'Collision Event' and in the next state use a 'set velocity' and set your velocity to 0

SammyJoeUK

  • Playmaker Newbie
  • *
  • Posts: 32
Re: Zero Out/Change Object Velocity on Collision
« Reply #2 on: October 16, 2016, 01:10:06 PM »
Hey thanks for getting back to me so quick - just gave this a go but it's still not happening. Once the stopping block is moved out the way, the velocity continues.

:(

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Zero Out/Change Object Velocity on Collision
« Reply #3 on: October 16, 2016, 04:31:09 PM »
Hi,
That should work
can you show the fsm/states/actions?

SammyJoeUK

  • Playmaker Newbie
  • *
  • Posts: 32
Re: Zero Out/Change Object Velocity on Collision
« Reply #4 on: October 17, 2016, 03:09:48 PM »
Does it matter if I place it on the moveable character or the blocking object provided it points to the right places?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Zero Out/Change Object Velocity on Collision
« Reply #5 on: October 17, 2016, 04:15:22 PM »
Hi,
The collision event works on the object that the fsm is on

The Set velocity is standard on 'use owner' but you can change this by selecting 'specify game object' then you can drag in an object or use a variable.

So if you have it on the blocking object you need to 'specify game object' and drag in the movable character

If its on the movable character you can leave it on 'use owner'
also be sure that your set velocity on the start is not set to every frame.

SammyJoeUK

  • Playmaker Newbie
  • *
  • Posts: 32
Re: Zero Out/Change Object Velocity on Collision
« Reply #6 on: October 17, 2016, 07:00:21 PM »
Think I've got it, had it set to Collision Stay rather than Collision Enter! :D

Thanks so much for your help man! :)

EDIT: Why would cloning the object not work with the same code added? Just tried to add a second blocker (with the new set velocity set in an FSM on it) and it's not working?
« Last Edit: October 17, 2016, 07:05:03 PM by SammyJoeUK »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Zero Out/Change Object Velocity on Collision
« Reply #7 on: October 18, 2016, 01:47:24 AM »
Hi,
That depends on how you have set up your fsm's
if you can show how you set up your fsm's/states/actions i can help you in the right direction

SammyJoeUK

  • Playmaker Newbie
  • *
  • Posts: 32
Re: Zero Out/Change Object Velocity on Collision
« Reply #8 on: October 20, 2016, 05:28:46 PM »
Hey, sorry I've been away from my desk for a couple days.

Here's the playmaker window from the object in question...




Thanks again bud :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Zero Out/Change Object Velocity on Collision
« Reply #9 on: October 21, 2016, 01:33:10 AM »
Hi,
Every Frame should not be enabled on Blockade and on charholder.

SammyJoeUK

  • Playmaker Newbie
  • *
  • Posts: 32
Re: Zero Out/Change Object Velocity on Collision
« Reply #10 on: October 21, 2016, 04:13:33 PM »
If I disable every frame on the charHolder, the cube grinds to a halt on it's way to hitting the blockade

If I disable every frame on the blockade, if I want to push the charHolder back on collision, it doesn't move.

:(

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Zero Out/Change Object Velocity on Collision
« Reply #11 on: October 22, 2016, 02:19:10 PM »
Hi,
Both should be disabled.

i made a quick sample video :


SammyJoeUK

  • Playmaker Newbie
  • *
  • Posts: 32
Re: Zero Out/Change Object Velocity on Collision
« Reply #12 on: October 23, 2016, 04:28:27 AM »
Thank you so much for the video! I think i've found my problem. I've had the Rigidbody "Use Gravity" ticked on my player character so when every frame was unticked - it would just grind to a halt halfway to the blocker.

I will need gravity applied to the character though, is there any way to remedy this?
« Last Edit: October 23, 2016, 04:52:41 AM by SammyJoeUK »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Zero Out/Change Object Velocity on Collision
« Reply #13 on: October 23, 2016, 04:32:12 PM »
Hi,
Thank you so much for the video! I think i've found my problem. I've had the Rigidbody "Use Gravity" ticked on my player character so when every frame was unticked - it would just grind to a halt halfway to the blocker.

Can you show this in a video

SammyJoeUK

  • Playmaker Newbie
  • *
  • Posts: 32
Re: Zero Out/Change Object Velocity on Collision
« Reply #14 on: October 25, 2016, 07:32:25 PM »
https://www.youtube.com/watch?v=1-FpHPxbdcY

As requested. Hope this helps illustrate the problem.