Download

Help converting simple physics rigid body control (unity)Javascript into a bluprint ?

Howdy, i’m trying to recreate my old unity control script into a bluprint but i’m getting really confused and most examples I find look way more complicated than what I need.
Anybody that knows unityscript and bluprint please can I get some help patching this together.
So in Unity I would apply this script to a rigidbody that I want to control, a bit like making a Pawn class bluprint I think…
This is the script in unityscript:

var spinforce : int = 100;

function FixedUpdate () {

   var yRotation : float = Input.GetAxis ("Horizontal")*spinforce *Time.deltaTime ;
 
       rigidbody.AddRelativeTorque (0,yRotation,0);
}   

So basically I have an axis input “horizontal” (left and right keys) and its using the variable of 100 to spin a rigidbody around its local y axis.
I have figured out how to get most of these things in the graph but they don’t seem to plug in together how I think they should in the blueprint.
Also is their an equivalent blueprint node for Time.deltaTime (http://docs.unity3d.com/ScriptReference/Time-deltaTime.html) ?
I’m also a little confused to how I can override and or get rid of the engines in build playercontrol system, I don’t want the mouse,wasd and up,down,left and right keys controlling the camera I want them just for controlling my rigidbodys in the scene.
Ideally I would love somebody to show my a blueprint version of this with an explanation of whats different and why but any help would be much appreciated as i’m pretty lost currently.

Ok so i’ve got it working like this but my view is fixed to the object for some reason ?

Depending on what you’re trying to achieve, you probably shouldn’t set the angular velocity directly but apply a angular force or impulse

Regarding your control issues, it’s because of the default pawn and player controller. It took me a while to work out what does what and how to do it, it’s not too bad but I think the tutorials gloss over it a bit and the examples aren’t exactly helpful unfortanately.

Try making your game as a blank project instead of starting as a 3rd person or whatever, and DON"T include starter content.

That way you have to make everything from scratch so you kinda have to learn how to do it all and in the end you end up understanding all aspects of control and camera control etc.

IMO

Your view is fixed to the object because of the settings in the player controller, the default pawn and the camera controller.

I think someone needs to do a wee breakdown of pawns, player controllers, camera controllers etc and how they all work together. Too many of the examples have hacks to simplify the process but end up a hinderance

(for example, you can put camera in pawn and set pawn to auto-possess and place pawn in level with editor and hit play and it’ll work, but it’s incredibly inflexible and a very bad way to do it, but some of the examples use those methods)

To be clear, it’s all talked about in the documentation, but it took me a LOT of times reading them to understand what was going on, and because you can make it work with little hacks I was content using them for a while and in the end had to refactor a bunch of things to change it up later

Hey dude, thanks for the reply, yeah angular velocity was just a test to see if I could get something actually working but totally follow what your saying.
I did start with a blank project and I think because I was getting confused as the control seems locked into what I want now.
I was kinda panicking because the engine seems the do so much by default that I don’t want and I was not looking forward to unplugging it all.

Yeah I get what you mean, I think unreal could learn a lot from how Unity is put together but don’t get me wrong unreal has so much to offer its worth the digging.

Its really good to hear your experiences and that i’m not alone in all this fella, you’ve definitely have helped spur me along now so massive thanks to you fella !

Ok new problem, it seems the “Set Physics Angular velocity” node works fine but when I try to use something more realistic like Add Force or Add Torque the blueprint won’t wont. I guess it doesn’t help that I don’t understand the hole, get and set principle and perhaps this is part of the problem. Also perhaps i’m looking in the wrong place but the API doesn’t seem to have relevant examples for bluprints, you would expect to find example code associated with important functions like Add force etc right ?

Ok problem solved !
I’d somehow missed the example ball project that perfectly answers this question, many thanks to a members on a facebook group.
I’ve modified the code slightly to include delta time so its not framerate dependent.
162e4c5796dc73a535548d1fb685772e5e4f5c0c.jpeg