How To Change The Friction On A Box Collider 2D - collider

I am trying to change the friction on my box collider 2d but the option in the inspector is grey so I can't change it from there so I made this code:
private BoxCollider2D bc;
bc = GetComponent<BoxCollider2D>();
bc.friction = 0;
When I open it in Unity I get this error:
Error CS0200: Property or indexer 'Collider2D.friction' cannot be assigned to -- it is read only
Does anybody know how I can circumvent this?
Any help is appreciated, thank you in advance!

This post and this post has a workaround for your question.
But you could just add a RigidBody 2D on your gameobject, then create a Physics Material 2D for it, which you can easily edit without writing any code at all.
Be sure the components have 2D at the end of their name or else you'll be adding 3D versions :D

Related

Ue4 TiledMap Generation in 3d

How i can generate a Island shaped 2d Map with tiled cubes? Does someone can give me tipps or links or some other help please?
I already tried it with Noise but it ends in weird results cause i dont get how i use it in a 2d way.
Also i tried to give each tiles numbers so i knew what was the last placed tile.
But that ended in a big Chaos.
What i dont understand right now is how to "move" in that grid or how to know what was last and what could be the next and ye.
I really guess there is a simple way to handle that all which i dont realize at the moment?
I work for right now only with BP.
Thanks

Can I apply BABYLON textures and materials to vertices of a ground?

I'm new in babylon.js and trying to create a dynamic water surface.
I succeeded in creating waves on a flat surface (using a ground and updateVerticesData).
What i need now is doing reflections (thought about reflection textures) and refractions (tought about mirrors).
Both are done by babylon by using planes but my surface is not flat but dynamic.
Can I apply the correct reflections and refractions to the vertices or to the triangles componing my ground ?
Is it ok to do that in a realtime rendering ?
Thanks for any suggestions !
Forgive my lack of details and research.
I succeed by using Babylon.waterMaterial : https://www.babylonjs-playground.com/#1SLLOJ#481.
Indeed, using updateVerticesData and waterMaterial both is ok.

How to draw smooth ellipse (circle) in Qt?

I need to create QGraphicsItem for circle and I'm getting the output as the one which I attached along with my question. How do I draw smooth circle with good quality ? Above is my code and and above is my output. Please help me regarding this. I've tried Antialiasing and SmoothPixMapTransform of the QGraphicsView using QPainter property. But, still the result is same.
set Anti-aliasing render hint for view
http://doc.qt.io/qt-5/qgraphicsview.html#renderHints-prop
Looks like your default rendering engine doesn't support antialiasing.
Try the -graphicssystem raster command line parameter to force the raster (software) rendering.
Try also the "basicdrawing" example of QtCreator to check how widgets are rendered.
See setStartAngle() and setSpanAngle() documentation:
Sets the start angle for an ellipse segment to angle, which is in 16ths of a degree.
Sets the span angle for an ellipse segment to angle, which is in 16ths of a degree.
It's highly probable that your 20 and 45 (e.g. 1.25° and 2.8125°) are not what you want.
To enable antialiasing, you should add the following line:
view->setRenderHints(QPainter::Antialiasing);
Result:
Antialiased
Normal

threejs texture causes "GL ERROR :GL_INVALID_OPERATION : glDrawElements"

I'm trying to apply a texture to a geometry created at runtime, reading a binary asset from a remote server.
I create the geometry assigning UVs (geometry.faceVertexUvs = uvs;), normals (face.vertexNormals.push(...)) and tangents (face.vertexTangents.push(...)).
If I try to create a mesh with a basic material, there are no problems, but when I create the mesh with that geometry and I try to apply my texture, webgl doesn't display any geometry and I get this warning:
[.WebGLRenderingContext]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 1
Does anybody know what is going on? I think that my geometry has something wrong, because if I use a THREE.Sphere, I can actually apply the texture.
But everyone told me that in order to apply texture I need UVs, and I have'em.
I think that my faceVertexUvs is wrong.
The real question is: geometry.faceVertexUvs.length should be equal to geometry.vertices.length, or it should be equal to geometry.faces.length ?
Thank you very much.
PS: I've already read the following posts
WebGL drawElements out of range?
Three JS Map Material causes WebGL Warning
THREEjs can't use the material on the JSON Model when initializing. Gives me WebGL errors
Loading a texture for a custom geometry causes “GL_INVALID_OPERATION” error
problem solved!!
#GuyGood: you're right when you say that every vertex need a UV-Vector2, but it's wrong to say that geometry.faceVertexUvs.length should be equal to geometry.vertices.length...
it seems that facevertexUvs is a matrix, and not an array..well, it is an array of arrays..not properly a matrix..in fact I think it can be used to handle multi-mesh objects..if facevertexUvs.length == 3, we have 3 submeshes, so 3 arrays..each one of them has a length equal to the number of faces of a particular submesh..and every face knows the UV mapping about the 3 vertices defining that face..
hope this is clear and helpful!!

By Illustrator SDK, how to know if a selected art object is blend type?

In Adobe Illustrator, just draw a rectangle and a circle, then give them different colors. Choose AI menu "Object | Blend | Make", before this step you could open "Blend Options..." to set "Specified steps" to an integer. Now you get a series of arts. Using Direct Select Tool you can select the rectangle or circle you drawed at first.
My question is, how to write code to know if the art object you selected is one part of the blended series? Is there any useful suite in SDK? I have looked into the document but cannot find a proper API to get the infomation in AIArtSuite. (for CS5 & CS6)
Cound anyone help me, thanks in advance.
A Blend Object should be registered as a PlugInObject, at least in the JSX documentation(pdf link).
You can try something hacky like this in JSX(javascript):
#target illustrator
var doc = app.activeDocument;
var sel = doc.selection;
if(sel.length) alert("is part of blend: " + sel[0].parent.parent.typename == "PluginItem");
with an object that is part of a blend selected.
The assumption is the selected object has at least 2 parents: the Group and Blend PlugInItem, but it's not exact. I'm hoping other more exact answers will pop up.

Resources