- Home /
spheres not colliding with world
ok i am make this game called worminator and the character is made in unity it is composed of 3 spheres parented together like this (worm)-(bodypart1)-(bodypart2) ok the worm sphere is the head the rest are spheres that are my body part ok and the worm part has a movement script and a charaacter controller and a sphere collider and the bodyparts have just a spherecolider becuase thay dont need a script 2 move just the parent becuse the childern follow the parent and do whatever the paretn dose right? well heres the funny thing when i play the game i try like collding with a box or something the worm parts collides but when i turn around i notice that the bodyparts do not collide with any thing even though thay have collider??? what the crap lol..can any one help me thank you ohh ya heres my script two
var jumpSpeed: float = 5.0;
var speed: float = 6.0;
var rotateSpeed: float = 60.0;
var gravity: float = 10.0; // gravity acceleration
private var vSpeed: float = 0; // store vertical speed in a separate variable
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
// Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed * Time.deltaTime, 0);
// Move forward / backward
var curSpeed = speed * Input.GetAxis ("Vertical");
var moveDir = transform.forward * curSpeed;
// Jump code
if (controller.isGrounded){ // if character is grounded...
vSpeed = 0; // its vert speed is zero
if (Input.GetButtonDown("Jump"))
{ // but if jump pressed, set it to jumpSpeed
vSpeed = jumpSpeed;
}
}
// apply gravity acceleration
vSpeed -= gravity * Time.deltaTime;
moveDir.y = vSpeed; // include vSpeed in moveDir
// moveDir * Time.deltaTime is the displacement since last frame
controller.Move(moveDir * Time.deltaTime);
}
@script RequireComponent(CharacterController)
ok i added a photo mayby this could help!!!!!!!!!! 0k thats the best i can do
please: a.) use punctuation b.) use grammar c.) use the code sample button so we can read that code example
do the other objects you want the "worm" to collide with have colliders?
This is possibly because you have either messed with your collision layer settings in physics (they should all be checked.), or because you have checked the Collider boxes on the children as "IsTrigger" or that whatever they are supposed to be colliding with are not setup correctly. No idea why you attached a code snippet. Delete that link us a screenshot with one of your colliders selected and your inspector pane.
You surely know how to use the !, but nothing else. By far worse grammar and punctuation Ive seen in a long time.
Age has nothing to do with it. If you cant type properly when typing fast, then dont type fast. Slow down and make sure your question is clean and legible. Its greatly appreciated.
O$$anonymous$$ peoples, I'm going to have to pull rank (by age only !) and tell everyone to chill out a little, and remember this is a knowledge-based forum. This is not FB so personal reflections should be left at the log-in screen =]
This has been tough, and thanks for everyone helping out with my frustration of seeing the same question come up 3-4 times, but the OP had a point, there was a problem with the way the project is put together. But at the same time, the OP (blenderbros) must realize that the error did not make sense, and my point of no-one could help without doing the tutorial was correct (without knowing you had a script with transform
attached to a collider).
So in future if someone says 'do it again', just Be Cool , and politely explain that you feel you have covered all considerations, and that there is definitely a problem you don't understand. Patience and politeness (now I really sound old !) ok, cool =]
btw in my brain I am younger than all of you haa haa.
I have found other problems with it while working through, so bear with me blenderbros until I get it sorted out (it's 5 am where I am, and I should be asleep, and I should catch up on the last 2 days of missed coding). I may not get it working, so if I do then it's a bonus, hey. Have you finished the rest of the tutorial (ignoring the fact that the tail can phase through objects)? There are some free assets too if you follow the link to the gameprefabs 'site, then click the worm tutorial.
Answer by AlucardJay · Jul 24, 2012 at 10:54 PM
After doing video's 1-5, and the first part of 9, I can see the problem you are describing. With all spheres having Sphere Colliders, the tail of the worm does go through objects. I even added rigidbody's with the same result. I think the cause of the problem is the SmoothFollow Script.
Why? Well, the script uses transform.position
, so it is directly positioning the object, whether there is another object there or not. This script is for the camera basically, which doesn't need to consider collisions (well, that's not true, but the script is basic, so it doesn't do occlusion, culling, collisions etc).
Without going any further, my suggestion for fixing this at this stage is to make the tail out of rigidbody's, and use joints instead of script. I guess this tutorial isn't meant to be perfect, it is just an intro to using Unity, so alot of 'pro' considerations like the ones I mentioned above arn't covered. How far have you got? Made any terrains/levels? Got the turrets working? As I have made it to video 9, I guess I'll keep going.
SO fair enough, I take back some of the comments I made, as there is a problem you have found. But by similar consideration, without actually doing the project no-one would ever know why you had these problems. Knowing that a script with 'transform' in it is attached certainly helps to figuring out why : when with colliders the tail goes through objects. I hope you are happy that I did take time to look into it.
I havn't checked if this would fix the problem, but there is a modified SmoothFollow script on UnifyCommunity that may solve the problem. You'll just have to experiment and see ....
http://unifycommunity.com/wiki/index.php?title=SmoothFollowWithCameraBumper
http://unifycommunity.com/wiki/index.php?title=SmoothFollowAdvanced
thank you dude can you tell me the correct way to add joints to my worm thank you
ok can you tell me how to add the joints to my worm i have tried but i dont know the correct way
While it may take me a little while (I have other stuff going on), I won't forget this and shall do my best to figure out a workaround to get the tail acting like a physical object. Just consider there is no guarantees, ok, but I shall try.
In the meantime, have a play around with this short tutorial, it shows an introduction to hinges (this was my first, and I made a wrecking ball !) : http://www.unity3dstudent.com/2010/07/beginner-b11-basic-joints/
A 3D buzz link I havn't tried (need to be member, free to join up, just email and away) : http://www.3dbuzz.com/vbforum/sv_showvideo.php?v=4846