Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: coxy17 on March 07, 2014, 09:49:57 AM

Title: Jump at a set distance
Post by: coxy17 on March 07, 2014, 09:49:57 AM
Hi,

Ive made a my player jump using the 'add force' to the object. But i cant get a precise enough jump for what im trying to achieve.

Im trying to get my player to jump from one platform to another but land exactly in the middle of the other platform (or near enough)

Does iTween offer a jump motion like in my diagram attached(arc shaped)? Or is there another way that doesn't involve iTween?

Thanks

Nick
Title: Re: Jump at a set distance
Post by: coxy17 on March 13, 2014, 05:20:08 AM
Im not sure whats the best solution. Ive looked into this post from @jeanfabre
http://hutonggames.com/playmakerforum/index.php?topic=1951.0 (http://hutonggames.com/playmakerforum/index.php?topic=1951.0) but its not quite what im after?

Ive looked over the samples but it mainly covers the 'Character Motor'. Im using 'Add Froce'

I can get near the exact target with just using 'AddForce' e.g. X=130 Y=200, but need it to adjust itself to the exact position before moving again.

Could using 'get' and 'set' position work?

Thanks

nick
Title: Re: Jump at a set distance
Post by: xhidnoda on March 13, 2014, 09:03:19 AM
Try use a action traslate.
So, when you player jump with add force send event to another state with traslate.position

Note.: check this link and example. https://hutonggames.fogbugz.com/default.asp?W890
Title: Re: Jump at a set distance
Post by: coxy17 on March 14, 2014, 04:23:26 AM
Hi xhidnoda,

I have taken a look at the example and im not sure as to where to find the example within the project file you are referring to?

is it the one under the 'Jump Game' and under the player object FSM?

Thanks

Nick
Title: Re: Jump at a set distance
Post by: xhidnoda on March 14, 2014, 08:23:25 AM
Just follow the instruction below.
When you have the example in your project, open scene of jump game.

Send image if what your don't understand.
Title: Re: Jump at a set distance
Post by: coxy17 on March 14, 2014, 11:08:59 AM
Hi xhidnoda,

I have attached a screenshot of my game along with the screenshot of the example game link you sent.

I cant get my head around what to setup from your suggestion....
'So, when you player jump with add force send event to another state with traslate.position'

at the moment the player jumps and lands e.g. from 0.00 > 1.98 (approx) on Z axis

How do i use 'translate.position' to finish moving the character once the player is done? so the '1.98 is 2.00'

e.g. i always need the player to jump forward and land 2.00 along Z (local) axis.

Sorry if i doesn't make sense. Could you please provide me with an example? would be most appreciated

Nick
Title: Re: Jump at a set distance
Post by: coxy17 on March 14, 2014, 07:35:31 PM
Hi im just replying again bit i stumbled upon an example online which use Parabola. Seems like the principle im after in playmaker, but wanted to avoid scripts.
http://forum.unity3d.com/threads/211681-Generating-Dynamic-Parabola (http://forum.unity3d.com/threads/211681-Generating-Dynamic-Parabola)

Title: Re: Jump at a set distance
Post by: xhidnoda on March 14, 2014, 10:54:22 PM
Hi
Let me see...
I'm think you don't use a add force Z axis to move your player. (Have you know the coordinates of 3D?).
In the example the player use add force to jump in the Y axis...right? So, use Y axis to jump.
Add a new action to Jump state. The action "Traslate" and set the X axis to "how far to go the player when jump in the X axis".

1. Jump with add force in Y axis (add force - action)
2. Traslate the player when don't grounded yet in X axis. (traslate - action)

Bye
Xhidnoda - from Paraguay (sorry my bad english)
Title: Re: Jump at a set distance
Post by: coxy17 on March 15, 2014, 09:57:04 AM
Hi,

The co-ordinates are from self position 0.00 and to 2.00

The reason i cant use world position is that the character is controlled that way.

Right, i understand what you are saying in your 2 steps. But how do i use '(add force - action)'?

..............................................................................

I found this script which looked ok (but doesnt jump smoothly). Can this be made with playmaker?
Code: [Select]
using UnityEngine;
using System.Collections;

public class jump : MonoBehaviour {
public float forward, up;
public float maxForward = 10, maxUp = 10, speedForward = .01f, speedUp = .01f;
public bool jumpBool;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

if (Input.GetKeyUp(KeyCode.Space))
{
jumpBool = true;

}
if (jumpBool)
{
if (forward <= maxForward)
forward+=speedForward;
if (up <= maxUp)
up +=speedUp;

transform.position = new Vector3 (transform.position.x + forward, transform.position.y + up, 0);
}

}
}

Sorry for all the questions.

