Dancing Pickups

Hello Experts,

when I worked with Unity, I used a very simple script to merge the Position of my Pickups with a sin wave:

#pragma strict
//Object moves up and down on a sine wave.
public var posHeight: float = 1.5;
public var sinSpeed: float = 3;
public var damping: float = 4;
function Update () {
	var sinus = Mathf.Sin(Time.time * sinSpeed);
	var v3 : Vector3;
	v3.x = transform.localPosition.x;
	v3.z = transform.localPosition.z;
	v3.y = posHeight + (Mathf.Abs(sinus) / damping);
	transform.localPosition = v3;

Now I tried to achieve this with blueprint, but I could not find any working Nodes.
Event Tick connected to a sine node gives me a stream of infinite rising values, not a sine wave containing values between -1.0 and 1.0

Now I formed a sine wave in a Timeline and used this with Add Local Offset.
But this has two strange effects:

  1. Although my Curve in the Timeline looks smooth, the object moves like driven by a square. It stops on Top/Bottom of the wave for same Frames. Very ugly!
  2. Observed over a few Minutes it is drifting upwards. After a longer Time it will disappear in the sky.

How would an Blueprint Expert implement my Unity Script?

Best regards

Hi ,

Interesting Problem. I am no expert but I’ll give it a shot. I would do the following.

Thank you for your support. Sadly I am not able to use this, because I have some basic problems to understand blueprint, I guess. I recreated your network, but it does nothing. For my Understanding it can not work, because Pickup Object and Sinewave Object are empty Object Variables. I do not know how to fill them. I tried to connect my Object instead, but the node do not accept it. I tried to create some additional network in the Construction Script to set up the object variables, but I am not able to do it right. Is there a way to set Actor Variables in the Detail Panel? Always the same Problem with Blueprint. Math is clear, but everything with “get” and “set” needs unknown casting nodes or other strange tricks.

Best regards

Your problems can be solved by watching and following few basic tutorials. That or you can discover it by yourself in editor, imo tutorial solution is much more painless.

Hi ,

Keep persevering, it gets easier the more you fiddle and experiment.

You would have to replace the Sinewave and Pickup Objects shown in the above diagrams with your own Actors. You mentioned you already you have done this but they didn’t link. Did you reference them correctly? Can you post a screenshot of your network.

I don’t know what you have called them so I just placed two empty objects as an example. To reference your own actors all you need to do is select them in your world view and with it selected in your level right click anywhere in the blueprint then select Create a reference to <Your Object Name>. (its right near the top) This will create a correct reference to your object.

A correct reference will probably look similar to this, but yours will be named differently.


From here you can hook them up to the above network and remove the two example objects. One thing to keep in mind after this is that your pickup object isn’t static and is movable, but I assume as you are already seeing them move into the sky that they are already.


deleted grumbling.

It is working now … but the movement stops at the top of the sin wave for some Frames. Any Idea why this happens?

Oh, wait. The Math turns up the lower Phase (Abs). I changed the second Expression to (sinus * factor), set factor to 10 and now I am happy.
Thanks to Drifyt for help. :smiley:

Glad you got it working well done!

Correct me if I’m wrong but couldn’t you use a timeline for this functionality?.. link the timeline (I think it’s called that) to the set location to create the dancing behaviours. (not at a pc to verify right now)

Khaja, He is using a timeline for this. The issue he was having was aligning spawned pickups to his sine wave. I believe the issue has been resolved.

my bad, I can’t read…thanks