I'm making a bubble shield. I use the Sphere Mask in Shader Graph to make a collision effect (the Sphere Mask uses global position as Coords). But if I move the shield, the Sphere Mask will be in the same world place, so the collision effect won't work properly. How can I make the Center property follow the parent?
I'm using this to set the Center:
vfx.SetVector3("SphereCenter", collider.ClosestPoint(transform.position));
Related
I am trying to move forward like this
float speed = 40;
this.transform.Translate(0,0,speed/50);
It works well when character's face is looking horizontally(y=0)
However when character's face is looking down,
Somehow, It goes down through the terrain.
Is there any good way to move horizontally even character's face is looking down??
If the GameObject the script is attached to is passing through the terrain (to find out look in the scene view with the object selected and see if its position is inside the terrain):
transform.Translate moves the position of a GameObject in the direction specified even if there is an object with a collider in the way such as terrain.
If you want to move an object with collision detection you should think about using a Rigidbody or CharacterController.
If the camera is seeing through the terrain even though the camera is not inside the terrain (to find out look in the scene view with the camera selected and see if its position is inside the terrain):
It is possible that the value of the camera's near clipping plane is too large. The camera's clipping planes tell Unity at what distances to start and stop rendering geometry. The far clipping plane tells Unity at what distance away from the camera to stop rendering geometry and the near clipping plane tells Unity at what distance from the camera to start rendering geometry. Any geometry within the two values is rendered and any geometry outside the two values is not. To stop the camera seeing through the terrain you could try lowering the value of the near clipping plane, to have geometry closer to the camera rendered or move the camera further away from the terrain.
I have a sphere with a texture on the outer side. I want the texture to be on the inside of the sphere. The outside should be transparant, so texturing both sides won't work.
I want to use the sphere for an AR portal to display 360 content.
Set the cullMode property of the SCNMaterial to front instead of the default back. The doubleSided property has to be NO/false. Both sides are textured by default, setting the cull mode to front will cause it to render only back facing faces, as if the normals are flipped, and will give you the desired results.
I have a ramp and I move a sphere with arrows. I have unity's gravity and I want the rigid body of sphere to slide when it is stoped at the top of the ramp but without rotating it's body. The problem is if I Freeze rotation on x axis, it won't slide.
Try to use physics materials like ice and freeze rotations.
See info about materials here. "Like ice" means than you need set frictions to zero.
You should create a new Physical Material and set both dynamic and static friction to 0. Then drag it to the sphere and maybe also to the ramp.
Test with both rotation constrained and not.
I want to know the best approach to make a sprite ball move within concentric circle using accelerometer in cocos2d. Ive used the equation of the circle to see if the sprite lies within the circle or not.
Find next position of your sprite according to accelerometer input, check if it lies within your area, if yes, update sprite's position.
I have a simple animation in Cocos2d Chipmunk with the tasks:
One round shaped sprite situated in the center of the screen, rigid body type. Center of gravity needs to be located in center of this sprite.
From different sides of screen (spontaneously and beyond screen size) other rigid round sprites must fall into central sprite to fill visible screen space.
Sprites should not overlap one another.
So the questions are:
How to reassign the vector of gravity to the center of the screen?
How to implement collision detection between rigid body types in Cocos2d Chipmunk?
Thanks, colleagues!
You can't set a center for the gravity. You can only set a direction (the same for all objects). It's possible to create an effect you describe, but you'll have to do the work yourself. In every frame you have to set a force or apply an impulse on every body in the direction of your gravity. And the "regular" chipmunk gravity should be (0, 0).
See this tutorial about collision detection.