- Home /
i need some code suggestions
im pretty new to javascript so i cant do everything. what i need help with is i have a rigid body cube that spawns but i want it to be sent forward at a slow speed almost like a spell. but when it hits something go back to being a physics cube, any help would be amazing
Here are some links I strongly suggest to all new users :
Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/essential-skills/
Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/beginner/
this is the YouTube link for the above as one playlist : http://www.youtube.com/watch?v=-oXYHNSmTxg&list=PL27B696FB515608D2&feature=plcp
the Unity Wiki : http://wiki.unity3d.com/index.php/Tutorials
A list of resources : http://answers.unity3d.com/questions/12321/how-can-i-start-learning-unity-fast-list-of-tutori.html
Helpful page with information on using Built-In Arrays and Lists :
The unity wiki link above is very handy with lots of scripts and shaders too (just check out all the links down the left, and the tabs along the top : http://wiki.unity3d.com/index.php/Scripts )
http://forum.unity3d.com/threads/132628-How-to-help-the-Absolute-Beginner
Answer by sparkzbarca · Nov 10, 2012 at 09:00 AM
you can instantiate it and have a script attached that you call starts movement if you want it be a spell like thing turn off gravity and add force. alternatly you can make it a kinematic rigidbody and slowly move it yourself
that would just be a lerp from to
instantiate(Cube);
//script attached to cube
//physics (rigidbody enabled)
force is a speed and a direction you multiple the speed by the direction
speed = 10;
direction = vector you want to travel
force = speed * direction
rigidbody.addforce(force)
//non physics
transform.position = vector3.lerp(transform.position, destination, time.deltatime)
OnCollision(collider other){
rigidbody.enable = true;
rigidbody.iskinematic = false;
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
C# Unity 3D Lock Rotation but allow Rotation of Parent Object 1 Answer
whay cant i move with this script???? 3 Answers
What is wrong with this script? 2 Answers
SCRIPT NOT WORKING 2 Answers