Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: SammyJoeUK on October 16, 2016, 08:04:17 AM

Title: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK 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?
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: djaydino 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
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK 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.

:(
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: djaydino on October 16, 2016, 04:31:09 PM
Hi,
That should work
can you show the fsm/states/actions?
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK 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?
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: djaydino 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.
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK 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?
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: djaydino 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
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK 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...

(http://oi63.tinypic.com/vhcbhy.jpg)
(http://oi65.tinypic.com/2r2sx2x.jpg)

Thanks again bud :)
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: djaydino on October 21, 2016, 01:33:10 AM
Hi,
Every Frame should not be enabled on Blockade and on charholder.
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK 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.

:(
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: djaydino on October 22, 2016, 02:19:10 PM
Hi,
Both should be disabled.

i made a quick sample video :

Title: Re: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK 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?
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: djaydino 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
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK on October 25, 2016, 07:32:25 PM
https://www.youtube.com/watch?v=1-FpHPxbdcY (https://www.youtube.com/watch?v=1-FpHPxbdcY)

As requested. Hope this helps illustrate the problem.
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: djaydino on October 26, 2016, 05:34:03 AM
Hi,
I made a video with some solutions, i hope these help you out :


here you can find the user tutorial wiki page (https://hutonggames.fogbugz.com/default.asp?W548)
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK on October 28, 2016, 08:09:32 PM
Awesome! Will take a look and let you know - thanks so much for your help!
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: SammyJoeUK on November 13, 2016, 06:17:31 PM
That's worked brilliantly! Thank you! :D

One final quick question - how much would setting velocity to "every frame" affect performance?
Title: Re: Zero Out/Change Object Velocity on Collision
Post by: djaydino on November 13, 2016, 06:57:23 PM
Hi,
I don't know how much.
You can test this by looking to the profiler
But should alway try if you can do something without using every frame.

Things that affect performance a lot are Creating objects and finding objects