Does anyone know a script which allows you to hold the left mouse button to hold an object with a rigid body in air. Pretty much like in Portal. I’m a complete newbie when it comes to scripting so all help is appreciated!
To ask other members for complete scripting solutions is unfortunately not the way it works. And that`s what you are asking for here. Divide your problem into its solvable subparts. And then solve it one by one. A first step could be to write a script where you can change a variable by clicking with the mouse.
Well, that was a wonderful reply.
First, get if you have a mouse button down:
A rigid body can be held in the air by setting it’s Position and Velocity. (Set the velocity to zero)
You can calculate the position that you want by using the forward vector of the camera if you are in first person.
This will be a normalized vector facing forward (normalized means it has a length of 1, so you can multiply times a distance and get a correct distance to the place you want it to be.)
Go forth and play, come up with some script and post back if you have questions.
It still falls when velocity is set to zero.
turn off gravity while it is held
Hey I have added 2 Script to Complete a full Grab toggle and ready to move code,
Fixed An Inversion Error and a Euler read error while moving. since yesterday it is now working as stated below
ObjectReplyIdAndLock, ObjectGrabIdAndMove
ObjectGrabIdAndLock goes on Main player,… ObjectReplyIdAndMove goes on Moveable Objects remember to add layers in you want to hit in inspector and pick the Headcam Ect
Updated Scripts Since the other week now with full movement And Rotation and Full Inversion Options
This is Complete bar Diagnals and Mouse Rotation as im adding this now, you want to use the option OverideDiagnals and possibly UseDefaultRotation if u hate my defualt.
too add mouse copy the whole auto inversion and paste it underneath and swap the names to the mouse names instead of the default keys its a mission dont attempt it lol. i will do this over the week as still cleaing up the script its pretty large, Please contact at Exvalid@gmail.com To give me job coding.
cheers Ryan kappeslink text Exvalid@gmail.com
3286098–254366–ObjectGrabScripts.zip (11.4 KB)