Nick
Title: Re: Jump at a set distance
Post by: xhidnoda on March 15, 2014, 10:05:04 AM
your game is a 3D camera or 2D camera?
Title: Re: Jump at a set distance
Post by: coxy17 on March 18, 2014, 09:23:43 AM
3D camera.... im making a 3d game but its just a jump moving along one axis (z)
Title: Re: Jump at a set distance
Post by: xhidnoda on March 18, 2014, 03:20:06 PM
So?...you can make this work?
Title: Re: Jump at a set distance
Post by: coxy17 on March 18, 2014, 04:10:02 PM
Still working on it. Haven't had time to test. Ill try it tonight.
Title: Re: Jump at a set distance
Post by: coxy17 on March 18, 2014, 06:46:31 PM
I works ok  :)

Just struggling to get all the script recreated in playmaker, the code below is what im struggling over.

Code: [Select]
transform.position = new Vector3 (transform.position.x + forward, transform.position.y + up, 0);

Any ideas?

Nick
Title: Re: Jump at a set distance
Post by: xhidnoda on March 18, 2014, 09:38:04 PM
Make 2 variables (forward and up as Float)
Set the forward value = 5 (just example)
Set the up value = 7 (just example)


Use translate action

Set the x axis to forward variable
Set the y axis to up variable

Test.
Title: Re: Jump at a set distance
Post by: coxy17 on March 19, 2014, 04:21:15 AM
Hi

Thanks, ive used the 'translate' action

I think ive done this part of the code wrong now lol

Code: [Select]
if (forward <= maxForward)
forward+=speedForward;
if (up <= maxUp)
up +=speedUp;

Do i use a 'FloatAdd' for the speed? or just use 'FloatCompare'?

or have i got the wrong idea?

thanks again

Nick
Title: Re: Jump at a set distance
Post by: xhidnoda on March 19, 2014, 08:08:38 AM
both action.
for this: if (forward <= maxForward)
use: FloatCompare
for this: forward+=speedForward;
use: FloatAdd
As for the rest.


Title: Re: Jump at a set distance
Post by: coxy17 on March 19, 2014, 01:22:41 PM
Thanks! I'll give that a test
Title: Re: Jump at a set distance
Post by: coxy17 on March 21, 2014, 10:39:04 AM
Hi,

Ive had a go and i think i must be doing something wrong? The player jumps to the location but when falling it doesn't move smoothly?

attached my setup.

thanks again

Nick
Title: Re: Jump at a set distance
Post by: xhidnoda on March 21, 2014, 04:48:17 PM
Hi
I don't understand what is the problem here.
Your player jumps in the location rigth?
But when is falling  doesn't move? this is the problem?
Title: Re: Jump at a set distance
Post by: coxy17 on March 21, 2014, 08:55:48 PM
hi,

The player jumps and lands in the location.

The problem is when the player is falling down (dropping) The player moves (shakes/wobbles) when falling.

something must be setup wrong with my FSM?

attached a video of how it behaves.
https://www.dropbox.com/s/v77fiqz2hnka61k/2.avi (https://www.dropbox.com/s/v77fiqz2hnka61k/2.avi)

Thanks

Nick
Title: Re: Jump at a set distance
Post by: xhidnoda on March 24, 2014, 09:51:02 AM
don't not really why happen this.  :o
Sorry can't help you on this.


Title: Re: Jump at a set distance
Post by: coxy17 on March 27, 2014, 11:11:58 AM
Hi xhidnoda,

I had a bit of luck and i fixed the issue with the shake/wobble. I noticed that the original script used a Vector3 and applied my own in playmaker. Now it works :)

Demo:
https://www.dropbox.com/s/l9qfwgpru9nt1tf/bounce003.avi (https://www.dropbox.com/s/l9qfwgpru9nt1tf/bounce003.avi)


but now i have an issue where my player doesnt bounce to my exact location i specified in the 'forward' float.

e.g. i setup the 'forward' (Z axis) to be (2.00) but my player jumps to e.g. (2.10003) instead

Any ideas?

Could i somehow Clamp it at 2.00? Maybe a FloatClamp or Vector3Clamp? not sure as ive never done this before.

OR is there a calculation i could do to work out the end position of the jump? maybe by using the floats i have already...

My Floats are:
- forward
- SpeedForward
- MaxForward

- Up
- SpeedUp
- MaxUp

Thanks, hope im making sense.

Nick

Title: Re: Jump at a set distance
Post by: xhidnoda on March 28, 2014, 11:46:33 PM
Hi
Yes use Float Clamp to specific how far go your player when jump (z axis)
Title: Re: Jump at a set distance
Post by: coxy17 on April 10, 2014, 05:34:10 PM
Hi

That's works. But sometimes the player stops at 1.9999 instead of 2.00. Other times its over e.g.2.1

My setup is minimum=2.   maximum=2

Could this be the player sliding?

Thanks again

Nick