Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: logiquefloue on October 25, 2013, 02:55:59 AM
-
Hello,
You can do this with PlayMaker? :
Set all Uvs vector with coordinates (x1, y1) of the game object to new coordinates (x2, y2).
Thank you for your help
-
Yes, you can drag the material (or any other component) on to your fsm state 'sheet' and you are offered to get/ set properties for whatever the component has exposed, with materials you can get/set the x and y of uv's for example.
-
Thank you for the answer.
But I can not find in the properties "UV coordinates" of the game object. for more information, I want to move the coordinates of the mesh of the object and not the material (texture)
thank you
-
Sorry misunderstood that. No UV's are not available for editing straight out of the box AFAIK. There are some UV editing packs on asset store but don't know if they offer variable movement.
-
Maybe there's another way to get what you want without tweaking UV's ?
-
I made this script that works (I started in the program), if anyone can transform into action PlayMaker to enjoy everyone ...
#pragma strict
public var theCube : Transform;
function Start ()
{
var x1 : float = 0.0;
var y1 : float = 0.0;
var x2 : float = 1.0;
var y2 : float = 1.0;
if (theCube == null)
theCube = this.transform;
var theMesh : Mesh = theCube.GetComponent(MeshFilter).mesh as Mesh;
var UVs : Vector2[] = new Vector2[theMesh.uv.Length];
UVs = theMesh.uv;
for (var i:int = 0; i < theMesh.vertices.length; i ++) {
if (UVs[i] == Vector2 (x1,y1)){
UVs[i] = Vector2 (x2, y2);
}
theMesh.uv = UVs;
}
}
I try to animate the uv coordinates to simulate a rise in temperatures of an object. I made a texture dérgadée (from red to blue) and I want to move the uvs depending on the temperatures.
-
I use "mouse pick uv" to trace the UV coordinates.
When I change the uv coordinates via script, "mouse pick uv" does not give me the new coordinates, but it still shows me the original details! (Uv map made in Blender)
Any idea?
-
http://hutonggames.com/playmakerforum/index.php?topic=2285.msg10058#msg10058
-
Thank you, but the action moves all uv mesh. True?
I'm looking to control a uv mesh in an individual way (with a selection of initial coordinates)
-
Hi,
Simply adapt the script you made with that custom action, Have you tried?
bye,
Jean
-
Hi,
Simply adapt the script you made with that custom action, Have you tried?
bye,
Jean
Hello Jean
I tried but my programming skills are minimal. but I'm still at same point. must share all frame works because the variable is calculated by equations
thank you
-
Hi,
Ok, I think the current behavior that you created will cause massive performance hit if you stat using it on big meshes. You would be better storing references of UV indexes against temperatures and only adjust the one you need to change, in your case, this means that ALL uvs are scanned for ALL changes, that 99% do not apply.
But anyway here's a custom action for this. If you are having trouble making it work, let me know.
Bye,
Jean
-
Hello John and thank you for action ...
The filter is not working.
1 / When I chose a base value, all coordinates are set (0.0)! not to the target value
2 / When no base value is selected, all coordinates are set to target value (this function very well)
You're right, it is not necessary that this function every frame.
-
Hi,
Could you provide a repro scene? I am not sure what's wrong here.
bye,
Jean
-
Hello jean,
I do not put A scene in this post a scene! Here are some screen printing.
When one of the values (base) of the filter is set, all UVS targets are set (0.0)
-
Hi,
It works here, I think you are simply not properly setting the base values, so it doesn't match any uvs.
bye,
Jean
-
Very strange!
I pay attention to basic values (here uv base values of the cube)
Another strange thing , the values displayed by UV "mouse pick uv" remains that of the original mesh and does not change when I move the uvs while the texture changes color!
-
Hi,
your uv values showned for the cube are wrong, uv ranges from 0.0 to 1.0, so what script are you using the get these values?
bye,
Jean
-
This is an imported cube Blender, the script told me exactly the same values as in Blender.
Here is the script
#pragma strict
public var theCube : Transform;
private var theUVs : String = "";
function Start ()
{
if (theCube == null)
theCube = this.transform;
var theMesh : Mesh = theCube.GetComponent(MeshFilter).mesh as Mesh;
theUVs = theUVs + "(" + theMesh.uv.length.ToString() + ") :";
for (var i:int = 0; i < theMesh.vertices.length; i ++) {
theUVs = theUVs + " " + i + "=" + theMesh.uv[i].ToString();
}
}
function OnGUI ()
{
GUI.Label( Rect( 10, Screen.height * 0.25, Screen.width - 20, Screen.height * 0.25), "UVs " + theUVs );
}
Having said that, with the following script, I can move my UVs ... but when I use "mouse select uv'' to the new coordinates, it does not work, I always start UV coordinates, have you any idea? Merci
#pragma strict
public var theCube : Transform;
function MoveUV_1 ( UVf : float)
{
if (theCube == null)
theCube = this.transform;
var theMesh : Mesh = theCube.GetComponent(MeshFilter).mesh as Mesh;
var UVs : Vector2[] = new Vector2[theMesh.uv.Length];
UVs = theMesh.uv;
for (var i:int = 0; i < theMesh.vertices.length; i ++) {
if (UVs[i].x == 0.1){
UVs[i] = Vector2 (0.1, UVf);
}
theMesh.uv = UVs;
}
}
-
Hi,
Then, pm me with this object and your scene if you can, cause it works ok with all the tests I carried over.
bye,
Jean
-
Hi,
Here the scene.
Reminder of malfunctions:
1 / If UV base is defined, the coordinates UV targets are defined in 0.0
2 / When I move the uv, "Mouse Pick UV" always gives my old coordinates and not the news!
-
Hi,
You need to package the scene, otherwise, I won't have the model and the texture.
bye,
Jean
-
sorry
Here the package
-
Hi,
Ok, thanks, I could find the problem! Thanks for the scene, it helped me finding what exactly I was doing wrong in my tests. Can you redownload from the original post, ti should work fine now.
bye,
Jean
-
It works fine now, thanks :)
The new coordinates are not displayed by "pick mouse UV" do you know why?
-
Hi,
Maybe you should wait one frame, the mesh update cycle maybe not done yet.
bye,
Jean
-
Hi Jean,
Uv pixel is set to "every frame". the strange thing is that the texture changes is OK (that means that the mesh is updated, right?) but we still have the old UV coordinates! The problem is visible on the package that I sent yesterday.
Thank you for your help.
-
Hi,
Try to put a mesh collider on the cube. A box collider will not work.
bye,
Jean
-
Even with <Mesh collider> I do not have the new UV coordinates, and the old coordinates are displayed <Mouse Pick Uv>!
I think <Mouse Pick Uv> ignores changes to a mesh prefab in real time (execution)!
thank you
-
Hi,
Good catch, What happens is that editing a mesh can be done locally, or actually to the mesh on the asset folder ( the shared mesh), and then ALL components using this mesh will actually see the changes.
Redownload the action, it nows has options to "Affect shared mesh" when you set UV.
Bye,
Jean
-
Thank you very much Jean it works :). I learned a lot of things with you ;)